From a4c1aaaa75d7908c94eb098ea9fa30144fe364c6 Mon Sep 17 00:00:00 2001 From: dAjaY85 Date: Mon, 9 Jan 2023 01:11:10 +0100 Subject: [PATCH 1/6] Update vom MonochromeDisplay aud SSD1306. Displays werden nun mit der Lib u8g2 verwendet. --- src/platformio.ini | 43 +-- .../MonochromeDisplay/MonochromeDisplay.h | 299 +++++++++--------- 2 files changed, 150 insertions(+), 192 deletions(-) diff --git a/src/platformio.ini b/src/platformio.ini index d64a8c93a..e95109ab6 100644 --- a/src/platformio.ini +++ b/src/platformio.ini @@ -104,8 +104,8 @@ lib_deps = paulstoffregen/Time https://github.com/bertmelis/espMqttClient#v1.3.3 bblanchon/ArduinoJson - olikraus/U8g2 https://github.com/JChristensen/Timezone + olikraus/U8g2 [env:esp8266-ssd1306] platform = espressif8266 @@ -122,26 +122,8 @@ lib_deps = paulstoffregen/Time https://github.com/bertmelis/espMqttClient#v1.3.3 bblanchon/ArduinoJson - https://github.com/ThingPulse/esp8266-oled-ssd1306.git - https://github.com/JChristensen/Timezone - -[env:esp8266-sh1106] -platform = espressif8266 -board = esp12e -board_build.f_cpu = 80000000L -build_flags = -D RELEASE -DENA_SH1106 -monitor_filters = - ;default ; Remove typical terminal control codes from input - time ; Add timestamp with milliseconds for each new line - ;log2file ; Log data to a file “platformio-device-monitor-*.log” located in the current working directory -lib_deps = - https://github.com/yubox-node-org/ESPAsyncWebServer - nrf24/RF24 - paulstoffregen/Time - https://github.com/bertmelis/espMqttClient#v1.3.3 - bblanchon/ArduinoJson - https://github.com/ThingPulse/esp8266-oled-ssd1306.git https://github.com/JChristensen/Timezone + olikraus/U8g2 [env:esp32-wroom32-release] platform = espressif32 @@ -179,8 +161,8 @@ lib_deps = paulstoffregen/Time https://github.com/bertmelis/espMqttClient#v1.3.3 bblanchon/ArduinoJson - olikraus/U8g2 https://github.com/JChristensen/Timezone + olikraus/U8g2 [env:esp32-wroom32-ssd1306] platform = espressif32 @@ -199,21 +181,4 @@ lib_deps = bblanchon/ArduinoJson https://github.com/ThingPulse/esp8266-oled-ssd1306.git https://github.com/JChristensen/Timezone - -[env:esp32-wroom32-sh1106] -platform = espressif32 -board = lolin_d32 -build_flags = -D RELEASE -std=gnu++14 -DENA_SH1106 -build_unflags = -std=gnu++11 -monitor_filters = - ;default ; Remove typical terminal control codes from input - time ; Add timestamp with milliseconds for each new line - ;log2file ; Log data to a file “platformio-device-monitor-*.log” located in the current working directory -lib_deps = - https://github.com/yubox-node-org/ESPAsyncWebServer - nrf24/RF24 - paulstoffregen/Time - https://github.com/bertmelis/espMqttClient#v1.3.3 - bblanchon/ArduinoJson - https://github.com/ThingPulse/esp8266-oled-ssd1306.git - https://github.com/JChristensen/Timezone \ No newline at end of file + olikraus/U8g2 \ No newline at end of file diff --git a/src/plugins/MonochromeDisplay/MonochromeDisplay.h b/src/plugins/MonochromeDisplay/MonochromeDisplay.h index 3bfe94589..3f8c5747b 100644 --- a/src/plugins/MonochromeDisplay/MonochromeDisplay.h +++ b/src/plugins/MonochromeDisplay/MonochromeDisplay.h @@ -1,19 +1,13 @@ #ifndef __MONOCHROME_DISPLAY__ #define __MONOCHROME_DISPLAY__ -#if defined(ENA_NOKIA) || defined(ENA_SSD1306) || defined(ENA_SH1106) +/* esp8266 : SCL = 5, SDA = 4 */ +/* ewsp32 : SCL = 22, SDA = 21 */ +#if defined(ENA_NOKIA) || defined(ENA_SSD1306) +#include #ifdef ENA_NOKIA - #include #define DISP_PROGMEM U8X8_PROGMEM -#else // ENA_SSD1306 || ENA_SH1106 - /* esp8266 : SCL = 5, SDA = 4 */ - /* ewsp32 : SCL = 22, SDA = 21 */ - #include - #ifdef ENA_SSD1306 - #include - # else //ENA_SH1106 - #include - #endif +#else // ENA_SSD1306 #define DISP_PROGMEM PROGMEM #endif @@ -22,6 +16,23 @@ #include "../../utils/helper.h" #include "../../hm/hmSystem.h" +/** + * Made with Marlin Bitmap Converter + * https://marlinfw.org/tools/u8glib/converter.html + * + * This bitmap from the file 'logo1_small.png' + */ +#pragma once + +#define VEMIU_BMPWIDTH 16 + +static uint8_t bmp_logo[] PROGMEM = { + B00000000,B00000000,B00000000,B00000000,B00001100,B00100000,B00001111,B11100000, + B00000000,B00000000,B00000000,B00000000,B00000000,B00000010,B00000000,B00101000, + B00000000,B10101000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000, + B00000110,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000 +}; + static uint8_t bmp_arrow[] DISP_PROGMEM = { B00000000, B00011100, B00011100, B00001110, B00001110, B11111110, B01111111, B01110000, B01110000, B00110000, B00111000, B00011000, B01111111, B00111111, @@ -38,12 +49,10 @@ class MonochromeDisplay { mNewPayload = false; mExtra = 0; } - #else // ENA_SSD1306 || ENA_SH1106 - MonochromeDisplay() : mDisplay(0x3c, SDA, SCL), mCE(CEST, CET) { + #else // ENA_SSD1306 + MonochromeDisplay() : mDisplay(U8G2_R0, SCL, SDA, U8X8_PIN_NONE), mCE(CEST, CET) { mNewPayload = false; mExtra = 0; - mRx = 0; - mUp = 1; } #endif @@ -53,23 +62,8 @@ class MonochromeDisplay { memset( mToday, 0, sizeof(float)*MAX_NUM_INVERTERS ); memset( mTotal, 0, sizeof(float)*MAX_NUM_INVERTERS ); mLastHour = 25; - #if defined(ENA_NOKIA) mDisplay.begin(); ShowInfoText("booting..."); - #else - mDisplay.init(); - mDisplay.flipScreenVertically(); - mDisplay.setContrast(63); - mDisplay.setBrightness(63); - - mDisplay.clear(); - mDisplay.setFont(ArialMT_Plain_24); - mDisplay.setTextAlignment(TEXT_ALIGN_CENTER_BOTH); - - mDisplay.drawString(64,22,"Starting..."); - mDisplay.display(); - mDisplay.setTextAlignment(TEXT_ALIGN_LEFT); - #endif } void loop(void) { @@ -92,7 +86,6 @@ class MonochromeDisplay { } private: - #if defined(ENA_NOKIA) void ShowInfoText(const char *txt) { /* u8g2_font_open_iconic_embedded_2x_t 'D' + 'G' + 'J' */ mDisplay.clear(); @@ -116,10 +109,9 @@ class MonochromeDisplay { mDisplay.sendBuffer(); } while( mDisplay.nextPage() ); } - #endif void DataScreen(void) { - String timeStr = ah::getDateTimeStr(mCE.toLocal(*mUtcTs)).substring(2, 22); + String timeStr = ah::getDateTimeStr(mCE.toLocal(*mUtcTs)).substring(2, 16); int hr = timeStr.substring(9,2).toInt(); IPAddress ip = WiFi.localIP(); float totalYield = 0.0, totalYieldToday = 0.0, totalActual = 0.0; @@ -167,139 +159,137 @@ class MonochromeDisplay { } /* u8g2_font_open_iconic_embedded_2x_t 'D' + 'G' + 'J' */ mDisplay.clear(); - #if defined(ENA_NOKIA) mDisplay.firstPage(); do { - if(ucnt) { - mDisplay.drawXBMP(10,1,8,17,bmp_arrow); - mDisplay.setFont(u8g2_font_logisoso16_tr); - mDisplay.setCursor(25,17); - sprintf(fmtText,"%3.0f",totalActual); - mDisplay.print(String(fmtText)+F(" W")); - } - else - { - mDisplay.setFont(u8g2_font_logisoso16_tr ); - mDisplay.setCursor(10,17); - mDisplay.print(String(F("offline"))); - } - mDisplay.drawHLine(2,20,78); - mDisplay.setFont(u8g2_font_5x8_tr); - mDisplay.setCursor(5,29); - if (( num_inv < 2 ) || !(mExtra%2)) - { - sprintf(fmtText,"%4.0f",totalYieldToday); - mDisplay.print(F("today ")+String(fmtText)+F(" Wh")); - mDisplay.setCursor(5,37); - sprintf(fmtText,"%.1f",totalYield); - mDisplay.print(F("total ")+String(fmtText)+F(" kWh")); - } - else - { - int id1=(mExtra/2)%(num_inv-1); - if( pow_i[id1] ) - mDisplay.print(F("#")+String(id1+1)+F(" ")+String(pow_i[id1])+F(" W")); + #ifdef ENA_NOKIA + if(ucnt) { + mDisplay.drawXBMP(10,1,8,17,bmp_arrow); + mDisplay.setFont(u8g2_font_logisoso16_tr); + mDisplay.setCursor(25,17); + sprintf(fmtText,"%3.0f",totalActual); + mDisplay.print(String(fmtText)+F(" W")); + } else - mDisplay.print(F("#")+String(id1+1)+F(" -----")); - mDisplay.setCursor(5,37); - if( pow_i[id1+1] ) - mDisplay.print(F("#")+String(id1+2)+F(" ")+String(pow_i[id1+1])+F(" W")); + { + mDisplay.setFont(u8g2_font_logisoso16_tr ); + mDisplay.setCursor(10,17); + mDisplay.print(String(F("offline"))); + } + mDisplay.drawHLine(2,20,78); + mDisplay.setFont(u8g2_font_5x8_tr); + mDisplay.setCursor(5,29); + if (( num_inv < 2 ) || !(mExtra%2)) + { + sprintf(fmtText,"%4.0f",totalYieldToday); + mDisplay.print(F("today ")+String(fmtText)+F(" Wh")); + mDisplay.setCursor(5,37); + sprintf(fmtText,"%.1f",totalYield); + mDisplay.print(F("total ")+String(fmtText)+F(" kWh")); + } else - mDisplay.print(F("#")+String(id1+2)+F(" -----")); - } - if ( !(mExtra%10) && ip ) { - mDisplay.setCursor(5,47); - mDisplay.print(ip.toString()); - } - else { - mDisplay.setCursor(0,47); - mDisplay.print(timeStr); - } - + { + int id1=(mExtra/2)%(num_inv-1); + if( pow_i[id1] ) + mDisplay.print(F("#")+String(id1+1)+F(" ")+String(pow_i[id1])+F(" W")); + else + mDisplay.print(F("#")+String(id1+1)+F(" -----")); + mDisplay.setCursor(5,37); + if( pow_i[id1+1] ) + mDisplay.print(F("#")+String(id1+2)+F(" ")+String(pow_i[id1+1])+F(" W")); + else + mDisplay.print(F("#")+String(id1+2)+F(" -----")); + } + if ( !(mExtra%10) && ip ) { + mDisplay.setCursor(5,47); + mDisplay.print(ip.toString()); + } + else { + mDisplay.setCursor(5,47); + mDisplay.print(timeStr); + } + #else // ENA_SSD1306 + //mDisplay.drawXBM(100,5,16,16,bmp_logo); + mDisplay.setFont(u8g2_font_ncenB08_tr); + mDisplay.setCursor(90,63); + mDisplay.print(F("AHOY")); + if(ucnt) { + //=====> Actual Production + mDisplay.setPowerSave(false); + displaySleep=false; + mDisplay.setFont(u8g2_font_logisoso18_tr); + mDisplay.drawXBM(10,5,8,17,bmp_arrow); + mDisplay.setCursor(25,20); + if (totalActual>999){ + sprintf(fmtText,"%3.0f",(totalActual/1000)); + mDisplay.print(String(fmtText)+F(" kW")); + } else { + sprintf(fmtText,"%3.0f",totalActual); + mDisplay.print(String(fmtText)+F(" W")); + } + //<======================= + } + else + { + //=====> Offline + if(!displaySleep) { + displaySleepTimer = millis(); + displaySleep=true; + } + mDisplay.setFont(u8g2_font_logisoso18_tr); + mDisplay.setCursor(10,20); + mDisplay.print(String(F("offline"))); + if ((millis() - displaySleepTimer) > displaySleepDelay) { + mDisplay.setPowerSave(true); + } + //<======================= + } + mDisplay.drawLine(1, 23, 123, 23); + mDisplay.setFont(u8g2_font_ncenB10_tr); + mDisplay.setCursor(5,36); + if (( num_inv < 2 ) || !(mExtra%2)) + { + //=====> Today & Total Production + sprintf(fmtText,"%5.0f",totalYieldToday); + mDisplay.print(F("today: ")+String(fmtText)+F(" Wh")); + mDisplay.setCursor(5,50); + sprintf(fmtText,"%.1f",totalYield); + mDisplay.print(F("total: ")+String(fmtText)+F(" kWh")); + //<======================= + } + else + { + int id1=(mExtra/2)%(num_inv-1); + if( pow_i[id1] ) + mDisplay.print(F("#")+String(id1+1)+F(" ")+String(pow_i[id1])+F(" W")); + else + mDisplay.print(F("#")+String(id1+1)+F(" -----")); + mDisplay.setCursor(5,50); + if( pow_i[id1+1] ) + mDisplay.print(F("#")+String(id1+2)+F(" ")+String(pow_i[id1+1])+F(" W")); + else + mDisplay.print(F("#")+String(id1+2)+F(" -----")); + } + mDisplay.setFont(u8g2_font_5x8_tr); + if ( !(mExtra%10) && ip ) { + mDisplay.setCursor(5,63); + mDisplay.print(ip.toString()); + } + else { + mDisplay.setCursor(5,63); + mDisplay.print(timeStr); + } + #endif mDisplay.sendBuffer(); } while( mDisplay.nextPage() ); + delay(2000); mExtra++; - #else // ENA_SSD1306 || ENA_SH1106 - if(mUp) { - mRx += 2; - if(mRx >= 20) - mUp = 0; - } else { - mRx -= 2; - if(mRx <= 0) - mUp = 1; - } - int ex = 2*( mExtra % 5 ); - - if(ucnt) { - mDisplay.setBrightness(63); - mDisplay.drawXbm(10+ex,5,8,17,bmp_arrow); - mDisplay.setFont(ArialMT_Plain_24); - sprintf(fmtText,"%3.0f",totalActual); - mDisplay.drawString(25+ex,0,String(fmtText)+F(" W")); - } - else - { - mDisplay.setBrightness(1); - mDisplay.setFont(ArialMT_Plain_24); - mDisplay.drawString(25+ex,0,String(F("offline"))); - } - mDisplay.setFont(ArialMT_Plain_16); - - if (( num_inv < 2 ) || !(mExtra%2)) - { - sprintf(fmtText,"%4.0f",totalYieldToday); - mDisplay.drawString(5,22,F("today ")+String(fmtText)+F(" Wh")); - sprintf(fmtText,"%.1f",totalYield); - mDisplay.drawString(5,35,F("total ")+String(fmtText)+F(" kWh")); - } - else - { - int id1=(mExtra/2)%(num_inv-1); - if( pow_i[id1] ) - mDisplay.drawString(15,22,F("#")+String(id1+1)+F(" ")+String(pow_i[id1])+F(" W")); - else - mDisplay.drawString(15,22,F("#")+String(id1+1)+F(" -----")); - if( pow_i[id1+1] ) - mDisplay.drawString(15,35,F("#")+String(id1+2)+F(" ")+String(pow_i[id1+1])+F(" W")); - else - mDisplay.drawString(15,35,F("#")+String(id1+2)+F(" -----")); - } - mDisplay.drawLine(2,23,123,23); - - if ( (!(mExtra%10) && ip )|| (timeStr.length()<16)) - { - mDisplay.drawString(5,49,ip.toString()); - } - else - { - int w=mDisplay.getStringWidth(timeStr.c_str(),timeStr.length(),0); - if ( w>127 ) - { - String tt=timeStr.substring(9,17); - w=mDisplay.getStringWidth(tt.c_str(),tt.length(),0); - mDisplay.drawString(127-w-mRx,49,tt); - } - else - mDisplay.drawString(0,49,timeStr); - } - - mDisplay.display(); - mExtra++; - #endif } // private member variables #if defined(ENA_NOKIA) U8G2_PCD8544_84X48_1_4W_HW_SPI mDisplay; #else // ENA_SSD1306 - #ifdef ENA_SSD1306 - SSD1306Wire mDisplay; - # else //ENA_SH1106 - SH1106Wire mDisplay; - #endif - int mRx; - char mUp; + U8G2_SSD1306_128X64_NONAME_1_HW_I2C mDisplay; #endif int mExtra; bool mNewPayload; @@ -309,6 +299,9 @@ class MonochromeDisplay { int mLastHour; HMSYSTEM *mSys; Timezone mCE; + bool displaySleep; + uint32_t displaySleepTimer; + const uint32_t displaySleepDelay= 60000; }; #endif From 2504c427453e48e4249bce93314db725b2d5d16a Mon Sep 17 00:00:00 2001 From: dAjaY85 Date: Mon, 9 Jan 2023 01:20:02 +0100 Subject: [PATCH 2/6] =?UTF-8?q?update=20MonochromeDisplay,=20gel=C3=B6scht?= =?UTF-8?q?=20unn=C3=B6tigen=20Code?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MonochromeDisplay/MonochromeDisplay.h | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/src/plugins/MonochromeDisplay/MonochromeDisplay.h b/src/plugins/MonochromeDisplay/MonochromeDisplay.h index 3f8c5747b..12007948f 100644 --- a/src/plugins/MonochromeDisplay/MonochromeDisplay.h +++ b/src/plugins/MonochromeDisplay/MonochromeDisplay.h @@ -16,23 +16,6 @@ #include "../../utils/helper.h" #include "../../hm/hmSystem.h" -/** - * Made with Marlin Bitmap Converter - * https://marlinfw.org/tools/u8glib/converter.html - * - * This bitmap from the file 'logo1_small.png' - */ -#pragma once - -#define VEMIU_BMPWIDTH 16 - -static uint8_t bmp_logo[] PROGMEM = { - B00000000,B00000000,B00000000,B00000000,B00001100,B00100000,B00001111,B11100000, - B00000000,B00000000,B00000000,B00000000,B00000000,B00000010,B00000000,B00101000, - B00000000,B10101000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000, - B00000110,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000 -}; - static uint8_t bmp_arrow[] DISP_PROGMEM = { B00000000, B00011100, B00011100, B00001110, B00001110, B11111110, B01111111, B01110000, B01110000, B00110000, B00111000, B00011000, B01111111, B00111111, From a60980d38a5fb0e47e866ec7e0f8bcbd032ac34d Mon Sep 17 00:00:00 2001 From: dAjaY85 Date: Mon, 9 Jan 2023 13:22:52 +0100 Subject: [PATCH 3/6] Update MonoDisplay --- src/platformio.ini | 37 +++++++++++++ .../MonochromeDisplay/MonochromeDisplay.h | 55 +++++++++++++++---- 2 files changed, 81 insertions(+), 11 deletions(-) diff --git a/src/platformio.ini b/src/platformio.ini index e95109ab6..897cd451b 100644 --- a/src/platformio.ini +++ b/src/platformio.ini @@ -125,6 +125,24 @@ lib_deps = https://github.com/JChristensen/Timezone olikraus/U8g2 +[env:esp8266-sh1106] +platform = espressif8266 +board = esp12e +board_build.f_cpu = 80000000L +build_flags = -D RELEASE -DENA_SH1106 +monitor_filters = + ;default ; Remove typical terminal control codes from input + time ; Add timestamp with milliseconds for each new line + ;log2file ; Log data to a file “platformio-device-monitor-*.log” located in the current working directory +lib_deps = + https://github.com/yubox-node-org/ESPAsyncWebServer + nrf24/RF24 + paulstoffregen/Time + https://github.com/bertmelis/espMqttClient#v1.3.3 + bblanchon/ArduinoJson + https://github.com/JChristensen/Timezone + olikraus/U8g2 + [env:esp32-wroom32-release] platform = espressif32 board = lolin_d32 @@ -169,6 +187,25 @@ platform = espressif32 board = lolin_d32 build_flags = -D RELEASE -std=gnu++14 -DENA_SSD1306 build_unflags = -std=gnu++11 +monitor_filters = + ;default ; Remove typical terminal control codes from input + time ; Add timestamp with milliseconds for each new line + ;log2file ; Log data to a file “platformio-device-monitor-*.log” located in the current working directory +lib_deps = + https://github.com/yubox-node-org/ESPAsyncWebServer + nrf24/RF24 + paulstoffregen/Time + https://github.com/bertmelis/espMqttClient#v1.3.3 + bblanchon/ArduinoJson + https://github.com/ThingPulse/esp8266-oled-ssd1306.git + https://github.com/JChristensen/Timezone + olikraus/U8g2 + +[env:esp32-wroom32-sh1106] +platform = espressif32 +board = lolin_d32 +build_flags = -D RELEASE -std=gnu++14 -DENA_SH1106 +build_unflags = -std=gnu++11 monitor_filters = ;default ; Remove typical terminal control codes from input time ; Add timestamp with milliseconds for each new line diff --git a/src/plugins/MonochromeDisplay/MonochromeDisplay.h b/src/plugins/MonochromeDisplay/MonochromeDisplay.h index 12007948f..e081f29b8 100644 --- a/src/plugins/MonochromeDisplay/MonochromeDisplay.h +++ b/src/plugins/MonochromeDisplay/MonochromeDisplay.h @@ -3,11 +3,11 @@ /* esp8266 : SCL = 5, SDA = 4 */ /* ewsp32 : SCL = 22, SDA = 21 */ -#if defined(ENA_NOKIA) || defined(ENA_SSD1306) +#if defined(ENA_NOKIA) || defined(ENA_SSD1306) || defined(ENA_SH1106) #include #ifdef ENA_NOKIA #define DISP_PROGMEM U8X8_PROGMEM -#else // ENA_SSD1306 +#else // ENA_SSD1306 || ENA_SH1106 #define DISP_PROGMEM PROGMEM #endif @@ -16,6 +16,27 @@ #include "../../utils/helper.h" #include "../../hm/hmSystem.h" + +static uint8_t bmp_logo[] PROGMEM = { + B00000000,B00000000, // ................ + B11101100,B00110111, // ..##.######.##.. + B11101100,B00110111, // ..##.######.##.. + B11100000,B00000111, // .....######..... + B11010000,B00001011, // ....#.####.#.... + B10011000,B00011001, // ...##..##..##... + B10000000,B00000001, // .......##....... + B00000000,B00000000, // ................ + B01111000,B00011110, // ...####..####... + B11111100,B00111111, // ..############.. + B01111100,B00111110, // ..#####..#####.. + B00000000,B00000000, // ................ + B11111100,B00111111, // ..############.. + B11111110,B01111111, // .##############. + B01111110,B01111110, // .######..######. + B00000000,B00000000 // ................ +}; + + static uint8_t bmp_arrow[] DISP_PROGMEM = { B00000000, B00011100, B00011100, B00001110, B00001110, B11111110, B01111111, B01110000, B01110000, B00110000, B00111000, B00011000, B01111111, B00111111, @@ -27,12 +48,12 @@ static TimeChangeRule CET = {"CET ", Last, Sun, Oct, 3, 60}; // Central Eu template class MonochromeDisplay { public: - #if defined(ENA_NOKIA) + #ifdef ENA_NOKIA MonochromeDisplay() : mDisplay(U8G2_R0, 5, 4, 16), mCE(CEST, CET) { mNewPayload = false; mExtra = 0; } - #else // ENA_SSD1306 + #else // ENA_SSD1306 || ENA_SH1106 MonochromeDisplay() : mDisplay(U8G2_R0, SCL, SDA, U8X8_PIN_NONE), mCE(CEST, CET) { mNewPayload = false; mExtra = 0; @@ -146,17 +167,27 @@ class MonochromeDisplay { do { #ifdef ENA_NOKIA if(ucnt) { + //=====> Actual Production mDisplay.drawXBMP(10,1,8,17,bmp_arrow); mDisplay.setFont(u8g2_font_logisoso16_tr); mDisplay.setCursor(25,17); - sprintf(fmtText,"%3.0f",totalActual); - mDisplay.print(String(fmtText)+F(" W")); + if (totalActual>999){ + sprintf(fmtText,"%3.0f",(totalActual/1000)); + mDisplay.print(String(fmtText)+F(" kW")); + } else { + sprintf(fmtText,"%3.0f",totalActual); + mDisplay.print(String(fmtText)+F(" W")); + } + //<======================= } else { + //=====> Offline mDisplay.setFont(u8g2_font_logisoso16_tr ); mDisplay.setCursor(10,17); mDisplay.print(String(F("offline"))); + //<======================= + } mDisplay.drawHLine(2,20,78); mDisplay.setFont(u8g2_font_5x8_tr); @@ -191,7 +222,7 @@ class MonochromeDisplay { mDisplay.print(timeStr); } #else // ENA_SSD1306 - //mDisplay.drawXBM(100,5,16,16,bmp_logo); + mDisplay.drawXBM(106,5,16,16,bmp_logo); mDisplay.setFont(u8g2_font_ncenB08_tr); mDisplay.setCursor(90,63); mDisplay.print(F("AHOY")); @@ -226,7 +257,7 @@ class MonochromeDisplay { } //<======================= } - mDisplay.drawLine(1, 23, 123, 23); + mDisplay.drawLine(2, 23, 123, 23); mDisplay.setFont(u8g2_font_ncenB10_tr); mDisplay.setCursor(5,36); if (( num_inv < 2 ) || !(mExtra%2)) @@ -264,15 +295,17 @@ class MonochromeDisplay { #endif mDisplay.sendBuffer(); } while( mDisplay.nextPage() ); - delay(2000); + delay(500); mExtra++; } // private member variables - #if defined(ENA_NOKIA) + #ifdef ENA_NOKIA U8G2_PCD8544_84X48_1_4W_HW_SPI mDisplay; - #else // ENA_SSD1306 + #elif defined(ENA_SSD1306) U8G2_SSD1306_128X64_NONAME_1_HW_I2C mDisplay; + #elif defined(ENA_SH1106) + U8G2_SH1106_128X64_NONAME_1_HW_I2C mDisplay; #endif int mExtra; bool mNewPayload; From 8827e11cec5c44f16f1240aeb779e9f3bc7f21ee Mon Sep 17 00:00:00 2001 From: dAjaY85 Date: Mon, 9 Jan 2023 13:37:17 +0100 Subject: [PATCH 4/6] =?UTF-8?q?=C3=84nderung=20beim=20Anzeigen=20ActualPro?= =?UTF-8?q?duction=20in=20kW=20mit=201=20Nachkommastelle.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/plugins/MonochromeDisplay/MonochromeDisplay.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/MonochromeDisplay/MonochromeDisplay.h b/src/plugins/MonochromeDisplay/MonochromeDisplay.h index e081f29b8..0b5417302 100644 --- a/src/plugins/MonochromeDisplay/MonochromeDisplay.h +++ b/src/plugins/MonochromeDisplay/MonochromeDisplay.h @@ -172,7 +172,7 @@ class MonochromeDisplay { mDisplay.setFont(u8g2_font_logisoso16_tr); mDisplay.setCursor(25,17); if (totalActual>999){ - sprintf(fmtText,"%3.0f",(totalActual/1000)); + sprintf(fmtText,"%2.1f",(totalActual/1000)); mDisplay.print(String(fmtText)+F(" kW")); } else { sprintf(fmtText,"%3.0f",totalActual); @@ -234,7 +234,7 @@ class MonochromeDisplay { mDisplay.drawXBM(10,5,8,17,bmp_arrow); mDisplay.setCursor(25,20); if (totalActual>999){ - sprintf(fmtText,"%3.0f",(totalActual/1000)); + sprintf(fmtText,"%2.1f",(totalActual/1000)); mDisplay.print(String(fmtText)+F(" kW")); } else { sprintf(fmtText,"%3.0f",totalActual); From 11b34ead2db2fa854f4a04e23718631c8ffac32f Mon Sep 17 00:00:00 2001 From: dAjaY85 Date: Mon, 9 Jan 2023 13:50:41 +0100 Subject: [PATCH 5/6] =?UTF-8?q?AHOY=20Schriftzug=20unten=20rechts=20entfer?= =?UTF-8?q?nt,=20da=20Display=20=C3=BCberladen=20aussah.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/plugins/MonochromeDisplay/MonochromeDisplay.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/plugins/MonochromeDisplay/MonochromeDisplay.h b/src/plugins/MonochromeDisplay/MonochromeDisplay.h index 0b5417302..9fc28c9fb 100644 --- a/src/plugins/MonochromeDisplay/MonochromeDisplay.h +++ b/src/plugins/MonochromeDisplay/MonochromeDisplay.h @@ -224,8 +224,6 @@ class MonochromeDisplay { #else // ENA_SSD1306 mDisplay.drawXBM(106,5,16,16,bmp_logo); mDisplay.setFont(u8g2_font_ncenB08_tr); - mDisplay.setCursor(90,63); - mDisplay.print(F("AHOY")); if(ucnt) { //=====> Actual Production mDisplay.setPowerSave(false); From 7e14377341fc3031fc6d57d1fc0220a30c31bc5c Mon Sep 17 00:00:00 2001 From: dAjaY85 Date: Tue, 10 Jan 2023 21:56:45 +0100 Subject: [PATCH 6/6] =?UTF-8?q?pxZittern=20wieder=20eingef=C3=BCgt=20+(0-8?= =?UTF-8?q?px).?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MonochromeDisplay/MonochromeDisplay.h | 38 +++++++++---------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/src/plugins/MonochromeDisplay/MonochromeDisplay.h b/src/plugins/MonochromeDisplay/MonochromeDisplay.h index 9fc28c9fb..51c105db4 100644 --- a/src/plugins/MonochromeDisplay/MonochromeDisplay.h +++ b/src/plugins/MonochromeDisplay/MonochromeDisplay.h @@ -222,15 +222,18 @@ class MonochromeDisplay { mDisplay.print(timeStr); } #else // ENA_SSD1306 - mDisplay.drawXBM(106,5,16,16,bmp_logo); + mDisplay.setContrast(60); + // pxZittern in +x (0 - 8 px) + int ex = 2*( mExtra % 5 ); + mDisplay.drawXBM(100+ex,2,16,16,bmp_logo); mDisplay.setFont(u8g2_font_ncenB08_tr); if(ucnt) { //=====> Actual Production mDisplay.setPowerSave(false); displaySleep=false; mDisplay.setFont(u8g2_font_logisoso18_tr); - mDisplay.drawXBM(10,5,8,17,bmp_arrow); - mDisplay.setCursor(25,20); + mDisplay.drawXBM(10+ex,2,8,17,bmp_arrow); + mDisplay.setCursor(25+ex,20); if (totalActual>999){ sprintf(fmtText,"%2.1f",(totalActual/1000)); mDisplay.print(String(fmtText)+F(" kW")); @@ -248,52 +251,47 @@ class MonochromeDisplay { displaySleep=true; } mDisplay.setFont(u8g2_font_logisoso18_tr); - mDisplay.setCursor(10,20); + mDisplay.setCursor(10+ex,20); mDisplay.print(String(F("offline"))); if ((millis() - displaySleepTimer) > displaySleepDelay) { mDisplay.setPowerSave(true); } //<======================= } - mDisplay.drawLine(2, 23, 123, 23); + mDisplay.drawLine(2+ex, 23, 123, 23); mDisplay.setFont(u8g2_font_ncenB10_tr); - mDisplay.setCursor(5,36); + mDisplay.setCursor(2+ex,36); if (( num_inv < 2 ) || !(mExtra%2)) { //=====> Today & Total Production sprintf(fmtText,"%5.0f",totalYieldToday); mDisplay.print(F("today: ")+String(fmtText)+F(" Wh")); - mDisplay.setCursor(5,50); + mDisplay.setCursor(2+ex,50); sprintf(fmtText,"%.1f",totalYield); mDisplay.print(F("total: ")+String(fmtText)+F(" kWh")); //<======================= - } - else - { + } else { int id1=(mExtra/2)%(num_inv-1); if( pow_i[id1] ) mDisplay.print(F("#")+String(id1+1)+F(" ")+String(pow_i[id1])+F(" W")); else mDisplay.print(F("#")+String(id1+1)+F(" -----")); - mDisplay.setCursor(5,50); + mDisplay.setCursor(5+ex,50); if( pow_i[id1+1] ) mDisplay.print(F("#")+String(id1+2)+F(" ")+String(pow_i[id1+1])+F(" W")); else mDisplay.print(F("#")+String(id1+2)+F(" -----")); } mDisplay.setFont(u8g2_font_5x8_tr); - if ( !(mExtra%10) && ip ) { - mDisplay.setCursor(5,63); + mDisplay.setCursor(5+ex,63); + if ( !(mExtra%10) && ip ) mDisplay.print(ip.toString()); - } - else { - mDisplay.setCursor(5,63); + else mDisplay.print(timeStr); - } #endif mDisplay.sendBuffer(); } while( mDisplay.nextPage() ); - delay(500); + delay(200); mExtra++; } @@ -301,9 +299,9 @@ class MonochromeDisplay { #ifdef ENA_NOKIA U8G2_PCD8544_84X48_1_4W_HW_SPI mDisplay; #elif defined(ENA_SSD1306) - U8G2_SSD1306_128X64_NONAME_1_HW_I2C mDisplay; + U8G2_SSD1306_128X64_NONAME_F_HW_I2C mDisplay; #elif defined(ENA_SH1106) - U8G2_SH1106_128X64_NONAME_1_HW_I2C mDisplay; + U8G2_SH1106_128X64_NONAME_F_HW_I2C mDisplay; #endif int mExtra; bool mNewPayload;