- Posts: 4
- Thank you received: 0
Import pin value in handler.py
1 year 3 months ago #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
Please Log in to join the conversation.
1 year 3 months ago #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 to join the conversation.
1 year 3 months ago #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 to join the conversation.
1 year 3 months ago #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 to join the conversation.
1 year 3 months ago #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 to join the conversation.
1 year 3 months ago #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")
Please Log in to join the conversation.
1 year 3 months ago #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 to join the conversation.
Time to create page: 0.107 seconds
