Import pin value in handler.py
- TMinj
- Offline
- New Member
-
Less
More
- Posts: 4
- Thank you received: 0
01 Jul 2025 20:06 - 01 Jul 2025 20:10 #331079
by TMinj
Import pin value in handler.py was created by TMinj
Hello,
I'm still fairly new to LinuxCNC and QTVCP. I'm trying to modify the QTDragon GUI.
I added a status label and a progress bar using Qt5.
In handler.py, I added the following lines, and I can display the value:
- self.w.OilPumpPositionGage.setValue(int(multiplied_pwm_value))
- self.w.OilPumpPositionValue.setText(f"{multiplied_pwm_value:.2f} %")
My issue is that I would like multiplied_pwm_value = pwmgen.0.value * 100 but I can't figure out how to access the "pmw.0.value" value from handler.py
I tried working with the "newpin" function, but it's not working.
Where can I find information on how to do this, or could someone point me in the right direction?Thanks in advance
I'm still fairly new to LinuxCNC and QTVCP. I'm trying to modify the QTDragon GUI.
I added a status label and a progress bar using Qt5.
In handler.py, I added the following lines, and I can display the value:
- self.w.OilPumpPositionGage.setValue(int(multiplied_pwm_value))
- self.w.OilPumpPositionValue.setText(f"{multiplied_pwm_value:.2f} %")
My issue is that I would like multiplied_pwm_value = pwmgen.0.value * 100 but I can't figure out how to access the "pmw.0.value" value from handler.py
I tried working with the "newpin" function, but it's not working.
Where can I find information on how to do this, or could someone point me in the right direction?Thanks in advance
Last edit: 01 Jul 2025 20:10 by TMinj.
Please Log in or Create an account to join the conversation.
- cmorley
- Offline
- Moderator
-
Less
More
- Posts: 7948
- Thank you received: 2160
01 Jul 2025 21:55 #331081
by cmorley
Replied by cmorley on topic Import pin value in handler.py
if the pin value you wish to read is not created in the qtvcp handler then you must either connect to the pin or read it directly.
to read it directly:
pwmValue = self.h.hal.get_value('pwmgen.0.value')
use the full HAL name.
Otherwise you must make a qtdragon pin and connected it in a HAL file to the pwmgen pin.
Hopefully that helps.
to read it directly:
pwmValue = self.h.hal.get_value('pwmgen.0.value')
use the full HAL name.
Otherwise you must make a qtdragon pin and connected it in a HAL file to the pwmgen pin.
Hopefully that helps.
Please Log in or Create an account to join the conversation.
- TMinj
- Offline
- New Member
-
Less
More
- Posts: 4
- Thank you received: 0
02 Jul 2025 13:30 #331101
by TMinj
Replied by TMinj on topic Import pin value in handler.py
Thank you for your response. The line pwmValue = self.h.hal.get_value('pwmgen.0.value') is working well.
However, I’m having trouble with the QPushButton (or Action button). I’m not receiving any callback when it’s clicked.
However, I’m having trouble with the QPushButton (or Action button). I’m not receiving any callback when it’s clicked.
Please Log in or Create an account to join the conversation.
- cmorley
- Offline
- Moderator
-
Less
More
- Posts: 7948
- Thank you received: 2160
03 Jul 2025 05:44 #331143
by cmorley
Replied by cmorley on topic Import pin value in handler.py
Did you set any callback in designer or in the handler?
Please Log in or Create an account to join the conversation.
- TMinj
- Offline
- New Member
-
Less
More
- Posts: 4
- Thank you received: 0
03 Jul 2025 10:04 #331150
by TMinj
Replied by TMinj on topic Import pin value in handler.py
I finally found the "Signal/Slot Editor" in Qt, and the callback is now working.
Is : halcmd show pin div2.OilPump.in the correct way to write to a pin?
Is : halcmd show pin div2.OilPump.in the correct way to write to a pin?
Please Log in or Create an account to join the conversation.
- cmorley
- Offline
- Moderator
-
Less
More
- Posts: 7948
- Thank you received: 2160
03 Jul 2025 15:54 - 08 Jul 2025 01:16 #331168
by cmorley
Replied by cmorley on topic Import pin value in handler.py
No.
to write to a pin you made in qtdragon handler depends on how you made a reference to it.
for instance if you created the pin like this:
self.myPin = QHAL.newpin("MyPin", QHAL.HAL_BIT, QHAL.HAL_OUT)
then you could use:
self.myPin.set(True)
or it you didn't keep a reference to the pin (the 'self.myPin' part)
self.h.myPin.set(True)
To write to a system pin directly (it can't be connected to anything)
QHAL.setp('qtdragon.myPin','1')
or
self.h.hal.set_p("qtdragon.myPin","1")
to write to a pin you made in qtdragon handler depends on how you made a reference to it.
for instance if you created the pin like this:
self.myPin = QHAL.newpin("MyPin", QHAL.HAL_BIT, QHAL.HAL_OUT)
then you could use:
self.myPin.set(True)
or it you didn't keep a reference to the pin (the 'self.myPin' part)
self.h.myPin.set(True)
To write to a system pin directly (it can't be connected to anything)
QHAL.setp('qtdragon.myPin','1')
or
self.h.hal.set_p("qtdragon.myPin","1")
Last edit: 08 Jul 2025 01:16 by cmorley.
Please Log in or Create an account to join the conversation.
- TMinj
- Offline
- New Member
-
Less
More
- Posts: 4
- Thank you received: 0
07 Jul 2025 20:09 #331483
by TMinj
Replied by TMinj on topic Import pin value in handler.py
It work well using this : self.myPin = QHAL.newpin("MyPin", QHAL.HAL_BIT, QHAL.HAL_OUT)
Thanks a lot for your help
Thanks a lot for your help
Please Log in or Create an account to join the conversation.
Moderators: cmorley
Time to create page: 0.068 seconds