|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Build and Development Commands |
| 6 | + |
| 7 | +This is an Arduino/ESP32 project using PlatformIO for build management. |
| 8 | + |
| 9 | +**Build Commands:** |
| 10 | +- `pio run` - Build the project (compiles firmware) |
| 11 | +- `pio run --target upload` - Flash firmware to connected device |
| 12 | +- `pio run --target clean` - Clean build artifacts |
| 13 | +- `pio device list` - List connected devices/serial ports |
| 14 | +- `pio device monitor` - Serial monitor for debugging |
| 15 | + |
| 16 | +**Environment:** |
| 17 | +- Default target: `OpenPPG-CESP32S3-CAN-SP140` (ESP32-S3 based) |
| 18 | +- Build type: debug (configurable in platformio.ini) |
| 19 | +- Monitor speed: 115200 baud |
| 20 | + |
| 21 | +**Binary Generation:** |
| 22 | +For creating update files, use esptool to merge binaries: |
| 23 | +```bash |
| 24 | +esptool.py --chip esp32s3 merge_bin \ |
| 25 | + -o .pio/build/OpenPPG-CESP32S3-CAN-SP140/merged-firmware.bin \ |
| 26 | + --flash_mode dio --flash_freq 80m --flash_size 8MB \ |
| 27 | + 0x0 .pio/build/OpenPPG-CESP32S3-CAN-SP140/bootloader.bin \ |
| 28 | + 0x8000 .pio/build/OpenPPG-CESP32S3-CAN-SP140/partitions.bin \ |
| 29 | + 0xe000 ~/.platformio/packages/framework-arduinoespressif32/tools/partitions/boot_app0.bin \ |
| 30 | + 0x10000 .pio/build/OpenPPG-CESP32S3-CAN-SP140/firmware.bin |
| 31 | +``` |
| 32 | + |
| 33 | +**Testing:** |
| 34 | +- Basic test files exist in `/test/` directory |
| 35 | +- No automated test framework configured - testing is primarily hardware-in-the-loop |
| 36 | + |
| 37 | +## Code Architecture |
| 38 | + |
| 39 | +**Project Structure:** |
| 40 | +- `/src/sp140/` - Main application source code |
| 41 | +- `/inc/sp140/` - Header files and configuration |
| 42 | +- `/src/assets/` - Fonts, images, and UI resources |
| 43 | +- `/lib/` - Custom libraries |
| 44 | +- `platformio.ini` - Build configuration |
| 45 | + |
| 46 | +**Core Components:** |
| 47 | + |
| 48 | +**Main Controller (`sp140.ino`):** |
| 49 | +The entry point that coordinates all subsystems. Handles: |
| 50 | +- Hardware initialization and SPI bus management |
| 51 | +- Main control loop and state management |
| 52 | +- Button input processing with debouncing |
| 53 | +- Safety interlocks and watchdog management |
| 54 | + |
| 55 | +**Key Subsystems:** |
| 56 | +- **ESC Control** (`esc.h/cpp`) - Motor speed control and CAN communication |
| 57 | +- **BMS Interface** (`bms.h/cpp`) - Battery management system communication |
| 58 | +- **Throttle Processing** (`throttle.h/cpp`) - Input filtering and response curves |
| 59 | +- **Display/LVGL** (`lvgl/`) - LCD graphics and user interface |
| 60 | +- **Altimeter** (`altimeter.h/cpp`) - Barometric altitude sensing |
| 61 | +- **Device State** (`device_state.h/cpp`) - System state machine management |
| 62 | +- **Mode Control** (`mode.h/cpp`) - Flight modes (manual, cruise, etc.) |
| 63 | + |
| 64 | +**Hardware Platform:** |
| 65 | +- ESP32-S3 microcontroller (M5Stack STAMPS3 board) |
| 66 | +- CAN bus communication for ESC and BMS |
| 67 | +- Shared SPI bus for display and peripherals |
| 68 | +- NeoPixel RGB LEDs for status indication |
| 69 | +- Analog throttle input with ResponsiveAnalogRead filtering |
| 70 | + |
| 71 | +**Configuration:** |
| 72 | +- Hardware pin definitions in `esp32s3-config.h` |
| 73 | +- Device settings and globals in `globals.h` |
| 74 | +- Build flags and library versions in `platformio.ini` |
| 75 | + |
| 76 | +**Data Structures:** |
| 77 | +- Telemetry data structures defined in `structs.h` |
| 78 | +- Temperature monitoring with multiple sensor states |
| 79 | +- BMS pack data with cell-level monitoring |
| 80 | +- ESC telemetry with real-time performance data |
| 81 | + |
| 82 | +This codebase implements a safety-critical paramotor throttle controller with real-time requirements and hardware integration. |
0 commit comments