Update value spinbox
16 Mar 2020 23:30 #160485
by cmorley
Here is the python file
Replied by cmorley on topic Update value spinbox
Here is the python file
Attachments:
Please Log in or Create an account to join the conversation.
17 Mar 2020 07:36 - 20 Mar 2020 05:50 #160514
by jurod
Replied by jurod on topic Update value spinbox
I have more "M" and remapped "G" codes. They work well. The paths are also right.
The yours mcode M105 is almost empty.
Command: halcmd setp gladevcp.test True ;without effect
Does it only test functionality?
INI:
The yours mcode M105 is almost empty.
Command: halcmd setp gladevcp.test True ;without effect
Does it only test functionality?
INI:
[RS274NGC]
PARAMETER_FILE = linuxcnc.var
USER_M_PATH= /home/hcnc/linuxcnc/configs/LINKA/Mcodes
SUBROUTINE_PATH = /home/hcnc/linuxcnc/configs/LINKA/Mcodes
RS274NGC_STARTUP_CODE = G64 P1 G40 G80 G92.1 G17 F50000
FEATURES = 12
LOG_LEVEL = 9
ON_ABORT_COMMAND = O <on_abort> call
REMAP=G6 modalgroup=1 argspec=xy ngc=g6
REMAP=G6.1 modalgroup=1 ngc=g6_1
REMAP=G11 modalgroup=1 ngc=g11
REMAP=G12 modalgroup=1 argspec=xy ngc=g12
REMAP=G12.1 modalgroup=1 argspec=xy ngc=g12_1
REMAP=G12.2 modalgroup=1 argspec=xy ngc=g12_2
REMAP=G13 modalgroup=1 argspec=xy ngc=g13
REMAP=G13.1 modalgroup=1 argspec=xy ngc=g13_1
REMAP=G13.2 modalgroup=1 argspec=xy ngc=g13_2
REMAP=G14 modalgroup=1 ngc=g14
REMAP=G15 modalgroup=1 ngc=g15
REMAP=G16 modalgroup=1 ngc=g16
REMAP=G74 modalgroup=1 ngc=g74
REMAP=G75 modalgroup=1 ngc=g75
Last edit: 20 Mar 2020 05:50 by jurod.
Please Log in or Create an account to join the conversation.
17 Mar 2020 07:41 - 17 Mar 2020 07:43 #160516
by jurod
Replied by jurod on topic Update value spinbox
EDIT: sorry i was no see your last post. I'll try the python. Thanks.
Last edit: 17 Mar 2020 07:43 by jurod.
Please Log in or Create an account to join the conversation.
19 Mar 2020 19:23 - 20 Mar 2020 05:53 #160766
by jurod
Replied by jurod on topic Update value spinbox
Hi, everything works perfectly. (M105 and the "dob_button.py") Now I need to add HAL pin but other than "test". Please how?
My example:
py:
gladevcp.hal:
M101:
My example:
py:
#!/usr/bin/env python
import hal
import hal_glib
class HandlerClass:
def __init__(self, halcomp,builder,useropts):
self.builder = builder
self.example_trigger = hal_glib.GPin(halcomp.newpin('glad_r1b', hal.HAL_BIT, hal.HAL_IO))
self.example_trigger.connect('value-changed', self._on_example_trigger_change)
self.r1b_spinbox = self.builder.get_object('r1b')
def on_example_trigger_changed(self,pin):
if pin.get():
pin.set(False)
new = self.r1b_spinbox.get_value() -1
if new <=0:
self.r1b_spinbox.set_value(0)
print 'pause'
else:
self.r1b_spinbox.set_value(new)
def get_handlers(halcomp,builder,useropts):
return [HandlerClass(halcomp,builder,useropts)]
gladevcp.hal:
net glad_r1b <= motion.digital-out-17
M101:
#!/bin/sh
halcmd setp motion.digital-out-17 True
exit 0
Last edit: 20 Mar 2020 05:53 by jurod.
Please Log in or Create an account to join the conversation.
19 Mar 2020 21:34 #160775
by cmorley
Replied by cmorley on topic Update value spinbox
First
if you are going to paste a ;large chunk of code in the message please use the <code> quoting system - your code hurts my eyes. ( you have to click 'Action / reply' rather then 'quick reply'
Second:
I would need more information to help you. what kind or HAL pin? What direction? What is it for?
This is the docs for the python hal library:
linuxcnc.org/docs/2.7/html/hal/halmodule.html
That shows the very basics for using it like how to make a HAL pin.
If you want a HAL pin with a signal to call a function then that example is the code I already gave you.
Chris
if you are going to paste a ;large chunk of code in the message please use the <code> quoting system - your code hurts my eyes. ( you have to click 'Action / reply' rather then 'quick reply'
Second:
I would need more information to help you. what kind or HAL pin? What direction? What is it for?
This is the docs for the python hal library:
linuxcnc.org/docs/2.7/html/hal/halmodule.html
That shows the very basics for using it like how to make a HAL pin.
If you want a HAL pin with a signal to call a function then that example is the code I already gave you.
Chris
Please Log in or Create an account to join the conversation.
20 Mar 2020 08:56 - 20 Mar 2020 09:00 #160844
by jurod
Replied by jurod on topic Update value spinbox
So, thanks for the link linuxcnc.org/docs/2.7/html/hal/halmodule.html from you.
I already have more pins created. Without a HAL.
I'm learning to work with python.
This my example is ok:
.ini:r2.py:M102:gcode:
later
Of course, all four buttons work for me.
Great thanks to Chris Cmorley
I already have more pins created. Without a HAL.
I'm learning to work with python.
This my example is ok:
.ini:
GLADEVCP = -u savestate_gladevcp.py -u dob_button.py -u r_1b.py -u r2.py -u r3.py gladevcp.ui
#!/usr/bin/env python
import hal
import hal_glib
class HandlerClass:
def __init__(self, halcomp,builder,useropts):
self.builder = builder
self.trigger = hal_glib.GPin(halcomp.newpin('glad_r2', hal.HAL_BIT, hal.HAL_IO))
self.trigger.connect('value-changed', self.on_trigger_changed)
self.r2_spinbox = self.builder.get_object('r2')
def on_trigger_changed(self,pin):
if pin.get():
pin.set(False)
new = self.r2_spinbox.get_value() -1
if new <=0:
self.r2_spinbox.set_value(0)
else:
self.r2_spinbox.set_value(new)
def get_handlers(halcomp,builder,useropts):
return [HandlerClass(halcomp,builder,useropts)]
#!/bin/sh
halcmd setp gladevcp.glad_r2 True
exit 0
later
Of course, all four buttons work for me.
Great thanks to Chris Cmorley
Last edit: 20 Mar 2020 09:00 by jurod.
Please Log in or Create an account to join the conversation.
20 Mar 2020 09:08 #160845
by cmorley
Replied by cmorley on topic Update value spinbox
Thanks for using the code formatting in the message - much easier to read!
I'm glad you are finding success.
I see you are using a python handler file per spinbutton.
there is nothing wrong with this - it's a good way to keep them separate if they are going to do different things.
I just want to point out that they all could be in one python file. It might matter if things get more complicated.
I'm going to add more info about using signals with HAL pins to the documentation for the next person.
Thanks for the update!
Chris
I'm glad you are finding success.
I see you are using a python handler file per spinbutton.
there is nothing wrong with this - it's a good way to keep them separate if they are going to do different things.
I just want to point out that they all could be in one python file. It might matter if things get more complicated.
I'm going to add more info about using signals with HAL pins to the documentation for the next person.
Thanks for the update!
Chris
Please Log in or Create an account to join the conversation.
Time to create page: 0.073 seconds