Question about keyboard for cnc build
16 Mar 2021 22:41 #202536
by andypugh
Replied by andypugh on topic Question about keyboard for cnc build
matrix_kb and sendkeys expect 0x80 + code for Key Up and 0x40 + code for key down. So the key-up is a match, but key-down won't fit.
The 7i73 also sends 0x00 as an "all up" and 0x40 as "nothing".
You could manipulate the codes inside your Python to suit, but you might as well just make the Python send keys and set HAL pins.
See here for how to set up HAL pins in Python code:
linuxcnc.org/docs/2.8/html/hal/halmodule.html
Note that setting HAL pins with set_p etc is documented there, but the component really should create its own pins and manipulate them using the h = value method.
The 7i73 also sends 0x00 as an "all up" and 0x40 as "nothing".
You could manipulate the codes inside your Python to suit, but you might as well just make the Python send keys and set HAL pins.
See here for how to set up HAL pins in Python code:
linuxcnc.org/docs/2.8/html/hal/halmodule.html
Note that setting HAL pins with set_p etc is documented there, but the component really should create its own pins and manipulate them using the h = value method.
Please Log in or Create an account to join the conversation.
- robertspark
- Offline
- Platinum Member
Less
More
- Posts: 915
- Thank you received: 216
16 Mar 2021 23:08 - 16 Mar 2021 23:35 #202541
by robertspark
Replied by robertspark on topic Question about keyboard for cnc build
thanks Andy, I can create the pins (all 112) no problem and change their status from true to false.
I can link them to other hal pins.
however, what I am struggling to figure out is how to create a component that simulates a keypress
I've been looking at many options but all I am looking for is simple means to input keypresses into the MDI..... no mouse movement.... just be able to type a G/M/etc.... or maybe G00/G01 etc
I know that there are methods / functions / libraries / programmes such as
xdotool
pynput.py
keyboard.py
I am ok to load / install them and use them but I was wondering if there is a built in bash tool or python library that is installed as a default setup as part of the linuxcnc.iso.....
I don't like to add files that are not necessary if there is something inbuilt
I can link them to other hal pins.
however, what I am struggling to figure out is how to create a component that simulates a keypress
I've been looking at many options but all I am looking for is simple means to input keypresses into the MDI..... no mouse movement.... just be able to type a G/M/etc.... or maybe G00/G01 etc
I know that there are methods / functions / libraries / programmes such as
xdotool
pynput.py
keyboard.py
I am ok to load / install them and use them but I was wondering if there is a built in bash tool or python library that is installed as a default setup as part of the linuxcnc.iso.....
I don't like to add files that are not necessary if there is something inbuilt
Last edit: 16 Mar 2021 23:35 by robertspark.
Please Log in or Create an account to join the conversation.
- robertspark
- Offline
- Platinum Member
Less
More
- Posts: 915
- Thank you received: 216
16 Mar 2021 23:41 #202543
by robertspark
Replied by robertspark on topic Question about keyboard for cnc build
trying to find (and understand) the on-screen keyboard as I would have thought that they use keypress / keyup/ keydown combination with mouse down and up....
Please Log in or Create an account to join the conversation.
16 Mar 2021 23:43 #202544
by andypugh
It probably makes sense to read a config file, which is a list of rows and columns, and create HAL pins or keystrokes accordingly.
Something like:Which would create HAL pins called "coolant" and "run" and send a 44 key event (KEY_Z) for the third. And do nothing for the blanks.
I think that python-evdev looks like the best way:
python-evdev.readthedocs.io/en/latest/
This seems a close match to the way that my sendkeys component does it in C.
The keycodes are here: wiki.linuxcnc.org/cgi-bin/wiki.pl?Scancodes
Replied by andypugh on topic Question about keyboard for cnc build
thanks Andy, I can create the pins (all 112) no problem and change their status from true to false.
It probably makes sense to read a config file, which is a list of rows and columns, and create HAL pins or keystrokes accordingly.
Something like:
r1c1 pin coolant
r1c2 pin run
r1c3 key 44
r1c4
r1c5
...
I am looking for is simple means to input keypresses into the MDI.
I think that python-evdev looks like the best way:
python-evdev.readthedocs.io/en/latest/
This seems a close match to the way that my sendkeys component does it in C.
The keycodes are here: wiki.linuxcnc.org/cgi-bin/wiki.pl?Scancodes
The following user(s) said Thank You: robertspark
Please Log in or Create an account to join the conversation.
- robertspark
- Offline
- Platinum Member
Less
More
- Posts: 915
- Thank you received: 216
16 Mar 2021 23:56 #202545
by robertspark
Replied by robertspark on topic Question about keyboard for cnc build
thanks very much, off to study
Please Log in or Create an account to join the conversation.
17 Mar 2021 00:02 - 17 Mar 2021 00:04 #202546
by andypugh
Replied by andypugh on topic Question about keyboard for cnc build
thanks Andy, I can create the pins (all 112) no problem and change their status from true to false.
It probably makes sense to read a config file, which is a list of rows and columns, and create HAL pins or keystrokes accordingly.
Something like:Which would create HAL pins called "coolant" and "run" and send a 44 key event (KEY_Z) for the third. And do nothing for the blanks or for rows/columns omitted.r1c1 pin coolant r1c2 pin run r1c3 key 44 r1c4 r1c5 ...
Parsing in Python can be done with regexes, to parse the above format:import re ... [row, column, type, val] = re.split("r(\d*)c(\d*) (.*?) (.*)", "r1c2 pin hello")[1:5]
I find this web site invaluable for experimenting with regexes: regexr.com
I am looking for is simple means to input keypresses into the MDI.
I think that python-evdev looks like the best way:
python-evdev.readthedocs.io/en/latest/
This seems a close match to the way that my sendkeys component does it in C.
The keycodes are here: wiki.linuxcnc.org/cgi-bin/wiki.pl?Scancodes
Last edit: 17 Mar 2021 00:04 by andypugh.
The following user(s) said Thank You: robertspark
Please Log in or Create an account to join the conversation.
17 Mar 2021 00:46 #202552
by andypugh
Replied by andypugh on topic Question about keyboard for cnc build
Also look at PanelUI. That can also respond to key codes, and does a lot more too.
linuxcnc.org/docs/2.8/html/gui/panelui.html
linuxcnc.org/docs/2.8/html/gui/panelui.html
The following user(s) said Thank You: robertspark
Please Log in or Create an account to join the conversation.
- robertspark
- Offline
- Platinum Member
Less
More
- Posts: 915
- Thank you received: 216
17 Mar 2021 22:31 #202663
by robertspark
Replied by robertspark on topic Question about keyboard for cnc build
thanks andy, penny has (finally) dropped..... sendkeys it is!
I see an easy way forward using pins in sendkeys
thank you very much
I see an easy way forward using pins in sendkeys
thank you very much
Please Log in or Create an account to join the conversation.
Time to create page: 0.085 seconds