Files
stc32g128k/Docs/implementation_plan.md

2.9 KiB

French Language & Addressable RGB LED (XL-2020RGBC-2812B) Implementation Plan

Goal Description

Modify the wristband firmware to support French-only UI display and replace the discrete 3-pin LED control with the single-wire addressable RGB LED (XL-2020RGBC-2812B) protocol (WS2812B timing compatible).

User Review Required

Important

  1. RGB LED (WS2812B) Control Pin: The single-wire addressable RGB LED requires a high-speed bit-stream control pin (DIN). We will use the P0.0 pin (originally LED_R net) to drive the WS2812B DIN. P0.0 is already configured as a Push-Pull output. Pins P2.7 (originally LED_G) and P2.6 (originally LED_B) will be disabled (set to standard inputs or high logic).
  2. French Translations: All UI strings will be replaced with French equivalents formatted to fit the 120-pixel wide OLED screen (max 15 characters per line).

Open Questions

None. The specifications are fully understood and mapping is direct.

Proposed Changes

Hardware / Drivers

[MODIFY] lcd_font.h

No change needed for font, but we might include character translations if custom accent characters were needed. Since we use standard French without accents (like "ARME" instead of "ARMÉ") to avoid custom font complexity, no changes to lcd_font.h are required.

Application Logic

[MODIFY] main.c

  1. Redefine LED output:
    • Redefine LED_R, LED_G, LED_B as virtual/soft registers (bit variables). This allows the current logic in Timer1_Isr (which computes blink rates, colors, and vibrations) to remain 100% unchanged.
  2. Implement WS2812B bit-bang driver:
    • Write a precise assembly/C bit-bang function WS2812_Write24Bit(u8 g, u8 r, u8 b) that drives P0.0 (DIN) with the correct WS2812 high-speed timing (typical T0H = 0.35us, T0L = 0.9us, T1H = 0.8us, T1L = 0.4us).
    • Implement WS2812_Reset() by holding DI low for >80us to latch data.
  3. Trigger RGB updates:
    • At the end of Timer1_Isr (or during main loop), monitor changes to the virtual LED_R, LED_G, LED_B variables. If any changes are detected, output the 24-bit color to the WS2812 LED using the bit-bang driver.
  4. French UI Translation:
    • Translate all string literals displayed on the screen into French (e.g. menu items, sensor default names, and system state texts).

Verification Plan

Automated Tests

  • Build code with Keil C251 to ensure 0 compile/link errors.

Manual Verification

  • Test using UART simulation commands:
    • Verify that the simulated LED output in the serial log shows correct R/G/B status changes for different states.
    • Verify that French strings are printed correctly on the screen simulator or display.
    • Test pairing, confirmation, alarm, and SOS states to verify correct RGB LED color outputs.