Update value spinbox

More
6 years 7 months ago #160485 by cmorley
Replied by cmorley on topic Update value spinbox

Attachment not found


Here is the python file

Please Log in to join the conversation.

More
6 years 7 months ago #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:
Code:
[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

Please Log in to join the conversation.

More
6 years 7 months ago #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.

Please Log in to join the conversation.

More
6 years 7 months ago #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:
Code:
#!/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:
Code:
net glad_r1b <= motion.digital-out-17

M101:
Code:
#!/bin/sh halcmd setp motion.digital-out-17 True exit 0

Please Log in to join the conversation.

More
6 years 7 months ago #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

Please Log in to join the conversation.

More
6 years 7 months ago #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:
Code:
GLADEVCP = -u savestate_gladevcp.py -u dob_button.py -u r_1b.py -u r2.py -u r3.py gladevcp.ui
r2.py:
Code:
#!/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)]
M102:
Code:
#!/bin/sh halcmd setp gladevcp.glad_r2 True exit 0
gcode:
later


Of course, all four buttons work for me.
Great thanks to Chris Cmorley

Please Log in to join the conversation.

More
6 years 7 months ago #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

Please Log in to join the conversation.

Time to create page: 0.055 seconds
Powered by Kunena Forum