Custom user Button Touchoff in Axis

More
06 Sep 2020 12:24 #180979 by phillc54
Find the code in Axis you want to hack then have a look here:
linuxcnc.org/docs/2.8/html/gui/axis.html..._an_existing_command
The following user(s) said Thank You: snowgoer540

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

More
06 Sep 2020 23:38 #181073 by snowgoer540

Find the code in Axis you want to hack then have a look here:
linuxcnc.org/docs/2.8/html/gui/axis.html..._an_existing_command


Ok, so trying to figure this out here. Not really sure I know where things go, but I found
commands.set_view_z() 
in the link you gave me, and I figured that might work if I could figure out how to call it... to test, I changed it to view_x to see if it moved at first. My thought being I may have to have it move off of Z and then go back to Z to get it to work.

Anyways, I added:
def rezoom():
      commands.set_view_x()

And further down I added
TclCommands.rezoom = rezoom

but I really dont know how to call that from a click in the ini file. Just adding "rezoom" to the button code gives an error.

Forgive how green I look at the moment, I spent over an hour trying to figure this out this evening. A few nudges in the right direction would be helpful. :blush:

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

More
07 Sep 2020 06:28 - 07 Sep 2020 06:44 #181096 by phillc54
I have a pendant so I figured doing it with a HAL pin would be a good option. All the coding is in plasmac_axis.py.
We need to add a HAL pin then test the value of that pin on every Axis update.
We need to do three things to achieve our goal, reload the file, clear the live plot then set the view to Z. These can have timing issues if we try to do them in one hit because we update every 0.1~0.15 seconds which is not enough time to complete everything. So we need to run them sequentially, each time we do one function we increment the HAL pin then test again on the next cycle. We don't care if the HAL pin get set to an unused value as the sequence only begins if the value is one.

The button coded ended up:
BUTTON_5_CODE           = G10 L20 P0 X0 Y0 \ %halcmd setp axisui.touchoff 1

Edit: refresh is probably a better name for the HAL pin as it doesn't actually touchoff

Video:
Warning: Spoiler!
Last edit: 07 Sep 2020 06:44 by phillc54.

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

More
07 Sep 2020 10:36 - 07 Sep 2020 10:37 #181114 by snowgoer540
I guess I should have read this post first, either you brilliantly anticipated our needs, or there's an update lurking :laugh:

This looks awesome! I can't wait to see the code to see how many weeks it would have taken me to do the same lol
Last edit: 07 Sep 2020 10:37 by snowgoer540.

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

More
07 Sep 2020 10:41 #181116 by phillc54
If you want to keep practising then the first function you found is used along with two others with a similar beginning.
The following user(s) said Thank You: tommylight

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

More
07 Sep 2020 10:51 #181119 by snowgoer540

If you want to keep practising then the first function you found is used along with two others with a similar beginning.

Ok, so what I'm thinking at my kitchen table with my first cup of coffee is, you created a HAL pin, and set it to 0. Then plasmac_axis checks constantly to see if it changed states. When you press the button, it changes the HAL pin from a 0 to a 1. Then that kicks off a little routine, which increments at each read cycle of the system. Cycle 1 reloads the file. Cycle 2 clears the live plot. Cycle 3 re-zooms the preview, and sets both the HAL pin and the counter back to zero. Sound close?

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

More
07 Sep 2020 10:54 #181121 by phillc54

Ok, so what I'm thinking at my kitchen table with my first cup of coffee is, you created a HAL pin, and set it to 0. Then plasmac_axis checks constantly to see if it changed states. When you press the button, it changes the HAL pin from a 0 to a 1. Then that kicks off a little routine, which increments at each read cycle of the system. Cycle 1 reloads the file. Cycle 2 clears the live plot. Cycle 3 re-zooms the preview, and sets both the HAL pin and the counter back to zero. Sound close?

Yep, that it...

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

More
07 Sep 2020 11:04 #181128 by snowgoer540

Yep, that it...

On my end, the logic of it is the easy part... now to figure out how to charm the Python snakes. :lol:

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

More
07 Sep 2020 11:18 #181133 by snowgoer540
Give me one quick nudge here please... where is the proper place to establish the "axisui.refresh" HAL pin? Hal connections file?

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

More
07 Sep 2020 11:22 #181134 by phillc54

Give me one quick nudge here please... where is the proper place to establish the "axisui.refresh" HAL pin? Hal connections file?

All the code for this needs to be in plasmac_axis.py, you should be able to find in there where HAL pins are created and also the function that runs every cycle.

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

Moderators: snowgoer540
Time to create page: 0.218 seconds
Powered by Kunena Forum