diff --git a/include/Animation.h b/include/Animation.h index 9b5793f6..6469e71b 100644 --- a/include/Animation.h +++ b/include/Animation.h @@ -1,5 +1,6 @@ #pragma once +#include "font.h" #include "icons.h" #include diff --git a/include/Animation.hpp b/include/Animation.hpp index 4f1e50f8..3f1289ca 100644 --- a/include/Animation.hpp +++ b/include/Animation.hpp @@ -242,7 +242,7 @@ void Animation::analyzeColors(RgbfColor **dest, RgbfColor **source, for (int r = 0; r < max_rows; r++) { for (int c = 0; c < max_cols; c++) { if (source == STRIPE) { - color = led_get_pixel( + color = led.getPixel( usedUhrType->getFrontMatrix(r + row_start, c + col_start)); } else { color = source[r][c]; @@ -293,21 +293,21 @@ void Animation::analyzeColors(RgbfColor **dest, RgbfColor **source, void Animation::set_minutes() { if (G.zeige_min > 0) { uint8_t m = lastMinute % 5; - led_set_pixel_Color_Object(usedUhrType->getMinArr(G.zeige_min - 1, 0), - m > 0 ? foregroundMinute : background); - led_set_pixel_Color_Object(usedUhrType->getMinArr(G.zeige_min - 1, 1), - m > 1 ? foregroundMinute : background); - led_set_pixel_Color_Object(usedUhrType->getMinArr(G.zeige_min - 1, 2), - m > 2 ? foregroundMinute : background); - led_set_pixel_Color_Object(usedUhrType->getMinArr(G.zeige_min - 1, 3), - m > 3 ? foregroundMinute : background); + led.setPixelColorObject(usedUhrType->getMinArr(G.zeige_min - 1, 0), + m > 0 ? foregroundMinute : background); + led.setPixelColorObject(usedUhrType->getMinArr(G.zeige_min - 1, 1), + m > 1 ? foregroundMinute : background); + led.setPixelColorObject(usedUhrType->getMinArr(G.zeige_min - 1, 2), + m > 2 ? foregroundMinute : background); + led.setPixelColorObject(usedUhrType->getMinArr(G.zeige_min - 1, 3), + m > 3 ? foregroundMinute : background); } } // Ueberschreibe die LEDs mit interner Matrix void Animation::copy2Stripe(RgbfColor **source) { for (uint8_t row = 0; row < max_rows; row++) { for (uint8_t col = 0; col < max_cols; col++) { - led_set_pixel_Color_Object( + led.setPixelColorObject( usedUhrType->getFrontMatrix(row + row_start, col + col_start), source[row][col]); } @@ -404,7 +404,7 @@ void Animation::loop(struct tm &tm) { copyMatrix(work, act); colorize(work); copy2Stripe(work); - led_show(); + led.show(); } } else { if ((animType != lastAnimType) || @@ -466,7 +466,7 @@ void Animation::loop(struct tm &tm) { } animColorChange(); copy2Stripe(work); - led_show(); + led.show(); } } } diff --git a/include/EEPROMAnything.h b/include/EEPROMAnything.h index 753cb02f..306f6a50 100644 --- a/include/EEPROMAnything.h +++ b/include/EEPROMAnything.h @@ -62,13 +62,14 @@ void eeprom_read() { Serial.printf("LDR : %u\n", G.ldr); Serial.printf("LDRCal : %u\n", G.ldrCal); Serial.printf("Uhrtype : %u\n", G.UhrtypeDef); - Serial.printf("MQTT_State : %u\n", G.MQTT_State); - Serial.printf("MQTT_Server : %s\n", G.MQTT_Server); - Serial.printf("MQTT_User : %s\n", G.MQTT_User); - Serial.printf("MQTT_Pass : %s\n", G.MQTT_Pass); - Serial.printf("MQTT_ClientId : %s\n", G.MQTT_ClientId); - Serial.printf("MQTT_Topic : %s\n", G.MQTT_Topic); - Serial.printf("MQTT_Port : %u\n", G.MQTT_Port); + + Serial.printf("MQTT_State : %u\n", G.mqtt.state); + Serial.printf("MQTT_Server : %s\n", G.mqtt.serverAdress); + Serial.printf("MQTT_User : %s\n", G.mqtt.user); + Serial.printf("MQTT_Pass : %s\n", G.mqtt.password); + Serial.printf("MQTT_ClientId : %s\n", G.mqtt.clientId); + Serial.printf("MQTT_Topic : %s\n", G.mqtt.topic); + Serial.printf("MQTT_Port : %u\n", G.mqtt.port); Serial.printf("autoLdrEnabled : %u\n", G.autoLdrEnabled); Serial.printf("autoLdrBright : %u\n", G.autoLdrBright); @@ -85,9 +86,9 @@ void eeprom_read() { Serial.printf("bootShowIP : %u\n", G.bootShowIP); Serial.printf("Colortype : %u\n", G.Colortype); Serial.print("OWM_apikey: "); - Serial.println(G.apikey); + Serial.println(G.openWeatherMap.apikey); Serial.print("OWM_city : "); - Serial.println(G.cityid); + Serial.println(G.openWeatherMap.cityid); delay(100); } diff --git a/include/Network.h b/include/Network.h deleted file mode 100644 index b4c02cd9..00000000 --- a/include/Network.h +++ /dev/null @@ -1,15 +0,0 @@ -#pragma once - -#include - -void Network_info(); -int Network_getQuality(); -void Network_disable(); -void Network_reboot(); -void Network_resetSettings(); -String Network_getSSID(); -void Network_rtcMode(); -void Network_changeHostname(const char *hostname); - -void Network_setup(const char *hostname); -void Network_loop(); diff --git a/include/Uhr.h b/include/Uhr.h index b51fb8c1..1d41dbfd 100644 --- a/include/Uhr.h +++ b/include/Uhr.h @@ -33,6 +33,21 @@ enum uhrzeit_t { H_ZWOELF = 21 }; +struct MqttData { + uint8_t state; + char serverAdress[PAYLOAD_LENGTH]; + char user[PAYLOAD_LENGTH]; + char password[PAYLOAD_LENGTH]; + char clientId[PAYLOAD_LENGTH]; + char topic[PAYLOAD_LENGTH]; + uint16_t port; +}; + +struct OpenWeatherMapData { + char apikey[35]; + char cityid[8]; +}; + struct GLOBAL { uint8_t sernr; uint16_t prog; @@ -47,8 +62,6 @@ struct GLOBAL { uint8_t hell; uint16_t ldr; uint16_t ldrCal; - char apikey[35]; - char cityid[8]; int geschw; uint8_t client_nr; uint8_t zeige_sek; @@ -69,13 +82,10 @@ struct GLOBAL { uint8_t UhrtypeDef; uint8_t Colortype; - uint8_t MQTT_State; - char MQTT_Server[PAYLOAD_LENGTH]; - char MQTT_User[PAYLOAD_LENGTH]; - char MQTT_Pass[PAYLOAD_LENGTH]; - char MQTT_ClientId[PAYLOAD_LENGTH]; - char MQTT_Topic[PAYLOAD_LENGTH]; - uint16_t MQTT_Port; + + MqttData mqtt; + + OpenWeatherMapData openWeatherMap; uint8_t autoLdrEnabled; uint8_t autoLdrBright; @@ -172,9 +182,9 @@ enum Command { COMMAND_MODE_WORD_CLOCK = 1, COMMAND_MODE_SECONDS = 2, - COMMAND_MODE_MARQUEE = 3, - COMMAND_MODE_RAINBOW = 4, - COMMAND_MODE_CHANGE = 5, + COMMAND_MODE_SCROLLINGTEXT = 3, + COMMAND_MODE_RAINBOWCYCLE = 4, + COMMAND_MODE_RAINBOW = 5, COMMAND_MODE_COLOR = 6, COMMAND_MODE_ANIMATION = 10, @@ -200,7 +210,6 @@ enum Command { COMMAND_SET_BOOT = 101, COMMAND_SET_AUTO_LDR = 102, - COMMAND_BRIGHTNESS = 151, COMMAND_SPEED = 152, COMMAND_REQUEST_CONFIG_VALUES = 200, diff --git a/include/WebPage_Adapter.h b/include/WebPage_Adapter.h index 1c87afc5..5f0610cd 100644 --- a/include/WebPage_Adapter.h +++ b/include/WebPage_Adapter.h @@ -1,6 +1,5 @@ #pragma once -#include "Network.h" #include "Uhr.h" #include "WebPageContent.h" #include "WebSocketsServer.h" @@ -204,10 +203,7 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t *payload, case COMMAND_MODE_SECONDS: { // Sekunden G.prog = COMMAND_MODE_SECONDS; - G.param1 = split(payload, 33); - if (G.param1 == 0) { - G.prog_init = 1; - } + G.prog_init = 1; G.rgb[Effect][0] = split(payload, 3); G.rgb[Effect][1] = split(payload, 6); @@ -220,12 +216,9 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t *payload, //------------------------------------------------------------------------------ - case COMMAND_MODE_MARQUEE: { // Laufschrift - G.prog = COMMAND_MODE_MARQUEE; - G.param1 = split(payload, 33); - if (G.param1 == 0) { - G.prog_init = 1; - } + case COMMAND_MODE_SCROLLINGTEXT: { + G.prog = COMMAND_MODE_SCROLLINGTEXT; + G.prog_init = 1; G.rgb[Effect][0] = split(payload, 3); G.rgb[Effect][1] = split(payload, 6); @@ -238,8 +231,8 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t *payload, //------------------------------------------------------------------------------ - case COMMAND_MODE_RAINBOW: { // Regenbogen - G.prog = COMMAND_MODE_RAINBOW; + case COMMAND_MODE_RAINBOWCYCLE: { + G.prog = COMMAND_MODE_RAINBOWCYCLE; G.prog_init = 1; G.hell = split(payload, 27); @@ -249,8 +242,8 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t *payload, //------------------------------------------------------------------------------ - case COMMAND_MODE_CHANGE: { // Farbwechsel - G.prog = COMMAND_MODE_CHANGE; + case COMMAND_MODE_RAINBOW: { + G.prog = COMMAND_MODE_RAINBOW; G.prog_init = 1; G.hell = split(payload, 27); @@ -289,15 +282,8 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t *payload, //------------------------------------------------------------------------------ - case COMMAND_BRIGHTNESS: { // Helligkeit - G.hell = split(payload, 27); - break; - } - - //------------------------------------------------------------------------------ - case COMMAND_SPEED: { // Geschwindigkeit - G.geschw = split(payload, 30); + G.geschw = split(payload, 3); break; } @@ -394,18 +380,18 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t *payload, case COMMAND_SET_MQTT: { // MQTT Daten speichern G.conf = COMMAND_SET_MQTT; - G.MQTT_State = split(payload, 3); - G.MQTT_Port = split(payload, 6, 5); + G.mqtt.state = split(payload, 3); + G.mqtt.port = split(payload, 6, 5); uint8_t index_start = 11; - payloadTextHandling(payload, G.MQTT_Server, index_start); + payloadTextHandling(payload, G.mqtt.serverAdress, index_start); index_start += PAYLOAD_LENGTH; - payloadTextHandling(payload, G.MQTT_User, index_start); + payloadTextHandling(payload, G.mqtt.user, index_start); index_start += PAYLOAD_LENGTH; - payloadTextHandling(payload, G.MQTT_Pass, index_start); + payloadTextHandling(payload, G.mqtt.password, index_start); index_start += PAYLOAD_LENGTH; - payloadTextHandling(payload, G.MQTT_ClientId, index_start); + payloadTextHandling(payload, G.mqtt.clientId, index_start); index_start += PAYLOAD_LENGTH; - payloadTextHandling(payload, G.MQTT_Topic, index_start); + payloadTextHandling(payload, G.mqtt.topic, index_start); break; } @@ -451,25 +437,25 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t *payload, ii = 0; for (uint8_t k = 3; k < 10; k++) { if (payload[k] != ' ') { - G.cityid[ii] = payload[k]; + G.openWeatherMap.cityid[ii] = payload[k]; ii++; } } - G.cityid[ii] = '\0'; + G.openWeatherMap.cityid[ii] = '\0'; // jj = 0; for (uint8_t l = 11; l < 43; l++) { if (payload[l] != ' ') { - G.apikey[jj] = payload[l]; + G.openWeatherMap.apikey[jj] = payload[l]; jj++; } } - G.apikey[jj] = '\0'; + G.openWeatherMap.apikey[jj] = '\0'; Serial.println("write EEPROM!"); Serial.print("CityID : "); - Serial.println(G.cityid); + Serial.println(G.openWeatherMap.cityid); Serial.print("APIkey : "); - Serial.println(G.apikey); + Serial.println(G.openWeatherMap.apikey); break; } @@ -485,6 +471,7 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t *payload, G.h20 = split(payload, 18); G.h22 = split(payload, 21); G.h24 = split(payload, 24); + G.hell = split(payload, 27); break; } diff --git a/include/clockWork.h b/include/clockWork.h new file mode 100644 index 00000000..c842d453 --- /dev/null +++ b/include/clockWork.h @@ -0,0 +1,40 @@ +#pragma once + +#include + +class ClockWork { +private: + void loopSecondsFrame(); + void loopWeather(); + void loopLdrLogic(); + + void rainbow(); + void rainbowCycle(); + void scrollingText(const char *buf); + + bool changesInClockface(); + void copyClockface(const uint16_t source[], uint16_t destination[]); + void calcClockface(); + + void setClock(); + void setHour(const uint8_t std, const uint8_t voll); + void setMinute(uint8_t min, uint8_t &offsetH, uint8_t &voll); + void showMinute(uint8_t min); + void showWeather(); + +public: + ClockWork() = default; + ~ClockWork() = default; + + iUhrType *getPointer(uint8_t type); + + void loop(struct tm &tm); + + void initBootLed(); + void initBootLedBlink(); + void initBootLedSweep(uint32_t delay); + void initBootShowIp(const char *buf); + void initBootWifiSignalStrength(int strength); + + void initLedStrip(uint8_t num); +}; diff --git a/include/uhr_func.hpp b/include/clockWork.hpp similarity index 62% rename from include/uhr_func.hpp rename to include/clockWork.hpp index 1bf5ef1c..0d2a3450 100644 --- a/include/uhr_func.hpp +++ b/include/clockWork.hpp @@ -1,173 +1,14 @@ +#include "Animation.h" +#include "NeoMultiFeature.hpp" #include "Uhr.h" +#include "Uhrtypes/Uhrtype.hpp" +#include "clockWork.h" +#include "openwmap.h" #include -void led_set_pixel(uint8_t rr, uint8_t gg, uint8_t bb, uint8_t ww, uint16_t i) { - - if (G.Colortype == Grbw) { - strip_RGBW->SetPixelColor(i, RgbwColor(rr, gg, bb, ww)); - } else { - strip_RGB->SetPixelColor(i, RgbColor(rr, gg, bb)); - } -} - -//------------------------------------------------------------------------------ - -void led_set_pixel_Color_Object(uint16_t i, RgbColor color) { - - if (G.Colortype == Grbw) { - strip_RGBW->SetPixelColor(i, RgbwColor(color)); - } else { - strip_RGB->SetPixelColor(i, color); - } -} - -//------------------------------------------------------------------------------ - -void led_set_pixel_Color_Object_rgbw(uint16_t i, RgbwColor color) { - strip_RGBW->SetPixelColor(i, RgbwColor(color)); -} - -//------------------------------------------------------------------------------ - -RgbColor led_get_pixel(uint16_t i) { - if (G.Colortype == Grbw) { - RgbwColor rgbw = strip_RGBW->GetPixelColor(i); - return RgbColor(rgbw.R, rgbw.G, rgbw.B); - } - return strip_RGB->GetPixelColor(i); -} - //------------------------------------------------------------------------------ -RgbwColor led_get_pixel_rgbw(uint16_t i) { - return strip_RGBW->GetPixelColor(i); -} - -//------------------------------------------------------------------------------ -// Helligkeitsregelung nach Uhrzeiten oder per LDR -//------------------------------------------------------------------------------ -static uint8_t autoLdr(uint8_t val) { - if (G.autoLdrEnabled) { - // G.hh enthaelt zeitabhaengige Helligkeitswerte in % - uint16_t u16 = (val * G.hh) / 100; - return ((uint8_t)((u16 * ldrVal) / 100)); - } - return val; -} - -//------------------------------------------------------------------------------ - -static void set_helligkeit_ldr(uint8_t &rr, uint8_t &gg, uint8_t &bb, - uint8_t &ww, uint8_t position) { - if (G.autoLdrEnabled) { - rr = autoLdr(G.rgb[position][0]); - gg = autoLdr(G.rgb[position][1]); - bb = autoLdr(G.rgb[position][2]); - ww = autoLdr(G.rgb[position][3]); - } else { - if (G.ldr == 1) { - rr = G.rgb[position][0] * ldrVal / 100; - gg = G.rgb[position][1] * ldrVal / 100; - bb = G.rgb[position][2] * ldrVal / 100; - ww = G.rgb[position][3] * ldrVal / 100; - } else { - rr = G.rgb[position][0] * G.hh / 100; - gg = G.rgb[position][1] * G.hh / 100; - bb = G.rgb[position][2] * G.hh / 100; - ww = G.rgb[position][3] * G.hh / 100; - } - } -} - -//------------------------------------------------------------------------------ - -void set_helligkeit(uint8_t &rr, uint8_t &gg, uint8_t &bb, uint8_t &ww, - uint8_t position, uint8_t percentage = 100) { - rr = G.rgb[position][0] * percentage / 100; - gg = G.rgb[position][1] * percentage / 100; - bb = G.rgb[position][2] * percentage / 100; - ww = G.rgb[position][3] * percentage / 100; - uint16_t zz = rr + gg + bb; - if (zz > 150) { - zz = zz * 10 / 150; - rr = rr * 10 / zz; - gg = gg * 10 / zz; - bb = bb * 10 / zz; - ww = ww * 10 / zz; - } -} - -//------------------------------------------------------------------------------ - -void led_show() { - if (G.Colortype == Grbw) { - strip_RGBW->Show(); - } else { - strip_RGB->Show(); - } -} - -//------------------------------------------------------------------------------ - -static inline void led_clear_pixel(uint16_t i) { - if (G.Colortype == Grbw) { - strip_RGBW->SetPixelColor(i, 0); - } else { - strip_RGB->SetPixelColor(i, 0); - } -} - -//------------------------------------------------------------------------------ - -void led_clear() { - for (uint16_t i = 0; i < usedUhrType->NUM_PIXELS(); i++) { - Word_array[i] = 500; - } - for (uint16_t i = 0; i < usedUhrType->NUM_PIXELS(); i++) { - led_clear_pixel(i); - } -} - -//------------------------------------------------------------------------------ - -static inline void uhr_clear() { - for (uint16_t i = 0; i < usedUhrType->NUM_SMATRIX(); i++) { - led_clear_pixel(usedUhrType->getSMatrix(i)); - } -} - -//------------------------------------------------------------------------------ - -static inline void rahmen_clear() { - for (uint16_t i = 0; i < usedUhrType->NUM_RMATRIX(); i++) { - led_clear_pixel(usedUhrType->getRMatrix(i)); - } -} - -//------------------------------------------------------------------------------ - -static void led_set(bool changed = false) { - uint8_t rr, gg, bb, ww; - uint8_t r2, g2, b2, w2; - set_helligkeit_ldr(rr, gg, bb, ww, Foreground); - set_helligkeit_ldr(r2, g2, b2, w2, Background); - for (uint16_t i = 0; i < usedUhrType->NUM_PIXELS(); i++) { - if (Word_array_old[i] < usedUhrType->NUM_PIXELS()) { - // foreground - led_set_pixel(rr, gg, bb, ww, i); - } else { - // background - led_set_pixel(r2, g2, b2, w2, i); - } - } - if (animation->led_show_notify(changed, _minute)) { - led_show(); - } -} - -//------------------------------------------------------------------------------ - -void copy_array(const uint16_t source[], uint16_t destination[]) { +void ClockWork::copyClockface(const uint16_t source[], uint16_t destination[]) { for (uint16_t i = 0; i < usedUhrType->NUM_PIXELS(); i++) { destination[i] = source[i]; } @@ -175,162 +16,18 @@ void copy_array(const uint16_t source[], uint16_t destination[]) { //------------------------------------------------------------------------------ -bool changes_in_array() { - bool return_value = false; +bool ClockWork::changesInClockface() { for (uint16_t i = 0; i < usedUhrType->NUM_PIXELS(); i++) { if (Word_array[i] != Word_array_old[i]) { - return_value = true; - } - } - return return_value; -} - -//------------------------------------------------------------------------------ - -void led_set_Icon(uint8_t num_icon, uint8_t brightness = 100, - bool rgb_icon = false) { - uint8_t rr, gg, bb, ww; - set_helligkeit(rr, gg, bb, ww, Foreground, brightness); - for (uint8_t col = 0; col < GRAFIK_11X10_COLS; col++) { - if (rgb_icon) { - rr = col < 3 ? 255 : 0; - gg = (col > 3) && (col < 7) ? 255 : 0; - bb = col > 7 ? 255 : 0; - ww = 0; + return true; } - for (uint8_t row = 0; row < GRAFIK_11X10_ROWS; row++) { - if (pgm_read_word(&(grafik_11x10[num_icon][row])) & - (1 << (GRAFIK_11X10_COLS - 1 - col))) { - led_set_pixel(rr, gg, bb, ww, - usedUhrType->getFrontMatrix(row, col)); - } else { - led_clear_pixel(usedUhrType->getFrontMatrix(row, col)); - } - } - } - led_show(); -} - -//------------------------------------------------------------------------------ -// HSV to RGB 8Bit -// Farbkreis hue = 0 bis 360 (Farbwert) -// bri = 0 bis 255 (Dunkelstufe) -// sat = 0 bis 255 (Farbsättigung) -//------------------------------------------------------------------------------ - -void hsv_to_rgb(double hue, float sat, float bri, uint8_t *c) { - hue = 3.14159F * hue / 180.0F; // convert to radians. - sat /= 255.0F; // from percentage to ratio - bri /= 255.0F; // from percentage to ratio - sat = sat > 0 ? (sat < 1 ? sat : 1) : 0; // clamp s and i to interval [0,1] - bri = bri > 0 ? (bri < 1 ? bri : 1) : 0; // clamp s and i to interval [0,1] - bri = bri * - std::sqrt(bri); // shape intensity to have finer granularity near 0 - - if (G.Colortype == Grbw) { - if (hue < 2.09439) { - c[0] = sat * 255.0 * bri / 3.0 * - (1 + std::cos(hue) / std::cos(1.047196667 - hue)); - c[1] = sat * 255.0 * bri / 3.0 * - (1 + (1 - std::cos(hue) / std::cos(1.047196667 - hue))); - c[2] = 0; - c[3] = 255.0 * (1.0 - sat) * bri; - } else if (hue < 4.188787) { - hue = hue - 2.09439; - c[1] = sat * 255.0 * bri / 3.0 * - (1 + std::cos(hue) / std::cos(1.047196667 - hue)); - c[2] = sat * 255.0 * bri / 3.0 * - (1 + (1 - std::cos(hue) / std::cos(1.047196667 - hue))); - c[0] = 0; - c[3] = 255.0 * (1.0 - sat) * bri; - } else { - hue = hue - 4.188787; - c[2] = sat * 255.0 * bri / 3.0 * - (1 + std::cos(hue) / std::cos(1.047196667 - hue)); - c[0] = sat * 255.0 * bri / 3.0 * - (1 + (1 - std::cos(hue) / std::cos(1.047196667 - hue))); - c[1] = 0; - c[3] = 255.0 * (1 - sat) * bri; - } - } else { - while (hue < 0) { - hue += 360.0F; - } // cycle h around to 0-360 degrees - while (hue >= 360) { - hue -= 360.0F; - } - - if (hue < 2.09439) { - c[0] = 255 * bri / 3 * - (1 + sat * std::cos(hue) / std::cos(1.047196667 - hue)); - c[1] = - 255 * bri / 3 * - (1 + sat * (1 - std::cos(hue) / std::cos(1.047196667 - hue))); - c[2] = 255 * bri / 3 * (1 - sat); - } else if (hue < 4.188787) { - hue = hue - 2.09439; - c[1] = 255 * bri / 3 * - (1 + sat * std::cos(hue) / std::cos(1.047196667 - hue)); - c[2] = - 255 * bri / 3 * - (1 + sat * (1 - std::cos(hue) / std::cos(1.047196667 - hue))); - c[0] = 255 * bri / 3 * (1 - sat); - } else { - hue = hue - 4.188787; - c[2] = - 255 * bri / 3 * (1 + sat * cos(hue) / cos(1.047196667 - hue)); - c[0] = 255 * bri / 3 * - (1 + sat * (1 - cos(hue) / cos(1.047196667 - hue))); - c[1] = 255 * bri / 3 * (1 - sat); - } - c[3] = 0; - } -} - -//------------------------------------------------------------------------------ - -static void led_single(uint8_t wait) { - - float h; - uint8_t c[4]; - - for (uint16_t i = 0; i < usedUhrType->NUM_PIXELS(); i++) { - - h = 360.0 * i / (usedUhrType->NUM_PIXELS() - 1); - h = h + 360.0 / usedUhrType->NUM_PIXELS(); - if (h > 360) { - h = 0; - } - - led_clear(); - hsv_to_rgb(h, 255, 255, c); - led_set_pixel(c[0], c[1], c[2], c[3], i); - led_show(); - delay(wait); - } -} - -//------------------------------------------------------------------------------ - -static void led_set_all(uint8_t rr, uint8_t gg, uint8_t bb, uint8_t ww) { - for (uint16_t i = 0; i < usedUhrType->NUM_PIXELS(); i++) { - led_set_pixel(rr, gg, bb, ww, i); } + return false; } //------------------------------------------------------------------------------ -static void set_farbe() { - uint8_t rr, gg, bb, ww; - set_helligkeit(rr, gg, bb, ww, Effect); - led_set_all(rr, gg, bb, ww); -} - -//------------------------------------------------------------------------------ -// Routine Helligkeitsregelung -//------------------------------------------------------------------------------ - -static void doLDRLogic() { +void ClockWork::loopLdrLogic() { int16_t lux = analogRead(A0); // Range 0-1023 uint8_t ldrValOld = ldrVal; @@ -343,7 +40,7 @@ static void doLDRLogic() { if (lux <= minimum) lux = minimum; if (G.autoLdrDark == G.autoLdrBright) { - // map() wuerde mit division durch 0 crashen + // map() //Would crash with division by zero ldrVal = 100; } else { ldrVal = map(lux, G.autoLdrDark, G.autoLdrBright, 10, 100); @@ -353,127 +50,81 @@ static void doLDRLogic() { lux = lux - (G.ldrCal * 20); if (lux >= 900) { lux = 900; - } // Maximale Helligkeit + } // Max Brightness if (lux <= 1) { lux = 1; - } // Minimale Helligkeit + } // Min Brightness ldrVal = map(lux, 1, 900, 1, 100); } } if (ldrValOld != ldrVal) { - // lass den LDR sofort wirken - led_set(); + led.set(); } } //------------------------------------------------------------------------------ -static void set_farbe_rahmen() { - uint8_t rr, gg, bb, ww; - set_helligkeit(rr, gg, bb, ww, Frame); - - for (uint16_t i = 0; i < usedUhrType->NUM_RMATRIX(); i++) { - led_set_pixel(rr, gg, bb, ww, usedUhrType->getRMatrix(i)); - } -} - -//------------------------------------------------------------------------------ - -static void rainbow() { - - static float h = 0.0; - uint8_t c[4]; - hsv_to_rgb(h, 255, G.hell * 10, c); +void ClockWork::rainbow() { + static float hue = 0; for (uint16_t i = 0; i < usedUhrType->NUM_PIXELS(); i++) { - led_set_pixel(c[0], c[1], c[2], c[3], i); - } - led_show(); - h++; - if (h > 359) { - h = 0.0; + led.setPixelHsb(i, hue, 100, G.hell); } + led.show(); + hue++; + led.checkIfHueIsOutOfBound(hue); } //----------------------------------------------------------------------------- -static void rainbowCycle() { - static float h = 0; - float hh; - uint8_t c[4]; +void ClockWork::rainbowCycle() { + static float hue = 0; + float displayedHue; - hh = h; + displayedHue = hue; for (uint16_t i = 0; i < usedUhrType->NUM_SMATRIX(); i++) { - hsv_to_rgb(hh, 255, G.hell * 10, c); - led_set_pixel(c[0], c[1], c[2], c[3], usedUhrType->getSMatrix(i)); - hh = hh + 360.0 / usedUhrType->NUM_SMATRIX(); - if (hh > 360) { - hh = 0; - } - } - led_show(); - h++; - if (h > 360) { - h = 0.0; + led.setPixelHsb(usedUhrType->getSMatrix(i), displayedHue, 100, G.hell); + displayedHue = displayedHue + 360.0 / usedUhrType->NUM_SMATRIX(); + led.checkIfHueIsOutOfBound(displayedHue); } + led.show(); + hue++; + led.checkIfHueIsOutOfBound(hue); } //------------------------------------------------------------------------------ -void shift_all_pixels_to_right() { - for (uint8_t col = 0; col < usedUhrType->COLS_MATRIX() - 1; col++) { - for (uint8_t row = 0; - row < usedUhrType->ROWS_MATRIX() - 1 /* Only Front*/; row++) { - if (G.Colortype == Grbw) { - led_set_pixel_Color_Object_rgbw( - usedUhrType->getFrontMatrix(row, col), - led_get_pixel_rgbw( - usedUhrType->getFrontMatrix(row, col + 1))); - } else { - led_set_pixel_Color_Object( - usedUhrType->getFrontMatrix(row, col), - led_get_pixel(usedUhrType->getFrontMatrix(row, col + 1))); - } - } - } -} - -//------------------------------------------------------------------------------ - -static void laufschrift(const char *buf) { +void ClockWork::scrollingText(const char *buf) { static uint8_t i = 0, ii = 0; - static uint8_t offsetRow = 1; + uint8_t offsetRow = (usedUhrType->ROWS_MATRIX() - fontHeight - 1) / 2; uint8_t fontIndex = buf[ii]; - shift_all_pixels_to_right(); + led.shiftColumnToRight(); + led.clearFrontExeptofFontspace(offsetRow); - if (usedUhrType->has24HourLayout()) { - offsetRow = 4; - } - - if (i < 5) { - for (uint8_t row = 0; row < 8; row++) { + if (i < fontWidth) { + for (uint8_t row = 0; row < fontHeight; row++) { if (pgm_read_byte(&(font_7x5[fontIndex][i])) & (1u << row)) { - led_set_pixel( + led.setPixel( G.rgb[Effect][0], G.rgb[Effect][1], G.rgb[Effect][2], G.rgb[Effect][3], usedUhrType->getFrontMatrix( row + offsetRow, usedUhrType->COLS_MATRIX() - 1)); } else { - led_clear_pixel(usedUhrType->getFrontMatrix( + led.clearPixel(usedUhrType->getFrontMatrix( row + offsetRow, usedUhrType->COLS_MATRIX() - 1)); } } } else { - for (uint8_t row = 0; row < 8; row++) { - led_clear_pixel(usedUhrType->getFrontMatrix( + for (uint8_t row = 0; row < fontHeight; row++) { + led.clearPixel(usedUhrType->getFrontMatrix( row + offsetRow, usedUhrType->COLS_MATRIX() - 1)); } } - led_show(); + led.show(); i++; - if (i > 5) { + if (i > fontWidth) { i = 0; ii++; if (ii > strlen(buf)) { @@ -484,72 +135,31 @@ static void laufschrift(const char *buf) { //------------------------------------------------------------------------------ -static void zeigeip(const char *buf) { +void ClockWork::initBootShowIp(const char *buf) { uint8_t StringLength = strlen(buf); StringLength = StringLength * 6; // Times 6, because thats the length of a // char in the 7x5 font plus spacing for (uint16_t i = 0; i <= StringLength; i++) { - laufschrift(buf); + scrollingText(buf); delay(200); } } //------------------------------------------------------------------------------ -void set_pixel_for_char(uint8_t col, uint8_t row, uint8_t offsetCol, - uint8_t offsetRow, unsigned char unsigned_d1) { - if (pgm_read_byte(&(font_7x5[unsigned_d1][col])) & (1u << row)) { - led_set_pixel( - G.rgb[Effect][0], G.rgb[Effect][1], G.rgb[Effect][2], - G.rgb[Effect][3], - usedUhrType->getFrontMatrix(row + offsetRow, col + offsetCol)); - } -} - -//------------------------------------------------------------------------------ -// show signal-strenght by using different brightness for the individual rings -//------------------------------------------------------------------------------ - -void show_icon_wlan(int strength) { +void ClockWork::initBootWifiSignalStrength(int strength) { if (strength <= 100) { - led_set_Icon(WLAN100, 100); + led.setIcon(WLAN100, 100); } else if (strength <= 60) { - led_set_Icon(WLAN60, 60); + led.setIcon(WLAN60, 60); } else if (strength <= 30) { - led_set_Icon(WLAN30, 30); - } -} - -//------------------------------------------------------------------------------ - -static void zahlen(const char d1, const char d2) { - uhr_clear(); - static uint8_t offsetLetter0 = 0; - static uint8_t offsetLetter1 = 6; - static uint8_t offsetRow = 1; - - if (usedUhrType->has24HourLayout()) { - offsetLetter0 = 3; - offsetLetter1 = 9; - offsetRow = 4; - } - - for (uint8_t col = 0; col < 5; col++) { - for (uint8_t row = 0; row < 8; row++) { - // 1. Zahl ohne Offset - set_pixel_for_char(col, row, offsetLetter0, offsetRow, - static_cast(d1)); - // 2. Zahl mit Offset - set_pixel_for_char(col, row, offsetLetter1, offsetRow, - static_cast(d2)); - } + led.setIcon(WLAN30, 30); } - led_show(); } //------------------------------------------------------------------------------ -static void set_stunde(const uint8_t std, const uint8_t voll) { +void ClockWork::setHour(const uint8_t std, const uint8_t voll) { switch (std) { case 0: usedUhrType->show(h_zwoelf); @@ -641,10 +251,8 @@ static void set_stunde(const uint8_t std, const uint8_t voll) { //------------------------------------------------------------------------------ -void show_minuten(uint8_t min) { +void ClockWork::showMinute(uint8_t min) { if (G.zeige_min > 0) { - // Minuten / Sekunden-Animation - // Minute (1-4) ermitteln while (min > 4) { min -= 5; } @@ -670,14 +278,14 @@ void show_minuten(uint8_t min) { //------------------------------------------------------------------------------ -void set_minute(uint8_t min, uint8_t &offsetH, uint8_t &voll) { +void ClockWork::setMinute(uint8_t min, uint8_t &offsetH, uint8_t &voll) { if (!usedUhrType->has24HourLayout()) { - show_minuten(min); + showMinute(min); min /= 5; min *= 5; } switch (min) { - case 0: // volle Stunde + case 0: // full hour usedUhrType->show(uhr); voll = 1; break; @@ -703,7 +311,7 @@ void set_minute(uint8_t min, uint8_t &offsetH, uint8_t &voll) { usedUhrType->show(minuten); usedUhrType->show(nach); break; - case 15: // viertel nach + case 15: // quarter past if (G.Sprachvariation[ItIs15]) { usedUhrType->show(viertel); offsetH = 1; @@ -719,7 +327,7 @@ void set_minute(uint8_t min, uint8_t &offsetH, uint8_t &voll) { usedUhrType->show(min); usedUhrType->show(nach); break; - case 20: // 20 nach + case 20: // 20 past if (!usedUhrType->hasZwanzig() || G.Sprachvariation[ItIs20]) { usedUhrType->show(zehn); usedUhrType->show(vor); @@ -750,7 +358,7 @@ void set_minute(uint8_t min, uint8_t &offsetH, uint8_t &voll) { usedUhrType->show(halb); offsetH = 1; break; - case 30: // halb + case 30: // half usedUhrType->show(halb); offsetH = 1; break; @@ -774,7 +382,7 @@ void set_minute(uint8_t min, uint8_t &offsetH, uint8_t &voll) { usedUhrType->show(halb); offsetH = 1; break; - case 40: // 20 vor + case 40: // 20 to if (!usedUhrType->hasZwanzig() || G.Sprachvariation[ItIs40]) { usedUhrType->show(zehn); usedUhrType->show(nach); @@ -793,7 +401,7 @@ void set_minute(uint8_t min, uint8_t &offsetH, uint8_t &voll) { usedUhrType->show(vor); offsetH = 1; break; - case 45: // viertel vor + case 45: // quarter to if (usedUhrType->hasDreiviertel() && G.Sprachvariation[ItIs45]) { usedUhrType->show(dreiviertel); } else { @@ -877,7 +485,7 @@ static void countdownToMidnight() { //------------------------------------------------------------------------------ -static void set_uhrzeit() { +void ClockWork::setClock() { uhrzeit = 0; if (!G.Sprachvariation[NotShowItIs]) { @@ -887,23 +495,13 @@ static void set_uhrzeit() { uint8_t offsetH = 0; uint8_t voll = 0; - set_minute(_minute, offsetH, voll); - set_stunde(_stunde + offsetH, voll); + setMinute(_minute, offsetH, voll); + setHour(_stunde + offsetH, voll); } //------------------------------------------------------------------------------ -static void show_sekunde() { - uint8_t rr, gg, bb, ww; - set_helligkeit(rr, gg, bb, ww, Effect); - - led_set_pixel(rr, gg, bb, ww, usedUhrType->getRMatrix(_sekunde48)); -} - -//------------------------------------------------------------------------------ -// Wetterdaten anzeigen -//------------------------------------------------------------------------------ -static void show_wetter() { +void ClockWork::showWeather() { switch (wetterswitch) { // +6h @@ -1400,16 +998,16 @@ static void show_wetter() { //------------------------------------------------------------------------------ -static void calc_word_array() { +void ClockWork::calcClockface() { uint8_t rr, gg, bb, ww; if (_stunde == 23 && _minute == 59 && _sekunde >= 50) { countdownToMidnight(); } else { - set_uhrzeit(); + setClock(); } - // Helligkeitswert ermitteln + // Set Brighness hour dependent if (_stunde < 6) { G.hh = G.h24; } else if (_stunde < 8) { @@ -1428,14 +1026,517 @@ static void calc_word_array() { G.hh = G.h22; } - set_helligkeit_ldr(rr, gg, bb, ww, Background); + led.setBrightnessLdr(rr, gg, bb, ww, Background); - // Hintergrund setzen + // set Background color for (uint16_t i = 0; i < usedUhrType->NUM_PIXELS(); i++) { - led_set_pixel(rr, gg, bb, ww, i); + led.setPixel(rr, gg, bb, ww, i); } if (usedUhrType->hasWeatherLayout()) { - show_wetter(); + showWeather(); + } +} + +//------------------------------------------------------------------------------ + +iUhrType *ClockWork::getPointer(uint8_t type) { + switch (type) { + case Uhr_114: + return &Uhr_114_type; + case Uhr_114_Alternative: + return &Uhr_114_Alternative_type; + case Uhr_114_2Clock: + return &Uhr_114_2Clock_type; + case Uhr_114_Dutch: + return &Uhr_114_dutch_type; + case Uhr_125: + return &Uhr_125_type; + case Uhr_125_Type2: + return &Uhr_125_type2_type; + case Uhr_169: + return &Uhr_169_type; + case Uhr_242: + return &Uhr_242_type; + case Uhr_291: + return &Uhr_291_type; + default: + return nullptr; + } +} + +//------------------------------------------------------------------------------ + +void ClockWork::initLedStrip(uint8_t num) { + NeoMultiFeature::setColortype(num); + if (num == Grbw) { + if (strip_RGB != NULL) { + delete strip_RGB; // delete the previous dynamically created strip + strip_RGB = NULL; + } + if (strip_RGBW == NULL) { + strip_RGBW = new NeoPixelBus( + usedUhrType->NUM_PIXELS()); + strip_RGBW->Begin(); + } + } else { + if (strip_RGBW != NULL) { + delete strip_RGBW; // delete the previous dynamically created strip + strip_RGBW = NULL; + } + if (strip_RGB == NULL) { + strip_RGB = new NeoPixelBus( + usedUhrType->NUM_PIXELS()); + strip_RGB->Begin(); + } } } + +//------------------------------------------------------------------------------ + +void ClockWork::loop(struct tm &tm) { + unsigned long currentMillis = millis(); + count_delay += currentMillis - previousMillis; + if (usedUhrType->hasSecondsFrame()) { + count_millis48 += currentMillis - previousMillis; + } + previousMillis = currentMillis; + + // Faster runtime for demo + animation->demoMode(_minute, _sekunde); + + //------------------------------------------------ + // SecondsFrame + //------------------------------------------------ + if (usedUhrType->hasSecondsFrame()) { + loopSecondsFrame(); + } + + //------------------------------------------------ + // Secounds and LDR Routine + //------------------------------------------------ + if (last_sekunde != _sekunde) { + + if (DEBUG == true) { + char currentTime[80]; + strftime(currentTime, sizeof(currentTime), "%F %T (%z)\n", &tm); + Serial.printf(currentTime); + } + + // Weather Clock + if (usedUhrType->hasWeatherLayout()) { + weather_tag++; + } + + // LDR Routine + if ((G.ldr == 1) || G.autoLdrEnabled) { + loopLdrLogic(); + } + + if (G.prog == 0 && G.conf == 0) { + led.clear(); + G.prog = COMMAND_MODE_WORD_CLOCK; + } + + last_sekunde = _sekunde; + + if (usedUhrType->hasWeatherLayout()) { + loopWeather(); + } + } + + //------------------------------------------------ + // Minute + //------------------------------------------------ + if (last_minute != _minute) { + _sekunde48 = 0; + last_minute = _minute; + } + + //------------------------------------------------ + // Pull Waether Data + //------------------------------------------------ + if (usedUhrType->hasWeatherLayout() && + weather_tag >= 600) { // @Eisbaeeer changed for Debug (should be 600) + weather_tag = 0; + if (WiFi.status() == WL_CONNECTED) { + getweather(); + } + } + + switch (G.conf) { + + case COMMAND_RESET: { + delay(500); + ESP.reset(); + ESP.restart(); + while (true) { + } + break; + } + + case COMMAND_REQUEST_MQTT_VALUES: { + DynamicJsonDocument config(1024); + config["command"] = "mqtt"; + config["MQTT_State"] = G.mqtt.state; + config["MQTT_Port"] = G.mqtt.port; + config["MQTT_Server"] = G.mqtt.serverAdress; + config["MQTT_User"] = G.mqtt.user; + config["MQTT_Pass"] = G.mqtt.password; + config["MQTT_ClientId"] = G.mqtt.clientId; + config["MQTT_Topic"] = G.mqtt.topic; + serializeJson(config, str); + Serial.print("Sending Payload:"); + Serial.println(str); + webSocket.sendTXT(G.client_nr, str, strlen(str)); + G.conf = COMMAND_IDLE; + break; + } + + case COMMAND_REQUEST_CONFIG_VALUES: { + DynamicJsonDocument config(1024); + config["command"] = "config"; + config["ssid"] = network.getSSID(); + config["zeitserver"] = G.zeitserver; + config["hostname"] = G.hostname; + config["ltext"] = G.ltext; + config["h6"] = G.h6; + config["h8"] = G.h8; + config["h12"] = G.h12; + config["h16"] = G.h16; + config["h18"] = G.h18; + config["h20"] = G.h20; + config["h22"] = G.h22; + config["h24"] = G.h24; + for (uint8_t i = 0; i < 5; i++) { + sprintf(s, "spv%d", i); + config[s] = static_cast(G.Sprachvariation[i]); + } + config["hell"] = G.hell; + config["zeige_sek"] = G.zeige_sek; + config["zeige_min"] = G.zeige_min; + config["ldr"] = G.ldr; + config["ldrCal"] = G.ldrCal; + config["cityid"] = G.openWeatherMap.cityid; + config["apikey"] = G.openWeatherMap.apikey; + config["colortype"] = G.Colortype; + config["UhrtypeDef"] = G.UhrtypeDef; + config["bootLedBlink"] = G.bootLedBlink; + config["bootLedSweep"] = G.bootLedSweep; + config["bootShowWifi"] = G.bootShowWifi; + config["bootShowIP"] = G.bootShowIP; + config["autoLdrEnabled"] = G.autoLdrEnabled; + config["hasDreiviertel"] = usedUhrType->hasDreiviertel(); + config["hasZwanzig"] = usedUhrType->hasZwanzig(); + config["hasWeatherLayout"] = usedUhrType->hasWeatherLayout(); + config["hasSecondsFrame"] = usedUhrType->hasSecondsFrame(); + serializeJson(config, str); + Serial.print("Sending Payload:"); + Serial.println(str); + webSocket.sendTXT(G.client_nr, str, strlen(str)); + G.conf = COMMAND_IDLE; + break; + } + + case COMMAND_REQUEST_COLOR_VALUES: { + DynamicJsonDocument config(1024); + config["command"] = "set"; + for (uint8_t i = 0; i < 4; i++) { + for (uint8_t ii = 0; ii < 4; ii++) { + sprintf(s, "rgb%d%d", i, ii); + config[s] = G.rgb[i][ii]; + } + } + config["hell"] = G.hell; + config["geschw"] = G.geschw; + config["colortype"] = G.Colortype; + config["prog"] = G.prog; + serializeJson(config, str); + webSocket.sendTXT(G.client_nr, str, strlen(str)); + G.conf = COMMAND_IDLE; + break; + } + + case COMMAND_REQUEST_AUTO_LDR: { + DynamicJsonDocument config(1024); + config["command"] = "autoLdr"; + if (G.param1 == 0) { + config["autoLdrEnabled"] = G.autoLdrEnabled; + config["autoLdrBright"] = G.autoLdrBright; + config["autoLdrDark"] = G.autoLdrDark; + } + config["autoLdrValue"] = map(analogRead(A0), 0, 1023, 0, 255); + serializeJson(config, str); + webSocket.sendTXT(G.client_nr, str, strlen(str)); + G.conf = COMMAND_IDLE; + break; + } + + case COMMAND_REQUEST_ANIMATION: { + DynamicJsonDocument config(1024); + config["command"] = "animation"; + config["animType"] = G.animType; + config["animDuration"] = G.animDuration; + config["animSpeed"] = G.animSpeed; + config["animDemo"] = G.animDemo; + config["animColorize"] = G.animColorize; + JsonArray types = config.createNestedArray("animTypes"); + // Sequence must match to 'enum Anim' + types.add("keine"); + types.add("Hoch rollen"); + types.add("Runter rollen"); + types.add("Links schieben"); + types.add("Rechts schieben"); + types.add("Überblenden"); + types.add("Laser"); + types.add("Matrix"); + types.add("Baelle"); + types.add("Feuerwerk"); + types.add("Schlange"); + types.add("zufällig"); + serializeJson(config, str); + webSocket.sendTXT(G.client_nr, str, strlen(str)); + G.conf = COMMAND_IDLE; + break; + } + + case COMMAND_SET_TIME: + case COMMAND_SET_INITIAL_VALUES: + case COMMAND_SET_WEATHER_DATA: + case COMMAND_SET_MARQUEE_TEXT: + case COMMAND_SET_BOOT: { + eeprom_write(); + delay(100); + G.conf = COMMAND_IDLE; + break; + } + + case COMMAND_SET_MINUTE: + case COMMAND_SET_BRIGHTNESS: + case COMMAND_SET_LDR: + case COMMAND_SET_AUTO_LDR: + case COMMAND_SET_LANGUAGE_VARIANT: + case COMMAND_SET_SETTING_SECOND: + case COMMAND_SET_TIME_MANUAL: { + eeprom_write(); + led.clear(); + parameters_changed = true; + G.conf = COMMAND_IDLE; + break; + } + + case COMMAND_SET_MQTT: { + if (G.mqtt.state && !mqtt.getConnected()) { + mqtt.reInit(); + } + + eeprom_write(); + G.conf = COMMAND_IDLE; + break; + } + + case COMMAND_SET_COLORTYPE: { + // G.param1 sets new Colortype + Serial.printf("LED Colortype: %u\n", G.param1); + + // if ((G.param1 != G.Colortype) && ((G.param1 == Grbw) || + // (G.Colortype == Grbw))) { + // G.conf = COMMAND_RESET; + // } else { + G.conf = COMMAND_IDLE; + // } + + // the G.Colortype must be called at the same time as initLedStrip, + // otherwise it is referenced via a null-pointer. + G.Colortype = G.param1; + eeprom_write(); + initLedStrip(G.Colortype); + led.setIcon(RGB_I, 100, true); + break; + } + + case COMMAND_SET_UHRTYPE: { + eeprom_write(); + Serial.printf("Uhrtype: %u\n", G.UhrtypeDef); + usedUhrType = getPointer(G.UhrtypeDef); + G.conf = COMMAND_IDLE; + break; + } + + case COMMAND_SET_HOSTNAME: { + Serial.print("Hostname: "); + Serial.println(G.hostname); + eeprom_write(); + network.reboot(); + G.conf = COMMAND_IDLE; + break; + } + + case COMMAND_SET_WIFI_DISABLED: { + eeprom_write(); + delay(100); + Serial.println("Conf: WLAN off"); + network.disable(); + G.conf = COMMAND_IDLE; + break; + } + + case COMMAND_SET_WIFI_AND_RESTART: { + Serial.println("Conf: new Wifi Config"); + network.resetSettings(); + G.conf = COMMAND_IDLE; + break; + } + + default: + break; + } + + switch (G.prog) { + + case COMMAND_MODE_SECONDS: { + if (G.prog_init == 1) { + led.clear(); + G.prog_init = 0; + } + char d1[5]; + char d2[5]; + sprintf(d1, "%d", (int)(_sekunde / 10)); + sprintf(d2, "%d", (int)(_sekunde % 10)); + led.showNumbers(d1[0], d2[0]); + break; + } + + case COMMAND_MODE_SCROLLINGTEXT: + case COMMAND_MODE_RAINBOWCYCLE: + case COMMAND_MODE_RAINBOW: { + if (G.prog_init == 1) { + G.prog_init = 0; + led.clear(); + count_delay = (11u - G.geschw) * 30u; + } + if (count_delay >= (11u - G.geschw) * 30u) { + switch (G.prog) { + case COMMAND_MODE_SCROLLINGTEXT: { + scrollingText(G.ltext); + break; + } + case COMMAND_MODE_RAINBOWCYCLE: { + rainbowCycle(); + break; + } + case COMMAND_MODE_RAINBOW: { + rainbow(); + break; + } + default: + break; + } + count_delay = 0; + } + break; + } + + case COMMAND_MODE_COLOR: { + if (G.prog_init == 1) { + G.prog_init = 0; + led.setColor(); + led.show(); + } + break; + } + + case COMMAND_MODE_ANIMATION: { + if (G.prog_init == 1) { + G.prog_init = 0; + eeprom_write(); + delay(100); + } + // There is no break here on purpose, directly after the call + // COMMAND_MODE_ANIMATION, COMMAND_MODE_WORD_CLOCK must be called + } + + case COMMAND_MODE_WORD_CLOCK: { + calcClockface(); + + if (changesInClockface()) { + copyClockface(Word_array, Word_array_old); + led.set(true); + } else if (parameters_changed) { + led.set(); + } + parameters_changed = false; + + if (usedUhrType->hasSecondsFrame() && G.zeige_sek < 1 && + G.zeige_min < 2) { + led.setFrameColor(); + } + G.prog = COMMAND_IDLE; + } + default: + break; + } + + if (count_delay > 10000) { + count_delay = 0; + } +} + +//------------------------------------------------------------------------------ + +void ClockWork::loopSecondsFrame() { + if (count_millis48 >= interval48) { + count_millis48 = 0; + _sekunde48++; + if (_sekunde48 > 47) { + _sekunde48 = 0; + } + } + if (last_sekunde48 != _sekunde48) { + if (G.prog == 0 && G.conf == 0) { + if (G.zeige_sek == 1 || G.zeige_min == 2) { + led.clearFrame(); + } + if (G.zeige_sek > 0) { + led.showSeconds(); + } + led.show(); + } + last_sekunde48 = _sekunde48; + } +} + +//------------------------------------------------------------------------------ + +void ClockWork::loopWeather() { + if ((_sekunde == 0) | (_sekunde == 10) | (_sekunde == 20) | + (_sekunde == 30) | (_sekunde == 40) | (_sekunde == 50)) { + wetterswitch++; + led.clear(); + if (wetterswitch > 4) { + wetterswitch = 1; + } + Serial.print("Wetterswitch: "); + Serial.println(wetterswitch); + Serial.print("WStunde: "); + Serial.println(wstunde); + } +} + +//------------------------------------------------------------------------------ + +void ClockWork::initBootLedBlink() { + led.setAllPixels(50, 50, 50, 50); + led.show(); +} + +//------------------------------------------------------------------------------ + +void ClockWork::initBootLedSweep(uint32_t delay) { led.setSingle(delay); } + +//------------------------------------------------------------------------------ + +void ClockWork::initBootLed() { + led.clear(); + led.show(); +} diff --git a/include/font.h b/include/font.h index 4e3bcca6..7d8b8d85 100644 --- a/include/font.h +++ b/include/font.h @@ -1,5 +1,265 @@ +#pragma once + #include -#pragma once +const PROGMEM uint8_t fontHeight = 7; +const PROGMEM uint8_t fontWidth = 5; -extern const PROGMEM byte font_7x5[256][5]; +const PROGMEM byte font_7x5[256][5] = { + {0x00, 0x00, 0x00, 0x00, 0x00}, // 0 + {0x00, 0x00, 0x00, 0x00, 0x00}, // 1 + {0x00, 0x00, 0x00, 0x00, 0x00}, // 2 + {0x00, 0x00, 0x00, 0x00, 0x00}, // 3 + {0x00, 0x00, 0x00, 0x00, 0x00}, // 4 + {0x00, 0x00, 0x00, 0x00, 0x00}, // 5 + {0x00, 0x00, 0x00, 0x00, 0x00}, // 6 + {0x00, 0x00, 0x00, 0x00, 0x00}, // 7 + {0x00, 0x00, 0x00, 0x00, 0x00}, // 8 + {0x00, 0x00, 0x00, 0x00, 0x00}, // 9 + {0x00, 0x00, 0x00, 0x00, 0x00}, // 10 + {0x00, 0x00, 0x00, 0x00, 0x00}, // 11 + {0x00, 0x00, 0x00, 0x00, 0x00}, // 12 + {0x00, 0x00, 0x00, 0x00, 0x00}, // 13 + {0x00, 0x00, 0x00, 0x00, 0x00}, // 14 + {0x00, 0x00, 0x00, 0x00, 0x00}, // 15 + {0x00, 0x00, 0x00, 0x00, 0x00}, // 16 + {0x00, 0x00, 0x00, 0x00, 0x00}, // 17 + {0x00, 0x00, 0x00, 0x00, 0x00}, // 18 + {0x00, 0x00, 0x00, 0x00, 0x00}, // 19 + {0x00, 0x00, 0x00, 0x00, 0x00}, // 20 + {0x00, 0x00, 0x00, 0x00, 0x00}, // 21 + {0x00, 0x00, 0x00, 0x00, 0x00}, // 22 + {0x00, 0x00, 0x00, 0x00, 0x00}, // 23 + {0x00, 0x00, 0x00, 0x00, 0x00}, // 24 + {0x00, 0x00, 0x00, 0x00, 0x00}, // 25 + {0x00, 0x00, 0x00, 0x00, 0x00}, // 26 + {0x00, 0x00, 0x00, 0x00, 0x00}, // 27 + {0x00, 0x00, 0x00, 0x00, 0x00}, // 28 + {0x00, 0x00, 0x00, 0x00, 0x00}, // 29 + {0x00, 0x00, 0x00, 0x00, 0x00}, // 30 + {0x00, 0x00, 0x00, 0x00, 0x00}, // 31 + {0x00, 0x00, 0x00, 0x00, 0x00}, // 32 + {0x00, 0x00, 0x5F, 0x00, 0x00}, // 33 ! + {0x00, 0x07, 0x00, 0x07, 0x00}, // 34 " + {0x14, 0x7F, 0x14, 0x7F, 0x14}, // 35 # + {0x24, 0x2A, 0x6B, 0x2A, 0x12}, // 36 $ + {0x23, 0x13, 0x08, 0x64, 0x62}, // 37 % + {0x36, 0x49, 0x59, 0x26, 0x50}, // 38 & + {0x00, 0x00, 0x04, 0x03, 0x00}, // 39 ' + {0x00, 0x1C, 0x22, 0x41, 0x00}, // 40 ( + {0x00, 0x41, 0x22, 0x1C, 0x00}, // 41 ) + {0x24, 0x18, 0x7E, 0x18, 0x24}, // 42 * + {0x08, 0x08, 0x3E, 0x08, 0x08}, // 43 + + {0x00, 0x00, 0x58, 0x38, 0x00}, // 44 , + {0x08, 0x08, 0x08, 0x08, 0x08}, // 45 - + {0x00, 0x00, 0x60, 0x60, 0x00}, // 46 . + {0x20, 0x10, 0x08, 0x04, 0x02}, // 47 / + {0x3E, 0x51, 0x49, 0x45, 0x3E}, // 48 0 + {0x00, 0x04, 0x42, 0x7F, 0x40}, // 49 1 + {0x42, 0x61, 0x51, 0x49, 0x46}, // 50 2 + {0x22, 0x41, 0x49, 0x49, 0x36}, // 51 3 + {0x18, 0x14, 0x52, 0x7F, 0x50}, // 52 4 + {0x27, 0x45, 0x45, 0x45, 0x39}, // 53 5 + {0x3C, 0x4A, 0x49, 0x49, 0x30}, // 54 6 + {0x61, 0x11, 0x09, 0x05, 0x03}, // 55 7 + {0x36, 0x49, 0x49, 0x49, 0x36}, // 56 8 + {0x06, 0x49, 0x49, 0x49, 0x3E}, // 57 9 + {0x00, 0x00, 0x36, 0x36, 0x00}, // 58 : + {0x00, 0x00, 0x56, 0x36, 0x00}, // 59 ; + {0x00, 0x08, 0x14, 0x22, 0x41}, // 60 < + {0x14, 0x14, 0x14, 0x14, 0x14}, // 61 = + {0x00, 0x41, 0x22, 0x14, 0x08}, // 62 > + {0x02, 0x01, 0x51, 0x09, 0x06}, // 63 ? + {0x3E, 0x41, 0x5D, 0x55, 0x1E}, // 64 @ + {0x7C, 0x12, 0x11, 0x12, 0x7C}, // 65 A + {0x7F, 0x49, 0x49, 0x49, 0x36}, // 66 B + {0x3E, 0x41, 0x41, 0x41, 0x22}, // 67 C + {0x7F, 0x41, 0x41, 0x22, 0x1C}, // 68 D + {0x7F, 0x49, 0x49, 0x49, 0x41}, // 69 E + {0x7F, 0x09, 0x09, 0x09, 0x01}, // 70 F + {0x3E, 0x41, 0x49, 0x49, 0x3A}, // 71 G + {0x7F, 0x08, 0x08, 0x08, 0x7F}, // 72 H + {0x00, 0x41, 0x7F, 0x41, 0x00}, // 73 I + {0x20, 0x40, 0x41, 0x3F, 0x01}, // 74 J + {0x7F, 0x08, 0x14, 0x22, 0x41}, // 75 K + {0x7F, 0x40, 0x40, 0x40, 0x40}, // 76 L + {0x7F, 0x02, 0x04, 0x02, 0x7F}, // 77 M + {0x7F, 0x02, 0x0C, 0x10, 0x7F}, // 78 N + {0x3E, 0x41, 0x41, 0x41, 0x3E}, // 79 O + {0x7F, 0x09, 0x09, 0x09, 0x06}, // 80 P + {0x3E, 0x41, 0x51, 0x21, 0x5E}, // 81 Q + {0x7F, 0x09, 0x19, 0x29, 0x46}, // 82 R + {0x26, 0x49, 0x49, 0x49, 0x32}, // 83 S + {0x01, 0x01, 0x7F, 0x01, 0x01}, // 84 T + {0x3F, 0x40, 0x40, 0x40, 0x3F}, // 85 U + {0x1F, 0x20, 0x40, 0x20, 0x1F}, // 86 V + {0x3F, 0x40, 0x30, 0x40, 0x3F}, // 87 W + {0x63, 0x14, 0x08, 0x14, 0x63}, // 88 X + {0x07, 0x08, 0x70, 0x08, 0x07}, // 89 Y + {0x61, 0x51, 0x49, 0x45, 0x43}, // 90 Z + {0x00, 0x7F, 0x41, 0x41, 0x00}, // 91 [ + {0x02, 0x04, 0x08, 0x10, 0x20}, // 92 BACKSLASH + {0x00, 0x41, 0x41, 0x7F, 0x00}, // 93 ] + {0x04, 0x02, 0x01, 0x02, 0x04}, // 94 ^ + {0x40, 0x40, 0x40, 0x40, 0x40}, // 95 _ + {0x00, 0x00, 0x03, 0x04, 0x00}, // 96 ` + {0x20, 0x54, 0x54, 0x54, 0x78}, // 97 a + {0x7F, 0x44, 0x44, 0x44, 0x38}, // 98 b + {0x38, 0x44, 0x44, 0x44, 0x44}, // 99 c + {0x38, 0x44, 0x44, 0x44, 0x7F}, // 100 d + {0x38, 0x54, 0x54, 0x54, 0x18}, // 101 e + {0x44, 0x7E, 0x45, 0x01, 0x02}, // 102 f + {0x08, 0x54, 0x54, 0x54, 0x3C}, // 103 g + {0x7F, 0x08, 0x04, 0x04, 0x78}, // 104 h + {0x00, 0x44, 0x7D, 0x40, 0x00}, // 105 i + {0x20, 0x40, 0x44, 0x3D, 0x00}, // 106 j + {0x7F, 0x10, 0x28, 0x44, 0x00}, // 107 k + {0x00, 0x41, 0x7F, 0x40, 0x00}, // 108 l + {0x7C, 0x04, 0x7C, 0x04, 0x78}, // 109 m + {0x7C, 0x08, 0x04, 0x04, 0x78}, // 110 n + {0x38, 0x44, 0x44, 0x44, 0x38}, // 111 o + {0x7C, 0x14, 0x14, 0x14, 0x08}, // 112 p + {0x08, 0x14, 0x14, 0x14, 0x7C}, // 113 q + {0x00, 0x7C, 0x08, 0x04, 0x04}, // 114 r + {0x48, 0x54, 0x54, 0x54, 0x24}, // 115 s + {0x04, 0x3F, 0x44, 0x40, 0x20}, // 116 t + {0x3C, 0x40, 0x40, 0x20, 0x7C}, // 117 u + {0x1C, 0x20, 0x40, 0x20, 0x1C}, // 118 v + {0x3C, 0x40, 0x30, 0x40, 0x3C}, // 119 w + {0x44, 0x28, 0x10, 0x28, 0x44}, // 120 x + {0x0C, 0x50, 0x50, 0x50, 0x3C}, // 121 y + {0x44, 0x64, 0x54, 0x4C, 0x44}, // 122 z + {0x08, 0x08, 0x36, 0x41, 0x41}, // 123 { + {0x00, 0x00, 0x77, 0x00, 0x00}, // 124 | + {0x41, 0x41, 0x36, 0x08, 0x08}, // 125 } + {0x08, 0x04, 0x04, 0x08, 0x08}, // 126 ~ + {0x00, 0x00, 0x00, 0x00, 0x00}, // 127 + {0x1E, 0xA1, 0xE1, 0x21, 0x12}, /* 128 € */ + {0x3C, 0x41, 0x40, 0x21, 0x7C}, /* 129  */ + {0x38, 0x54, 0x56, 0x55, 0x18}, /* 130 ‚ */ + {0x20, 0x56, 0x55, 0x56, 0x78}, /* 131 ƒ */ + {0x20, 0x55, 0x54, 0x55, 0x78}, /* 132 „ */ + {0x20, 0x54, 0x55, 0x56, 0x78}, /* 133 … */ + {0x20, 0x54, 0x57, 0x57, 0x78}, /* 134 † */ + {0x1C, 0xA2, 0xE2, 0x22, 0x14}, /* 135 ‡ */ + {0x38, 0x56, 0x55, 0x56, 0x18}, /* 136 ˆ */ + {0x38, 0x55, 0x54, 0x55, 0x18}, /* 137 ‰ */ + {0x38, 0x54, 0x55, 0x56, 0x18}, /* 138 Š */ + {0x00, 0x45, 0x7C, 0x41, 0x00}, /* 139 ‹ */ + {0x00, 0x46, 0x7D, 0x42, 0x00}, /* 140 Œ */ + {0x00, 0x44, 0x7D, 0x42, 0x00}, /* 141  */ + {0x79, 0x14, 0x12, 0x14, 0x79}, /* 142 Ž */ + {0x78, 0x14, 0x17, 0x17, 0x78}, /* 143  */ + {0x7C, 0x54, 0x55, 0x56, 0x44}, /* 144  */ + {0x00, 0x00, 0x00, 0x00, 0x00}, // 145 + {0x00, 0x00, 0x00, 0x00, 0x00}, // 146 + {0x30, 0x4A, 0x49, 0x4A, 0x30}, /* 147 “ */ + {0x38, 0x45, 0x44, 0x45, 0x38}, /* 148 ” */ + {0x38, 0x45, 0x46, 0x44, 0x38}, /* 149 • */ + {0x38, 0x42, 0x41, 0x22, 0x78}, /* 150 – */ + {0x3C, 0x41, 0x42, 0x20, 0x7C}, /* 151 — */ + {0x0C, 0x51, 0x50, 0x51, 0x3C}, /* 152 ˜ */ + {0x3D, 0x42, 0x42, 0x42, 0x3D}, /* 153 ™ */ + {0x3C, 0x41, 0x40, 0x21, 0x7C}, /* 154 š */ + {0x1C, 0x22, 0x63, 0x22, 0x22}, /* 155 › */ + {0x68, 0x7E, 0x49, 0x42, 0x20}, /* 156 œ */ + {0x00, 0x00, 0x00, 0x00, 0x00}, /* 157  */ + {0x00, 0x00, 0x00, 0x00, 0x00}, /* 158 ž */ + {0x20, 0x48, 0x3e, 0x09, 0x02}, /* 159 Ÿ */ + {0x20, 0x54, 0x56, 0x55, 0x78}, /* 160   */ + {0x00, 0x46, 0x7D, 0x40, 0x00}, /* 161  */ + {0x38, 0x44, 0x46, 0x45, 0x38}, /* 162 ¢ */ + {0x3C, 0x40, 0x42, 0x21, 0x7C}, /* 163 £ */ + {0x78, 0x12, 0x09, 0x0A, 0x71}, /* 164 ¤ */ + {0x7C, 0x0A, 0x11, 0x22, 0x7D}, /* 165 ¥ */ + {0x00, 0x06, 0x09, 0x0F, 0x08}, /* 166 ¦ */ + {0x00, 0x06, 0x09, 0x09, 0x06}, /* 167 § */ + {0x20, 0x40, 0x45, 0x48, 0x30}, /* 168 ¨ */ + {0x00, 0x00, 0xF8, 0xF8, 0x18}, /* 169 © */ + {0x18, 0x18, 0xF8, 0xF8, 0x00}, /* 170 ª */ + {0x17, 0x08, 0x04, 0x76, 0x5D}, /* 171 « */ + {0x17, 0x08, 0x1C, 0x76, 0x11}, /* 172 ¬ */ + {0x00, 0x00, 0x7D, 0x00, 0x00}, /* 173 ­ */ + {0x08, 0x14, 0x2A, 0x14, 0x22}, /* 174 ® */ + {0x22, 0x14, 0x2A, 0x14, 0x08}, /* 175 ¯ */ + {0x44, 0x11, 0x44, 0x11, 0x44}, /* 176 ° */ + {0x55, 0xAA, 0x55, 0xAA, 0x55}, /* 177 ± */ + {0x55, 0xFF, 0x55, 0xFF, 0x55}, /* 178 ² */ + {0x00, 0x00, 0xFF, 0xFF, 0x00}, /* 179 ³ */ + {0x18, 0x18, 0xFF, 0xFF, 0x00}, /* 180 ´ */ + {0x24, 0x24, 0xFF, 0xFF, 0x00}, /* 181 µ */ + {0x18, 0xFF, 0x00, 0x00, 0xFF}, /* 182 ¶ */ + {0x18, 0xF8, 0x08, 0x08, 0xF8}, /* 183 · */ + {0x24, 0x24, 0xFF, 0xFF, 0x00}, /* 184 ¸ */ + {0x24, 0xE7, 0x00, 0x00, 0xE7}, /* 185 ¹ */ + {0x00, 0xFF, 0x00, 0x00, 0xFF}, /* 186 º */ + {0x24, 0xE4, 0x04, 0x04, 0xFC}, /* 187 » */ + {0x24, 0x27, 0x20, 0x20, 0x3F}, /* 188 ¼ */ + {0x18, 0x1F, 0x18, 0x18, 0x1F}, /* 189 ½ */ + {0x24, 0x24, 0x3F, 0x3F, 0x00}, /* 190 ¾ */ + {0x18, 0x18, 0xF8, 0xF8, 0x00}, /* 191 ¿ */ + {0x00, 0x00, 0x1F, 0x1F, 0x18}, /* 192 À */ + {0x18, 0x18, 0x1F, 0x1F, 0x18}, /* 193 Á */ + {0x18, 0x18, 0xF8, 0xF8, 0x18}, /* 194  */ + {0x00, 0x00, 0xFF, 0xFF, 0x18}, /* 195 à */ + {0x18, 0x18, 0x18, 0x18, 0x18}, /* 196 Ä */ + {0x18, 0x18, 0xFF, 0xFF, 0x18}, /* 197 Å */ + {0x00, 0x00, 0xFF, 0xFF, 0x24}, /* 198 Æ */ + {0x00, 0xFF, 0x00, 0x00, 0xFF}, /* 199 Ç */ + {0x00, 0x3F, 0x20, 0x20, 0x27}, /* 200 È */ + {0x00, 0xFC, 0x04, 0x04, 0xE4}, /* 201 É */ + {0x24, 0x27, 0x20, 0x20, 0x27}, /* 202 Ê */ + {0x24, 0xE4, 0x04, 0x04, 0xE4}, /* 203 Ë */ + {0x00, 0xFF, 0x00, 0x00, 0xE7}, /* 204 Ì */ + {0x24, 0x24, 0x24, 0x24, 0x24}, /* 205 Í */ + {0x24, 0xE7, 0x00, 0x00, 0xE7}, /* 206 Î */ + {0x24, 0x24, 0x27, 0x27, 0x24}, /* 207 Ï */ + {0x18, 0x1F, 0x18, 0x18, 0x1F}, /* 208 Ð */ + {0x24, 0x24, 0xE4, 0xE4, 0x24}, /* 209 Ñ */ + {0x18, 0xF8, 0x18, 0x18, 0xF8}, /* 210 Ò */ + {0x00, 0x1F, 0x18, 0x18, 0x1F}, /* 211 Ó */ + {0x00, 0x00, 0x3F, 0x3F, 0x24}, /* 212 Ô */ + {0x00, 0x00, 0xFC, 0xFC, 0x24}, /* 213 Õ */ + {0x00, 0xF8, 0x18, 0x18, 0xF8}, /* 214 Ö */ + {0x18, 0xFF, 0x18, 0x18, 0xFF}, /* 215 × */ + {0x24, 0x24, 0xFF, 0xFF, 0x24}, /* 216 Ø */ + {0x18, 0x18, 0x1F, 0x1F, 0x00}, /* 217 Ù */ + {0x00, 0x00, 0xF8, 0xF8, 0x18}, /* 218 Ú */ + {0xFF, 0xFF, 0xFF, 0xFF, 0xFF}, /* 219 Û */ + {0xF0, 0xF0, 0xF0, 0xF0, 0xF0}, /* 220 Ü */ + {0xFF, 0xFF, 0xFF, 0x00, 0x00}, /* 221 Ý */ + {0x00, 0x00, 0x00, 0xFF, 0xFF}, /* 222 Þ */ + {0x0F, 0x0F, 0x0F, 0x0F, 0x0F}, /* 223 ß */ + {0x38, 0x44, 0x44, 0x38, 0x44}, /* 224 à */ + {0x7e, 0x01, 0x09, 0x49, 0x36}, /* 225 á */ + {0x01, 0x7F, 0x01, 0x01, 0x03}, /* 226 â */ + {0x04, 0x7C, 0x04, 0x7C, 0x04}, /* 227 ã */ + {0x43, 0x65, 0x59, 0x41, 0x63}, /* 228 ä */ + {0x3C, 0x42, 0x42, 0x26, 0x1A}, /* 229 å */ + {0x40, 0x3E, 0x08, 0x08, 0x06}, /* 230 æ */ + {0x04, 0x06, 0x7F, 0x06, 0x04}, /* 231 Pfeil oben */ + {0x10, 0x30, 0x5F, 0x30, 0x10}, /* 232 Pfeil unten */ + {0x1C, 0x6B, 0x49, 0x6B, 0x1C}, /* 233 é */ + {0x5C, 0x62, 0x02, 0x62, 0x5C}, /* 234 ê */ + {0x00, 0x30, 0x4E, 0x49, 0x32}, /* 235 ë */ + {0x18, 0x24, 0x18, 0x24, 0x18}, /* 236 ì */ + {0x2C, 0x12, 0x2A, 0x24, 0x1A}, /* 237 í */ + {0x14, 0x2A, 0x49, 0x49, 0x41}, /* 238 î */ + {0x7E, 0x01, 0x01, 0x01, 0x7E}, /* 239 ï */ + {0x2A, 0x2A, 0x2A, 0x2A, 0x2A}, /* 240 ð */ + {0x00, 0x24, 0x2E, 0x24, 0x00}, /* 241 ñ */ + {0x40, 0x51, 0x4A, 0x44, 0x40}, /* 242 ò */ + {0x40, 0x44, 0x4A, 0x51, 0x40}, /* 243 ó */ + {0x00, 0x00, 0xFE, 0x01, 0x02}, /* 244 ô */ + {0x40, 0x80, 0x7F, 0x00, 0x00}, /* 245 õ */ + {0x08, 0x08, 0x2A, 0x08, 0x08}, /* 246 ö */ + {0x24, 0x12, 0x24, 0x12, 0x00}, /* 247 ÷ */ + {0x00, 0x07, 0x05, 0x07, 0x00}, /* 248 ø */ + {0x00, 0x18, 0x18, 0x00, 0x00}, /* 249 ù */ + {0x00, 0x10, 0x10, 0x10, 0x00}, /* 250 ú */ + {0x10, 0x30, 0x40, 0x38, 0x07}, /* 251 û */ + {0x15, 0x15, 0x1F, 0x00, 0x00}, /* 252 3 hoch */ + {0x1D, 0x15, 0x17, 0x00, 0x00}, /* 253 ý */ + {0x74, 0x54, 0x5C, 0x00, 0x00}, /* 254 2 tief */ + {0x1C, 0x10, 0x78, 0x00, 0x00} /* 255 4 tief */ +}; diff --git a/include/led.h b/include/led.h new file mode 100644 index 00000000..ad71787c --- /dev/null +++ b/include/led.h @@ -0,0 +1,49 @@ +#pragma once + +#include + +class Led { +private: +public: + Led(/* args */) = default; + ~Led() = default; + + inline void checkIfHueIsOutOfBound(float &hue); + + void set(bool changed = false); + void setColor(); + void setIcon(uint8_t num_icon, uint8_t brightness, bool rgb_icon = false); + void setFrameColor(); + void setSingle(uint8_t wait); + void setAllPixels(uint8_t rr, uint8_t gg, uint8_t bb, uint8_t ww); + void setPixelColorObject(uint16_t i, RgbColor color); + void setPixelColorObject(uint16_t i, RgbwColor color); + void setPixel(uint8_t rr, uint8_t gg, uint8_t bb, uint8_t ww, uint16_t i); + void setPixelHsb(uint16_t ledIndex, float hue, float sat, float bri, + uint8_t alpha = 0); + + void setPixelForChar(uint8_t col, uint8_t row, uint8_t offsetCol, + uint8_t offsetRow, unsigned char unsigned_d1); + + uint8_t setBrightnessAuto(uint8_t val); + void setBrightnessLdr(uint8_t &rr, uint8_t &gg, uint8_t &bb, uint8_t &ww, + uint8_t position); + void setBrightness(uint8_t &rr, uint8_t &gg, uint8_t &bb, uint8_t &ww, + uint8_t position, uint8_t percentage); + + inline void clear(); + inline void clearFrame(); + inline void clearPixel(uint16_t i); + inline void clearFrontExeptofFontspace(uint8_t offsetRow); + inline void clearClock(); + inline void clearRow(uint8_t row); + + void shiftColumnToRight(); + + void show(); + void showSeconds(); + void showNumbers(const char d1, const char d2); + + RgbColor getPixel(uint16_t i); + RgbwColor getPixelRgbw(uint16_t i); +}; diff --git a/include/led.hpp b/include/led.hpp new file mode 100644 index 00000000..ce09c508 --- /dev/null +++ b/include/led.hpp @@ -0,0 +1,350 @@ +#include "Animation.h" +#include "NeoMultiFeature.hpp" +#include "Uhr.h" +#include "Uhrtypes/Uhrtype.hpp" +#include "font.h" +#include "icons.h" +#include "led.h" +#include + +extern NeoPixelBus *strip_RGB; +extern NeoPixelBus *strip_RGBW; + +extern iUhrType *usedUhrType; +extern Animation *animation; + +//------------------------------------------------------------------------------ + +void Led::setPixel(uint8_t rr, uint8_t gg, uint8_t bb, uint8_t ww, uint16_t i) { + + if (G.Colortype == Grbw) { + strip_RGBW->SetPixelColor(i, RgbwColor(rr, gg, bb, ww)); + } else { + strip_RGB->SetPixelColor(i, RgbColor(rr, gg, bb)); + } +} + +//------------------------------------------------------------------------------ + +void Led::setPixelHsb(uint16_t ledIndex, float hue, float sat, float bri, + uint8_t alpha) { + HsbColor hsbColor = HsbColor(hue / 360, sat / 100, bri / 100); + + if (G.Colortype == Grbw) { + RgbColor rgbColor = RgbColor(hsbColor); + + strip_RGBW->SetPixelColor( + ledIndex, RgbwColor(rgbColor.R, rgbColor.G, rgbColor.B, alpha)); + } else { + strip_RGB->SetPixelColor(ledIndex, hsbColor); + } +} + +//------------------------------------------------------------------------------ + +void Led::setPixelColorObject(uint16_t i, RgbColor color) { + + if (G.Colortype == Grbw) { + strip_RGBW->SetPixelColor(i, RgbwColor(color)); + } else { + strip_RGB->SetPixelColor(i, color); + } +} + +//------------------------------------------------------------------------------ + +void Led::setPixelColorObject(uint16_t i, RgbwColor color) { + strip_RGBW->SetPixelColor(i, color); +} + +//------------------------------------------------------------------------------ + +RgbColor Led::getPixel(uint16_t i) { + if (G.Colortype == Grbw) { + RgbwColor rgbw = strip_RGBW->GetPixelColor(i); + return RgbColor(rgbw.R, rgbw.G, rgbw.B); + } + return strip_RGB->GetPixelColor(i); +} + +//------------------------------------------------------------------------------ + +RgbwColor Led::getPixelRgbw(uint16_t i) { return strip_RGBW->GetPixelColor(i); } + +//------------------------------------------------------------------------------ + +uint8_t Led::setBrightnessAuto(uint8_t val) { + // G.hh contains time-dependent brightness values in %. + uint16_t u16 = (val * G.hh) / 100; + return (static_cast((u16 * ldrVal) / 100)); +} + +//------------------------------------------------------------------------------ + +void Led::setBrightnessLdr(uint8_t &rr, uint8_t &gg, uint8_t &bb, uint8_t &ww, + uint8_t position) { + if (G.autoLdrEnabled) { + rr = setBrightnessAuto(G.rgb[position][0]); + gg = setBrightnessAuto(G.rgb[position][1]); + bb = setBrightnessAuto(G.rgb[position][2]); + ww = setBrightnessAuto(G.rgb[position][3]); + } else { + if (G.ldr == 1) { + rr = G.rgb[position][0] * ldrVal / 100; + gg = G.rgb[position][1] * ldrVal / 100; + bb = G.rgb[position][2] * ldrVal / 100; + ww = G.rgb[position][3] * ldrVal / 100; + } else { + rr = G.rgb[position][0] * G.hh / 100; + gg = G.rgb[position][1] * G.hh / 100; + bb = G.rgb[position][2] * G.hh / 100; + ww = G.rgb[position][3] * G.hh / 100; + } + } +} + +//------------------------------------------------------------------------------ + +void Led::setBrightness(uint8_t &rr, uint8_t &gg, uint8_t &bb, uint8_t &ww, + uint8_t position, uint8_t percentage = 100) { + rr = G.rgb[position][0] * percentage / 100; + gg = G.rgb[position][1] * percentage / 100; + bb = G.rgb[position][2] * percentage / 100; + ww = G.rgb[position][3] * percentage / 100; + uint16_t zz = rr + gg + bb; + if (zz > 150) { + zz = zz * 10 / 150; + rr = rr * 10 / zz; + gg = gg * 10 / zz; + bb = bb * 10 / zz; + ww = ww * 10 / zz; + } +} + +//------------------------------------------------------------------------------ + +void Led::show() { + if (G.Colortype == Grbw) { + strip_RGBW->Show(); + } else { + strip_RGB->Show(); + } +} + +//------------------------------------------------------------------------------ + +inline void Led::clearPixel(uint16_t i) { + if (G.Colortype == Grbw) { + strip_RGBW->SetPixelColor(i, 0); + } else { + strip_RGB->SetPixelColor(i, 0); + } +} + +//------------------------------------------------------------------------------ + +inline void Led::clear() { + for (uint16_t i = 0; i < usedUhrType->NUM_PIXELS(); i++) { + Word_array[i] = 500; + clearPixel(i); + } +} + +//------------------------------------------------------------------------------ + +inline void Led::clearClock() { + for (uint16_t i = 0; i < usedUhrType->NUM_SMATRIX(); i++) { + clearPixel(usedUhrType->getSMatrix(i)); + } +} + +//------------------------------------------------------------------------------ + +inline void Led::clearRow(uint8_t row) { + for (uint8_t i = 0; i < usedUhrType->COLS_MATRIX(); i++) { + clearPixel(usedUhrType->getFrontMatrix(row, i)); + } +} + +//------------------------------------------------------------------------------ + +inline void Led::clearFrontExeptofFontspace(uint8_t offsetRow) { + for (uint8_t i = 0; i < offsetRow; i++) { + clearRow(i); + } + + for (uint8_t i = usedUhrType->ROWS_MATRIX() - 1; i > offsetRow + fontHeight; + i--) { + clearRow(i - 1); + } +} + +//------------------------------------------------------------------------------ + +inline void Led::clearFrame() { + for (uint16_t i = 0; i < usedUhrType->NUM_RMATRIX(); i++) { + clearPixel(usedUhrType->getRMatrix(i)); + } +} + +//------------------------------------------------------------------------------ + +void Led::set(bool changed) { + uint8_t rr, gg, bb, ww; + uint8_t r2, g2, b2, w2; + setBrightnessLdr(rr, gg, bb, ww, Foreground); + setBrightnessLdr(r2, g2, b2, w2, Background); + for (uint16_t i = 0; i < usedUhrType->NUM_PIXELS(); i++) { + if (Word_array_old[i] < usedUhrType->NUM_PIXELS()) { + // foreground + setPixel(rr, gg, bb, ww, i); + } else { + // background + setPixel(r2, g2, b2, w2, i); + } + } + if (animation->led_show_notify(changed, _minute)) { + show(); + } +} + +//------------------------------------------------------------------------------ + +void Led::setIcon(uint8_t num_icon, uint8_t brightness = 100, bool rgb_icon) { + uint8_t rr, gg, bb, ww; + setBrightness(rr, gg, bb, ww, Foreground, brightness); + for (uint8_t col = 0; col < GRAFIK_11X10_COLS; col++) { + if (rgb_icon) { + rr = col < 3 ? 255 : 0; + gg = (col > 3) && (col < 7) ? 255 : 0; + bb = col > 7 ? 255 : 0; + ww = 0; + } + for (uint8_t row = 0; row < GRAFIK_11X10_ROWS; row++) { + if (pgm_read_word(&(grafik_11x10[num_icon][row])) & + (1 << (GRAFIK_11X10_COLS - 1 - col))) { + setPixel(rr, gg, bb, ww, usedUhrType->getFrontMatrix(row, col)); + } else { + clearPixel(usedUhrType->getFrontMatrix(row, col)); + } + } + } + show(); +} + +//------------------------------------------------------------------------------ + +void Led::setSingle(uint8_t wait) { + float hue; + + for (uint16_t i = 0; i < usedUhrType->NUM_PIXELS(); i++) { + hue = 360.0 * i / (usedUhrType->NUM_PIXELS() - 1); + hue = hue + 360.0 / usedUhrType->NUM_PIXELS(); + checkIfHueIsOutOfBound(hue); + + clear(); + setPixelHsb(i, hue, 100, 100); + show(); + delay(wait); + } +} + +//------------------------------------------------------------------------------ + +void Led::setAllPixels(uint8_t rr, uint8_t gg, uint8_t bb, uint8_t ww) { + for (uint16_t i = 0; i < usedUhrType->NUM_PIXELS(); i++) { + setPixel(rr, gg, bb, ww, i); + } +} + +//------------------------------------------------------------------------------ + +void Led::setColor() { + uint8_t rr, gg, bb, ww; + setBrightness(rr, gg, bb, ww, Effect); + setAllPixels(rr, gg, bb, ww); +} + +//------------------------------------------------------------------------------ + +void Led::setFrameColor() { + uint8_t rr, gg, bb, ww; + setBrightness(rr, gg, bb, ww, Frame); + + for (uint16_t i = 0; i < usedUhrType->NUM_RMATRIX(); i++) { + setPixel(rr, gg, bb, ww, usedUhrType->getRMatrix(i)); + } +} + +//------------------------------------------------------------------------------ + +void Led::shiftColumnToRight() { + for (uint8_t col = 0; col < usedUhrType->COLS_MATRIX() - 1; col++) { + for (uint8_t row = 0; + row < usedUhrType->ROWS_MATRIX() - 1 /* Only Front*/; row++) { + if (G.Colortype == Grbw) { + setPixelColorObject( + usedUhrType->getFrontMatrix(row, col), + getPixelRgbw(usedUhrType->getFrontMatrix(row, col + 1))); + } else { + setPixelColorObject( + usedUhrType->getFrontMatrix(row, col), + getPixel(usedUhrType->getFrontMatrix(row, col + 1))); + } + } + } +} + +//------------------------------------------------------------------------------ + +void Led::setPixelForChar(uint8_t col, uint8_t row, uint8_t offsetCol, + uint8_t offsetRow, unsigned char unsigned_d1) { + if (pgm_read_byte(&(font_7x5[unsigned_d1][col])) & (1u << row)) { + setPixel(G.rgb[Effect][0], G.rgb[Effect][1], G.rgb[Effect][2], + G.rgb[Effect][3], + usedUhrType->getFrontMatrix(row + offsetRow, col + offsetCol)); + } +} + +//------------------------------------------------------------------------------ + +void Led::showNumbers(const char d1, const char d2) { + clearClock(); + static uint8_t offsetLetter0 = 0; + static uint8_t offsetLetter1 = fontWidth + 1; + uint8_t offsetRow = (usedUhrType->ROWS_MATRIX() - fontHeight - 1) / 2; + + if (usedUhrType->has24HourLayout()) { + offsetLetter0 = 3; + offsetLetter1 = fontWidth + 4; + } + + for (uint8_t col = 0; col < fontWidth; col++) { + for (uint8_t row = 0; row < fontHeight; row++) { + // 1. Number without Offset + setPixelForChar(col, row, offsetLetter0, offsetRow, + static_cast(d1)); + // 2. Number with Offset + setPixelForChar(col, row, offsetLetter1, offsetRow, + static_cast(d2)); + } + } + show(); +} + +//------------------------------------------------------------------------------ + +void Led::showSeconds() { + uint8_t rr, gg, bb, ww; + setBrightness(rr, gg, bb, ww, Effect); + + setPixel(rr, gg, bb, ww, usedUhrType->getRMatrix(_sekunde48)); +} + +//------------------------------------------------------------------------------ + +inline void Led::checkIfHueIsOutOfBound(float &hue) { + if (hue > 360) { + hue = 0; + } +} \ No newline at end of file diff --git a/include/mqtt.h b/include/mqtt.h new file mode 100644 index 00000000..7ebc54c0 --- /dev/null +++ b/include/mqtt.h @@ -0,0 +1,19 @@ +#pragma once + +#include + +class Mqtt { +private: + void reconnect(); + static void callback(char *topic, byte *payload, unsigned int length); + +public: + Mqtt() = default; + ~Mqtt() = default; + + void init(); + void reInit(); + void loop(); + + bool getConnected(); +}; diff --git a/include/mqtt_func.hpp b/include/mqtt.hpp similarity index 54% rename from include/mqtt_func.hpp rename to include/mqtt.hpp index 2aac1c23..2fb18c87 100644 --- a/include/mqtt_func.hpp +++ b/include/mqtt.hpp @@ -1,9 +1,46 @@ -#pragma once -// =========================================================== -// Callback Funktion von MQTT. Die Funktion wird aufgerufen -// wenn ein Wert empfangen wurde. -// =========================================================== -void MQTT_callback(char *topic, byte *payload, unsigned int length) { + +#include "Uhr.h" +#include "mqtt.h" +#include +#include +#include + +extern WiFiClient client; + +PubSubClient mqttClient(client); + +//------------------------------------------------------------------------------ + +void Mqtt::init() { + mqttClient.setServer(G.mqtt.serverAdress, G.mqtt.port); + mqttClient.setCallback(callback); + mqttClient.connect(G.mqtt.clientId, G.mqtt.user, G.mqtt.password); + mqttClient.subscribe(G.mqtt.topic); +} + +//------------------------------------------------------------------------------ + +void Mqtt::reInit() { + mqttClient.connect(G.mqtt.clientId, G.mqtt.user, G.mqtt.password); + reconnect(); +} + +//------------------------------------------------------------------------------ + +bool Mqtt::getConnected() { return mqttClient.connected(); } + +//------------------------------------------------------------------------------ + +void Mqtt::loop() { + if (!mqttClient.connected()) { + reconnect(); + } + mqttClient.loop(); +} + +//------------------------------------------------------------------------------ + +void Mqtt::callback(char *topic, byte *payload, unsigned int length) { //{"state": "on", "brightness": 255, "color": [255, 255, 255], "effect": //"rainbow"} StaticJsonDocument<200> doc; @@ -38,11 +75,11 @@ void MQTT_callback(char *topic, byte *payload, unsigned int length) { } else if (str_buffer.compare("Sekundenanzeige")) { G.prog = COMMAND_MODE_SECONDS; } else if (str_buffer.compare("Laufschrift")) { - G.prog = COMMAND_MODE_MARQUEE; + G.prog = COMMAND_MODE_SCROLLINGTEXT; } else if (str_buffer.compare("Regenbogen")) { - G.prog = COMMAND_MODE_RAINBOW; + G.prog = COMMAND_MODE_RAINBOWCYCLE; } else if (str_buffer.compare("Farbwechsel")) { - G.prog = COMMAND_MODE_CHANGE; + G.prog = COMMAND_MODE_RAINBOW; } else if (str_buffer.compare("Farbe")) { G.prog = COMMAND_MODE_COLOR; } @@ -58,7 +95,9 @@ void MQTT_callback(char *topic, byte *payload, unsigned int length) { } } -void MQTT_reconnect() { - mqttClient.subscribe(G.MQTT_Topic); +//------------------------------------------------------------------------------ + +void Mqtt::reconnect() { + mqttClient.subscribe(G.mqtt.topic); Serial.println("MQTT Connected..."); } diff --git a/include/network.h b/include/network.h new file mode 100644 index 00000000..71f2220e --- /dev/null +++ b/include/network.h @@ -0,0 +1,22 @@ +#pragma once + +class Network { +private: + const char *connectionSSID = "WortUhr_verbinden"; + +public: + Network(/* args */) = default; + ~Network() = default; + + void info(); + int getQuality(); + void disable(); + void reboot(); + void resetSettings(); + String getSSID(); + void rtcMode(); + void changeHostname(const char *hostname); + + void setup(const char *hostname); + void loop(); +}; diff --git a/include/network.hpp b/include/network.hpp new file mode 100644 index 00000000..4d727936 --- /dev/null +++ b/include/network.hpp @@ -0,0 +1,40 @@ +#include "network.h" + +#include +#include +#include + +WiFiManager wifiManager(Serial); + +void Network::info() { WiFi.printDiag(Serial); } + +int Network::getQuality() { + int rssi = WiFi.RSSI(); + return wifiManager.getRSSIasQuality(rssi); +} + +void Network::rtcMode() { wifiManager.setConfigPortalTimeout(120); } + +void Network::disable() { wifiManager.disconnect(); } + +void Network::reboot() { wifiManager.reboot(); } + +void Network::resetSettings() { + wifiManager.resetSettings(); + wifiManager.reboot(); +} + +String Network::getSSID() { return wifiManager.getWiFiSSID(); } + +void Network::setup(const char *hostname) { + wifiManager.setHostname(hostname); +#ifdef MANUAL_WIFI_SETTINGS + wifiManager.preloadWiFi(WIFI_SSID, WIFI_PASSWORD); +#endif + wifiManager.autoConnect(connectionSSID); + // explicitly disable AP, esp defaults to STA+AP + WiFi.enableAP(false); + Network::info(); +} + +void Network::loop() { wifiManager.process(); } diff --git a/include/openwmap.h b/include/openwmap.h index 6798f99d..f290577e 100644 --- a/include/openwmap.h +++ b/include/openwmap.h @@ -15,9 +15,9 @@ void getweather() { // create calling URL memset(resource, 0, sizeof(resource)); strncat(resource, resource1, 22); - strncat(resource, G.cityid, 7); + strncat(resource, G.openWeatherMap.cityid, 7); strncat(resource, resource2, 20); - strncat(resource, G.apikey, 35); + strncat(resource, G.openWeatherMap.apikey, 35); strncat(resource, resource3, 6); Serial.print("Calling URL: "); diff --git a/include/wifi_func.hpp b/include/wifi_func.hpp index d057c451..24efb8ff 100644 --- a/include/wifi_func.hpp +++ b/include/wifi_func.hpp @@ -37,7 +37,7 @@ void WlanStart() { Serial.println(""); // IP-Adresse als Laufschrift anzeigen if (G.bootShowIP) { - zeigeip(ip_adress); + clockWork.initBootShowIp(ip_adress); } Serial.printf("-- Ende WlanStart -- \n\n"); diff --git a/package.json b/package.json index 5462817a..632c444a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "Wortuhr", - "version": "2.6.2", + "version": "2.6.3", "description": "For building a german layouted wordclock with an esp8266 module and WS2812/SK2812.", "license": "BSD-3-Clause", "contributors": [ @@ -20,6 +20,10 @@ "name": "David Panusch", "url": "https://github.com/dbambus" }, + { + "name": "shortN0te", + "url": "https://github.com/shortN0te" + }, { "name": "Flo455", "url": "https://github.com/Flo455" diff --git a/platformio.ini b/platformio.ini index 7a94428a..65d1988f 100644 --- a/platformio.ini +++ b/platformio.ini @@ -14,6 +14,7 @@ default_envs = nodemcuv2 [env:nodemcuv2] platform = espressif8266 board = nodemcuv2 +board_build.f_cpu = 160000000L framework = arduino upload_speed = 230400 monitor_speed = 115200 diff --git a/src/Network.cpp b/src/Network.cpp deleted file mode 100644 index d3aeb0b9..00000000 --- a/src/Network.cpp +++ /dev/null @@ -1,42 +0,0 @@ -#include "Network.h" - -#include -#include -#include - -WiFiManager wifiManager(Serial); - -const char *connectionSSID = "WortUhr_verbinden"; - -void Network_info() { WiFi.printDiag(Serial); } - -int Network_getQuality() { - int rssi = WiFi.RSSI(); - return wifiManager.getRSSIasQuality(rssi); -} - -void Network_rtcMode() { wifiManager.setConfigPortalTimeout(120); } - -void Network_disable() { wifiManager.disconnect(); } - -void Network_reboot() { wifiManager.reboot(); } - -void Network_resetSettings() { - wifiManager.resetSettings(); - wifiManager.reboot(); -} - -String Network_getSSID() { return wifiManager.getWiFiSSID(); } - -void Network_setup(const char *hostname) { - wifiManager.setHostname(hostname); -#ifdef MANUAL_WIFI_SETTINGS - wifiManager.preloadWiFi(WIFI_SSID, WIFI_PASSWORD); -#endif - wifiManager.autoConnect(connectionSSID); - // explicitly disable AP, esp defaults to STA+AP - WiFi.enableAP(false); - Network_info(); -} - -void Network_loop() { wifiManager.process(); } diff --git a/src/Wortuhr.cpp b/src/Wortuhr.cpp index 8cbe244d..7051e3d6 100644 --- a/src/Wortuhr.cpp +++ b/src/Wortuhr.cpp @@ -57,7 +57,6 @@ bool DEBUG = true; // DEBUG ON|OFF wenn auskommentiert #include #include #include -#include #include #include #include @@ -97,7 +96,6 @@ NeoPixelBus *strip_RGB = NULL; NeoPixelBus *strip_RGBW = NULL; WiFiClient client; -PubSubClient mqttClient(client); //--OTA-- ESP8266WebServer httpServer(81); @@ -111,74 +109,31 @@ const char TZ_Europe_Berlin[] = "CET-1CEST,M3.5.0,M10.5.0/3"; RTC_Type RTC; #include "Animation.h" -#include "font.h" -#include "icons.h" -#include "mqtt_func.hpp" -#include "openwmap.h" -#include "uhr_func.hpp" -#include "wifi_func.hpp" - -#include "Animation.hpp" +#include "clockWork.h" +#include "led.h" +#include "mqtt.h" +#include "network.h" Animation *animation; +Led led; +ClockWork clockWork; +Mqtt mqtt; +Network network; + +#include "Animation.hpp" +#include "clockWork.hpp" +#include "icons.h" +#include "led.hpp" +#include "mqtt.hpp" +#include "network.hpp" +#include "wifi_func.hpp" #define EEPROM_SIZE 512 _Static_assert(sizeof(G) <= EEPROM_SIZE, "Datenstruktur G zu gross für reservierten EEPROM Bereich"); -//------------------------------------------------------------------------------ - -iUhrType *getPointer(uint8_t num) { - switch (num) { - case 1: - return reinterpret_cast(&Uhr_114_type); - case 2: - return reinterpret_cast(&Uhr_114_Alternative_type); - case 6: - return reinterpret_cast(&Uhr_114_2Clock_type); - case 9: - return reinterpret_cast(&Uhr_114_dutch_type); - case 3: - return reinterpret_cast(&Uhr_125_type); - case 8: - return reinterpret_cast(&Uhr_125_type2_type); - case 4: - return reinterpret_cast(&Uhr_169_type); - case 5: - return reinterpret_cast(&Uhr_242_type); - case 7: - return reinterpret_cast(&Uhr_291_type); - default: - return nullptr; - } -} //------------------------------------------------------------------------------ -void InitLedStrip(uint8_t num) { - NeoMultiFeature::setColortype(num); - if (num == Grbw) { - if (strip_RGB != NULL) { - delete strip_RGB; // delete the previous dynamically created strip - strip_RGB = NULL; - } - if (strip_RGBW == NULL) { - strip_RGBW = new NeoPixelBus( - usedUhrType->NUM_PIXELS()); - strip_RGBW->Begin(); - } - } else { - if (strip_RGBW != NULL) { - delete strip_RGBW; // delete the previous dynamically created strip - strip_RGBW = NULL; - } - if (strip_RGB == NULL) { - strip_RGB = new NeoPixelBus( - usedUhrType->NUM_PIXELS()); - strip_RGB->Begin(); - } - } -} - uint32_t sntp_startup_delay_MS_rfc_not_less_than_60000() { if (externalRTC) { Serial.println("SNTP startup delay 1min"); @@ -191,6 +146,8 @@ uint32_t sntp_startup_delay_MS_rfc_not_less_than_60000() { } } +//------------------------------------------------------------------------------ + void time_is_set() { time_t utc = time(nullptr); if (externalRTC) { @@ -270,8 +227,8 @@ void setup() { G.zeige_min = 1; G.ldr = 0; G.ldrCal = 0; - strcpy(G.cityid, ""); - strcpy(G.apikey, ""); + strcpy(G.openWeatherMap.cityid, ""); + strcpy(G.openWeatherMap.apikey, ""); strcpy(G.zeitserver, "europe.pool.ntp.org"); strcpy(G.hostname, "uhr"); strcpy(G.ltext, "HELLO WORLD "); @@ -289,13 +246,13 @@ void setup() { G.Sprachvariation[i] = false; } - G.MQTT_State = 0; - G.MQTT_Port = 1883; - strcpy(G.MQTT_Server, "192.168.4.1"); - strcpy(G.MQTT_User, "User"); - strcpy(G.MQTT_Pass, "Passwort"); - strcpy(G.MQTT_ClientId, "ClientId"); - strcpy(G.MQTT_Topic, "Wortuhr"); + G.mqtt.state = 0; + G.mqtt.port = 1883; + strcpy(G.mqtt.serverAdress, "192.168.4.1"); + strcpy(G.mqtt.user, "User"); + strcpy(G.mqtt.password, "Passwort"); + strcpy(G.mqtt.clientId, "ClientId"); + strcpy(G.mqtt.topic, "Wortuhr"); G.UhrtypeDef = DEFAULT_LAYOUT; G.Colortype = DEFAULT_LEDTYPE; @@ -323,7 +280,7 @@ void setup() { // Get Pointer for Uhrtype //------------------------------------- - usedUhrType = getPointer(G.UhrtypeDef); + usedUhrType = clockWork.getPointer(G.UhrtypeDef); // Bereich der animiert wird: // LED-Rahmen horizontal @@ -338,17 +295,15 @@ void setup() { // LEDs initialisieren //------------------------------------- Serial.println("LED Init"); - InitLedStrip(G.Colortype); + clockWork.initLedStrip(G.Colortype); if (G.bootLedBlink) { - led_set_all(0x40, 0x40, 0x40, 0x40); - led_show(); + clockWork.initBootLedBlink(); delay(20); } if (G.bootLedSweep) { - led_single(20); + clockWork.initBootLedSweep(20); } - led_clear(); - led_show(); + clockWork.initBootLed(); G.conf = COMMAND_IDLE; @@ -361,7 +316,7 @@ void setup() { struct timeval tv; tv.tv_sec = RTC.now().unixtime(); settimeofday(&tv, nullptr); - Network_rtcMode(); + network.rtcMode(); externalRTC = true; } else { Serial.println("No external RealtimeClock found"); @@ -381,13 +336,13 @@ void setup() { // Start WiFi //------------------------------------- if (G.bootShowWifi) { - show_icon_wlan(0); + clockWork.initBootWifiSignalStrength(0); } - Network_setup(G.hostname); - int strength = Network_getQuality(); + network.setup(G.hostname); + int strength = network.getQuality(); Serial.printf("Signal strength: %i\n", strength); if (G.bootShowWifi) { - show_icon_wlan(strength); + clockWork.initBootWifiSignalStrength(strength); } WlanStart(); configTime(0, 0, G.zeitserver); @@ -411,11 +366,8 @@ void setup() { // MQTT //------------------------------------- - if (G.MQTT_State == 1) { - mqttClient.setServer(G.MQTT_Server, G.MQTT_Port); - mqttClient.setCallback(MQTT_callback); - mqttClient.connect(G.MQTT_ClientId, G.MQTT_User, G.MQTT_Pass); - mqttClient.subscribe(G.MQTT_Topic); + if (G.mqtt.state == 1) { + mqtt.init(); } //------------------------------------- @@ -433,10 +385,12 @@ void setup() { MDNS.addService("http", "tcp", 80); MDNS.addService("http", "tcp", 81); + /* // setup frame if (usedUhrType->hasSecondsFrame() && G.zeige_sek < 1 && G.zeige_min < 2) { - set_farbe_rahmen(); + led.setFrameColor(); } + */ //------------------------------------- Serial.println("--------------------------------------"); @@ -475,13 +429,6 @@ void setup() { //------------------------------------------------------------------------------ void loop() { - unsigned long currentMillis = millis(); - count_delay += currentMillis - previousMillis; - if (usedUhrType->hasSecondsFrame()) { - count_millis48 += currentMillis - previousMillis; - } - previousMillis = currentMillis; - time_t utc = time(nullptr); struct tm tm; localtime_r(&utc, &tm); @@ -491,8 +438,7 @@ void loop() { _stunde = tm.tm_hour; } - // lass die Zeit im Demo Mode der Animation schneller ablaufen - animation->demoMode(_minute, _sekunde); + network.loop(); MDNS.update(); @@ -503,447 +449,14 @@ void loop() { //------------------------------------------------ // MQTT //------------------------------------------------ - if (G.MQTT_State == 1 && WiFi.status() == WL_CONNECTED) { - if (!mqttClient.connected()) { - MQTT_reconnect(); - } - mqttClient.loop(); - } - - //------------------------------------------------ - // SecondsFrame - //------------------------------------------------ - if (usedUhrType->hasSecondsFrame()) { - if (count_millis48 >= interval48) { - count_millis48 = 0; - _sekunde48++; - if (_sekunde48 > 47) { - _sekunde48 = 0; - } - } - if (last_sekunde48 != _sekunde48) { - if (G.prog == 0 && G.conf == 0) { - if (G.zeige_sek == 1 || G.zeige_min == 2) { - rahmen_clear(); - } - if (G.zeige_sek > 0) { - show_sekunde(); - } - led_show(); - } - last_sekunde48 = _sekunde48; - } - } - - //------------------------------------------------ - // Sekunde und LDR Regelung - //------------------------------------------------ - if (last_sekunde != _sekunde) { - - // Wetteruhr - if (usedUhrType->hasWeatherLayout()) { - weather_tag++; - } - - //--- LDR Regelung - if ((G.ldr == 1) || G.autoLdrEnabled) { - doLDRLogic(); - } - - if (G.prog == 0 && G.conf == 0) { - led_clear(); - G.prog = COMMAND_MODE_WORD_CLOCK; - } - last_sekunde = _sekunde; - - if (usedUhrType->hasWeatherLayout()) { - if ((_sekunde == 0) | (_sekunde == 10) | (_sekunde == 20) | - (_sekunde == 30) | (_sekunde == 40) | (_sekunde == 50)) { - wetterswitch++; - led_clear(); - if (wetterswitch > 4) { - wetterswitch = 1; - } - Serial.print("Wetterswitch: "); - Serial.println(wetterswitch); - Serial.print("WStunde: "); - Serial.println(wstunde); - } - } - - char currentTime[80]; - strftime(currentTime, sizeof(currentTime), "%F %T (%z)\n", &tm); - Serial.printf(currentTime); + if (G.mqtt.state == 1 && WiFi.status() == WL_CONNECTED) { + mqtt.loop(); } animation->loop(tm); // muss periodisch aufgerufen werden - //------------------------------------------------ - // Minute - //------------------------------------------------ - if (last_minute != _minute) { - _sekunde48 = 0; - last_minute = _minute; - } - - //------------------------------------------------ - // Wetterdaten abrufen - //------------------------------------------------ - if (usedUhrType->hasWeatherLayout() && - weather_tag >= 600) { // Eisbaeeer changed for Debug (soll 600) - weather_tag = 0; - if (WiFi.status() == WL_CONNECTED) { - getweather(); - } - } - - Network_loop(); - - switch (G.conf) { - - case COMMAND_RESET: // Reset - { - delay(500); - ESP.reset(); - ESP.restart(); - while (true) { - } - break; - } - - case COMMAND_REQUEST_MQTT_VALUES: // MQTT Config Senden - { - DynamicJsonDocument config(1024); - config["command"] = "mqtt"; - config["MQTT_State"] = G.MQTT_State; - config["MQTT_Port"] = G.MQTT_Port; - config["MQTT_Server"] = G.MQTT_Server; - config["MQTT_User"] = G.MQTT_User; - config["MQTT_Pass"] = G.MQTT_Pass; - config["MQTT_ClientId"] = G.MQTT_ClientId; - config["MQTT_Topic"] = G.MQTT_Topic; - serializeJson(config, str); - Serial.print("Sending Payload:"); - Serial.println(str); - webSocket.sendTXT(G.client_nr, str, strlen(str)); - G.conf = COMMAND_IDLE; - break; - } - - case COMMAND_REQUEST_CONFIG_VALUES: // Config Senden - { - DynamicJsonDocument config(1024); - config["command"] = "config"; - config["ssid"] = Network_getSSID(); - config["zeitserver"] = G.zeitserver; - config["hostname"] = G.hostname; - config["ltext"] = G.ltext; - config["h6"] = G.h6; - config["h8"] = G.h8; - config["h12"] = G.h12; - config["h16"] = G.h16; - config["h18"] = G.h18; - config["h20"] = G.h20; - config["h22"] = G.h22; - config["h24"] = G.h24; - for (uint8_t i = 0; i < 5; i++) { - sprintf(s, "spv%d", i); - config[s] = static_cast(G.Sprachvariation[i]); - } - config["hell"] = G.hell; - config["zeige_sek"] = G.zeige_sek; - config["zeige_min"] = G.zeige_min; - config["ldr"] = G.ldr; - config["ldrCal"] = G.ldrCal; - config["cityid"] = G.cityid; - config["apikey"] = G.apikey; - config["colortype"] = G.Colortype; - config["UhrtypeDef"] = G.UhrtypeDef; - config["bootLedBlink"] = G.bootLedBlink; - config["bootLedSweep"] = G.bootLedSweep; - config["bootShowWifi"] = G.bootShowWifi; - config["bootShowIP"] = G.bootShowIP; - config["autoLdrEnabled"] = G.autoLdrEnabled; - config["hasDreiviertel"] = usedUhrType->hasDreiviertel(); - config["hasZwanzig"] = usedUhrType->hasZwanzig(); - config["hasWeatherLayout"] = usedUhrType->hasWeatherLayout(); - config["hasSecondsFrame"] = usedUhrType->hasSecondsFrame(); - serializeJson(config, str); - Serial.print("Sending Payload:"); - Serial.println(str); - webSocket.sendTXT(G.client_nr, str, strlen(str)); - G.conf = COMMAND_IDLE; - break; - } - - case COMMAND_REQUEST_COLOR_VALUES: // Config Farbwerte senden - { - DynamicJsonDocument config(1024); - config["command"] = "set"; - for (uint8_t i = 0; i < 4; i++) { - for (uint8_t ii = 0; ii < 4; ii++) { - sprintf(s, "rgb%d%d", i, ii); - config[s] = G.rgb[i][ii]; - } - } - config["hell"] = G.hell; - config["geschw"] = G.geschw; - config["colortype"] = G.Colortype; - config["prog"] = G.prog; - serializeJson(config, str); - webSocket.sendTXT(G.client_nr, str, strlen(str)); - G.conf = COMMAND_IDLE; - break; - } - - case COMMAND_REQUEST_AUTO_LDR: // Automatische Helligkeit - { - DynamicJsonDocument config(1024); - config["command"] = "autoLdr"; - if (G.param1 == 0) { - config["autoLdrEnabled"] = G.autoLdrEnabled; - config["autoLdrBright"] = G.autoLdrBright; - config["autoLdrDark"] = G.autoLdrDark; - } - config["autoLdrValue"] = map(analogRead(A0), 0, 1023, 0, 255); - serializeJson(config, str); - webSocket.sendTXT(G.client_nr, str, strlen(str)); - G.conf = COMMAND_IDLE; - break; - } - - case COMMAND_REQUEST_ANIMATION: // Animation - { - DynamicJsonDocument config(1024); - config["command"] = "animation"; - config["animType"] = G.animType; - config["animDuration"] = G.animDuration; - config["animSpeed"] = G.animSpeed; - config["animDemo"] = G.animDemo; - config["animColorize"] = G.animColorize; - JsonArray types = config.createNestedArray("animTypes"); - // Reihenfolge muss zu enum Ani passen! - types.add("keine"); - types.add("Hoch rollen"); - types.add("Runter rollen"); - types.add("Links schieben"); - types.add("Rechts schieben"); - types.add("Überblenden"); - types.add("Laser"); - types.add("Matrix"); - types.add("Baelle"); - types.add("Feuerwerk"); - types.add("Schlange"); - types.add("zufällig"); - serializeJson(config, str); - webSocket.sendTXT(G.client_nr, str, strlen(str)); - G.conf = COMMAND_IDLE; - break; - } - - case COMMAND_SET_TIME: // Uhrzeit setzen - case COMMAND_SET_INITIAL_VALUES: // Startwerte speichern - case COMMAND_SET_WEATHER_DATA: // OpenWeathermap Einstellung speichern - case COMMAND_SET_MARQUEE_TEXT: // Lauftext speichern - case COMMAND_SET_BOOT: // Bootoptionen speichern - { - eeprom_write(); - delay(100); - G.conf = COMMAND_IDLE; - break; - } - - case COMMAND_SET_MINUTE: // Anzeige Minuten speichern - case COMMAND_SET_BRIGHTNESS: // Helligkeit speichern - case COMMAND_SET_LDR: // LDR Einstellung speichern - case COMMAND_SET_AUTO_LDR: // Auto LDR Parameter speichern - case COMMAND_SET_LANGUAGE_VARIANT: // Sprachvarianten Einstellungen - case COMMAND_SET_SETTING_SECOND: // Anzeige Sekunde speichern - case COMMAND_SET_TIME_MANUAL: // Uhrzeit manuell einstellen - { - eeprom_write(); - led_clear(); - parameters_changed = true; - G.prog = COMMAND_MODE_WORD_CLOCK; - G.conf = COMMAND_IDLE; - break; - } - - case COMMAND_SET_MQTT: // MQTT Einstellungen - { - if (!mqttClient.connected() && G.MQTT_State) { - mqttClient.connect(G.MQTT_ClientId, G.MQTT_User, G.MQTT_Pass); - MQTT_reconnect(); - } - eeprom_write(); - G.conf = COMMAND_IDLE; - break; - } - - case COMMAND_SET_COLORTYPE: // Colortype der LED einstellen - { - // G.param1 enthält den neuen Colortype - Serial.printf("LED Colortype: %u\n", G.param1); - - // if ((G.param1 != G.Colortype) && ((G.param1 == Grbw) || - // (G.Colortype == Grbw))) { - // G.conf = COMMAND_RESET; - // } else { - G.conf = COMMAND_IDLE; - // } - - // der G.Colortype muss zeitgleich zu InitLedStrip erfolgen, - // sonst wird über einen null-pointer referenziert - G.Colortype = G.param1; - eeprom_write(); - InitLedStrip(G.Colortype); - led_set_Icon(RGB_I, 100, true); - break; - } - - case COMMAND_SET_UHRTYPE: // Uhrtype Layout einstellen - { - eeprom_write(); - Serial.printf("Uhrtype: %u\n", G.UhrtypeDef); - usedUhrType = getPointer(G.UhrtypeDef); - G.conf = COMMAND_IDLE; - break; - } - - case COMMAND_SET_HOSTNAME: // Hostname speichern - { - Serial.print("Hostname: "); - Serial.println(G.hostname); - eeprom_write(); - Network_reboot(); - G.conf = COMMAND_IDLE; - break; - } - - case COMMAND_SET_WIFI_DISABLED: // WLAN-Daten speichern und neu starten - { - eeprom_write(); - delay(100); - Serial.println("Conf: WLAN Abgeschaltet"); - Network_disable(); - G.conf = COMMAND_IDLE; - break; - } - - case COMMAND_SET_WIFI_AND_RESTART: // WLAN-Daten speichern und neu starten - { - Serial.println("Conf: WLAN neu konfiguriert"); - Network_resetSettings(); - G.conf = COMMAND_IDLE; - break; - } - - default: - break; - } - - switch (G.prog) { - - case COMMAND_MODE_SECONDS: // Sekundenanzeige - { - if (G.prog_init == 1) { - led_clear(); - G.prog_init = 0; - } - char d1[5]; - char d2[5]; - sprintf(d1, "%d", (int)(_sekunde / 10)); - sprintf(d2, "%d", (int)(_sekunde % 10)); - zahlen(d1[0], d2[0]); - break; - } - - case COMMAND_MODE_MARQUEE: // Laufschriftanzeige - { - if (G.prog_init == 1) { - G.prog_init = 0; - led_clear(); - count_delay = (G.geschw + 1) * 20; - } - if (count_delay >= (G.geschw + 1u) * 20u) { - laufschrift(G.ltext); - count_delay = 0; - } - break; - } - - case COMMAND_MODE_RAINBOW: // Regenbogenanzeige - { - if (G.prog_init == 1) { - G.prog_init = 0; - uhr_clear(); - count_delay = G.geschw * 7 + 1; - } - if (count_delay >= G.geschw * 7u + 1u) { - rainbowCycle(); - count_delay = 0; - } - break; - } - - case COMMAND_MODE_CHANGE: // Farbwechselanzeige - { - if (G.prog_init == 1) { - G.prog_init = 0; - led_clear(); - count_delay = G.geschw * 7 + 1; - } - if (count_delay >= G.geschw * 7u + 1u) { - rainbow(); - count_delay = 0; - } - break; - } - - case COMMAND_MODE_COLOR: // Farbe Rahmen - { - if (G.prog_init == 1) { - G.prog_init = 0; - set_farbe(); - led_show(); - } - break; - } - - case COMMAND_MODE_ANIMATION: // Animation - { - if (G.prog_init == 1) { - G.prog_init = 0; - eeprom_write(); - delay(100); - } - // Hier ist mit Absicht kein break, direkt nach dem Call - // COMMAND_MODE_ANIMATION muss COMMAND_MODE_WORD_CLOCK aufgerufen - // werden. - } - - case COMMAND_MODE_WORD_CLOCK: { - calc_word_array(); - - if (changes_in_array()) { - copy_array(Word_array, Word_array_old); - led_set(true); - } else if (parameters_changed) { - led_set(); - } - parameters_changed = false; - - if (usedUhrType->hasSecondsFrame() && G.zeige_sek < 1 && - G.zeige_min < 2) { - set_farbe_rahmen(); - } - G.prog = COMMAND_IDLE; - } - default: - break; - } + // lass die Zeit im Demo Mode der Animation schneller ablaufen + animation->demoMode(_minute, _sekunde); - if (count_delay > 10000) { - count_delay = 0; - } + clockWork.loop(tm); } diff --git a/src/font.cpp b/src/font.cpp deleted file mode 100644 index 815261b6..00000000 --- a/src/font.cpp +++ /dev/null @@ -1,260 +0,0 @@ -#include "font.h" - -const PROGMEM byte font_7x5[256][5] = { - {0x00, 0x00, 0x00, 0x00, 0x00}, // 0 - {0x00, 0x00, 0x00, 0x00, 0x00}, // 1 - {0x00, 0x00, 0x00, 0x00, 0x00}, // 2 - {0x00, 0x00, 0x00, 0x00, 0x00}, // 3 - {0x00, 0x00, 0x00, 0x00, 0x00}, // 4 - {0x00, 0x00, 0x00, 0x00, 0x00}, // 5 - {0x00, 0x00, 0x00, 0x00, 0x00}, // 6 - {0x00, 0x00, 0x00, 0x00, 0x00}, // 7 - {0x00, 0x00, 0x00, 0x00, 0x00}, // 8 - {0x00, 0x00, 0x00, 0x00, 0x00}, // 9 - {0x00, 0x00, 0x00, 0x00, 0x00}, // 10 - {0x00, 0x00, 0x00, 0x00, 0x00}, // 11 - {0x00, 0x00, 0x00, 0x00, 0x00}, // 12 - {0x00, 0x00, 0x00, 0x00, 0x00}, // 13 - {0x00, 0x00, 0x00, 0x00, 0x00}, // 14 - {0x00, 0x00, 0x00, 0x00, 0x00}, // 15 - {0x00, 0x00, 0x00, 0x00, 0x00}, // 16 - {0x00, 0x00, 0x00, 0x00, 0x00}, // 17 - {0x00, 0x00, 0x00, 0x00, 0x00}, // 18 - {0x00, 0x00, 0x00, 0x00, 0x00}, // 19 - {0x00, 0x00, 0x00, 0x00, 0x00}, // 20 - {0x00, 0x00, 0x00, 0x00, 0x00}, // 21 - {0x00, 0x00, 0x00, 0x00, 0x00}, // 22 - {0x00, 0x00, 0x00, 0x00, 0x00}, // 23 - {0x00, 0x00, 0x00, 0x00, 0x00}, // 24 - {0x00, 0x00, 0x00, 0x00, 0x00}, // 25 - {0x00, 0x00, 0x00, 0x00, 0x00}, // 26 - {0x00, 0x00, 0x00, 0x00, 0x00}, // 27 - {0x00, 0x00, 0x00, 0x00, 0x00}, // 28 - {0x00, 0x00, 0x00, 0x00, 0x00}, // 29 - {0x00, 0x00, 0x00, 0x00, 0x00}, // 30 - {0x00, 0x00, 0x00, 0x00, 0x00}, // 31 - {0x00, 0x00, 0x00, 0x00, 0x00}, // 32 - {0x00, 0x00, 0x5F, 0x00, 0x00}, // 33 ! - {0x00, 0x07, 0x00, 0x07, 0x00}, // 34 " - {0x14, 0x7F, 0x14, 0x7F, 0x14}, // 35 # - {0x24, 0x2A, 0x6B, 0x2A, 0x12}, // 36 $ - {0x23, 0x13, 0x08, 0x64, 0x62}, // 37 % - {0x36, 0x49, 0x59, 0x26, 0x50}, // 38 & - {0x00, 0x00, 0x04, 0x03, 0x00}, // 39 ' - {0x00, 0x1C, 0x22, 0x41, 0x00}, // 40 ( - {0x00, 0x41, 0x22, 0x1C, 0x00}, // 41 ) - {0x24, 0x18, 0x7E, 0x18, 0x24}, // 42 * - {0x08, 0x08, 0x3E, 0x08, 0x08}, // 43 + - {0x00, 0x00, 0x58, 0x38, 0x00}, // 44 , - {0x08, 0x08, 0x08, 0x08, 0x08}, // 45 - - {0x00, 0x00, 0x60, 0x60, 0x00}, // 46 . - {0x20, 0x10, 0x08, 0x04, 0x02}, // 47 / - {0x3E, 0x51, 0x49, 0x45, 0x3E}, // 48 0 - {0x00, 0x04, 0x42, 0x7F, 0x40}, // 49 1 - {0x42, 0x61, 0x51, 0x49, 0x46}, // 50 2 - {0x22, 0x41, 0x49, 0x49, 0x36}, // 51 3 - {0x18, 0x14, 0x52, 0x7F, 0x50}, // 52 4 - {0x27, 0x45, 0x45, 0x45, 0x39}, // 53 5 - {0x3C, 0x4A, 0x49, 0x49, 0x30}, // 54 6 - {0x61, 0x11, 0x09, 0x05, 0x03}, // 55 7 - {0x36, 0x49, 0x49, 0x49, 0x36}, // 56 8 - {0x06, 0x49, 0x49, 0x49, 0x3E}, // 57 9 - {0x00, 0x00, 0x36, 0x36, 0x00}, // 58 : - {0x00, 0x00, 0x56, 0x36, 0x00}, // 59 ; - {0x00, 0x08, 0x14, 0x22, 0x41}, // 60 < - {0x14, 0x14, 0x14, 0x14, 0x14}, // 61 = - {0x00, 0x41, 0x22, 0x14, 0x08}, // 62 > - {0x02, 0x01, 0x51, 0x09, 0x06}, // 63 ? - {0x3E, 0x41, 0x5D, 0x55, 0x1E}, // 64 @ - {0x7C, 0x12, 0x11, 0x12, 0x7C}, // 65 A - {0x7F, 0x49, 0x49, 0x49, 0x36}, // 66 B - {0x3E, 0x41, 0x41, 0x41, 0x22}, // 67 C - {0x7F, 0x41, 0x41, 0x22, 0x1C}, // 68 D - {0x7F, 0x49, 0x49, 0x49, 0x41}, // 69 E - {0x7F, 0x09, 0x09, 0x09, 0x01}, // 70 F - {0x3E, 0x41, 0x49, 0x49, 0x3A}, // 71 G - {0x7F, 0x08, 0x08, 0x08, 0x7F}, // 72 H - {0x00, 0x41, 0x7F, 0x41, 0x00}, // 73 I - {0x20, 0x40, 0x41, 0x3F, 0x01}, // 74 J - {0x7F, 0x08, 0x14, 0x22, 0x41}, // 75 K - {0x7F, 0x40, 0x40, 0x40, 0x40}, // 76 L - {0x7F, 0x02, 0x04, 0x02, 0x7F}, // 77 M - {0x7F, 0x02, 0x0C, 0x10, 0x7F}, // 78 N - {0x3E, 0x41, 0x41, 0x41, 0x3E}, // 79 O - {0x7F, 0x09, 0x09, 0x09, 0x06}, // 80 P - {0x3E, 0x41, 0x51, 0x21, 0x5E}, // 81 Q - {0x7F, 0x09, 0x19, 0x29, 0x46}, // 82 R - {0x26, 0x49, 0x49, 0x49, 0x32}, // 83 S - {0x01, 0x01, 0x7F, 0x01, 0x01}, // 84 T - {0x3F, 0x40, 0x40, 0x40, 0x3F}, // 85 U - {0x1F, 0x20, 0x40, 0x20, 0x1F}, // 86 V - {0x3F, 0x40, 0x30, 0x40, 0x3F}, // 87 W - {0x63, 0x14, 0x08, 0x14, 0x63}, // 88 X - {0x07, 0x08, 0x70, 0x08, 0x07}, // 89 Y - {0x61, 0x51, 0x49, 0x45, 0x43}, // 90 Z - {0x00, 0x7F, 0x41, 0x41, 0x00}, // 91 [ - {0x02, 0x04, 0x08, 0x10, 0x20}, // 92 BACKSLASH - {0x00, 0x41, 0x41, 0x7F, 0x00}, // 93 ] - {0x04, 0x02, 0x01, 0x02, 0x04}, // 94 ^ - {0x40, 0x40, 0x40, 0x40, 0x40}, // 95 _ - {0x00, 0x00, 0x03, 0x04, 0x00}, // 96 ` - {0x20, 0x54, 0x54, 0x54, 0x78}, // 97 a - {0x7F, 0x44, 0x44, 0x44, 0x38}, // 98 b - {0x38, 0x44, 0x44, 0x44, 0x44}, // 99 c - {0x38, 0x44, 0x44, 0x44, 0x7F}, // 100 d - {0x38, 0x54, 0x54, 0x54, 0x18}, // 101 e - {0x44, 0x7E, 0x45, 0x01, 0x02}, // 102 f - {0x08, 0x54, 0x54, 0x54, 0x3C}, // 103 g - {0x7F, 0x08, 0x04, 0x04, 0x78}, // 104 h - {0x00, 0x44, 0x7D, 0x40, 0x00}, // 105 i - {0x20, 0x40, 0x44, 0x3D, 0x00}, // 106 j - {0x7F, 0x10, 0x28, 0x44, 0x00}, // 107 k - {0x00, 0x41, 0x7F, 0x40, 0x00}, // 108 l - {0x7C, 0x04, 0x7C, 0x04, 0x78}, // 109 m - {0x7C, 0x08, 0x04, 0x04, 0x78}, // 110 n - {0x38, 0x44, 0x44, 0x44, 0x38}, // 111 o - {0x7C, 0x14, 0x14, 0x14, 0x08}, // 112 p - {0x08, 0x14, 0x14, 0x14, 0x7C}, // 113 q - {0x00, 0x7C, 0x08, 0x04, 0x04}, // 114 r - {0x48, 0x54, 0x54, 0x54, 0x24}, // 115 s - {0x04, 0x3F, 0x44, 0x40, 0x20}, // 116 t - {0x3C, 0x40, 0x40, 0x20, 0x7C}, // 117 u - {0x1C, 0x20, 0x40, 0x20, 0x1C}, // 118 v - {0x3C, 0x40, 0x30, 0x40, 0x3C}, // 119 w - {0x44, 0x28, 0x10, 0x28, 0x44}, // 120 x - {0x0C, 0x50, 0x50, 0x50, 0x3C}, // 121 y - {0x44, 0x64, 0x54, 0x4C, 0x44}, // 122 z - {0x08, 0x08, 0x36, 0x41, 0x41}, // 123 { - {0x00, 0x00, 0x77, 0x00, 0x00}, // 124 | - {0x41, 0x41, 0x36, 0x08, 0x08}, // 125 } - {0x08, 0x04, 0x04, 0x08, 0x08}, // 126 ~ - {0x00, 0x00, 0x00, 0x00, 0x00}, // 127 - {0x1E, 0xA1, 0xE1, 0x21, 0x12}, /* 128 € */ - {0x3C, 0x41, 0x40, 0x21, 0x7C}, /* 129  */ - {0x38, 0x54, 0x56, 0x55, 0x18}, /* 130 ‚ */ - {0x20, 0x56, 0x55, 0x56, 0x78}, /* 131 ƒ */ - {0x20, 0x55, 0x54, 0x55, 0x78}, /* 132 „ */ - {0x20, 0x54, 0x55, 0x56, 0x78}, /* 133 … */ - {0x20, 0x54, 0x57, 0x57, 0x78}, /* 134 † */ - {0x1C, 0xA2, 0xE2, 0x22, 0x14}, /* 135 ‡ */ - {0x38, 0x56, 0x55, 0x56, 0x18}, /* 136 ˆ */ - {0x38, 0x55, 0x54, 0x55, 0x18}, /* 137 ‰ */ - {0x38, 0x54, 0x55, 0x56, 0x18}, /* 138 Š */ - {0x00, 0x45, 0x7C, 0x41, 0x00}, /* 139 ‹ */ - {0x00, 0x46, 0x7D, 0x42, 0x00}, /* 140 Œ */ - {0x00, 0x44, 0x7D, 0x42, 0x00}, /* 141  */ - {0x79, 0x14, 0x12, 0x14, 0x79}, /* 142 Ž */ - {0x78, 0x14, 0x17, 0x17, 0x78}, /* 143  */ - {0x7C, 0x54, 0x55, 0x56, 0x44}, /* 144  */ - {0x00, 0x00, 0x00, 0x00, 0x00}, // 145 - {0x00, 0x00, 0x00, 0x00, 0x00}, // 146 - {0x30, 0x4A, 0x49, 0x4A, 0x30}, /* 147 “ */ - {0x38, 0x45, 0x44, 0x45, 0x38}, /* 148 ” */ - {0x38, 0x45, 0x46, 0x44, 0x38}, /* 149 • */ - {0x38, 0x42, 0x41, 0x22, 0x78}, /* 150 – */ - {0x3C, 0x41, 0x42, 0x20, 0x7C}, /* 151 — */ - {0x0C, 0x51, 0x50, 0x51, 0x3C}, /* 152 ˜ */ - {0x3D, 0x42, 0x42, 0x42, 0x3D}, /* 153 ™ */ - {0x3C, 0x41, 0x40, 0x21, 0x7C}, /* 154 š */ - {0x1C, 0x22, 0x63, 0x22, 0x22}, /* 155 › */ - {0x68, 0x7E, 0x49, 0x42, 0x20}, /* 156 œ */ - {0x00, 0x00, 0x00, 0x00, 0x00}, /* 157  */ - {0x00, 0x00, 0x00, 0x00, 0x00}, /* 158 ž */ - {0x20, 0x48, 0x3e, 0x09, 0x02}, /* 159 Ÿ */ - {0x20, 0x54, 0x56, 0x55, 0x78}, /* 160   */ - {0x00, 0x46, 0x7D, 0x40, 0x00}, /* 161  */ - {0x38, 0x44, 0x46, 0x45, 0x38}, /* 162 ¢ */ - {0x3C, 0x40, 0x42, 0x21, 0x7C}, /* 163 £ */ - {0x78, 0x12, 0x09, 0x0A, 0x71}, /* 164 ¤ */ - {0x7C, 0x0A, 0x11, 0x22, 0x7D}, /* 165 ¥ */ - {0x00, 0x06, 0x09, 0x0F, 0x08}, /* 166 ¦ */ - {0x00, 0x06, 0x09, 0x09, 0x06}, /* 167 § */ - {0x20, 0x40, 0x45, 0x48, 0x30}, /* 168 ¨ */ - {0x00, 0x00, 0xF8, 0xF8, 0x18}, /* 169 © */ - {0x18, 0x18, 0xF8, 0xF8, 0x00}, /* 170 ª */ - {0x17, 0x08, 0x04, 0x76, 0x5D}, /* 171 « */ - {0x17, 0x08, 0x1C, 0x76, 0x11}, /* 172 ¬ */ - {0x00, 0x00, 0x7D, 0x00, 0x00}, /* 173 ­ */ - {0x08, 0x14, 0x2A, 0x14, 0x22}, /* 174 ® */ - {0x22, 0x14, 0x2A, 0x14, 0x08}, /* 175 ¯ */ - {0x44, 0x11, 0x44, 0x11, 0x44}, /* 176 ° */ - {0x55, 0xAA, 0x55, 0xAA, 0x55}, /* 177 ± */ - {0x55, 0xFF, 0x55, 0xFF, 0x55}, /* 178 ² */ - {0x00, 0x00, 0xFF, 0xFF, 0x00}, /* 179 ³ */ - {0x18, 0x18, 0xFF, 0xFF, 0x00}, /* 180 ´ */ - {0x24, 0x24, 0xFF, 0xFF, 0x00}, /* 181 µ */ - {0x18, 0xFF, 0x00, 0x00, 0xFF}, /* 182 ¶ */ - {0x18, 0xF8, 0x08, 0x08, 0xF8}, /* 183 · */ - {0x24, 0x24, 0xFF, 0xFF, 0x00}, /* 184 ¸ */ - {0x24, 0xE7, 0x00, 0x00, 0xE7}, /* 185 ¹ */ - {0x00, 0xFF, 0x00, 0x00, 0xFF}, /* 186 º */ - {0x24, 0xE4, 0x04, 0x04, 0xFC}, /* 187 » */ - {0x24, 0x27, 0x20, 0x20, 0x3F}, /* 188 ¼ */ - {0x18, 0x1F, 0x18, 0x18, 0x1F}, /* 189 ½ */ - {0x24, 0x24, 0x3F, 0x3F, 0x00}, /* 190 ¾ */ - {0x18, 0x18, 0xF8, 0xF8, 0x00}, /* 191 ¿ */ - {0x00, 0x00, 0x1F, 0x1F, 0x18}, /* 192 À */ - {0x18, 0x18, 0x1F, 0x1F, 0x18}, /* 193 Á */ - {0x18, 0x18, 0xF8, 0xF8, 0x18}, /* 194  */ - {0x00, 0x00, 0xFF, 0xFF, 0x18}, /* 195 à */ - {0x18, 0x18, 0x18, 0x18, 0x18}, /* 196 Ä */ - {0x18, 0x18, 0xFF, 0xFF, 0x18}, /* 197 Å */ - {0x00, 0x00, 0xFF, 0xFF, 0x24}, /* 198 Æ */ - {0x00, 0xFF, 0x00, 0x00, 0xFF}, /* 199 Ç */ - {0x00, 0x3F, 0x20, 0x20, 0x27}, /* 200 È */ - {0x00, 0xFC, 0x04, 0x04, 0xE4}, /* 201 É */ - {0x24, 0x27, 0x20, 0x20, 0x27}, /* 202 Ê */ - {0x24, 0xE4, 0x04, 0x04, 0xE4}, /* 203 Ë */ - {0x00, 0xFF, 0x00, 0x00, 0xE7}, /* 204 Ì */ - {0x24, 0x24, 0x24, 0x24, 0x24}, /* 205 Í */ - {0x24, 0xE7, 0x00, 0x00, 0xE7}, /* 206 Î */ - {0x24, 0x24, 0x27, 0x27, 0x24}, /* 207 Ï */ - {0x18, 0x1F, 0x18, 0x18, 0x1F}, /* 208 Ð */ - {0x24, 0x24, 0xE4, 0xE4, 0x24}, /* 209 Ñ */ - {0x18, 0xF8, 0x18, 0x18, 0xF8}, /* 210 Ò */ - {0x00, 0x1F, 0x18, 0x18, 0x1F}, /* 211 Ó */ - {0x00, 0x00, 0x3F, 0x3F, 0x24}, /* 212 Ô */ - {0x00, 0x00, 0xFC, 0xFC, 0x24}, /* 213 Õ */ - {0x00, 0xF8, 0x18, 0x18, 0xF8}, /* 214 Ö */ - {0x18, 0xFF, 0x18, 0x18, 0xFF}, /* 215 × */ - {0x24, 0x24, 0xFF, 0xFF, 0x24}, /* 216 Ø */ - {0x18, 0x18, 0x1F, 0x1F, 0x00}, /* 217 Ù */ - {0x00, 0x00, 0xF8, 0xF8, 0x18}, /* 218 Ú */ - {0xFF, 0xFF, 0xFF, 0xFF, 0xFF}, /* 219 Û */ - {0xF0, 0xF0, 0xF0, 0xF0, 0xF0}, /* 220 Ü */ - {0xFF, 0xFF, 0xFF, 0x00, 0x00}, /* 221 Ý */ - {0x00, 0x00, 0x00, 0xFF, 0xFF}, /* 222 Þ */ - {0x0F, 0x0F, 0x0F, 0x0F, 0x0F}, /* 223 ß */ - {0x38, 0x44, 0x44, 0x38, 0x44}, /* 224 à */ - {0x7e, 0x01, 0x09, 0x49, 0x36}, /* 225 á */ - {0x01, 0x7F, 0x01, 0x01, 0x03}, /* 226 â */ - {0x04, 0x7C, 0x04, 0x7C, 0x04}, /* 227 ã */ - {0x43, 0x65, 0x59, 0x41, 0x63}, /* 228 ä */ - {0x3C, 0x42, 0x42, 0x26, 0x1A}, /* 229 å */ - {0x40, 0x3E, 0x08, 0x08, 0x06}, /* 230 æ */ - {0x04, 0x06, 0x7F, 0x06, 0x04}, /* 231 Pfeil oben */ - {0x10, 0x30, 0x5F, 0x30, 0x10}, /* 232 Pfeil unten */ - {0x1C, 0x6B, 0x49, 0x6B, 0x1C}, /* 233 é */ - {0x5C, 0x62, 0x02, 0x62, 0x5C}, /* 234 ê */ - {0x00, 0x30, 0x4E, 0x49, 0x32}, /* 235 ë */ - {0x18, 0x24, 0x18, 0x24, 0x18}, /* 236 ì */ - {0x2C, 0x12, 0x2A, 0x24, 0x1A}, /* 237 í */ - {0x14, 0x2A, 0x49, 0x49, 0x41}, /* 238 î */ - {0x7E, 0x01, 0x01, 0x01, 0x7E}, /* 239 ï */ - {0x2A, 0x2A, 0x2A, 0x2A, 0x2A}, /* 240 ð */ - {0x00, 0x24, 0x2E, 0x24, 0x00}, /* 241 ñ */ - {0x40, 0x51, 0x4A, 0x44, 0x40}, /* 242 ò */ - {0x40, 0x44, 0x4A, 0x51, 0x40}, /* 243 ó */ - {0x00, 0x00, 0xFE, 0x01, 0x02}, /* 244 ô */ - {0x40, 0x80, 0x7F, 0x00, 0x00}, /* 245 õ */ - {0x08, 0x08, 0x2A, 0x08, 0x08}, /* 246 ö */ - {0x24, 0x12, 0x24, 0x12, 0x00}, /* 247 ÷ */ - {0x00, 0x07, 0x05, 0x07, 0x00}, /* 248 ø */ - {0x00, 0x18, 0x18, 0x00, 0x00}, /* 249 ù */ - {0x00, 0x10, 0x10, 0x10, 0x00}, /* 250 ú */ - {0x10, 0x30, 0x40, 0x38, 0x07}, /* 251 û */ - {0x15, 0x15, 0x1F, 0x00, 0x00}, /* 252 3 hoch */ - {0x1D, 0x15, 0x17, 0x00, 0x00}, /* 253 ý */ - {0x74, 0x54, 0x5C, 0x00, 0x00}, /* 254 2 tief */ - {0x1C, 0x10, 0x78, 0x00, 0x00} /* 255 4 tief */ -}; diff --git a/webpage/index.html b/webpage/index.html index 6f4d2f1d..344130d9 100644 --- a/webpage/index.html +++ b/webpage/index.html @@ -125,7 +125,7 @@

