dashboard: queue latest relay target states

This commit is contained in:
2026-06-15 17:43:46 -06:00
parent 237d732f52
commit e1bbe2c135
@@ -541,7 +541,6 @@ static void relay_button_event_cb(lv_event_t *event)
pending_relay_previous_state[index] = previous_state; pending_relay_previous_state[index] = previous_state;
} }
// Latest-state queue: rapid taps overwrite this relay's desired target.
pending_relay_state[index] = next_state; pending_relay_state[index] = next_state;
relay_command_pending[index] = true; relay_command_pending[index] = true;
@@ -575,8 +574,6 @@ static void process_pending_relay_command()
bool next_state = pending_relay_state[index]; bool next_state = pending_relay_state[index];
bool previous_state = pending_relay_previous_state[index]; bool previous_state = pending_relay_previous_state[index];
// Clear before posting. If the user taps again after this command returns,
// the new desired state will be queued as a fresh command.
relay_command_pending[index] = false; relay_command_pending[index] = false;
bool ok = post_relay_state(relay_id, next_state); bool ok = post_relay_state(relay_id, next_state);
@@ -584,8 +581,7 @@ static void process_pending_relay_command()
if (ok) { if (ok) {
set_label_text_if_changed(system_status_label, last_system_status_text, "Relay command sent"); set_label_text_if_changed(system_status_label, last_system_status_text, "Relay command sent");
} else { } else {
// Only revert if no newer desired state was queued for this relay. if (!relay_command_pending[index]) {
if (!relay_command_pending[index] && index >= 0 && index < relay_count) {
relay_states[index] = previous_state; relay_states[index] = previous_state;
update_relay_buttons(); update_relay_buttons();
} }