led pattern, error in flashing if firmeware to large -> watchdog?

This commit is contained in:
2025-04-24 01:46:16 +02:00
parent 49614a2f96
commit 3572b15564
3 changed files with 32 additions and 15 deletions

View File

@@ -910,28 +910,47 @@ fn update_plant_state(
fn wait_infinity(wait_type: WaitType, reboot_now: Arc<AtomicBool>) -> ! {
let delay = wait_type.blink_pattern();
let mut led_count = 8;
let mut pattern_step = 0;
loop {
// TODO implement actually different blink patterns instead of modulating blink duration
if wait_type == WaitType::MissingConfig {
led_count %= 8;
led_count += 1;
};
unsafe {
BOARD_ACCESS.lock().unwrap().update_charge_indicator();
//do not trigger watchdog
for i in 0..8 {
BOARD_ACCESS.lock().unwrap().fault(i, i < led_count);
match wait_type {
WaitType::MissingConfig => {
// Keep existing behavior: circular filling pattern
led_count %= 8;
led_count += 1;
for i in 0..8 {
BOARD_ACCESS.lock().unwrap().fault(i, i < led_count);
}
}
WaitType::ConfigButton => {
// Alternating pattern: 1010 1010 -> 0101 0101
pattern_step = (pattern_step + 1) % 2;
for i in 0..8 {
BOARD_ACCESS.lock().unwrap().fault(i, (i + pattern_step) % 2 == 0);
}
}
WaitType::MqttConfig => {
// Moving dot pattern
pattern_step = (pattern_step + 1) % 8;
for i in 0..8 {
BOARD_ACCESS.lock().unwrap().fault(i, i == pattern_step);
}
}
}
BOARD_ACCESS.lock().unwrap().general_fault(true);
vTaskDelay(delay);
BOARD_ACCESS.lock().unwrap().general_fault(false);
//TODO move locking outside of loop and drop afterwards
// Clear all LEDs
for i in 0..8 {
BOARD_ACCESS.lock().unwrap().fault(i, false);
}
vTaskDelay(delay);
if wait_type == WaitType::MqttConfig {
if !STAY_ALIVE.load(std::sync::atomic::Ordering::Relaxed) {
reboot_now.store(true, std::sync::atomic::Ordering::Relaxed);
@@ -946,6 +965,7 @@ fn wait_infinity(wait_type: WaitType, reboot_now: Arc<AtomicBool>) -> ! {
}
}
fn main() {
let result = safe_main();
match result {