set time to nightmode to 22o'clock

night brightness=0
loadanimaiton step into new function and some coments
This commit is contained in:
lukas 2021-05-12 21:20:32 +02:00
parent fd91a6071b
commit 3630918a6f
4 changed files with 56 additions and 38 deletions

View File

@ -30,8 +30,8 @@ void Clock::turnOn() {
}
void Clock::paintAlwaysOnLeds() {
printWord(types::es, Adafruit_NeoPixel::Color(150, 150, 0));
printWord(types::ist, Adafruit_NeoPixel::Color(150, 0, 150));
printWord(types::es, Adafruit_NeoPixel::Color(255, 255, 0));
printWord(types::ist, Adafruit_NeoPixel::Color(255, 0, 255));
}
void Clock::printWord(const std::vector<uint8_t>& word, uint32_t color) {
@ -59,7 +59,7 @@ void Clock::refreshTime() {
const uint8_t minute = loctime->tm_min;
// enable night brighntess at 21' and disable it at 6'
if (hour >= 21 || hour <= 6) {
if (hour >= 22 || hour <= 6) {
strip.setBrightness(NIGHTBRIGHTNESS);
} else {
strip.setBrightness(DAYBRIGHTNESS);
@ -98,14 +98,14 @@ void Clock::setTime(uint8_t hour, uint8_t minute, bool twentyAfterSyntax, bool a
: hour == 0 || hour == 12 ? types::zwoelf
: hourWord;
printWord(hourWord, Adafruit_NeoPixel::Color(0, 0, 150));
printWord(hourWord, Adafruit_NeoPixel::Color(0, 255, 255));
// print the minute words and the corresponding after/before half words
printMinutes(minuteselector, twentyAfterSyntax);
// uhr
if (minuteselector == 0 || alwaysClockWord)
printWord(types::uhr, Adafruit_NeoPixel::Color(150, 0, 0));
printWord(types::uhr, Adafruit_NeoPixel::Color(255, 0, 0));
}
void Clock::printMinutes(uint8_t minuteSelector, bool twentyAfterSyntax) {
@ -126,7 +126,7 @@ void Clock::printMinutes(uint8_t minuteSelector, bool twentyAfterSyntax) {
else if (minuteSelector == 6)
minuteWord = types::halb;
printWord(minuteWord, Adafruit_NeoPixel::Color(0, 150, 0));
printWord(minuteWord, Adafruit_NeoPixel::Color(0, 255, 0));
// vor / nach
std::vector<uint8_t> vornachWord;
@ -142,13 +142,13 @@ void Clock::printMinutes(uint8_t minuteSelector, bool twentyAfterSyntax) {
|| minuteSelector == 10 || minuteSelector == 11 ||
((minuteSelector == 8) && twentyAfterSyntax)) // check if twentyafter enabled if yess -- display vor
vornachWord = types::vor;
printWord(vornachWord, Adafruit_NeoPixel::Color(150, 150, 150));
printWord(vornachWord, Adafruit_NeoPixel::Color(255, 255, 255));
// halb
if (minuteSelector >= 4 && minuteSelector <= 8) {
// only 3 times if twentyafter syntax is on
if (!twentyAfterSyntax || (minuteSelector >= 5 && minuteSelector <= 7))
printWord(types::halb, Adafruit_NeoPixel::Color(150, 0, 0));
printWord(types::halb, Adafruit_NeoPixel::Color(255, 0, 0));
}
}

View File

@ -16,8 +16,8 @@
// define the esp pin the stip is attached to
#define STRIPPIN D5
#define DAYBRIGHTNESS 255
#define NIGHTBRIGHTNESS 40
#define DAYBRIGHTNESS 150
#define NIGHTBRIGHTNESS 0
class Clock {
private:

View File

@ -6,8 +6,19 @@
#include "Types.h"
void LoadAnimator::startLoadAnimation(Adafruit_NeoPixel* strip) {
this->strip = strip;
if (!timer.active())
timer.attach_ms(100, [this, strip]() {
timer.attach_ms(100, std::bind(&LoadAnimator::animationStep, this));
}
void LoadAnimator::stopLoadAnimation() {
timer.detach();
}
LoadAnimator::LoadAnimator() : timer(), x(0), y(0), nro(0), nroo(0), nrooo(0){};
void LoadAnimator::animationStep() {
if (y == 0 && x < 7) {
x++;
} else if (x == 7 && y < 4) {
@ -32,11 +43,4 @@ void LoadAnimator::startLoadAnimation(Adafruit_NeoPixel* strip) {
nrooo = nroo;
nroo = nro;
nro = nr;
});
}
void LoadAnimator::stopLoadAnimation() {
timer.detach();
}
LoadAnimator::LoadAnimator() : timer(), x(0), y(0), nro(0), nroo(0), nrooo(0) {
}

View File

@ -12,11 +12,25 @@ class LoadAnimator {
private:
Ticker timer;
uint8_t x, y, nro, nroo, nrooo;
Adafruit_NeoPixel *strip;
/**
* one animation step to process the animation
*/
void animationStep();
public:
LoadAnimator();
/**
* start the animation if not already runnint
* @param strip pointer to strip object
*/
void startLoadAnimation(Adafruit_NeoPixel *strip);
/**
* stop the animation
*/
void stopLoadAnimation();
};