Keyboard simulation within a userspace component

More
18 Feb 2019 15:08 #126717 by silopolis
Hi,

i did a membrane keyboard controller using a STM32 as a USB HID. it emulates a standard keyboard plus a bunch of other keys which were handled by hal_input comp. rotary encoder and analog joystick can switch between being a mouse with a wheel and linuxcnc's MPG and joystick. 24-pos rotary switch is handled by an ADC. drives a chain of RGB addressable LEDs. also has a few hardware buttons for cycle start/stop etc...

if someone interested can share the code, but it is a bit more than a little messy, i think... :)


I'm contemplating building a similar panel and would love to know more about this gorgeous one as well as study the code if you will.

Thank you in advance

Best
Jeremie

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

More
19 Feb 2019 06:52 - 19 Feb 2019 06:54 #126751 by dm17ry
i haven't managed to touch the code since then, it is as ugly and undocumented as i first got it working a while back... i zipped entire project dir anyway:

yurtaev.com/yop/

most of source files in there were generated by STM32CubeMX for Keil MDK 5.
USB stuff is in Middlewares/ST/STM32_USB_Device_Library/Class/HID/Src/
Last edit: 19 Feb 2019 06:54 by dm17ry.

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

More
19 Feb 2019 11:45 #126763 by silopolis

... i zipped entire project dir anyway:
yurtaev.com/yop/
.../


Thank you very much

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

More
20 Feb 2019 15:36 - 20 Feb 2019 15:51 #126822 by dm17ry
if you have any questions, please ask. some notes below.

the code implements 3 HID interfaces/endpoints:
1. a keyboard with most of standard keys mapped somewhere on the matrix. this will work everywhere including BIOS setup, but the keymap doesn't match as a standard USB keyboard can only have the standard layout...
2. a wheel mouse emulated by the analog joystick, 2 buttons and the MPG wheel
3. a custom HID with 3 buttons, 32-pos dial (rotary switch), 2-axis joystick, a wheel (MPG), 64 keys, 11 LEDs

after linux boots i set a custom xkb keymap (yop_fagor) which fixes the layout so keys with shift produce correct symbols which are printed on them.

all HID events from the controller are processed by the linux input device. in linuxcnc i use hal_input. the sim_encoder component in 16k20.hal is used to generate a pulse train and feed it to a watchdog in the controller thru unused LED setting messages. it signals the controller that hal_input is listening, to switch the keyboard layout once again: to a linuxcnc/axis-optimized one, joystick/MPG events are being sent thru the custom interface 3 so they are visible at hal_input pins.

the rotary switch position 0 (unmarked/unused on the fagor panel) is treated specially - it re-enables mouse/wheel emulation.

on the hardware.
the MCU is STM32F103C8T6 on DIP40 PCB. the only additional electronic components used are 4 resistors to scale down 5V voltage outputs of the joystick to match ADC input range.

the key matrix is 8 rows/14 columns. MCU internal weak pull-up resistors are enabled for column inputs. a few unused crossings in the matrix are used to wire external hardware buttons.

the 24-pos rotary switch has 120ohm resistors soldered between terminals, so it effectively acts as a 2.76kOm potentiometer. it is given a 3.3v voltage across with the wiper connected to the MCU ADC input. ADC resolution/noise is enough to reliably detect 24 positions.

LEDs are a string of serial-addressed WS2812 RGB LEDs so 8 of them need only 1 pin on the MCU.

the MPG has 5V TTL output, wired directly. quadrature counting is done by the timer configured in encoder mode.
Last edit: 20 Feb 2019 15:51 by dm17ry.
The following user(s) said Thank You: silopolis

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

More
21 Feb 2019 15:24 #126863 by silopolis
Hi

if you have any questions, please ask. some notes below.


Thank you very much for taking the time to write all those notes.
Will get back to you when I'll reach this stage

Very best
Jeremie

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

More
09 Jan 2021 11:26 #194579 by porshe
Hello dm17ry. Could you post your project again? I can't find anything except photos.

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

More
09 Jan 2021 18:01 #194630 by dm17ry
done. same place

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

More
09 Jan 2021 21:02 #194647 by porshe
Thank you very much for your work.

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

More
13 Jun 2021 17:26 #211953 by microsprintbuilder
I have a Haas VF I would like to reuse the existing membrane keys that look just like what you have. Did you ever get it working?

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

More
15 Jun 2021 22:56 #212151 by andypugh
This is a bit of a zombie thread.

You might also like to look at:

linuxcnc.org/docs/2.8/html/man/man1/sendkeys.1.html

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

Time to create page: 0.294 seconds
Powered by Kunena Forum