Skip to content

Commit 4d9444a

Browse files
authored
Merge pull request #68 from openppg/dev-container
Add dev container info and small cleanup
2 parents 8475967 + d6800d4 commit 4d9444a

File tree

7 files changed

+233
-3
lines changed

7 files changed

+233
-3
lines changed

.claude/settings.local.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"permissions": {
3+
"allow": [
4+
"Bash(pio)",
5+
"Bash(pio run)"
6+
],
7+
"deny": []
8+
}
9+
}

.devcontainer/devcontainer.json

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
{
2+
"name": "Ubuntu Development Environment",
3+
"image": "mcr.microsoft.com/devcontainers/base:ubuntu-24.04",
4+
5+
"features": {
6+
"ghcr.io/devcontainers/features/python:1": {
7+
"version": "3.12"
8+
},
9+
"ghcr.io/devcontainers/features/git:1": {},
10+
"ghcr.io/devcontainers/features/node:1": {
11+
"version": "20"
12+
}
13+
},
14+
15+
"customizations": {
16+
"vscode": {
17+
"extensions": [
18+
"platformio.platformio-ide",
19+
"ms-vscode.cpptools-extension-pack",
20+
"ms-python.python"
21+
],
22+
"settings": {
23+
"C_Cpp.default.intelliSenseMode": "gcc-x64",
24+
"C_Cpp.default.compilerPath": "/usr/bin/gcc",
25+
"editor.tabSize": 2,
26+
"editor.insertSpaces": true,
27+
"files.associations": {
28+
"*.ino": "cpp",
29+
"*.h": "c",
30+
"*.hpp": "cpp"
31+
}
32+
}
33+
}
34+
},
35+
36+
"postCreateCommand": "bash .devcontainer/setup.sh",
37+
38+
"remoteUser": "vscode",
39+
40+
"mounts": [
41+
"source=/dev,target=/dev,type=bind,consistency=cached",
42+
"source=/Users/zach/.claude-code-router,target=/home/vscode/.claude-code-router,type=bind"
43+
],
44+
45+
"runArgs": [
46+
"--privileged"
47+
]
48+
}

.devcontainer/setup.sh

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
#!/bin/bash
2+
3+
# Setup script for Ubuntu development environment
4+
5+
set -e
6+
7+
echo "Setting up development environment..."
8+
9+
# Update package lists
10+
sudo apt-get update
11+
12+
# Install essential development tools
13+
sudo apt-get install -y \
14+
build-essential \
15+
git \
16+
curl \
17+
wget \
18+
unzip \
19+
software-properties-common \
20+
udev \
21+
python3-pip \
22+
python3-venv \
23+
pkg-config \
24+
libusb-1.0-0-dev \
25+
libudev-dev
26+
27+
# Install PlatformIO
28+
echo "Installing PlatformIO..."
29+
python3 -m pip install --upgrade pip
30+
python3 -m pip install --upgrade platformio
31+
32+
# Add PlatformIO to PATH
33+
echo 'export PATH=$PATH:~/.local/bin' >> ~/.bashrc
34+
35+
# Install PlatformIO udev rules for device access
36+
echo "Setting up udev rules for device access..."
37+
curl -fsSL https://raw.githubusercontent.com/platformio/platformio-core/develop/platformio/assets/system/99-platformio-udev.rules | sudo tee /etc/udev/rules.d/99-platformio-udev.rules
38+
sudo service udev restart
39+
sudo usermod -a -G dialout $USER
40+
sudo usermod -a -G plugdev $USER
41+
42+
# Create a symlink for common Arduino libraries location
43+
mkdir -p ~/Arduino/libraries
44+
45+
# Install additional Python packages that might be useful
46+
python3 -m pip install --upgrade \
47+
esptool \
48+
adafruit-ampy \
49+
pyserial
50+
51+
# Install Gemini CLI
52+
echo "Installing Gemini CLI..."
53+
curl -sS https://storage.googleapis.com/gemini-cli/install.sh | bash
54+
55+
# Install Claude Code CLI
56+
echo "Installing Claude Code CLI..."
57+
npm install -g @anthropic-ai/claude-code
58+
npm install -g @musistudio/claude-code-router
59+
60+
# Set up Git configuration (if not already configured)
61+
if [ -z "$(git config --global user.name)" ]; then
62+
echo "Git user name not configured. You may want to run:"
63+
echo "git config --global user.name 'Your Name'"
64+
echo "git config --global user.email 'your.email@example.com'"
65+
fi
66+
67+
echo "✅ Development environment setup complete!"
68+
echo ""
69+
echo "🚀 You can now:"
70+
echo " - Use 'pio' commands for PlatformIO operations"
71+
echo " - Use 'node' and 'npm' for JavaScript/TypeScript development"
72+
echo " - Develop Arduino/ESP32 projects with IntelliSense"
73+
echo ""
74+
echo "📋 Next steps:"
75+
echo " 1. Run 'pio run' to build the project"
76+
echo " 2. Run 'pio device list' to see connected devices"
77+
echo " 3. Use 'pio run --target upload' to flash firmware"
78+
echo ""
79+
echo "🔧 Hardware debugging:"
80+
echo " - USB devices are mounted with --privileged access"
81+
echo " - Serial ports should be accessible in /dev/"

.gemini/settings.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"telemetry": {
3+
"enabled": false
4+
},
5+
"usageStatisticsEnabled": false
6+
}

CLAUDE.md

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
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.

src/sp140/sp140.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,7 @@ void setupAnalogRead() {
576576

577577
void setupWatchdog() {
578578
#ifndef OPENPPG_DEBUG
579-
// Initialize Task Watchdog for main critical tasks (ESC/UI/BMS)
579+
// Initialize Task Watchdog
580580
ESP_ERROR_CHECK(esp_task_wdt_init(3000, true)); // 3 second timeout, panic on timeout
581581
#endif // OPENPPG_DEBUG
582582
}

src/sp140/vibration_pwm.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,9 @@ void vibeTask(void* parameter) {
6161
* @return Returns true if initialization was successful, false otherwise
6262
*/
6363
bool initVibeMotor() {
64+
extern HardwareConfig board_config;
6465
ledcSetup(VIBE_PWM_CHANNEL, VIBE_PWM_FREQ, VIBE_PWM_RESOLUTION);
65-
ledcAttachPin(VIBE_PWM_PIN, VIBE_PWM_CHANNEL);
66+
ledcAttachPin(board_config.vibe_pwm, VIBE_PWM_CHANNEL);
6667

6768
// Create vibration queue
6869
vibeQueue = xQueueCreate(5, sizeof(VibeRequest));
@@ -86,7 +87,10 @@ void pulseVibeMotor() {
8687
};
8788

8889
// Send request to queue (non-blocking)
89-
xQueueSend(vibeQueue, &request, 0); // Don't wait if queue is full
90+
if (xQueueSend(vibeQueue, &request, 0) != pdTRUE) {
91+
// Handle queue full error
92+
USBSerial.println("Vibration queue full!");
93+
}
9094
}
9195

9296
/**

0 commit comments

Comments
 (0)