Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

5 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

FunModularKeyboard โ€” Modular Macro Keypad

An ESP32-S3 powered modular macro keyboard featuring multi-key mapping, voice commands, speech-to-text, and magnetic snap-on expansion modules, all configurable via a companion desktop app.

Platform Framework


ๅฑๅน•ๆˆชๅ›พ 2026-07-19 162423 ๅฑๅน•ๆˆชๅ›พ 2026-07-18 232027 ๅฑๅน•ๆˆชๅ›พ 2026-07-18 231906 ๅฑๅน•ๆˆชๅ›พ 2026-07-18 232058 ๅฑๅน•ๆˆชๅ›พ 2026-07-19 162929

๐Ÿ“– Overview

FunModularKeyboard is a highly customizable macro keypad consisting of 1 main module + 2 magnetic expansion modules. The main unit communicates with expansion modules via a magnetic Pogo-Pin interface (IยฒC bus) with hot-plug support.

๐Ÿงฉ Hardware Architecture

Module MCU Description
Main Module ESP32-S3 TFT LCD display, 16-key matrix, rotary encoder, speaker, MEMS mic, Li-Po battery, RGB LEDs, magnetic host interface
Module A (ModA) STM8S103F3 3 rotary encoders + 2 slider potentiometers, IยฒC communication via magnetic connector
Module B (ModB) ESP32-S3 Based on SmartKnob โ€” brushless motor knob + strain gauge press sensing + LED ring, IยฒC via magnetic connector
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚            Main Module (ESP32-S3)            โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”‚
โ”‚  โ”‚ TFT โ”‚  โ”‚ 16-Key   โ”‚  โ”‚ Rotary Encoder โ”‚  โ”‚
โ”‚  โ”‚ LCD โ”‚  โ”‚ Matrix   โ”‚  โ”‚   + Button     โ”‚  โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”‚
โ”‚  โ”‚ Mic โ”‚  โ”‚Speakerโ”‚  โ”‚ RGB  โ”‚  โ”‚ Battery โ”‚  โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚
โ”‚         โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”                  โ”‚
โ”‚         โ”‚ USB  โ”‚  โ”‚ BLE  โ”‚  Dual-Mode HID   โ”‚
โ”‚         โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”˜                  โ”‚
โ”‚     โ•โ•โ•โ•โ•โ•โ•โ• Magnetic Pogo-Pin Port โ•โ•โ•โ•โ•โ•โ•  โ”‚
โ”‚          IยฒC + Power + UART                 โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚  Module A (STM8) โ”‚  Module B (ESP32-S3)     โ”‚
โ”‚  3ร— Encoders     โ”‚  BLDC Motor Knob (FOC)   โ”‚
โ”‚  2ร— Sliders      โ”‚  Strain Gauge Press      โ”‚
โ”‚                  โ”‚  8ร— LED Ring             โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

โœจ Features

โŒจ๏ธ Keyboard

  • 8 switchable keymap profiles โ€” toggle between profiles on-the-fly via the rotary encoder for different workflows
  • Macro key combos โ€” one keypress triggers multi-key combinations (e.g. Ctrl+Win+D to show desktop)
  • Multimedia controls โ€” play/pause, volume, track skip, etc.
  • USB HID + BLE dual-mode โ€” wired or wireless, your choice

๐ŸŽค Voice

  • Voice commands โ€” long-press the MIC key, speak a command, and trigger preset actions via Baidu ASR (e.g. "Open Spotify")
  • Speech-to-text โ€” voice input transcribed to text and sent to the PC
  • Custom keyword-to-script bindings supported

๐Ÿ’ป Companion Desktop App

A desktop configuration tool that communicates with the keyboard over WiFi/TCP:

  • ๐Ÿ—บ๏ธ Visual keymap editor โ€” drag-and-drop key function configuration
  • โš™๏ธ Device settings โ€” WiFi, RGB effects, display brightness/theme, volume, etc.
  • ๐Ÿ“œ Script engine โ€” Python script support for one-click app launching and desktop automation
  • ๐Ÿ”„ Firmware OTA updates โ€” wirelessly upgrade keyboard firmware
  • ๐Ÿ“Š PC status monitoring โ€” real-time CPU usage, disk space, and more shown on the keyboard display
  • ๐ŸŽต Music lyrics sync โ€” synchronized lyrics display while music plays
  • ๐Ÿ  HomeAssistant integration โ€” reserved interface for smart home control

