Complete reference for developers contributing to the project.
esp32_VR_sim/
├── src/
│ ├── main.c # Application entry point
│ ├── vr_signal.c/h # Waveform generation (DMA setup)
│ ├── freq_detector.c/h # GPIO4 frequency measurement
│ ├── can_reader.c/h # CAN interface (disabled)
│ └── CMakeLists.txt
├── platformio.ini # Build configuration
├── plot_vr_signals.py # Waveform visualization
├── docs/ # This documentation
└── README.md # User-facing overview
The core signal generator uses DMA for zero-CPU-overhead streaming:
Measures GPIO4 PWM input to extract RPM:
FreqDetectorTask (100ms intervals)
├── Count rising edges on GPIO4
├── Calculate frequency
└── Trigger waveform regeneration if needed
FreqPrintTask (1 second intervals)
├── Print current frequency and RPM
└── Log any RPM changes
WaveformReaderTask (on-demand)
├── Read new frequency from detector
├── Generate new waveform table
└── Update DMA descriptors
The desktop controller (rpm_controller_gui.py) uses:
Located in src/vr_signal.c, VR signal characteristics:
cfg->rpm = 3000.0f; // Default operating point
cfg->tooth_spacing_deg = 10.0f; // Degrees between teeth
cfg->compression_depth = 0.10f; // Compression effect amplitude
cfg->compression_order = 2.0f; // Harmonic order
cfg->peak_volts = 1.0f; // Signal peak voltage
cfg->vref = 3.3f; // DAC reference (3.3V)
cfg->sample_rate_hz = 48000; // DMA sample rate
# Install dependencies
pio pkg install
# Build for ESP32
pio run -e esp32
# Upload to connected board
pio run -e esp32 -t upload
# Monitor serial output
pio device monitor --baud 115200
Open the workspace and use the PlatformIO sidebar buttons for Build, Upload, and Monitor.
pio rundocs/ folderdocs/index.html with new versiondocs/manifest.json with release infogit tag -a v1.2.0 -m "Release 1.2.0"git push origin v1.2.0
Good: "Add CAN frequency sync from 0x280"
Bad: "fixed stuff"
Good: "Fix edge case in compression modulation (closes #42)"
Bad: "fix"
After each release, the web flasher must be updated:
pio rundocs/:
firmware_v1_2_0.bin → .pio/build/esp32/firmware.binbootloader.bin → .pio/build/esp32/bootloader.binpartitions.bin → .pio/build/esp32/partitions.bindocs/index.html version numberdocs/index.html in Chrome and test flash