qtdragon mod

More
1 year 6 months ago #327130 by Mr. Mass
Replied by Mr. Mass on topic qtdragon mod
One more question about HAL pin for fast/slow button. In the example there was this function to call, but it doesn't work as toggle, but as momentary.
Code:
def togle_jog_range_l(self, state):         self.w.btn_jog_l_slow.setChecked(state)         self.w.btn_jog_l_slow.clicked.emit(state)

Is it possible to make it toggle or is it only done in hal? And how can I know the status of this button? I want to change the step depending on the speed, because now at low speed the step is too big.

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

More
1 year 6 months ago - 1 year 6 months ago #327175 by cmorley
Replied by cmorley on topic qtdragon mod
Try this:
Code:
def togle_jog_range_l(self, state):   state = not self.w.btn_jog_l_slow.isChecked()   self.w.btn_jog_l_slow.setChecked(state)      self.w.btn_jog_l_slow.clicked.emit(state)
Last edit: 1 year 6 months ago by cmorley.

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

More
11 months 1 week ago #338881 by Mr. Mass
Replied by Mr. Mass on topic qtdragon mod
I came back to this topic again, and I had a new idea. I want to make a semaphore thingy using RGB LEDs. I used 3 OUT FLOAT, which I connected to PWM LEDs. The hardware works fine, the colors change, but I'm stuck on how to write the function correctly. Here's what I came up with:
Code:
def init_pins(self):# status LED pins pin = QHAL.newpin("led-red", QHAL.HAL_FLOAT, QHAL.HAL_OUT) pin.value_changed.connect(lambda: self.status_led_changed()) pin = QHAL.newpin("led-green", QHAL.HAL_FLOAT, QHAL.HAL_OUT) pin.value_changed.connect(lambda: self.status_led_changed()) pin = QHAL.newpin("led-blue", QHAL.HAL_FLOAT, QHAL.HAL_OUT) pin.value_changed.connect(lambda: self.status_led_changed()) def status_led_changed(self): if STATUS.is_man_mode(): print("status is manual mode", STATUS.is_man_mode()) self.h["led-red"] = 255 self.h["led-green"] = 0 self.h["led-blue"] = 0 elif STATUS.is_auto_mode(): print("status is auto mode", STATUS.is_auto_mode()) self.h["led-red"] = 0 self.h["led-green"] = 255 self.h["led-blue"] = 0

It seems to work, but only once at startup. How can I make this function run continuously?

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

More
11 months 1 week ago - 11 months 1 week ago #338911 by cmorley
Replied by cmorley on topic qtdragon mod
Setting 'value-changed' callback functions on output pins is not the thing to do.
'value-changed' only makes sense with input pins.

You should create a STATUS callback for manual and auto mode changes that change the LEDS.
Here is some details:
linuxcnc.org/docs/devel/html/gui/gstat.h...tension_code_pattern

Something like this:

Code:
def init_pins(self):# status LED pins     pin = QHAL.newpin("led-red", QHAL.HAL_FLOAT, QHAL.HAL_OUT)     pin = QHAL.newpin("led-green", QHAL.HAL_FLOAT, QHAL.HAL_OUT)     pin = QHAL.newpin("led-blue", QHAL.HAL_FLOAT, QHAL.HAL_OUT)     STATUS.connect("mode-manual",lambda w: self.set_manual_leds())     STATUS.connect("mode-auto",lambda w: self.set_auto_leds()) def set_manual_leds(self):     print("status is manual mode", STATUS.is_man_mode())     self.h["led-red"] = 255     self.h["led-green"] = 0     self.h["led-blue"] = 0 def set_auto_leds(self):     print("status is auto mode", STATUS.is_auto_mode())     self.h["led-red"] = 0     self.h["led-green"] = 255     self.h["led-blue"] = 0
Last edit: 11 months 1 week ago by cmorley.

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

More
11 months 1 week ago #339047 by Mr. Mass
Replied by Mr. Mass on topic qtdragon mod
Thanks for the explanation, it really helped. I made indicators for e-stop, on/off, manual mode, and MDI. There was a slight issue with auto mode. I wanted to make indicators for auto mode, running programs, and pause. This is the only way I could do it:
Code:
STATUS.connect("interp-run",lambda w: self.set_auto_led()) STATUS.connect("interp-paused",lambda w: self.set_auto_led()) STATUS.connect("interp-idle",lambda w: self.set_auto_led()) STATUS.connect("interp-waiting",lambda w: self.set_auto_led()) def set_auto_led(self): c = "" if STATUS.is_auto_running() and STATUS.is_auto_mode() and not STATUS.is_auto_paused(): c = "blue" self.set_led_color(c) elif STATUS.is_auto_paused() and STATUS.is_auto_mode(): c = "aquamarine" self.set_led_color(c) elif STATUS.is_auto_mode(): c = "green_dark" self.set_led_color(c) def set_led_color(self, color): print(color, self.LED_color[color]) self.h["led-red"] = self.LED_color[color][0] self.h["led-green"] = self.LED_color[color][1] self.h["led-blue"] = self.LED_color[color][2]

Is this ok, or is there a more elegant way?

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

More
10 months 4 weeks ago #339721 by Mr. Mass
Replied by Mr. Mass on topic qtdragon mod
A new day, new challengesimage missing /media/kunena/emoticons/smile.png
I'm trying to configure MPG, added HAL pins, seems like everything worked out. But there is a problem I can't solve. When MPG is activated, it is still possible to change the increments of movement on the screen. It would be great if this widget could only display the selected increment without the ability to change it. And when MPG is inactive, it should be possible to change the value on the screen again. But I couldn't figure out how to do it.

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

Moderators: cmorley
Time to create page: 0.079 seconds
Powered by Kunena Forum