๐ŸŽจ Visual

  • TFT LCD with LVGL โ€” rich GUI with multiple theme support
  • 16ร— WS2812B RGB LEDs โ€” rainbow, fire, meteor, pulse, and more effects
  • Music spectrum visualization โ€” real-time FFT audio spectrum animation
  • Status bar โ€” clock, battery level, connection status, active keymap profile, etc.

๐Ÿงฒ Expansion Modules

  • Module A โ€” 3 encoders + 2 sliders, ideal for color grading, audio mixing, video editing
  • Module B โ€” brushless motor knob (SimpleFOC), haptic feedback, strain-gauge press sensing, premium tactile feel
  • Expansion modules are plug-and-play via the magnetic connector with auto-detection

๐Ÿ“ Project Structure

FunModularKeyboard-OPEN/
โ”œโ”€โ”€ firmware/                         # Firmware source code
โ”‚   โ”œโ”€โ”€ FunModularKeyboard/           # Main module firmware (ESP32-S3, Arduino)
โ”‚   โ”‚   โ”œโ”€โ”€ src/                      # Core source
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ main.cpp              # Entry point
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ MainTask.cpp/h        # Main task scheduler
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ DisplayTask.cpp/h     # LVGL display task
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ MatrixScanner.cpp/h   # Key matrix scanner
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ RotaryEncoder.cpp/h   # Rotary encoder driver
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ RGBLightControl.cpp/h # RGB LED effects controller
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ USBKeyboardImpl.cpp/h # USB HID keyboard implementation
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ BLEKeyboardImpl.cpp/h # BLE keyboard implementation
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ VoiceRecognizer.cpp/h # Baidu ASR voice recognition
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ AudioAnalyzer.cpp/h   # FFT audio spectrum analyzer
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ Mic.cpp/h             # MEMS microphone driver
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ Speaker.cpp/h         # Speaker driver
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ SerialProtocol.cpp/h  # Host app communication protocol
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ Configuration.cpp/h   # Configuration file manager
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ Upgrade.cpp/h         # OTA firmware upgrade
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ LogManager.cpp/h      # Logging system
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ modules/              # IยฒC master controller & extensions
โ”‚   โ”‚   โ”œโ”€โ”€ data/                     # SPIFFS data files
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ config.ini            # Default configuration
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ keymap1~8.ini         # 8 keymap profiles
โ”‚   โ”‚   โ””โ”€โ”€ platformio.ini            # PlatformIO build configuration
โ”‚   โ”œโ”€โ”€ FunModularKeyboard_ModA/      # Module A firmware (STM8S103F3, IAR)
โ”‚   โ”‚   โ”œโ”€โ”€ main.c                    # Main program
โ”‚   โ”‚   โ”œโ”€โ”€ ec11.c/h                  # EC11 encoder driver
โ”‚   โ”‚   โ”œโ”€โ”€ adc.c/h                   # ADC slider reading
โ”‚   โ”‚   โ”œโ”€โ”€ i2c.c/h                   # IยฒC slave communication
โ”‚   โ”‚   โ””โ”€โ”€ Uart.c/h                  # UART debug output
โ”‚   โ””โ”€โ”€ FunModularKeyboard_ModB/      # Module B firmware (ESP32-S3, PlatformIO)
โ”‚       โ””โ”€โ”€ firmware/src/             # Modified SmartKnob-based firmware
โ”œโ”€โ”€ electronics/                      # PCB designs (LCSC EDA / EasyEDA)
โ”‚   โ”œโ”€โ”€ MainBoard/                    # Main board PCB project
โ”‚   โ”œโ”€โ”€ ModA/                         # Module A PCB project
โ”‚   โ””โ”€โ”€ ModB/                         # Module B PCB project
โ”œโ”€โ”€ cad/                              # 3D mechanical files
โ”‚   โ”œโ”€โ”€ Top.step / Bottom.step        # Main enclosure shells
โ”‚   โ”œโ”€โ”€ Plate.step                    # Switch mounting plate
โ”‚   โ”œโ”€โ”€ Keycap.step / Keycap2.step    # Keycaps
โ”‚   โ”œโ”€โ”€ FunModularKeyboard.3mf        # 3D printing project file
โ”‚   โ”œโ”€โ”€ ModA/                         # Module A enclosure
โ”‚   โ””โ”€โ”€ ModB/                         # Module B enclosure
โ”œโ”€โ”€ software/scripts/                 # Desktop automation scripts
โ”‚   โ”œโ”€โ”€ desktop_automation_launch_apps_template.py  # One-click app launcher template
โ”‚   โ””โ”€โ”€ desktop_automation_long_press_shutdown.py   # Long-press shutdown script
โ”œโ”€โ”€ tools/                            # Utility tools
โ””โ”€โ”€ README.md

