Thanks. I managed to add an I/O pin for the jog speed. It stays in sync with the slider and allows to r/w the jog speed.
It's quite a messy hack and consists of more comments than code in order to remember what I did and why.
It would be great if the pin would be added officially as you suggested.
In the meantime here is the python code, in case somebody else needs the functionality:
Code:
################################################################################################
# Description:
# This script creates a HAL pin to read/write the jog speed selected in the axis ui.
# It allows to access the ui jog speed via HAL (e.g. keep the ui in sync with physical
# jog speed controls and vice-versa).
#
# HAL pin:
# Name: axisui.jog.speed
# Type: float
# Direction: I/O
#
# Compatibility:
# Tested on LinucCNC 2.8.2 only
#
# Usage:
# Set this file as the user command file in the ini's display section. See docs for details.
# [DISPLAY]
# USER_COMMAND_FILE = axis_hal_jog_speed.py
#
# If a user command file is already in use, just merge the code accordingly:
# - HalJogspeed.init() must be called in user_hal_pins()
# - HalJogspeed.update() must be called in user_live_update()
# - class HalJogspeed must be in scope
# Note:
# The jog speed slider moves in steps and has a max and min value.
# Writing a value to the hal pin will select the nearest possible slider step and then update
# the hal pin to the resulting slider value.
# The hal pin will also 'self correct' it's value to stay in the configured jog speed bounds
# of the Axis-ui.
################################################################################################
# axis user callbacks, see docs
def user_hal_pins():
HalJogspeed.init()
def user_live_update():
HalJogspeed.update()
# keep axis namespace tidy
class HalJogspeed:
@staticmethod
def init():
# create and init hal pin with current ui jogspeed
comp.newpin("jog.speed", hal.HAL_FLOAT, hal.HAL_IO)
comp["jog.speed"] = vars.jog_speed.get()
### hook into slider change callback
# make python function availabe to tk
nf.makecommand(root_window, "jogspeed_slider_change", HalJogspeed.__slider_change)
# redirect the change callback
root_window.tk.eval("${pane_top}.jogspeed.s configure -command jogspeed_slider_change")
@staticmethod
def update():
# bail if hal pin is in sync with jog speed var
if comp["jog.speed"] == vars.jog_speed.get(): return
# write hal pin value to the jog speed var
vars.jog_speed.set(comp["jog.speed"])
# update the slider
root_window.tk.eval("${pane_top}.jogspeed.s set [setval $jog_speed $max_speed]")
# debug
print "[HalJogspeed] HAL -> UI", vars.jog_speed.get()
@staticmethod
def __slider_change(val):
# call the original tk callback; this will update the jog_speed var
root_window.tk.call("update_jog_slider_vel", val)
# write resulting jog speed to the hal pin
comp["jog.speed"] = vars.jog_speed.get()
# debug
print "[HalJogspeed] UI -> HAL", vars.jog_speed.get()