diff --git a/src/Clock.cpp b/src/Clock.cpp index 01ef58a..d77a08d 100644 --- a/src/Clock.cpp +++ b/src/Clock.cpp @@ -10,6 +10,7 @@ Clock::Clock() : strip(NUMPIXELS, STRIPPIN, NEO_GRB + NEO_KHZ800), animator(), r void Clock::init() { strip.begin(); + strip.setBrightness(DAYBRIGHTNESS); // initialize clock ticker turnOn(); @@ -42,10 +43,13 @@ void Clock::printWord(const std::vector& word, uint32_t color) { void Clock::refreshTime() { // grab the current instant in unix seconds time_t now = time(nullptr); + + // if not time is set (only seconds since start) start animation if (now <= 604800) { animator.startLoadAnimation(&strip); return; } + animator.stopLoadAnimation(); strip.clear(); @@ -54,6 +58,13 @@ void Clock::refreshTime() { const uint8_t hour = loctime->tm_hour; const uint8_t minute = loctime->tm_min; + // enable night brighntess at 21' and disable it at 6' + if (hour >= 21 || hour <= 6) { + strip.setBrightness(NIGHTBRIGHTNESS); + } else { + strip.setBrightness(DAYBRIGHTNESS); + } + paintAlwaysOnLeds(); setTime(hour, minute, this->twentyAfterSyntax, this->clockAlwaysOn); diff --git a/src/Clock.h b/src/Clock.h index 74b40b7..fbcfcaf 100644 --- a/src/Clock.h +++ b/src/Clock.h @@ -16,6 +16,9 @@ // define the esp pin the stip is attached to #define STRIPPIN D5 +#define DAYBRIGHTNESS 255 +#define NIGHTBRIGHTNESS 40 + class Clock { private: Adafruit_NeoPixel strip{};