Macropad Design Files


I controlli meccanici sono ora protetti. Sposto MCU verso l’angolo alto-sinistra e lascio USB/ESD/fusibile vicino al connettore per aprire un canale di routing centrale.
Ho eliminato quasi tutte le collisioni; restano due sovrapposizioni rame legate a un diodo/condensatore vicino al top-left. Le separo prima del pre-check routing.
Il placement ora è senza collisioni rilevate, ma il report di densità continua a segnalare congestione seria. Eseguo il pre-check dell’autorouter; se conferma il blocco, passo a 4 layer per tentare il routing senza cambiare la meccanica.
Il pre-check autorouter non ha trovato blocchi, solo avvisi su GND pour vuoti/da rigenerare. Avvio ora il routing completo mantenendo fissi i controlli meccanici.
Ho completato il placement elettronico: tasti, encoder e USB-C sono protetti/bloccati; MCU e passivi sono stati spostati per togliere collisioni, mantenendo fissa la meccanica. Il pre-check routing è passato senza blocchi gravi, ma il routing automatico non è partito perché l’account non ha ACUs disponibili.
Open item:
  • Routing non eseguito: serve disponibilità di ACUs per continuare.
  • Restano avvisi non bloccanti sui GND pour vuoti, da rigenerare/verificare dopo il routing.
Prossimi passi:
  1. Aggiungere ACUs.
  2. Riprendere il job di autorouting.
  3. Verificare airwires/DRC dopo il routing e fare cleanup mirato.
Rigenera GND e DRC
Mostra net congestionati
Strategia routing manuale

Waiting for input


Last modified 3mo ago

Firmware Starter — ATmega32U4 Macropad
Platform & Toolchain
  • MCU: ATMEGA32U4-AU
  • Framework: Arduino AVR core, Leonardo-compatible pin numbering
  • Build system: PlatformIO or Arduino IDE
  • USB mode: Native USB HID keyboard/macropad
Mapping note: this schematic maps D18/D19 using the common ATmega32U4 Leonardo mapping: D18 = PF7, D19 = PF6. The pasted requirement labels these as A4/A5; verify the exact firmware variant before committing production firmware.
Pin Mapping

Table


FunctionArduino pinATmega32U4 pin/netConnected toDirectionNotes
Key 1D2PD1SW1 + D1Input pull-upActive-low through diode
Key 2D3PD0SW2 + D2Input pull-upActive-low through diode
Key 3D4PD4SW3 + D3Input pull-upActive-low through diode
Key 4D5PC6SW4 + D4Input pull-upActive-low through diode
Key 5D6PD7SW5 + D5Input pull-upActive-low through diode
Key 6D7PE6SW6 + D6Input pull-upActive-low through diode
Key 7D8PB4SW7 + D7Input pull-upActive-low through diode
Key 8D9PB5SW8 + D8Input pull-upActive-low through diode
Key 9D10PB6SW9 + D9Input pull-upActive-low through diode
Key 10D14PB3 / MISOSW10 + D10Input pull-upActive-low through diode
Key 11D15PB1 / SCKSW11 + D11Input pull-upActive-low through diode
Encoder pushD16PB2 / MOSIENC1 push + D12Input pull-upActive-low through diode
Encoder AD18PF7ENC1 AInput pull-upQuadrature channel A
Encoder BD19PF6ENC1 BInput pull-upQuadrature channel B
ResetRESETRESETSW_RESET + R1HardwareR1 = 10 kΩ pull-up
HWBHWBPE2 / HWBR2Boot strapR2 = 10 kΩ pull-down
USBNativeD+ / D-J1 via U2/R3/R4USBUSB HID device
PlatformIO Setup
Create platformio.ini:

Ini


[env:leonardo]
platform = atmelavr
board = leonardo
framework = arduino
monitor_speed = 115200
lib_deps =
  nicohood/HID-Project@^2.8.4
Complete Starter Firmware

