rp2040-keyboard

RP2040 Auto-Deployment System

=============================

Automatyczny system pobierania bibliotek i deploymentu firmware na urządzenia RP2040-One z HAL (Hardware Abstraction Layer).

🚀 Szybki start

1. Jednorazowy deployment

# Podłącz RP2040-One i uruchom
make deploy
# lub
python3 deploy.py deploy
# lub
./auto-deploy.sh start

2. Monitorowanie i auto-deployment

# Uruchom monitorowanie - automatycznie wykryje i zdeployuje
make deploy-monitor
# lub
python3 deploy.py monitor
# lub  
./auto-deploy.sh monitor

3. Przygotowanie bibliotek

# Pobierz wymagane biblioteki (jednorazowo)
make deploy-setup
# lub
python3 deploy.py setup

📋 Konfiguracja

HAL Configuration Files

Projekt używa HAL (Hardware Abstraction Layer) do oddzielenia konfiguracji sprzętowej od kodu firmware:

# Główna konfiguracja sprzętowa
hal/hal_config.toml

# Profile konfiguracyjne
hal/profiles/default.toml   # Standard 9-key + encoder
hal/profiles/minimal.toml   # Minimal 4-key + encoder  
hal/profiles/gaming.toml    # Gaming WASD + fast encoder

# Szczegółowa specyfikacja sprzętowa
hal/hardware_pins.toml

Plik .env

Skopiuj .env.example do .env i dostosuj:

cp .env.example .env

Główne opcje:

🔧 Dostępne komendy

Makefile

make deploy          # Jednorazowy deployment
make deploy-monitor  # Monitorowanie urządzeń
make deploy-setup    # Pobierz biblioteki
make deploy-detect   # Wykryj urządzenia

HAL Configuration

make hal-sync        # Synchronizuj HAL → Firmware
make hal-save        # Zapisz Firmware → HAL
make hal-validate    # Waliduj konfigurację HAL
make hal-show        # Pokaż konfigurację HAL
make hal-profiles    # Lista dostępnych profili
make hal-apply PROFILE=default  # Zastosuj profil
make hal-backup      # Stwórz backup konfiguracji

Skrypty

./auto-deploy.sh start    # Jednorazowy deployment
./auto-deploy.sh monitor  # Monitorowanie
./auto-deploy.sh setup    # Pobierz biblioteki
./auto-deploy.sh detect   # Wykryj urządzenia

Python

python3 deploy.py deploy    # Jednorazowy deployment
python3 deploy.py monitor  # Monitorowanie
python3 deploy.py setup     # Pobierz biblioteki
python3 deploy.py detect    # Wykryj urządzenia

python3 -m rp2040_keyboard.hal_manager sync-from-hal  # HAL sync

📁 Struktura po deploymentu

CIRCUITPY/
├── boot.py              # Nasz firmware startowy
├── code.py              # Główny program klawiatury (generowany z HAL)
└── lib/
    └── adafruit_hid/    # Biblioteka HID (pobrana automatycznie)
        ├── __init__.py
        ├── keyboard.py
        ├── mouse.py
        └── ...

🔍 Jak to działa

HAL Integration

  1. Configuration in TOML: Hardware settings defined in hal/*.toml files
  2. Automatic Sync: HAL configuration synchronized before deployment
  3. Code Generation: Firmware generated dynamically from HAL configuration
  4. Profile System: Easy switching between hardware configurations

Deployment Process

  1. Device Detection: Scans for CircuitPython devices on common mount points
  2. HAL Synchronization: Reads and validates HAL configuration
  3. Firmware Generation: Generates boot.py and code.py from HAL settings
  4. Library Management: Downloads and installs required libraries
  5. Backup: Creates backups of existing files
  6. Installation: Copies generated firmware and libraries to device

HAL Configuration Example

[device]
name = "RP2040-One-Keypad"
version = "1.0"

[encoder]
enabled = true
clk_gpio = 11      # WE A signal
dt_gpio = 12       # WE B signal  
sw_gpio = 13       # PUSH button
middle_click = false  # Uses left click instead of middle
debounce = 3
scroll_speed = 2

[switches]
switch_1 = {gpio = 1, keycode = "Keycode.ONE", modifier = "Keycode.CONTROL+Keycode.ALT", label = "Ctrl+Alt+1"}
switch_2 = {gpio = 2, keycode = "Keycode.TWO", modifier = "Keycode.CONTROL+Keycode.ALT", label = "Ctrl+Alt+2"}
# ... more switches

🔄 Development Workflow

1. Configure Hardware

# Edit HAL configuration
nano hal/hal_config.toml

# Or use a profile
make hal-apply PROFILE=gaming

2. Validate Configuration

make hal-validate

3. Generate and Deploy

make deploy

4. Monitor and Auto-deploy

make deploy-monitor

🎯 HAL Profiles

Available Profiles

Profile Management

make hal-profiles              # List profiles
make hal-apply PROFILE=gaming # Apply profile
make hal-backup               # Backup current config
make hal-save                 # Save current as profile

🔧 Troubleshooting

Brak wykrytych urządzeń

# Sprawdź ręcznie
ls /media/*/CIRCUITPY 2>/dev/null || ls /mnt/*/CIRCUITPY 2>/dev/null

# Sprawdź HAL konfigurację
make hal-show

Błędy synchronizacji HAL

# Waliduj konfigurację
make hal-validate

# Sprawdź profile
make hal-profiles

# Resetuj synchronizację
rm .hal_sync.json
make hal-sync

Problemy z bibliotekami

# Wyczyść cache i pobierz ponownie
rm -rf lib_cache/
make deploy-setup

Konflikty GPIO

# Sprawdź walidację
make hal-validate

# Pokaż szczegóły
python3 -m rp2040_keyboard.hal_manager show

📝 Logi

System tworzy logi w:

🎯 Podsumowanie

System zapewnia:

HAL Benefits

Podłącz RP2040-One a system automatycznie zainstaluje wszystko co potrzebne na podstawie konfiguracji HAL! 🚀