Skip to content

Commit

Permalink
init WS2812 LED from main setup(), more logging
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasWaldmann committed May 13, 2021
1 parent 59da93b commit 731202e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions multigeiger/multigeiger.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 5 additions & 3 deletions multigeiger/status_led.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include <NeoPixelBus.h>

#include "log.h"
#include "status_led.h"

#define PIXEL_COUNT 1
Expand All @@ -18,7 +19,7 @@ RgbColor black(0, 0, 0);

static NeoPixelBus<NeoRgbFeature, Neo800KbpsMethod> LEDs(PIXEL_COUNT, PIXEL_PIN);

static RgbColor last_col = black;
static RgbColor last_col;

static void set_LED(RgbColor col) {
if (col == last_col)
Expand All @@ -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
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 2 additions & 0 deletions multigeiger/status_led.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

0 comments on commit 731202e

Please sign in to comment.