From 731202ed7717e8eef4028954bfa8706e64f4085c Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Thu, 13 May 2021 19:43:40 +0200 Subject: [PATCH] init WS2812 LED from main setup(), more logging --- multigeiger/multigeiger.ino | 1 + multigeiger/status_led.cpp | 8 +++++--- multigeiger/status_led.h | 2 ++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/multigeiger/multigeiger.ino b/multigeiger/multigeiger.ino index 1c0787cc..b55f5a38 100644 --- a/multigeiger/multigeiger.ino +++ b/multigeiger/multigeiger.ino @@ -43,6 +43,7 @@ static Switches switches; void setup() { bool isLoraBoard = init_hwtest(); setup_log(DEFAULT_LOG_LEVEL); + setup_status_LED(); setup_display(isLoraBoard); setup_switches(isLoraBoard); switches = read_switches(); // only read DIP switches once at boot time diff --git a/multigeiger/status_led.cpp b/multigeiger/status_led.cpp index 9507d427..892756cd 100644 --- a/multigeiger/status_led.cpp +++ b/multigeiger/status_led.cpp @@ -4,6 +4,7 @@ #include +#include "log.h" #include "status_led.h" #define PIXEL_COUNT 1 @@ -18,7 +19,7 @@ RgbColor black(0, 0, 0); static NeoPixelBus LEDs(PIXEL_COUNT, PIXEL_PIN); -static RgbColor last_col = black; +static RgbColor last_col; static void set_LED(RgbColor col) { if (col == last_col) @@ -29,7 +30,7 @@ static void set_LED(RgbColor col) { last_col = col; } -static void init_LED(void) { +void setup_status_LED(void) { LEDs.Begin(); // all LEDs off LEDs.Show(); last_col = black; // consistency sw state == hw state @@ -65,9 +66,10 @@ void indicate(float radiation, unsigned int indication) { RgbColor col; static int index = 0; // index counting modulo COLOR_SEQUENCE_LENGTH + log(INFO, "LED index: %d, radiation: %f", index, radiation); + switch (index) { case 0: // show a fixed dark separator after LED init - init_LED(); // (re-)init the LED col = black; break; case 1: diff --git a/multigeiger/status_led.h b/multigeiger/status_led.h index 2a23f8bf..22d6eb5a 100644 --- a/multigeiger/status_led.h +++ b/multigeiger/status_led.h @@ -13,3 +13,5 @@ // indicate radiation and special indications via a color time sequence. // you should call this in regular time intervals [e.g. 1s]. void indicate(float radiation, unsigned int indication); + +void setup_status_LED(void);