Cpp


#include <Arduino.h>
#include <HID-Project.h>

// Key inputs: active-low, using internal pull-ups.
static const uint8_t KEY_PINS[] = {
  2, 3, 4, 5, 6, 7, 8, 9, 10, 14, 15, 16
};
static const uint8_t NUM_KEYS = sizeof(KEY_PINS) / sizeof(KEY_PINS[0]);

static const uint8_t ENC_A_PIN = 18;
static const uint8_t ENC_B_PIN = 19;

static const uint16_t DEBOUNCE_MS = 5;
static bool keyState[NUM_KEYS];
static bool lastRawState[NUM_KEYS];
static uint32_t lastChangeMs[NUM_KEYS];

static int8_t lastEncState = 0;
static int32_t encoderPosition = 0;

// Example keymap. Replace with QMK-style actions or custom HID shortcuts as needed.
static const KeyboardKeycode KEYMAP[NUM_KEYS] = {
  KEY_F13, KEY_F14, KEY_F15, KEY_F16,
  KEY_F17, KEY_F18, KEY_F19, KEY_F20,
  KEY_F21, KEY_F22, KEY_F23, KEY_F24
};

static int8_t readEncoderState() {
  uint8_t a = digitalRead(ENC_A_PIN) == LOW ? 1 : 0;
  uint8_t b = digitalRead(ENC_B_PIN) == LOW ? 1 : 0;
  return (a << 1) | b;
}

static void handleEncoder() {
  static const int8_t transitionTable[16] = {
     0, -1,  1,  0,
     1,  0,  0, -1,
    -1,  0,  0,  1,
     0,  1, -1,  0
  };

  int8_t state = readEncoderState();
  int8_t transition = (lastEncState << 2) | state;
  int8_t delta = transitionTable[transition & 0x0F];
  lastEncState = state;

  if (delta != 0) {
    encoderPosition += delta;
    // Two quadrature transitions per detent is common; adjust for your encoder.
    if (encoderPosition >= 2) {
      Consumer.write(MEDIA_VOLUME_UP);
      encoderPosition = 0;
    } else if (encoderPosition <= -2) {
      Consumer.write(MEDIA_VOLUME_DOWN);
      encoderPosition = 0;
    }
  }
}

static void scanKeys() {
  uint32_t now = millis();

  for (uint8_t i = 0; i < NUM_KEYS; i++) {
    bool rawPressed = (digitalRead(KEY_PINS[i]) == LOW);

    if (rawPressed != lastRawState[i]) {
      lastRawState[i] = rawPressed;
      lastChangeMs[i] = now;
    }

    if ((now - lastChangeMs[i]) >= DEBOUNCE_MS && rawPressed != keyState[i]) {
      keyState[i] = rawPressed;
      if (keyState[i]) {
        BootKeyboard.press(KEYMAP[i]);
      } else {
        BootKeyboard.release(KEYMAP[i]);
      }
    }
  }
}

void setup() {
  for (uint8_t i = 0; i < NUM_KEYS; i++) {
    pinMode(KEY_PINS[i], INPUT_PULLUP);
    keyState[i] = false;
    lastRawState[i] = false;
    lastChangeMs[i] = 0;
  }

  pinMode(ENC_A_PIN, INPUT_PULLUP);
  pinMode(ENC_B_PIN, INPUT_PULLUP);
  lastEncState = readEncoderState();

  BootKeyboard.begin();
  Consumer.begin();
}

void loop() {
  scanKeys();
  handleEncoder();
  delay(1);
}
Build & Flash

Bash


pio run
pio run -t upload
pio device monitor
If the board does not enumerate, press SW_RESET once. For bootloader recovery, use the ATmega32U4 bootloader reset sequence supported by the selected bootloader/core.
  • Platform & Toolchain

  • Pin Mapping

  • PlatformIO Setup

  • Complete Starter Firmware

  • Build & Flash