Code Monkey home page Code Monkey logo

macropad-3-keys-1-knob's Introduction

20240426_140314

Macropad with 3 keys and 1 knob

Custom firmware for a 3-key + rotary encoder macropad (Based on IC CH552g) (https://hackaday.io/project/189914)
Forked from biemster/3keys_1knob, which is based on wagiminator/CH552-Macropad-mini.

Example data structure for the EEPROM

Hex Address 00 01 02 03 04 05 06 07 08 09 0A 0B
x0000000: T0 M0 C0 M1 C1 00 00 00 00 00 00 00
x000000c: T1 C0 C1 00 00 00 00 00 00 00 00 00
x0000018: T2 A0 C0 C1 C2 C3 C4 C5 C6 C7 C8 C9

T0 represents the type field of the first key
00 = keyboard key // 01 = consumer key // 02 = macro key

For keyboard and consumer keys

T0 represents the type field of the first key
00 = keyboard key // 01 = consumer key // 02 = macro key

For keyboard
M0 represents the mod field of the first keyboad key
M1 represents the mod field of the second keyboard key

C0 represents the code field of the first keyboad key
C1 represents the code field of the second keyboard key

For Consumer
C0 represents the code field of the first consumer key
C1 represents the code field of the second consumer key
(rarelly you need a mod for consumer keys so it is not used)

Note

The keyboard and consumer keys have 2 states, this because in consumer keys Play/Pause are two different keys and for Keyboard becomes useful to have Ctrl+c and Ctrl+v in the same key

For macro keys

A0 represents the ammount of keys in the macro
This number must be in Hex value, not decimal

*for visibility reasons any 00 after any data its just an FF or empty field
00 is different than FF

Visual Example data

Keyboard type

Raw bytes Type Mod Key Mod2 Key2 Result Result2
00 00 04 00 04 .. Keyboard None a None a a a
00 02 04 02 04 .. Keyboard Shift a Shift a A A
00 01 06 01 19 .. Keyboard Ctrl c Ctrl v Ctrl+C Ctrl+V
00 05 4C 03 29 .. Keyboard Ctrl+Alt DEL Ctrl+Shift ESC Ctrl+Alt+DEL Ctrl+Shift+ESC

Consumer Type

Raw bytes Type Key Key2
01 B6 B6 .. Consumer Previous Previous
01 B0 B1 .. Consumer Play Pause
01 E9 E9 .. Consumer Vol + Vol +
01 EA EA .. Consumer Vol - Vol -

Macro Type

Raw bytes Type # of Keys Code Code1 Code2 Result
02 03 06 04 17 .. Macro 3 c a t cat
02 03 07 12 0A .. Macro 3 d o g dog

Compilation

compile:

$ make bin

compile & flash to pad:

  • if on original firmware: depending on hardware you need to connect P3.6 to 5V (VCC) using a 1k resistor or P1.5 to GND, while connecting USB
  • if on this firmware: press key1 while connecting USB
  • $ make flash

configure keys:

  1. $ isp55e0 --data-dump flashdata.bin
  2. edit this binary (3 keys, plus 3 for the knob), and write it back:
  3. $ isp55e0 --data-flash flashdata.bin

Documentation

CH552x Datasheet
USB HID Codes
isp55e0

Modifiers

ID Function
00 None
01 Ctrl
02 Shift
03 Ctrl + Shift
04 Alt
05 Ctrl + Alt
06 Shift + Alt
07 Ctrl + Shift + Alt

Consumer Keyboard Keycodes

ID Function
30 SYS_POWER
31 SYS_RESET
32 SYS_SLEEP
E2 VOL_MUTE
E9 VOL_UP
EA VOL_DOWN
B0 CON_MEDIA_PLAY
B1 CON_MEDIA_PAUSE
B2 CON_MEDIA_RECORD
B3 MEDIA_FORWARD
B4 MEDIA_REWIND
B5 MEDIA_NEXT
B6 MEDIA_PREV
B7 MEDIA_STOP
B8 MEDIA_EJECT
B9 MEDIA_RANDOM
40 MENU
41 MENU_PICK
42 MENU_UP
43 MENU_DOWN
44 MENU_LEFT
45 MENU_RIGHT
46 MENU_ESCAPE
47 MENU_INCR
48 MENU_DECR

Notes:

Functions not supported yet by only reading the EEPROM

  • Strings of text (you may need a bigger EEPROM) (maybe a huffman algorithm)
  • Mouse movements/clicks (not sure, not tested)
  • Modifiers on macro secuences
  • Modifiers on consumer keys

i still havent found the way to make work the RIGTH_GUI and LEFT_GUI keys
(aka windows keys or Apple equivalent)

Yet to implement

  • After a key is pressed and changes to Second key, add a delay to change it automatically to First Key

(no idea of what else could it need)

macropad-3-keys-1-knob's People

Contributors

mrgeorgek55 avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.