gokul/macro-six-usbc
A six-key macro keyboard PCB paired with a separate physical enclosure.
- Version
- 0.1.16
- License
- unset
- Stars
- 0
Use with the tscircuit CLI
tsci is the tscircuit CLI. Install it with npm install -g tscircuit.
tsci clone gokul/macro-six-usbc # download the package files into ./macro-six-usbc
tsci add gokul/macro-six-usbc # add it to your project as @tsci/gokul.macro-six-usbcIn a cloned or new (tsci init) project: tsci dev starts a local preview, tsci build outputs Circuit JSON, and tsci push publishes to tscircuit.com.
outputs/release/firmware/README.md
# Macro Six application firmware
This firmware is for the existing ATmega32U4 board, with its 16 MHz crystal. The CPU runs at 8 MHz using the clock prescaler; USB still uses the 16 MHz oscillator. No PCB crystal change or fuse change is required for that prescaler setting.
Six keys send F13–F18, allowing macros to be assigned in the host application. The encoder sends volume up/down and its push button sends mute. Inputs are sampled every millisecond with 5 ms button debounce. Encoder decoding uses two quadrature transitions per detent for the EC11E18244AU (18 pulses, 36 detents in the [Alps specification](https://tech.alpsalpine.com/e/products/category/encorders/sub/01/series/ec11e/)). Direction and detent behavior still require checking on the assembled encoder.
RGB is off during startup, USB reset, disconnect and suspend. During suspend the six key inputs and encoder-push input are driven low to avoid current through their internal pull-ups; remote wake is not supported. The power LED resistor is 10 kΩ to reduce its continuous current to approximately 0.3 mA at a 3 V resistor drop. The data pin goes low before LED power is removed. Lighting starts only after USB configuration. Current animations use channel values of 8, with pressed-key green at 32 out of 255. The USB configuration requests 100 mA. This is a firmware budget, not a measured board consumption result.
## Build and local checks
Install AVR GCC, avr-libc, avr-binutils and make. Run:
```sh
make -C firmware
cc -std=c99 -Wall -Wextra -Werror -Ifirmware firmware/inputs.c firmware/tests/inputs-test.c -o /tmp/macro-six-inputs-test
/tmp/macro-six-inputs-test
```
The output is `firmware/macro-six.hex`. The checked build used avr-gcc 7.3.0 (Arduino's avr-gcc 7.3.0-atmel3.6.1-arduino7 toolchain). Source dependencies are vendored so builds do not fetch changing libraries.
**USB identity:** the default 1209:0001 ID is for private in-house testing only. It is not a product allocation. Obtain an authorized VID/PID before manufacturing or distributing a product and override `USB_VID` and `USB_PID` at compilation. See https://pid.codes/1209/0001/. This test firmware has not been validated on physical hardware.
## Flashing and first power-up
The board requires application firmware; a factory USB bootloader alone is not a macro keyboard. Confirm that the fitted ATmega32U4 contains the expected DFU bootloader. Hold BOOT, press and release RESET, then release BOOT. Confirm the device appears as an ATmega32U4 DFU device before selecting it in a programmer.
Use a compatible DFU programmer to erase/write the application region and verify the HEX. Preserve the bootloader and clock/boot fuses. If DFU is absent, use the labelled ISP pads with an AVR programmer and a separately reviewed bootloader/fuse configuration. Do not assume an unknown chip is already programmed. Flashing has not been performed by this project update.
## Pin mapping
| Function | MCU port |
|---|---|
| K1–K4 | PD0–PD3 |
| K5, K6 | PD4, PD6 |
| Encoder A, B, push | PD7, PB4, PB5 |
| RGB data | PB6 |
| RGB power gate, active low | PC6 |
## Physical acceptance tests
Before approving an assembled batch:
1. Verify all supply rails and absence of shorts before plugging into a computer. Use a current-limited supply for initial power checks.
2. Verify USB enumeration, all six keys (including simultaneous presses), clockwise/counterclockwise volume and mute. Test repeated reconnect, reset, suspend and resume.
3. Measure total USB current in configured operation, before configuration and during suspend. It must respect the declared 100 mA budget and applicable USB suspend limit. Measure with keys held too; pull-ups consume current.
4. Measure VCC and LED_5V at maximum supported brightness using the worst intended cable. Check both the MCU/USB and exact LED data-sheet supply limits. LED_5V must remain within 3.7–5.5 V for the selected SK6812MINI-HS. An 8 MHz CPU does not remove USB and LED voltage requirements.
5. Observe LED data and supply during suspend/reset. Data must stay low while the LED supply is off; no unexpected glow or injected supply voltage is acceptable.
6. Check LED timing, encoder detents and USB reliability on real hardware. Compilation and software tests cannot establish these electrical behaviors.
## Source licenses
Application code and the combined firmware are GPL-2.0-or-later, because the vendored light_ws2812 driver is GPL-2.0-or-later. Its license is in `vendor/light_ws2812/License.txt`. LUFA is MIT licensed; its copyright/license is retained in `vendor/LUFA/License.txt`. These licenses do not change the license of the PCB design.
The vendored LED driver has a local adaptation to use AVR OUT instructions for PORTB and SK6812 pulse targets, instead of its default WS2812 900 ns one pulse. At 8 MHz the inner loop targets 250 ns zero-high, 625 ns one-high and a 1.25 µs bit period. Verify the emitted waveform on hardware against the [selected LED data sheet](https://cdn-shop.adafruit.com/product-files/2659/2304101800_OPSCO-Optoelectronics-SK6812MINI-HS_C2922787.pdf).