Qtpyvcp - Widget Rules guidance?

More
10 Mar 2023 20:35 #266331 by spumco
Im guessing this is fairly simple, but I'm struggling.

I've added a Halledindicator to my screen
Edited the resulting hal pin name and connected it in postgui hal.
Figured out how to get the led state (on/off) to match the physical input & signal

Stumbling point: I'd like to use widget rules to make it blink when the input signal is low and stay steady-state when signal is high.

Having it blink red when off and steady green when on would be a bonus, but not necessary.

I've read the qtpyvcp site on widget rules and watched the nice vid from KCJ, but there seem to be some underlying assumptions about knowledge-level that are leaving me a bit lost.

Anyone care to walk me through this?

Please Log in or Create an account to join the conversation.

More
10 Mar 2023 23:27 #266350 by Lcvette
it sounds like you have a lot of the work to do in QTdesigner to setup the led for all the various states. once those are defined the widget rules really wouldn't be necessary i don't think. you would just be changing the appearance based on the style settings you make and the input connection in halui. i have not done a blinking led before, but if it is an option available inside the properties editor for the widget than you could make it do that. if it is not then you would have to add that functionality to the widget.py file either hard coded for that widget or add a property to the py file that would make that option available in qtdesigners properties editor. (this method would be something we could do a pull request on and add to qtpyvcp, hard coding we wuld not as it removes the base functionality with no user selectability.

The rules editor is more for tying widgets to existing predefined status or settings that are predefined between linuxcnc and python. you can change subtle things like text or enable/disable, but that is really no different then halui handling the enable disable state so kind of to many chefs in the kitchen situation.

Please Log in or Create an account to join the conversation.

More
10 Mar 2023 23:32 #266352 by Lcvette
so it appears there is a "flashing" option in the properties editor, so you could just set it to flash in the off state maybe and be green in the on state and define those in the style sheet.

Please Log in or Create an account to join the conversation.

More
10 Mar 2023 23:34 #266353 by Lcvette
hmm this may be one of those special fancy widgets that requires some additional work in the py file.  but play with it and see if you can sort what the style sheet does.  you can get some ideas by checking in the qss file in the probe basic directory, there are a few buttons etc that have multiple appearances for different states such as hover, pressed, clicked, toggled, off etc

Please Log in or Create an account to join the conversation.

More
11 Mar 2023 00:05 #266357 by spumco
I was able to choose flash, on, or off in the style sheet, as well as set the blink rate and the startup state.

While I can set the color, I can't figure out how to set an "off" color (or flash/not).  If I can set the 'off' color, I could set that to green, make it a flashing LED, and reverse the input state logic.

Any idea how to set the off color?

Please Log in or Create an account to join the conversation.

More
11 Mar 2023 00:15 #266358 by Lcvette
The flash and rate and color was a property defined in the py file to a user settable property.  The stylesheet is the yellow portion where you add customized lines of code per the qt stylesheet guidelines. 

Please Log in or Create an account to join the conversation.

More
11 Mar 2023 00:34 #266361 by Lcvette
here is an easier explanation maybe as i find it hard to converse with text when there may be naming discrepencies and it can make it more confusing..lol 

 

 
Attachments:

Please Log in or Create an account to join the conversation.

More
11 Mar 2023 03:19 #266365 by spumco
I think I found the underlying issue.

The qtpyvcp halledindicator depends on the base widget 'ledindicator.'

The base widget has no definition (or whatever the jargon is) for 'off-color'.

Part of my confusion was that I recalled fiddling with qtvcp (not qtPYvcp) and seeing the 'off-color' settings for an LED hal widget.

Opening both the qtpyvcp and qtvcp led_widget.py files shows that my memory wasn't completely gone:
  • qtvcp led_widget has a definition for off-state color
  • qtpyvcp led_widget defaults to black, but doesn't appear to expose that definition in the Properties window.
I wonder if it would be possible to add the qtvcp features to the qtpyvcp base widget?

 

 
Attachments:

Please Log in or Create an account to join the conversation.

More
11 Mar 2023 03:35 #266368 by Lcvette
sure, should just be able to copy the relevant bits, can also try just adding the off color to the style sheet.  but if you want to add the off section to the widget's py file and get it working just let me know and i can add to the main branch so any updates won't conflict in the future.  if there are any discrepancies in the py code, convert formatting to the existing qtpyvcp code used to avoid any issues.
 

Please Log in or Create an account to join the conversation.

More
11 Mar 2023 06:16 #266374 by spumco
I was about to throw tantrum because I know noting about editing .py files, but I decided to brute-force it.

I think I managed to get it without breaking anything serious.

If you d/l the file and substitute it for the original led_widget.py it should work.  Note that this is in the base widgets folder and not the hal_widgets.

The file is a bit of a mess, but that should help see what I was fooling with.

Off Color and Border Color now show up in the Properties Editor window.

In my particular case, I can set
On = red
Off = green
Border = black

and then connect my input-not to the qtpyvcp.led-something.flash pin.  If my air pressure sensor is low (no air), it flashes red/green, and once the air is good the led changes to steady-green.

Someone more clever might be able to figure out how to do a 3-color arrangement: color1 + color2 (flash), and color 3 (on or off).  That way it could flash red/black, then change to green. Right now it looks a little silly alternating between red & green.

If you test & like it, please feel free to clean up the file (de-idiot, in other words) and incorporate in the mainline as you see fit.


 
 
Attachments:

Please Log in or Create an account to join the conversation.

Moderators: KCJLcvette
Time to create page: 0.165 seconds
Powered by Kunena Forum