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

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

View File

@ -21,5 +21,6 @@ build-std = ["std", "panic_abort"]
MCU="esp32c6"
# Note: this variable is not used by the pio builder (`cargo build --features pio`)
ESP_IDF_VERSION = "v5.2.1"
CHRONO_TZ_TIMEZONE_FILTER="UTC|Europe/Berlin"
CARGO_WORKSPACE_DIR = { value = "", relative = true }
RUST_BACKTRACE = "full"

View File

@ -63,14 +63,10 @@ one-wire-bus = "0.1.1"
ds323x = "0.6.0"
#pure code dependencies
log = { version = "0.4", default-features = false }
once_cell = "1.19.0"
anyhow = { version = "1.0.75", features = ["std", "backtrace"] }
average = { version = "0.14.1" , features = ["std"] }
bit_field = "0.10.2"
strum = { version = "0.27.0", features = ["derive"] }
measurements = "0.11.0"
schemars = "0.8.16"
#json
serde = { version = "1.0.192", features = ["derive"] }
@ -78,7 +74,7 @@ serde_json = "1.0.108"
#timezone
chrono = { version = "0.4.23", default-features = false , features = ["iana-time-zone" , "alloc"] }
chrono-tz = {version="0.8.0", default-features = false}
chrono-tz = {version="0.8.0", default-features = false , features = [ "filter-by-regex" ]}
eeprom24x = "0.7.2"
url = "2.5.3"
crc = "3.2.1"

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 {