Skip to content

About

ZMK config for TOTEM split keyboard

Resources

Stars

0 stars

Watchers

0 watching

Forks

 
 

Repository files navigation

TOTEM logo font

ZMK CONFIG FOR THE TOTEM SPLIT KEYBOARD

Here you can find the hardware files and build guide.
Here you can find the QMK config for the TOTEM.

TOTEM is a 38 key column-staggered split keyboard running ZMK or QMK. It's meant to be used with a SEEED XIAO BLE or RP2040.

TOTEM layout

The image above shows the upstream default layout. This fork uses its own QWERTY layout, described below.

WHAT'S DIFFERENT IN THIS FORK

Keymap

  • QWERTY base layer with home-row mods: A/; Cmd, S/L Option, D/K Ctrl, F/J Shift.
  • Hold Tab (left middle thumb) for the NAV layer: arrows, Home/End, Page Up/Down and a numpad.
  • Hold Esc (right middle thumb) for the SYM layer.
  • Hold Tab + Enter (left middle and right inner thumb) for the ADJ layer: Bluetooth profiles, output toggle, F-keys, reset and bootloader.
  • Q + W together send Esc.
  • ZMK is pinned to v0.3 in config/west.yml, and a settings_reset firmware is built alongside the two halves.

Battery reporting for both halves

  • The left half (central) forwards the right half's battery level to the computer, so both levels are available over Bluetooth (config/totem.conf).
  • macOS' own Bluetooth menu only shows the left half. Use the status page or the menu bar app below to see both.

More accurate battery percentage

ZMK's default estimate is a straight line between 3.45 V and 4.2 V, and only reports 100% at 4.2 V, which a resting battery rarely reaches. This fork adds its own driver (drivers/battery/battery_lipo_divider.c) that:

  • maps the voltage to a typical LiPo discharge curve, and
  • corrects each half's readings for its own XIAO board's measurement error.

The divider resistors' tolerance and the ADC's gain error make every XIAO read the same battery a few percent differently, so each half has its own voltage-scale-permille in config/boards/shields/totem/totem_left.overlay and totem_right.overlay (currently 1037 and 1012, where 1000 means no correction). Raise a half's value if a full battery stops short of 100%; lower it if the level stays at 100% for too long after charging. The value belongs to the board: recalibrate after swapping a XIAO, but not after replacing a battery.

Battery life

The left half drains several times faster than the right: as the central of the split link it has to wake for every connection event (every 7.5 ms), while the right half may skip most of them when it has nothing to send. Two changes reduce the drain without affecting typing:

  • Deep sleep (config/totem.conf). The left half powers off after 30 minutes without a key press, the right half after 60 (config/totem_right.conf), and neither sleeps on USB power. A key press wakes a half, but that press is not typed. The right half sleeps later because it only sees its own keys: this way it does not drop off while the left half is still in use, and after breaks shorter than an hour a key on the left half wakes the whole keyboard.
  • Power saving when idle (src/idle_power_saving.c). After 30 seconds without a key press (ZMK's idle state) the left half slows the split link to 30 ms, and the next key press restores 7.5 ms. While typing nothing changes; the first right-half key after a pause can arrive up to about 20 ms later. It is on by default, and a bonded host can switch it through a small GATT service (the menu bar app's Power Saving When Idle item). The setting is stored on the keyboard.

Advertise key for the status page

Chrome's Web Bluetooth device picker on macOS only lists devices that are advertising, and ZMK stops advertising once it is connected. Press Tab + Enter + B (ADJ layer) to make the left half advertise for 10 seconds (drivers/behaviors/behavior_adv_burst.c).

The advertising is non-connectable, so it cannot open a new connection or drop the existing one. If the host connects, disconnects or the profile changes during those 10 seconds, the burst stops and ZMK's normal advertising takes over again.

Battery status page

web/index.html is a single-file page that reads both halves' battery levels over Web Bluetooth and keeps them updated. It is also hosted at ca110.us/keyboard.

  1. Open the page in Chrome or Edge (Safari and Firefox do not support Web Bluetooth).
  2. Click Connect keyboard, then press Tab + Enter + B on the keyboard.
  3. Pick TOTEM in the dialog.

Add ?demo to the URL to preview the page with sample data.

macOS menu bar app

macos/TotemBattery is a small AppKit menu bar app. It reads both halves' battery levels from the already-connected keyboard, so no advertise key is needed.

  • The menu bar shows the TOTEM icon with a dot for the lower of the two halves: green at 50% and above, yellow from 20%, red below 20%.
  • The menu lists each half's level, a refresh item, the keyboard's Power Saving When Idle setting and an Open at Login toggle.
  • Notifications warn when a half drops below 20% and again below 10%, and when the right half loses its link to the left half for 30 seconds while the keyboard stays connected. The whole keyboard disconnecting is not reported, since it powers off on purpose when idle, and drops while the Mac goes to sleep are ignored. Each kind can be switched off in the menu (Low Battery Alerts, Disconnect Alerts).
  • It subscribes to battery notifications instead of polling, and uses about 14 MB of memory.

Build it with macos/TotemBattery/build.sh, or create an installable disk image with macos/TotemBattery/package.sh (written to macos/TotemBattery/build/TotemBattery.dmg). It requires macOS 13 or later and asks for Bluetooth access on first launch. The app is ad-hoc signed, so it is meant for the Mac it was built on.

Repository layout

Path Contents
config/ Keymap, shield definition and ZMK settings
drivers/, src/, dts/, Kconfig, CMakeLists.txt, zephyr/module.yml The battery driver, advertise behavior and idle power saving, loaded by the build as a Zephyr module
web/ Battery status page
macos/TotemBattery/ Menu bar app

HOW TO USE

  • fork this repo
  • git clone your repo, to create a local copy on your PC (you can use the command line or github desktop)
  • adjust the config/totem.keymap file (find all the keycodes on the zmk docs pages)
  • git push your repo to your fork
  • on the GitHub page of your fork navigate to "Actions"
  • scroll down and unzip the firmware.zip archive that contains the latest firmware
  • connect the left half of the TOTEM to your PC, press reset twice
  • the keyboard should now appear as a mass storage device
  • drag'n'drop the totem_left-seeeduino_xiao_ble-zmk.uf2 file from the archive onto the storage device
  • repeat this process with the right half and the totem_right-seeeduino_xiao_ble-zmk.uf2 file.

Flashing tips

  • With the GitHub CLI you can download the firmware of a build directly:
    gh run download <run-id> -R <owner>/zmk-config-totem -n firmware -D ~/Downloads/totem-firmware
    
  • The left half can also enter the bootloader from the ADJ layer (Tab + Enter + A). The right half needs the double reset.
  • On a XIAO BLE the storage device is called XIAO-SENSE. If Finder fails to copy the file, use cp -X <file>.uf2 /Volumes/XIAO-SENSE/.
  • Bluetooth pairings are kept when flashing. Only if the halves stop pairing with each other, flash settings_reset-seeeduino_xiao_ble-zmk.uf2 to both halves, then flash the normal firmware again.

About

ZMK config for TOTEM split keyboard

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages