From 9ffe21adaa673b60a568adb30ed29b0dca08c695 Mon Sep 17 00:00:00 2001 From: Martin Hugh Date: Mon, 22 Jan 2024 12:06:49 +0000 Subject: [PATCH 1/4] Add Diagnostics flashing for blue LED --- src/hardware.c | 79 +++++++++++++++++++++++++++++++++++++------------- src/hardware.h | 2 +- 2 files changed, 60 insertions(+), 21 deletions(-) diff --git a/src/hardware.c b/src/hardware.c index 5693eca..6425154 100644 --- a/src/hardware.c +++ b/src/hardware.c @@ -72,6 +72,41 @@ uint8_t cur_pwr = 0; uint8_t led_status = 0; +// Blue LED diagnostic encoding, in 1/16s blocks over 4s (64 flags) +// Short pulse 3/8s (6 flags) +// Long pulse 1s (16 flags) +// OFF 3/8s (6 flags) + +// SS +// XXXXXX------XXXXXX-------------- --------------------------------- +uint8_t diag_led_flags_cameralost[64] = {1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, + 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; +// SSS +// XXXXXX------XXXXXX------XXXXXX-- --------------------------------- +uint8_t diag_led_flags_heatprotect[64] = {1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, + 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; +// SSSS +// XXXXXX------XXXXXX------XXXXXX-- ----XXXXXX----------------------- +uint8_t diag_led_flags_dm6300lost[64] = {1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, + 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, + 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; +// LS +// XXXXXXXXXXXXXXXX------XXXXXX-- --------------------------------- +uint8_t diag_led_flags_0mW[64] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; +// LSS +// XXXXXXXXXXXXXXXX------XXXXXX-- ----XXXXXX----------------------- +uint8_t diag_led_flags_pit[64] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, + 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; uint8_t temp_err = 0; #ifdef USE_TEMPERATURE_SENSOR int16_t temp0 = 0; @@ -107,6 +142,7 @@ uint8_t dispL_cnt = 0xff; uint8_t cameraLost = 0; uint8_t timer_cnt = 0; +uint8_t led_timer_cnt = 0; void LED_Init(); @@ -1461,32 +1497,30 @@ void LED_Flip() { } void LED_Task() { if (dm6300_lost) { - if (timer_cnt == 0 || timer_cnt == 4) { - LED_BLUE_ON; - led_status = ON; - } else if (timer_cnt == 2 || timer_cnt == 6) { - LED_BLUE_OFF; - led_status = OFF; - } + Set_Blue_LED(diag_led_flags_dm6300lost[led_timer_cnt]); + } else if (cameraLost) { - if (led_status == ON) { - LED_BLUE_OFF; - led_status = OFF; - } + Set_Blue_LED(diag_led_flags_cameralost[led_timer_cnt]); + } else if (heat_protect) { - if (timer_2hz) - LED_Flip(); + Set_Blue_LED(diag_led_flags_heatprotect[led_timer_cnt]); + } else if (cur_pwr == POWER_MAX + 2) { - if (timer_8hz) { - LED_Flip(); - } + Set_Blue_LED(diag_led_flags_0mW[led_timer_cnt]); + } else if (PIT_MODE != PIT_OFF) { - if (timer_4hz) { - LED_Flip(); - } - } else if (led_status == OFF) { + Set_Blue_LED(diag_led_flags_pit[led_timer_cnt]); + } else + Set_Blue_LED(1); +} + +void Set_Blue_LED(uint8_t flag) { + if (flag) { LED_BLUE_ON; led_status = ON; + } else { + LED_BLUE_OFF; + led_status = OFF; } } @@ -1557,6 +1591,11 @@ void timer_task() { timer_4hz = ((timer_cnt & 3) == 3); timer_8hz = ((timer_cnt & 1) == 1); timer_16hz = 1; + + // 4s timeframe for led diagnostic encoding + led_timer_cnt++; + led_timer_cnt &= 63; + } else { timer_2hz = 0; timer_4hz = 0; diff --git a/src/hardware.h b/src/hardware.h index 0763acb..330b1ef 100644 --- a/src/hardware.h +++ b/src/hardware.h @@ -93,7 +93,7 @@ void Set_1080P30(uint8_t page); void Flicker_LED(uint8_t n); void LED_Flip(); void LED_Task(); - +void Set_Blue_LED(uint8_t flag); uint8_t RF_BW_to_be_changed(void); void uart_baudrate_detect(void); uint8_t temperature_level(void); From 176bf20514f2f26ef336a8cdd7bf208a83e01b04 Mon Sep 17 00:00:00 2001 From: Martin Hugh Date: Tue, 23 Jan 2024 09:58:28 +0000 Subject: [PATCH 2/4] correct diag_led_flags_ array definitions --- src/hardware.c | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/src/hardware.c b/src/hardware.c index 6425154..ac13292 100644 --- a/src/hardware.c +++ b/src/hardware.c @@ -79,34 +79,34 @@ uint8_t led_status = 0; // SS // XXXXXX------XXXXXX-------------- --------------------------------- -uint8_t diag_led_flags_cameralost[64] = {1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, - 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; +const uint8_t diag_led_flags_cameralost[64] = {1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, + 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; // SSS // XXXXXX------XXXXXX------XXXXXX-- --------------------------------- -uint8_t diag_led_flags_heatprotect[64] = {1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, - 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; +const uint8_t diag_led_flags_heatprotect[64] = {1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, + 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; // SSSS // XXXXXX------XXXXXX------XXXXXX-- ----XXXXXX----------------------- -uint8_t diag_led_flags_dm6300lost[64] = {1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, - 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, - 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; +const uint8_t diag_led_flags_dm6300lost[64] = {1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, + 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, + 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; // LS // XXXXXXXXXXXXXXXX------XXXXXX-- --------------------------------- -uint8_t diag_led_flags_0mW[64] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; +const uint8_t diag_led_flags_0mW[64] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; // LSS // XXXXXXXXXXXXXXXX------XXXXXX-- ----XXXXXX----------------------- -uint8_t diag_led_flags_pit[64] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, - 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; +const uint8_t diag_led_flags_pit[64] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, + 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; uint8_t temp_err = 0; #ifdef USE_TEMPERATURE_SENSOR int16_t temp0 = 0; From c4bd43dc0f1544c234a3b6c3362f743808a19034 Mon Sep 17 00:00:00 2001 From: Martin Hugh Date: Tue, 23 Jan 2024 12:29:22 +0000 Subject: [PATCH 3/4] Adjust mark:space of led patterns --- src/hardware.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/hardware.c b/src/hardware.c index ac13292..ac3e45d 100644 --- a/src/hardware.c +++ b/src/hardware.c @@ -73,39 +73,39 @@ uint8_t cur_pwr = 0; uint8_t led_status = 0; // Blue LED diagnostic encoding, in 1/16s blocks over 4s (64 flags) -// Short pulse 3/8s (6 flags) +// Short pulse 1/4s (4 flags) // Long pulse 1s (16 flags) // OFF 3/8s (6 flags) // SS -// XXXXXX------XXXXXX-------------- --------------------------------- -const uint8_t diag_led_flags_cameralost[64] = {1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, - 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +// XXXX------XXXX--------------------------------------------------- +const uint8_t diag_led_flags_cameralost[64] = {1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; // SSS -// XXXXXX------XXXXXX------XXXXXX-- --------------------------------- -const uint8_t diag_led_flags_heatprotect[64] = {1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, - 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, +// XXXX------XXXX------XXXX----------------------------------------- +const uint8_t diag_led_flags_heatprotect[64] = {1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, + 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; // SSSS -// XXXXXX------XXXXXX------XXXXXX-- ----XXXXXX----------------------- -const uint8_t diag_led_flags_dm6300lost[64] = {1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, - 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, - 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, +// XXXX------XXXX------XXXX------XXXX------------------------------- +const uint8_t diag_led_flags_dm6300lost[64] = {1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, + 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, + 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; // LS -// XXXXXXXXXXXXXXXX------XXXXXX-- --------------------------------- +// XXXXXXXXXXXXXXXX------XXXX------------------------------------- const uint8_t diag_led_flags_0mW[64] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; // LSS -// XXXXXXXXXXXXXXXX------XXXXXX-- ----XXXXXX----------------------- +// XXXXXXXXXXXXXXXX------XXXX------XXXX--------------------------- const uint8_t diag_led_flags_pit[64] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, - 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, + 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; uint8_t temp_err = 0; #ifdef USE_TEMPERATURE_SENSOR From e2553b65c7ffecbf736a22adc90df9e043c061ea Mon Sep 17 00:00:00 2001 From: Martin Hugh Date: Tue, 23 Jan 2024 14:55:35 +0000 Subject: [PATCH 4/4] adjust space element of mW modes in flag array --- src/hardware.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hardware.c b/src/hardware.c index ac3e45d..e433f03 100644 --- a/src/hardware.c +++ b/src/hardware.c @@ -98,13 +98,13 @@ const uint8_t diag_led_flags_dm6300lost[64] = {1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, // LS // XXXXXXXXXXXXXXXX------XXXX------------------------------------- const uint8_t diag_led_flags_0mW[64] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; // LSS // XXXXXXXXXXXXXXXX------XXXX------XXXX--------------------------- const uint8_t diag_led_flags_pit[64] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; uint8_t temp_err = 0;