enable nightmode brightness at night
add some comments
This commit is contained in:
parent
4ed74164e8
commit
fd91a6071b
@ -10,6 +10,7 @@ Clock::Clock() : strip(NUMPIXELS, STRIPPIN, NEO_GRB + NEO_KHZ800), animator(), r
|
|||||||
|
|
||||||
void Clock::init() {
|
void Clock::init() {
|
||||||
strip.begin();
|
strip.begin();
|
||||||
|
strip.setBrightness(DAYBRIGHTNESS);
|
||||||
|
|
||||||
// initialize clock ticker
|
// initialize clock ticker
|
||||||
turnOn();
|
turnOn();
|
||||||
@ -42,10 +43,13 @@ void Clock::printWord(const std::vector<uint8_t>& word, uint32_t color) {
|
|||||||
void Clock::refreshTime() {
|
void Clock::refreshTime() {
|
||||||
// grab the current instant in unix seconds
|
// grab the current instant in unix seconds
|
||||||
time_t now = time(nullptr);
|
time_t now = time(nullptr);
|
||||||
|
|
||||||
|
// if not time is set (only seconds since start) start animation
|
||||||
if (now <= 604800) {
|
if (now <= 604800) {
|
||||||
animator.startLoadAnimation(&strip);
|
animator.startLoadAnimation(&strip);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
animator.stopLoadAnimation();
|
animator.stopLoadAnimation();
|
||||||
strip.clear();
|
strip.clear();
|
||||||
|
|
||||||
@ -54,6 +58,13 @@ void Clock::refreshTime() {
|
|||||||
const uint8_t hour = loctime->tm_hour;
|
const uint8_t hour = loctime->tm_hour;
|
||||||
const uint8_t minute = loctime->tm_min;
|
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();
|
paintAlwaysOnLeds();
|
||||||
setTime(hour, minute, this->twentyAfterSyntax, this->clockAlwaysOn);
|
setTime(hour, minute, this->twentyAfterSyntax, this->clockAlwaysOn);
|
||||||
|
|
||||||
|
@ -16,6 +16,9 @@
|
|||||||
// define the esp pin the stip is attached to
|
// define the esp pin the stip is attached to
|
||||||
#define STRIPPIN D5
|
#define STRIPPIN D5
|
||||||
|
|
||||||
|
#define DAYBRIGHTNESS 255
|
||||||
|
#define NIGHTBRIGHTNESS 40
|
||||||
|
|
||||||
class Clock {
|
class Clock {
|
||||||
private:
|
private:
|
||||||
Adafruit_NeoPixel strip{};
|
Adafruit_NeoPixel strip{};
|
||||||
|
Loading…
Reference in New Issue
Block a user