Added cable status detection

This commit is contained in:
Mark Qvist 2022-10-29 16:44:49 +02:00
parent c88d7b4534
commit de1a8aa36c

View File

@ -94,13 +94,13 @@ void setup() {
kiss_indicate_reset(); kiss_indicate_reset();
#endif #endif
// Validate board health, EEPROM and config
validateStatus();
#if HAS_DISPLAY #if HAS_DISPLAY
disp_ready = display_init(); disp_ready = display_init();
#endif #endif
// Validate board health, EEPROM and config
validateStatus();
#if HAS_BLUETOOTH #if HAS_BLUETOOTH
bt_ready = bt_init(); bt_ready = bt_init();
#endif #endif
@ -259,6 +259,7 @@ bool startRadio() {
// The radio could not be started. // The radio could not be started.
// Indicate this failure over both the // Indicate this failure over both the
// serial port and with the onboard LEDs // serial port and with the onboard LEDs
radio_error = true;
kiss_indicate_error(ERROR_INITRADIO); kiss_indicate_error(ERROR_INITRADIO);
led_indicate_error(0); led_indicate_error(0);
return false; return false;
@ -552,6 +553,10 @@ void serialCallback(uint8_t sbyte) {
} else if (command == CMD_IMPLICIT) { } else if (command == CMD_IMPLICIT) {
set_implicit_length(sbyte); set_implicit_length(sbyte);
kiss_indicate_implicit_length(); kiss_indicate_implicit_length();
} else if (command == CMD_LEAVE) {
if (sbyte == 0xFF) {
cable_state = CABLE_STATE_DISCONNECTED;
}
} else if (command == CMD_RADIO_STATE) { } else if (command == CMD_RADIO_STATE) {
cable_state = CABLE_STATE_CONNECTED; cable_state = CABLE_STATE_CONNECTED;
if (sbyte == 0xFF) { if (sbyte == 0xFF) {
@ -748,6 +753,9 @@ void validateStatus() {
boot_vector = START_FROM_BOOTLOADER; boot_vector = START_FROM_BOOTLOADER;
} else { } else {
Serial.write("Error, indeterminate boot vector\r\n"); Serial.write("Error, indeterminate boot vector\r\n");
#if HAS_DISPLAY
if (disp_ready) update_display();
#endif
led_indicate_boot_error(); led_indicate_boot_error();
} }
@ -772,6 +780,9 @@ void validateStatus() {
} else { } else {
hw_ready = false; hw_ready = false;
Serial.write("Error, incorrect boot vector\r\n"); Serial.write("Error, incorrect boot vector\r\n");
#if HAS_DISPLAY
if (disp_ready) update_display();
#endif
led_indicate_boot_error(); led_indicate_boot_error();
} }
} }
@ -828,15 +839,11 @@ void loop() {
#endif #endif
#if HAS_DISPLAY #if HAS_DISPLAY
if (disp_ready) { if (disp_ready) update_display();
update_display();
}
#endif #endif
#if HAS_PMU #if HAS_PMU
if (pmu_ready) { if (pmu_ready) update_pmu();
update_pmu();
}
#endif #endif
} }