Bit Driven Button Highlight

Moderators: TomKerekes, dynomotion

Post Reply
HowHardCanItBe
Posts: 16
Joined: Tue Nov 20, 2018 5:39 pm
Location: Sharonville, Ohio

Bit Driven Button Highlight

Post by HowHardCanItBe » Sat Oct 31, 2020 4:09 am

Trying to change a button's color ("Highlight") based on Virtual Bit 55. This button will eventually run a KMotion C program (Initialize file - Script not set up yet in attached pictures - forever loop sets Bit55 after initializing, clears same if need to re-initialize occurs).

The button's "Highlight" doesn't change when I cycle Bit 55 (as the Label for Tool Length, But30, does).
If I change the Style (e.g. to Label, then click Set, then back to Button, click Set), it does change, but not as expected (see attached);

Bit55=0 (57=1). Note black button.
Init Bit55 OFF.png

Bit55=1 (57=0) . Note Red button but with yellow font.
Init Bit55 ON.png
From https://www.dynomotion.com/wiki/index.p ... een_Editor;
Buttons can have all 4 options (foreground and background colors in on- and off-state) or they can also be bitmaps. Labels can load actions/scripts when the main screen is loaded.

What am I missing?

User avatar
TomKerekes
Posts: 1178
Joined: Mon Dec 04, 2017 1:49 am

Re: Bit Driven Button Highlight

Post by TomKerekes » Sat Oct 31, 2020 4:02 pm

Try using a Toggle Button.

Also don't set the text color and text background both to the same color (0 = black)
Regards,

Tom Kerekes
Dynomotion, Inc.

HowHardCanItBe
Posts: 16
Joined: Tue Nov 20, 2018 5:39 pm
Location: Sharonville, Ohio

Re: Bit Driven Button Highlight

Post by HowHardCanItBe » Sat Oct 31, 2020 7:41 pm

Thanks for the quick reply.

I was using your color fields incorrectly. Here is how I think they work for a Style=ToggleButton button;
  • First column of color fields is for the text color (top when bit=0, bottom when bit=1),
  • Second column of fields is for the fill color.
Screen Editor Text and Fill.png
Screen Editor Text and Fill.png (1.9 KiB) Viewed 254 times
And pressing the button in KMotionCNC immediately toggles the assigned bit (bit in the Var field) and executes whatever action has been assigned.

If the bit changes later, so does the button's text and fill attributes.

Since I don't want the button click events to determine the assigned bit's state (I want that to be dependent on successful completion of the assigned action - a C file, and subsequent events, like an axis disabling, etc.), I added code to clear the bit state at the beginning of my C file (presuming the ToggleButton's toggle event precedes my C code's ClearBit statement - perhaps I'll see it flash).

Please let me know if I'm missing anything.

What awesome support!

User avatar
TomKerekes
Posts: 1178
Joined: Mon Dec 04, 2017 1:49 am

Re: Bit Driven Button Highlight

Post by TomKerekes » Sat Oct 31, 2020 9:40 pm

That all sounds correct. Thx
Regards,

Tom Kerekes
Dynomotion, Inc.

Post Reply