2 Commits

Author SHA1 Message Date
0207c29d8c fix: Resolve all 7 compile errors and 4 linker errors (Issue #337)
COMPILE FIXES:
1. battery.c: Added #include <stdbool.h> for bool type
2. main.c: Updated buzzer_play() to buzzer_play_melody(MELODY_STARTUP)
3. main.c: Replaced bno055_active with bno055_is_ready() calls
4. servo.c: Removed duplicate ServoState typedef from .c file
5. ultrasonic.c: Added forward declaration for HAL_TIM_IC_Init_Compat
6. fan.c: Fixed HAL_TIM_PWM_Start to use handle &htim1 instead of register
7. watchdog.c: Created static IWDG_HandleTypeDef and updated refresh call

LINKER FIXES:
1. i2c1.h/c: Added i2c1_write() and i2c1_read() function implementations
2. servo.c: servo_tick() already exists (verified)
3. bno055.h/c: Added bno055_calibrated() function
4. main.c: Added imu_calibrated() wrapper for bno055_calibrated()
5. crsf.h/c: Added crsf_is_active() function

All 11 errors fixed. Build should now succeed.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-03-03 11:26:27 -05:00
4a46fad002 feat(rc): CRSF/ELRS RC integration — telemetry uplink + channel fix (Issue #103)
## Summary
- config.h: CH1[0]=steer, CH2[1]=throttle (was CH4/CH3); CRSF_FAILSAFE_MS→500ms
- include/battery.h + src/battery.c: ADC3 Vbat reading on PC1 (11:1 divider)
  battery_read_mv(), battery_estimate_pct() for 3S/4S auto-detection
- include/crsf.h + src/crsf.c: CRSF telemetry TX uplink
  crsf_send_battery() — type 0x08, voltage/current/SoC to ELRS TX module
  crsf_send_flight_mode() — type 0x21, "ARMED\0"/"DISARM\0" for handset OSD
- src/main.c: battery_init() after crsf_init(); 1Hz telemetry tick calls
  crsf_send_battery(vbat_mv, 0, soc_pct) + crsf_send_flight_mode(armed)
- test/test_crsf_frames.py: 28 pytest tests — CRC8-DVB-S2, battery frame
  layout/encoding, flight-mode frame, battery_estimate_pct SoC math

Existing (already complete from crsf-elrs branch):
  CRSF frame decoder UART4 420000 baud DMA circular + IDLE interrupt
  Mode manager: RC↔autonomous blend, CH6 3-pos switch, 500ms smooth transition
  Failsafe in main.c: disarm if crsf_state.last_rx_ms stale > CRSF_FAILSAFE_MS
  CH5 arm switch with ARMING_HOLD_MS interlock + edge detection
  RC override: mode_manager blends steer/speed per mode (CH6)

Closes #103

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-02 08:35:48 -05:00