Make brightness a bit look better

This commit is contained in:
2022-12-31 18:27:02 +01:00
parent cadd97909d
commit bb8da924df
+23 -6
View File
@@ -23,6 +23,10 @@
#include <WiFiManager.h> #include <WiFiManager.h>
// #define BRIGHTNESS 200 // #define BRIGHTNESS 200
#define BRIGHTNESS_HIGH 200
#define BRIGHTNESS_LOW 100
#define BRIGHTNESS_HIGH_TIME 8
#define BRIGHTNESS_LOW_TIME 20
#define NUM_LEDS 43 #define NUM_LEDS 43
#define DATA_PIN 5 #define DATA_PIN 5
@@ -94,7 +98,7 @@ uint8_t color = 0;
int lastmin = 100; int lastmin = 100;
void printDigits(int digits); void printDigits(int digits);
void sendNTPpacket(IPAddress &address); void sendNTPpacket(IPAddress &address);
uint8_t BRIGHTNESS = 200; uint8_t brightness = BRIGHTNESS_HIGH;
void clear(bool show=true) void clear(bool show=true)
{ {
@@ -110,7 +114,7 @@ void noWifi()
{ {
for(int i=0; i<NUM_LEDS; i++) for(int i=0; i<NUM_LEDS; i++)
{ {
leds[i] = CHSV((255/(NUM_LEDS-1))*i, 255, BRIGHTNESS); leds[i] = CHSV((255/(NUM_LEDS-1))*i, 255, brightness);
FastLED.show(); FastLED.show();
} }
} }
@@ -148,7 +152,7 @@ void setup()
clear(); clear();
for (int initcount=0; initcount <= NUM_LEDS; initcount++) { for (int initcount=0; initcount <= NUM_LEDS; initcount++) {
clear(); clear();
leds[initcount] = CHSV((255/NUM_LEDS)*initcount, 255, BRIGHTNESS); leds[initcount] = CHSV((255/NUM_LEDS)*initcount, 255, brightness);
FastLED.show(); FastLED.show();
delay(100); delay(100);
} }
@@ -211,7 +215,7 @@ void set_word(int word, time_t current_time = loctime) {
{ {
if (clockWords[word][i] >= 0) if (clockWords[word][i] >= 0)
{ {
leds[clockWords[word][i]] = CHSV(color, 255, BRIGHTNESS); leds[clockWords[word][i]] = CHSV(color, 255, brightness);
Serial.print(clockWords[word][i]); Serial.print(clockWords[word][i]);
Serial.print(" "); Serial.print(" ");
} }
@@ -223,6 +227,7 @@ void setClock() {
Serial.println("Updating display..."); Serial.println("Updating display...");
time_t current_time = loctime; time_t current_time = loctime;
clear(false); clear(false);
set_brightness(); // ***Should set brightness
set_word(M_ES); // switch es on set_word(M_ES); // switch es on
set_word(M_IST); // switch ist on set_word(M_IST); // switch ist on
getMinuteWord(); //get word for "minute" getMinuteWord(); //get word for "minute"
@@ -232,6 +237,20 @@ void setClock() {
Serial.println("... display updated."); Serial.println("... display updated.");
} }
void set_brightness();
{
switch(int(hour(loctime)))
{
case BRIGHTNESS_HIGH_TIME:
brightness = BRIGHTNESS_HIGH;
break;
case BRIGHTNESS_LOW_TIME:
brightness = BRIGHTNESS_LOW;
break;
}
}
int getHour() int getHour()
{ {
int h = int(hour(loctime)); int h = int(hour(loctime));
@@ -313,7 +332,6 @@ void getHourWord()
Serial.println("sieben"); Serial.println("sieben");
break; break;
case 8: case 8:
BRIGHTNESS = 200;
case 20: case 20:
set_word(H_ACHT); set_word(H_ACHT);
Serial.println("acht"); Serial.println("acht");
@@ -325,7 +343,6 @@ void getHourWord()
break; break;
case 10: case 10:
case 22: case 22:
BRIGHTNESS = 50;
set_word(H_ZEHN); set_word(H_ZEHN);
Serial.println("zehn"); Serial.println("zehn");
break; break;