๐Ÿ”ง Tech Stack

Category Technology
Main MCU ESP32-S3 (240 MHz, 320 KB RAM, 8 MB Flash)
Module A MCU STM8S103F3
Module B MCU ESP32-S3
Framework Arduino (PlatformIO) / IAR (STM8)
GUI Library LVGL 8.3 + TFT_eSPI
Keyboard Protocols USB HID (TinyUSB) + BLE HID
Voice Recognition Baidu Speech Recognition API (REST)
Motor Control SimpleFOC 2.3
Communication IยฒC (inter-module) / WiFi TCP (host app)
File System SPIFFS
RGB Driver FastLED (WS2812B)
FFT Analysis arduinoFFT

Key Library Dependencies

ESP32 BLE Keyboard    โ€” BLE HID keyboard
FastLED               โ€” RGB LED control
TFT_eSPI              โ€” TFT display driver
lvgl                  โ€” Embedded GUI framework
ESP32-audioI2S        โ€” IยฒS audio input
SimpleIni             โ€” INI config file parser
ArduinoJson           โ€” JSON serialization
arduinoFFT            โ€” Fast Fourier Transform
SimpleFOC             โ€” FOC motor control
TLV493D               โ€” 3D magnetic sensor

๐Ÿš€ Getting Started

Main Module Firmware

  1. Install PlatformIO IDE (VS Code extension)

  2. Clone the repo and navigate to the main firmware directory:

git clone https://github.com/yourname/FunModularKeyboard-OPEN.git
cd FunModularKeyboard-OPEN/firmware/FunModularKeyboard
  1. Configure WiFi and Baidu Speech API credentials (edit data/config.ini or configure via serial)

  2. Build and flash:

# Build
pio run

# Flash firmware + upload SPIFFS data
pio run --target upload
pio run --target uploadfs

Module A Firmware

Open firmware/FunModularKeyboard_ModA/RGB_INIT.eww with IAR for STM8, then build and flash.

Module B Firmware

cd FunModularKeyboard-OPEN/firmware/FunModularKeyboard_ModB
pio run --target upload

Pinout Reference

Main module key pin assignments (see platformio.ini and source code for full details):

Function GPIO
LED Data 6
LED Power 36
Encoder CLK 5
Encoder DT 21
Encoder SW 9
IยฒC SDA 15
IยฒC SCL 8
Key Matrix Rows 48, 10, 47, 33, 14
Key Matrix Cols 35, 34, 7, 13

๐ŸŽฎ Usage Guide

Keymap Configuration

  1. Connect to the companion desktop app over WiFi
  2. Use the visual drag-and-drop editor to assign functions to each key (single key, combo, macro, media control, etc.)
  3. Configure up to 8 different keymap profiles โ€” switch between them by long-pressing the rotary encoder

Voice Features

  1. Configure your Baidu API Key and Secret Key in the companion app
  2. Long-press the MIC-mapped key to start recording
  3. The recognized speech is matched against preset keywords and triggers the corresponding script

Firmware Upgrade

  1. The companion app pushes new firmware to the keyboard over WiFi
  2. The keyboard auto-reboots into OTA mode and completes the upgrade

๐Ÿ—๏ธ Hardware Fabrication

  • PCBs: Open the .epro2 project files under electronics/ with EasyEDA
  • 3D Enclosure: STEP mechanical files and 3MF print-ready files are provided in cad/
  • Magnetic Connector: Uses Pogo-Pin spring-loaded contacts for IยฒC communication and power delivery between modules

๐Ÿ“ Roadmap

  • Open-source the companion desktop configuration app
  • Community-contributed expansion modules
  • Full HomeAssistant integration
  • Macro recording and playback
  • Support for additional speech recognition engines
  • Complete English documentation

๐Ÿค Contributing

Issues and Pull Requests are welcome! If you've designed a cool expansion module, we'd love to see it shared here.


๐Ÿ™ Acknowledgments

  • SmartKnob โ€” excellent open-source haptic feedback knob project
  • LVGL โ€” lightweight embedded GUI library
  • PlatformIO โ€” cross-platform embedded development ecosystem
  • Baidu Speech Recognition โ€” Chinese speech recognition service

About

A modular macro keypad powered by ESP32-S3 with magnetic snap-on expansion modules. Features 8 switchable keymap profiles, voice commands & speech-to-text, USB+BLE dual-mode, LVGL touch display, RGB effects, and a WiFi companion desktop app for visual key mapping, OTA updates, PC monitoring, and script automation.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages