enable nightmode brightness at night
add some comments
This commit is contained in:
		@@ -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<uint8_t>& 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);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -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{};
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user