Keyboard simulation within a userspace component

More
7 years 8 months ago #126717 by silopolis
Hi,

dm17ry wrote: 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 to join the conversation.

More
7 years 8 months ago #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/

Please Log in to join the conversation.

More
7 years 8 months ago #126763 by silopolis

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


Thank you very much

Please Log in to join the conversation.

More
7 years 8 months ago #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.

Please Log in to join the conversation.

More
7 years 8 months ago #126863 by silopolis
Hi

dm17ry wrote: 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 to join the conversation.

More
5 years 9 months ago #194579 by porshe
Hello dm17ry. Could you post your project again? I can't find anything except photos.

Please Log in to join the conversation.

More
5 years 9 months ago #194630 by dm17ry
done. same place

Please Log in to join the conversation.

More
5 years 9 months ago #194647 by porshe
Thank you very much for your work.

Please Log in to join the conversation.

More
5 years 4 months ago #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 to join the conversation.

More
5 years 4 months ago #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 to join the conversation.

Time to create page: 0.426 seconds
Powered by Kunena Forum