Einstellung

-
+
@@ -138,7 +138,7 @@

Einstellung

-
+
@@ -767,7 +767,7 @@

Über

Die Software dieser Wortuhr basiert auf der Wortuhr von (Stand 2019) Ulrich Radig und wird nun weiterentwickelt auf GitHub von Lars Weimar, Pascal Wagler, dbambus, + href="https://github.com/Eisbaeeer">Lars Weimar, Pascal Wagler, dbambus, shortN0te, Flo455, Elektron79, tali, ATho95 und masju1.

Ein Update der Software ist möglich, dazu bitte hier klicken.

This project is open source licensed under the BSD 3-Clause License.

diff --git a/webpage/script.js b/webpage/script.js index b96b5697..cd6f1a59 100644 --- a/webpage/script.js +++ b/webpage/script.js @@ -112,9 +112,9 @@ var animDemo = false; // operation modes var COMMAND_MODE_WORD_CLOCK = 1; var COMMAND_MODE_SECONDS = 2; -var COMMAND_MODE_MARQUEE = 3; -var COMMAND_MODE_RAINBOW = 4; -var COMMAND_MODE_CHANGE = 5; +var COMMAND_MODE_SCROLLINGTEXT = 3; +var COMMAND_MODE_RAINBOWCYCLE = 4; +var COMMAND_MODE_RAINBOW = 5; var COMMAND_MODE_COLOR = 6; var COMMAND_MODE_ANIMATION = 10; @@ -418,7 +418,7 @@ function changeColor(color) { rgb[color.index][1] = color.green; rgb[color.index][2] = color.blue; rgb[color.index][3] = Math.round(255 * (1.0 - color.alpha)); - sendData(command, nstr(1)); + sendColorData(command, nstr(1)); } function createColorPicker() { @@ -442,14 +442,6 @@ function createColorPicker() { alphaSlider.classList.add("specific-colortype-4"); } -/** - * Gets all the values from the sliders and puts them in the config variables. - */ -function getSliders() { - hell = $("#slider-brightness").get("value"); - geschw = $("#slider-speed").get("value"); -} - /** * show the color configuration in the color picker */ @@ -505,7 +497,7 @@ function toggleBackground() { rgb[COLOR_BACKGROUND][3] = 0; } setColorPicker(withBackground); - sendData(command, nstr(1)); + sendColorData(command, nstr(1)); } /** @@ -573,29 +565,39 @@ function getPaddedString(string, maxStringLength) { return string.padEnd(maxStringLength, " "); } -function sendData(command, addData = "") { - var data = nstr(command) + - nstr(rgb[COLOR_FOREGROUND][0]) + - nstr(rgb[COLOR_FOREGROUND][1]) + - nstr(rgb[COLOR_FOREGROUND][2]) + - nstr(rgb[COLOR_FOREGROUND][3]) + - nstr(rgb[COLOR_BACKGROUND][0]) + - nstr(rgb[COLOR_BACKGROUND][1]) + - nstr(rgb[COLOR_BACKGROUND][2]) + - nstr(rgb[COLOR_BACKGROUND][3]) + - nstr(hell) + - nstr(geschw) + addData + "999"; - - websocket.send(data); - debugMessage("Send data: ", data); -} - function sendCmd(command, addData = "") { var data = nstr(command) + addData + "999"; websocket.send(data); debugMessage("Send data: ", data); } +function sendBrightnessData(command, addData = "") { + h6 = $("#brightness-6").get("value"); + h8 = $("#brightness-8").get("value"); + h12 = $("#brightness-12").get("value"); + h16 = $("#brightness-16").get("value"); + h18 = $("#brightness-18").get("value"); + h20 = $("#brightness-20").get("value"); + h22 = $("#brightness-22").get("value"); + h24 = $("#brightness-24").get("value"); + + sendCmd(COMMAND_SET_BRIGHTNESS, nstr(h6) + nstr(h8) + nstr(h12) + nstr(h16) + nstr(h18) + nstr(h20) + nstr(h22) + nstr(h24) + nstr(hell)); + debugMessage("Helligkeit wurde neu konfiguriert"); +} + +function sendColorData(command, addData = "") { + sendCmd(command, nstr(rgb[COLOR_FOREGROUND][0]) + + nstr(rgb[COLOR_FOREGROUND][1]) + + nstr(rgb[COLOR_FOREGROUND][2]) + + nstr(rgb[COLOR_FOREGROUND][3]) + + nstr(rgb[COLOR_BACKGROUND][0]) + + nstr(rgb[COLOR_BACKGROUND][1]) + + nstr(rgb[COLOR_BACKGROUND][2]) + + nstr(rgb[COLOR_BACKGROUND][3]) + + nstr(hell) + + nstr(geschw)); +} + $.ready(function() { initConfigValues(); @@ -691,17 +693,17 @@ $.ready(function() { if (id === "mode-marquee") { hasSpeed = true; hasText = true; - command = COMMAND_MODE_MARQUEE; + command = COMMAND_MODE_SCROLLINGTEXT; } if (id === "mode-rainbow") { hasBrightness = true; hasSpeed = true; - command = COMMAND_MODE_RAINBOW; + command = COMMAND_MODE_RAINBOWCYCLE; } if (id === "mode-change") { hasBrightness = true; hasSpeed = true; - command = COMMAND_MODE_CHANGE; + command = COMMAND_MODE_RAINBOW; } setAnimation(); @@ -745,7 +747,7 @@ $.ready(function() { }); } - sendData(command); + sendColorData(command); setSliders(); setColors(); }); @@ -754,12 +756,13 @@ $.ready(function() { var id = $(this).get("id"); if (sleep === 0) { - getSliders(); if (id === "slider-brightness") { - sendData(COMMAND_BRIGHTNESS); + hell = $("#slider-brightness").get("value"); + sendBrightnessData(COMMAND_SET_BRIGHTNESS); } if (id === "slider-speed") { - sendData(COMMAND_SPEED); + geschw = $("#slider-speed").get("value"); + sendCmd(COMMAND_SPEED, nstr(geschw)); } setSliders(); @@ -830,17 +833,7 @@ $.ready(function() { debugMessage("Lauftext wurde neu konfiguriert"); }); $("[id*='brightness']").on("change", function() { - h6 = $("#brightness-6").get("value"); - h8 = $("#brightness-8").get("value"); - h12 = $("#brightness-12").get("value"); - h16 = $("#brightness-16").get("value"); - h18 = $("#brightness-18").get("value"); - h20 = $("#brightness-20").get("value"); - h22 = $("#brightness-22").get("value"); - h24 = $("#brightness-24").get("value"); - - sendCmd(COMMAND_SET_BRIGHTNESS, nstr(h6) + nstr(h8) + nstr(h12) + nstr(h16) + nstr(h18) + nstr(h20) + nstr(h22) + nstr(h24)); - debugMessage("Helligkeit wurde neu konfiguriert"); + sendBrightnessData(COMMAND_SET_BRIGHTNESS); }); $("#weather-button").on("click", function() {