DevTerm Keyboard firmware mod: hot mode switching / gear switching

though there’s no perceivable difference in power consumption

Tried to squeeze out a few milliamps while the core is too excited about the keyboard
OOoooOOoohhh my keybooooard poll poll poll poll
there goes 100mA
:confused:

N̶o̶ ̶w̶o̶r̶k̶y̶,̶ ̶h̶a̶d̶ ̶t̶o̶ ̶r̶e̶v̶e̶r̶t̶ ̶t̶o̶ ̶p̶r̶e̶v̶i̶o̶u̶s̶ ̶o̶n̶e̶ xD
EDIT: no wait i’m stupid. downloaded an html file and tried to flash that, LOL

Works great (:

  • Adds horizontal scroll to JS mouse

Fun side note: as USB HID standards only define a vertical mouse wheel, mouses today rely on a “consumer device - AC Pan” to describe horizontal scrolling.

AC Pan, like panning the wind out of AC? Nice to have.

Thanks so much for this. This is the most essential community upgrade I have installed yet, I love being able to switch to the dpad-mouse.

However, I can’t get the service to start. Here’s the log from journalctl:

Jun 11 21:15:31 clockworkpi-a06 python3[1629]: Traceback (most recent call last):
Jun 11 21:15:31 clockworkpi-a06 python3[1629]: File “/usr/local/bin/devterm_keyboard.py”, line 1, in
Jun 11 21:15:31 clockworkpi-a06 python3[1629]: import serial
Jun 11 21:15:31 clockworkpi-a06 python3[1629]: ModuleNotFoundError: No module named ‘serial’
Jun 11 21:15:31 clockworkpi-a06 systemd[1]: devterm-keyboard.service: Main process exited, code=exited, status=1/FAILURE
Jun 11 21:15:31 clockworkpi-a06 systemd[1]: devterm-keyboard.service: Failed with result ‘exit-code’.

If you have a moment I’d appreciate your help! No worries if there isn’t a clear answer to this problem though.

glad you like it :stuck_out_tongue:
try install the serial module: sudo pip install serial
if it then complains about pip not found, then install pip (depends on what distro you’re on).

OK, halfway there… now journalctl says

File “/usr/local/bin/devterm_keyboard.py”, line 3, in
ser = serial.Serial(’/dev/ttyACM0’)
AttributeError: module ‘serial’ has no attribute ‘Serial’

EDIT: I’ll do some research, but I figured I would ask since you so kindly replied so quickly! Thanks for your help!

My bad. It should be: pip install pyserial
It’s in the Makefile but I commented it out

1 Like

Version 2 is released. See 1st post.
@pkr new feature, true powa savage!

3 Likes

Version 3 “emergency grooming” released ((

3 Likes

Version 4 is released, featuring Mouse Overlay.

2 Likes

I love it so much, that you focus on tinkering with the little details and offer help and functionality to the community.

I just struggle to understand, what you did?
Is there an easy way to understand you Upgrades and what the additional functionality brought by the version jumps actually means?

Looks like the flashing went fine on the presumably v4 firmware. Seems like fantastic work! Thank you!

Some questions:

  • Does your version include the changes from the post I've rewritten DevTerm keyboard & trackball firmware
  • Is there any visual indication of the mode/cpu gear? How do you find out? There doesn’t appear to be any, unlike the screenshot.
  • Your download doesn’t seem to have the sources, is the source available somewhere? No way to build manually.
  • Your post mentions services, but those would be in the missing sources directory
  • The git status shows that the bin file had been modified but not checked in. Could you include an sha256 sum of the current binary?
  • Possibly rename the download to include the version number?

FYI I am now on Ubuntu LTS 22.0.4.1 after upgrading, perhaps something has changed/

@jan-peter

I just struggle to understand, what you did?

:smiley: just random bits to improve the keyboard fw, including DPAD mouse, low power mode etc.

The changelog for version bumps are noted at the bottom of the post.

@mowgli

Yes! The trackball improvement was grafted into the official repo, and my work started afterwards.

  • Is there any visual indication of the mode/cpu gear? How do you find out?

This is done by installing the keyboard service, which will send notifications to the X11 desktop. Not ideal – I wish there were LEDs in the front panel for this.

  • Your download doesn’t seem to have the sources, is the source available somewhere? No way to build manually.

It’s in the repo at the top of the post. The keyboard service is also there: https://github.com/yatli/DevTerm/tree/main/Code/devterm_keyboard/service

  • The git status shows that the bin file had been modified but not checked in. Could you include an sha256 sum of the current binary?

Got to make sure we’re on the same page: you cloned the repo and built it, and then git status? Which files are changed? I don’t think there’s a build pipeline to obtain keyboard fw yet. The zipped fw files are built with the arduino IDE, then manually assembled.

  • Possibly rename the download to include the version number?

image

Emmm… you mean versions attached to files after unzip?

1 Like

Yes, sorry for the confusion. I’ve been reading most of these from my phone so I think I might have missed some things.
I downloaded the FW file from the original post, which included .git and the git history. That file wasn’t named that way. Let me check again.

Ok, so good news is I verified I have the correct firmware on the keyboard. I tried changing modes, but for some reason it wasn’t going back to Joystick Mode, but the d-pad keys were working in the terminal as regular keystrokes. Everything seems to be working, until I install the services. Nothing seems to happen so I do a reboot, but now the built in keyboard fails. Nothing works, not typing or rollerball.
Could this be a difference with udev rules in Ubuntu 22.04.1?

Unplugging the keyboard and re-plugging didn’t help.
Dmesg sees the keyboard:

[  285.744015] usb 5-1.1: USB disconnect, device number 3
[  343.055123] usb 5-1.1: new full-speed USB device number 6 using ehci-platform
[  343.164888] usb 5-1.1: New USB device found, idVendor=1eaf, idProduct=0003, bcdDevice= 2.01
[  343.164916] usb 5-1.1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[  343.164935] usb 5-1.1: Product: Maple 003
[  343.164951] usb 5-1.1: Manufacturer: LeafLabs
[  343.164967] usb 5-1.1: SerialNumber: LLM 003

EDIT: So apparently connecting via USB works correctly:

[ 2577.678093] usb 5-1.4: new full-speed USB device number 13 using ehci-platform
[ 2577.787888] usb 5-1.4: New USB device found, idVendor=1eaf, idProduct=0003, bcdDevice= 2.01
[ 2577.787919] usb 5-1.4: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 2577.787937] usb 5-1.4: Product: Maple 003
[ 2577.787954] usb 5-1.4: Manufacturer: LeafLabs
[ 2577.787970] usb 5-1.4: SerialNumber: LLM 003
[ 2578.735633] usb 5-1.4: USB disconnect, device number 13
[ 2578.958128] usb 5-1.4: new full-speed USB device number 14 using ehci-platform
[ 2579.069130] usb 5-1.4: New USB device found, idVendor=1eaf, idProduct=0024, bcdDevice= 2.00
[ 2579.069158] usb 5-1.4: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 2579.069177] usb 5-1.4: Product: DevTerm
[ 2579.069193] usb 5-1.4: Manufacturer: ClockworkPI
[ 2579.069210] usb 5-1.4: SerialNumber: 20210531
[ 2579.075895] input: ClockworkPI DevTerm Consumer Control as /devices/platform/fe380000.usb/usb5/5-1/5-1.4/5-1.4:1.0/0003:1EAF:0024.000E/input/input24
[ 2579.134963] input: ClockworkPI DevTerm Keyboard as /devices/platform/fe380000.usb/usb5/5-1/5-1.4/5-1.4:1.0/0003:1EAF:0024.000E/input/input25
[ 2579.136954] input: ClockworkPI DevTerm as /devices/platform/fe380000.usb/usb5/5-1/5-1.4/5-1.4:1.0/0003:1EAF:0024.000E/input/input26
[ 2579.137915] input: ClockworkPI DevTerm Mouse as /devices/platform/fe380000.usb/usb5/5-1/5-1.4/5-1.4:1.0/0003:1EAF:0024.000E/input/input27
[ 2579.139075] hid-generic 0003:1EAF:0024.000E: input,hidraw2: USB HID v1.10 Keyboard [ClockworkPI DevTerm] on usb-fe380000.usb-1.4/input0
[ 2579.140090] cdc_acm 5-1.4:1.1: ttyACM0: USB ACM device

But reconnecting it normally doesn’t work.

Try to disable devterm-mouse.service first:

systemctl --user stop devterm-mouse.service
systemctl --user disable devterm-mouse.service

That’s the part that interact with uinput and the udev rule.

You can also check the status of the service: systemctl status devterm-keyboard.service
If it says service “dead” with some logs, please post it here.

You can also stop the keyboard service, using sudo this time:
sudo systemctl stop devterm-keyboard.service
sudo systemctl disable devterm-keyboard.service

After both services are disabled, unplug and plug it back, check if it works.
When the keyboard is powered up, it will have the DPAD in mouse mode.


I downloaded the FW file from the original post, which included .git and the git history. That file wasn’t named that way. Let me check again.

Ok now I remember. Let me explain this a little bit:

  • Official firmware shell scripts: when you run that (e.g. DevTerm_keyboard_firmware_v0.3_utils.sh), it self-extracts the actual firmware, and flashing scripts then execute that (like the NVIDIA Linux driver run.sh :smiley: ). The .git directory comes from that and I didn’t clear it up.
  • I did not figure out how to build that self-extracting shell script, so I just replaced the actual firmware with mine and zipped it.

I rebooted, had the same problem, then completely powered off the DevTerm, took out the batteries and rebooted. I think there must be some hardware caching of usb locations internally. Now everything seems to work again on the keyboard and rollerball. The display notification doesn’t appear to work though, and I have pyserial installed both locally and as root (Your script does the pip install as root). How do you debug or find errors from the service?

Just run the script behind the service, directly:
sudo devterm_keyboard.py and see if it crashes or print out some logs

The installer Makefile says: ln -s which gearbox-clockworkpi-a06 /usr/local/bin/devterm_gearbox.py
This is wrong for Armbian. So the keyboard service probably won’t start…

× devterm-keyboard.service - devterm keyboard service
     Loaded: loaded (/etc/systemd/system/devterm-keyboard.service; enabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Thu 2022-08-04 08:29:51 UTC; 25min ago
    Process: 2014 ExecStart=/usr/bin/python3 /usr/local/bin/devterm_keyboard.py (code=exited, status=1/FAILURE)
   Main PID: 2014 (code=exited, status=1/FAILURE)
        CPU: 149ms

Aug 04 08:29:51 clockworkpi-a06 systemd[1]: devterm-keyboard.service: Scheduled restart job, restart counter is at 5.
Aug 04 08:29:51 clockworkpi-a06 systemd[1]: Stopped devterm keyboard service.
Aug 04 08:29:51 clockworkpi-a06 systemd[1]: devterm-keyboard.service: Start request repeated too quickly.
Aug 04 08:29:51 clockworkpi-a06 systemd[1]: devterm-keyboard.service: Failed with result 'exit-code'.
Aug 04 08:29:51 clockworkpi-a06 systemd[1]: Failed to start devterm keyboard service.

Thought so.

sudoedit /usr/local/bin/devterm_keyboard.py, and you can remove gear-related logic like this:

  • Line 7, # import devterm_gearbox, comment out by placing a “#” in the front.
  • Line 28, # devterm_gearbox.devterm.set_gear(gear)
  • Line 30, # devterm_gearbox.echo(gear, gear_file)
  • Line 80, # devterm_gearbox.devterm.set_gear(gear)