Skip to content

Commit

Permalink
Merge pull request #56 from ohAnd/develop
Browse files Browse the repository at this point in the history
releasing recent improvements

closes #52 
closes #53
  • Loading branch information
ohAnd authored Oct 10, 2024
2 parents 89f6e4f + fbb5fe3 commit 37c4386
Show file tree
Hide file tree
Showing 14 changed files with 387 additions and 230 deletions.
4 changes: 1 addition & 3 deletions include/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,11 @@ struct UserConfig
uint8_t displayBrightnessDay = 100;
uint8_t displayBrightnessNight = 10;
boolean displayNightClock = false; // in night mode: true - display clock/ false - display dark screen

boolean displayNightMode = false; // night mode enabled
boolean displayNightModeOfflineTrigger = false; // night mode triggered by offline state
uint16_t displayNightmodeStart = 1320; // 22:00 = 22 * 60 = 1320
uint16_t displayNightmodeEnd = 360; // 06:00 = 6 * 60 = 360



boolean wifiAPstart = true;
int selectedUpdateChannel = 0; // 0 - release 1 - snapshot
int timezoneOffest = 7200; // default CEST
Expand Down
62 changes: 60 additions & 2 deletions include/displayTFT.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ class DisplayTFT {

void checkChangedValues();

void drawIcon(const uint16_t *icon, int16_t x, int16_t y, int16_t w, int16_t h);

void checkNightMode();
void setBrightnessAuto();

Expand All @@ -70,4 +68,64 @@ class DisplayTFT {
int8_t getPinName(int8_t pin);
};

// Icon width and height
const uint16_t cloudWidth = 32;
const uint16_t cloudHeight = 26;

const unsigned short cloud[0x340] PROGMEM ={
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x00E3, // 0x0010 (16)
0x00A1, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0020 (32)
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x02EA, 0x0532, 0x0635, 0x0696, // 0x0030 (48)
0x0676, 0x0655, 0x0510, 0x0206, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0040 (64)
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x02AA, 0x06B9, 0x06FA, 0x06F9, 0x06F8, 0x06F8, // 0x0050 (80)
0x06F8, 0x0738, 0x0799, 0x07D9, 0x06B5, 0x0123, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0060 (96)
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x03F0, 0x06DB, 0x0699, 0x0638, 0x0657, 0x0677, 0x0697, // 0x0070 (112)
0x0697, 0x06B7, 0x06D7, 0x06F7, 0x07B9, 0x07D9, 0x0206, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0080 (128)
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x036E, 0x067B, 0x0618, 0x05F8, 0x0618, 0x0638, 0x0658, 0x0677, // 0x0090 (144)
0x0677, 0x0697, 0x06B7, 0x06D7, 0x06D7, 0x0778, 0x0799, 0x0144, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x00A0 (160)
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0125, 0x063B, 0x05D9, 0x05D8, 0x05F8, 0x05F8, 0x0618, 0x0638, 0x0658, // 0x00B0 (176)
0x0657, 0x0677, 0x0697, 0x06B7, 0x06B7, 0x06D7, 0x0799, 0x06B6, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x00C0 (192)
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0495, 0x05FB, 0x0598, 0x05B8, 0x05B8, 0x05D8, 0x05F8, 0x0618, 0x0638, // 0x00D0 (208)
0x0699, 0x0658, 0x0677, 0x0677, 0x0697, 0x06B7, 0x06D7, 0x0799, 0x02C9, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x00E0 (224)
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0082, 0x05BA, 0x0579, 0x0579, 0x0598, 0x0598, 0x05B8, 0x05D8, 0x0639, 0x05F7, // 0x00F0 (240)
0x04F3, 0x0658, 0x0678, 0x0657, 0x0677, 0x0697, 0x06B7, 0x0759, 0x05D4, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0100 (256)
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x020A, 0x059B, 0x0539, 0x0559, 0x0579, 0x0578, 0x0598, 0x05F9, 0x05B8, 0x0166, // 0x0110 (272)
0x0000, 0x028A, 0x0679, 0x0678, 0x0657, 0x0677, 0x0697, 0x06D8, 0x06F8, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0120 (288)
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x028D, 0x055B, 0x0519, 0x0539, 0x0539, 0x0558, 0x05BA, 0x0578, 0x0145, 0x0000, // 0x0130 (304)
0x0000, 0x0000, 0x0269, 0x0679, 0x0658, 0x0657, 0x0677, 0x0698, 0x06D8, 0x0490, 0x01C5, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0140 (320)
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x02AE, 0x053B, 0x04F9, 0x0519, 0x0519, 0x0559, 0x0518, 0x0125, 0x0000, 0x0000, // 0x0150 (336)
0x0000, 0x0000, 0x0000, 0x0249, 0x0638, 0x0638, 0x0638, 0x0657, 0x0677, 0x0719, 0x075A, 0x0635, 0x0185, 0x0000, 0x0000, 0x0000, // 0x0160 (352)
0x0000, 0x0000, 0x0000, 0x0000, 0x00C5, 0x0374, 0x04BA, 0x04DA, 0x04D9, 0x04F9, 0x04F9, 0x059B, 0x030E, 0x0000, 0x0000, 0x0041, // 0x0170 (368)
0x0000, 0x0041, 0x0000, 0x0000, 0x04D3, 0x0659, 0x0618, 0x0638, 0x0658, 0x0677, 0x0698, 0x0739, 0x077A, 0x02CA, 0x0000, 0x0000, // 0x0180 (384)
0x0000, 0x0000, 0x0000, 0x022E, 0x04BC, 0x04DC, 0x049A, 0x0499, 0x04B9, 0x04D9, 0x04D9, 0x051A, 0x0497, 0x0209, 0x03F3, 0x01A8, // 0x0190 (400)
0x0000, 0x024A, 0x038F, 0x026A, 0x05B8, 0x05F8, 0x05F8, 0x0618, 0x0638, 0x0658, 0x0657, 0x0677, 0x06D8, 0x075A, 0x0207, 0x0000, // 0x01A0 (416)
0x0000, 0x0000, 0x022E, 0x049D, 0x045B, 0x043A, 0x045A, 0x047A, 0x049A, 0x0499, 0x04B9, 0x04D9, 0x051A, 0x057B, 0x05BC, 0x0146, // 0x01B0 (432)
0x0000, 0x024A, 0x063C, 0x05FA, 0x05B9, 0x05B8, 0x05D8, 0x05F8, 0x0618, 0x0638, 0x0638, 0x0658, 0x0677, 0x06F9, 0x06D8, 0x0020, // 0x01C0 (448)
0x0000, 0x00A4, 0x043D, 0x041B, 0x041A, 0x041A, 0x043A, 0x045A, 0x047A, 0x047A, 0x0499, 0x04B9, 0x04D9, 0x04F9, 0x055B, 0x0146, // 0x01D0 (464)
0x0000, 0x022A, 0x05DA, 0x0579, 0x0598, 0x0598, 0x05B8, 0x05D8, 0x05F8, 0x05F8, 0x0618, 0x0638, 0x0658, 0x0657, 0x0719, 0x02EA, // 0x01E0 (480)
0x0000, 0x02D4, 0x041D, 0x03DA, 0x03FA, 0x03FA, 0x041A, 0x043A, 0x045A, 0x045A, 0x047A, 0x0499, 0x04B9, 0x04D9, 0x053B, 0x0146, // 0x01F0 (496)
0x0000, 0x020A, 0x059B, 0x0559, 0x0579, 0x0578, 0x0598, 0x05B8, 0x05D8, 0x05D8, 0x05F8, 0x0618, 0x0638, 0x0638, 0x06D9, 0x0553, // 0x0200 (512)
0x0043, 0x035A, 0x03BC, 0x03BA, 0x03DA, 0x03DA, 0x03FA, 0x041A, 0x043A, 0x043A, 0x045A, 0x047A, 0x049A, 0x049A, 0x051B, 0x0146, // 0x0210 (528)
0x0000, 0x020A, 0x057B, 0x0539, 0x0559, 0x0559, 0x0578, 0x0598, 0x05B8, 0x05B8, 0x05D8, 0x05F8, 0x0618, 0x0618, 0x0679, 0x05F6, // 0x0220 (544)
0x01D0, 0x035B, 0x037B, 0x039B, 0x039B, 0x03BA, 0x03DA, 0x03FA, 0x03FA, 0x041A, 0x043A, 0x045A, 0x045A, 0x047A, 0x04DB, 0x0126, // 0x0230 (560)
0x0000, 0x020A, 0x055B, 0x0519, 0x0539, 0x0539, 0x0559, 0x0579, 0x0598, 0x0598, 0x05B8, 0x05D8, 0x05F8, 0x05F8, 0x0659, 0x05F7, // 0x0240 (576)
0x0253, 0x033B, 0x035B, 0x037B, 0x037B, 0x039B, 0x03BA, 0x03DA, 0x03DA, 0x03FA, 0x041A, 0x043A, 0x043A, 0x045A, 0x04BB, 0x0126, // 0x0250 (592)
0x0000, 0x01EA, 0x053B, 0x04F9, 0x04F9, 0x0519, 0x0539, 0x0559, 0x0559, 0x0578, 0x0598, 0x05B8, 0x05B8, 0x05D8, 0x0639, 0x05B7, // 0x0260 (608)
0x014B, 0x031B, 0x033C, 0x035B, 0x035B, 0x037B, 0x039B, 0x03BB, 0x03BA, 0x03DA, 0x03FA, 0x041A, 0x041A, 0x043A, 0x049B, 0x0106, // 0x0270 (624)
0x0000, 0x01CA, 0x051B, 0x04D9, 0x04D9, 0x04F9, 0x0519, 0x0539, 0x0539, 0x0559, 0x0579, 0x0598, 0x0598, 0x05B8, 0x063A, 0x0514, // 0x0280 (640)
0x0000, 0x02B9, 0x033D, 0x031B, 0x033B, 0x035B, 0x037B, 0x037B, 0x039B, 0x03BA, 0x03DA, 0x03FA, 0x03FA, 0x041A, 0x047C, 0x0127, // 0x0290 (656)
0x0000, 0x020B, 0x04DC, 0x04B9, 0x04B9, 0x04D9, 0x04F9, 0x0519, 0x0519, 0x0539, 0x0559, 0x0579, 0x0578, 0x0598, 0x063A, 0x02EC, // 0x02A0 (672)
0x0000, 0x018F, 0x033E, 0x02FB, 0x031B, 0x033B, 0x035B, 0x035B, 0x037B, 0x039B, 0x03BA, 0x03BA, 0x03DA, 0x03FA, 0x043B, 0x0355, // 0x02B0 (688)
0x020C, 0x03D7, 0x049A, 0x047A, 0x0499, 0x04B9, 0x04D9, 0x04D9, 0x04F9, 0x0519, 0x0539, 0x0559, 0x0559, 0x05DA, 0x05FA, 0x0020, // 0x02C0 (704)
0x0000, 0x0000, 0x02FD, 0x031E, 0x02FB, 0x031B, 0x033B, 0x033B, 0x035B, 0x037B, 0x039B, 0x039B, 0x03BA, 0x03DA, 0x03DA, 0x043B, // 0x02D0 (720)
0x047C, 0x045B, 0x043A, 0x045A, 0x047A, 0x0499, 0x04B9, 0x04B9, 0x04D9, 0x04F9, 0x0519, 0x0519, 0x057A, 0x05FB, 0x0229, 0x0000, // 0x02E0 (736)
0x0000, 0x0000, 0x0064, 0x02FE, 0x031E, 0x02FC, 0x02FB, 0x031B, 0x033B, 0x035B, 0x037B, 0x037B, 0x039B, 0x03BA, 0x03DA, 0x03DA, // 0x02F0 (752)
0x03FA, 0x041A, 0x043A, 0x043A, 0x045A, 0x047A, 0x049A, 0x0499, 0x04B9, 0x04D9, 0x04F9, 0x055B, 0x05BC, 0x02CD, 0x0000, 0x0000, // 0x0300 (768)
0x0000, 0x0000, 0x0000, 0x0022, 0x029A, 0x031F, 0x031E, 0x033D, 0x033D, 0x035D, 0x037D, 0x039D, 0x03BC, 0x03BC, 0x03DC, 0x03FC, // 0x0310 (784)
0x041C, 0x043C, 0x043C, 0x045C, 0x047B, 0x049B, 0x04BB, 0x04BB, 0x04DB, 0x051C, 0x055C, 0x051A, 0x01A8, 0x0000, 0x0000, 0x0000, // 0x0320 (800)
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x00A7, 0x01D2, 0x0256, 0x0297, 0x0297, 0x0297, 0x02B7, 0x02D7, 0x02D7, 0x02F7, 0x0317, // 0x0330 (816)
0x0316, 0x0336, 0x0356, 0x0356, 0x0376, 0x0396, 0x0396, 0x03B6, 0x03B5, 0x0311, 0x0168, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0340 (832)
};


#endif // DISPLAYTFT_H
7 changes: 5 additions & 2 deletions include/dtuInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ struct connectionControl
{
boolean preventCloudErrors = true;
boolean dtuActiveOffToCloudUpdate = false;
boolean dtuConnectionOnline = true; // true if connection is online as valued a summary
uint8_t dtuConnectState = DTU_STATE_OFFLINE;
uint8_t dtuErrorState = DTU_ERROR_NO_ERROR;
uint8_t dtuTxRxState = DTU_TXRX_STATE_IDLE;
Expand Down Expand Up @@ -142,12 +143,14 @@ class DTUInterface {
void initializeCRC();

static void txrxStateObserver();

boolean lastOnlineOfflineState = false;
unsigned long lastOnlineOfflineChange = 0;
void dtuConnectionObserver();

void checkingDataUpdate();
void checkingForLastDataReceived();
boolean cloudPauseActiveControl();

// Protobuf functions
void writeReqAppGetHistPower();
void readRespAppGetHistPower(pb_istream_t istream);
Expand Down
3 changes: 3 additions & 0 deletions include/mqttHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ struct RemoteInverterData
uint8_t powerLimit = 254;
uint32_t dtuRssi = 0;
uint32_t wifi_rssi_gateway = 0;
boolean cloudPause = false;
boolean dtuConnectionOnline = false;
uint8_t dtuConnectState = 0;
uint32_t respTimestamp = 1704063600; // init with start time stamp > 0
boolean updateReceived = false;
boolean remoteDisplayActive = false;
Expand Down
6 changes: 3 additions & 3 deletions include/version.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#define VERSION "2.0.55_localDev"
#define BUILDTIME "11.09.2024 - 21:58:24"
#define BUILDTIMESTAMP "1726084704"
#define VERSION "2.0.150_localDev"
#define BUILDTIME "09.10.2024 - 09:02:52"
#define BUILDTIMESTAMP "1728457372"
8 changes: 4 additions & 4 deletions include/version.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"version": "2.0.55_localDev",
"versiondate": "11.09.2024 - 21:58:24",
"linksnapshot": "https://github.com/ohAnd/dtuGateway/releases/download/snapshot/dtuGateway_snapshot_2.0.55_localDev.bin",
"link": "https://github.com/ohAnd/dtuGateway/releases/latest/download/dtuGateway_release_2.0.55_localDev.bin"
"version": "2.0.150_localDev",
"versiondate": "09.10.2024 - 09:02:52",
"linksnapshot": "https://github.com/ohAnd/dtuGateway/releases/download/snapshot/dtuGateway_snapshot_2.0.150_localDev.bin",
"link": "https://github.com/ohAnd/dtuGateway/releases/latest/download/dtuGateway_release_2.0.150_localDev.bin"
}
8 changes: 4 additions & 4 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ platform = espressif32
board = esp32dev
framework = arduino
monitor_speed = 115200
monitor_port = COM6
upload_port = COM6
monitor_port = COM3
upload_port = COM3
upload_speed = 921600
lib_deps =
arduino-libraries/NTPClient @ ^3.2.1
Expand Down Expand Up @@ -64,8 +64,8 @@ platform = espressif8266
board = esp07s
framework = arduino
monitor_speed = 115200
monitor_port = COM3
upload_port = COM3
monitor_port = COM5
upload_port = COM5
upload_speed = 921600
lib_deps =
arduino-libraries/NTPClient @ ^3.2.1
Expand Down
21 changes: 12 additions & 9 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,20 +109,23 @@ So I decided to put this abstraction in an **ESP8266** to have a stable abstract
- brightness day [0...255] - will also be used without night mode enabled for standard brightness (falling back to this after power value changed)
- brightness night [0...255] - note: 0 = backlight off
- (to disable PWM control for TFT without backlight control set both brightness values to zero)
- night clock - on/off - if enabled the clock will be shown at night, otherwise blank or dark screen at night
- night mode enabled on/ off
- night mode OfflineTrigger on/off - the night mode will be additionally to the schedule triggered, if dtu is offline
- night mode start in minutes to start of the day - e.g. 1320 for 22:00
- night mode stop in minutes to start of the day - e.g. 360 for 6:00
- night clock enabled on/ off - on = clock will be displayed instead of dark screen
- example settings:

| setting | value | comment |
|-----------------|-------|---------
| brightnessDay | 150 | note: 255 - ~150 only difficult to perceive
| brightnessNight | 30 |
| nightClock | true | show the clock instead of black screen during night time
| nightMode | true | night mode is enabled
| nightmodeStart | 1320 | night time will start at 22 o'clock
| nightmodeEnd | 390 | night time will end at 6:30
| setting | value | comment |
|-------------------------|-------|---------
| brightnessDay | 150 | note: 255 - ~150 only difficult to perceive
| brightnessNight | 30 |
| nightClock | true | show the clock instead of black screen during night (and/ or offline)
| nightMode | true | night mode is enabled
| nightModeOfflineTrigger | true | night mode will be also triggered if dtu is offline
| nightmodeStart | 1320 | night time will start at 22 o'clock
| nightmodeEnd | 390 | night time will end at 6:30


- display hardware types
Expand Down Expand Up @@ -392,7 +395,7 @@ So I decided to put this abstraction in an **ESP8266** to have a stable abstract
| ESP-WROOM-32 NodeMCU-32S | ESP32 | 3.3V | GND | D22/GPIO22/SCL | D21/GPIO21/SDA | OK |

- optional display GC9A01 round TFT 1,28" 240x240 (e.g. [link](https://de.aliexpress.com/i/1005006190625792.html)):
- connect SSH1106 driven round TFT display (240x240) with your ESP8266/ ESP32 board (VCC, GND, SCL, SDA, DC, CS, RST)
- connect GC9A01 driven round TFT display (240x240) with your ESP8266/ ESP32 board (VCC, GND, SCL, SDA, DC, CS, RST, BLK)
- pinning for different boards (display connector to ESPxx board pins)
- BLK = backlight control - will be served with PWM via GPIO 4

Expand Down
4 changes: 4 additions & 0 deletions src/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ void UserConfigManager::printConfigdata()
Serial.println(userConfig.displayNightClock);
Serial.print(F("display night mode: \t\t"));
Serial.println(userConfig.displayNightMode);
Serial.print(F("display night mode offline trigger: \t"));
Serial.println(userConfig.displayNightModeOfflineTrigger);
Serial.print(F("display nightmode start: \t"));
Serial.println(userConfig.displayNightmodeStart);
Serial.print(F("display nightmode end: \t\t"));
Expand Down Expand Up @@ -216,6 +218,7 @@ JsonDocument UserConfigManager::mappingStructToJson(const UserConfig &config)
doc["display"]["brightnessNight"] = config.displayBrightnessNight;
doc["display"]["nightClock"] = config.displayNightClock;
doc["display"]["nightMode"] = config.displayNightMode;
doc["display"]["nightModeOfflineTrigger"] = config.displayNightModeOfflineTrigger;
doc["display"]["nightmodeStart"] = config.displayNightmodeStart;
doc["display"]["nightmodeEnd"] = config.displayNightmodeEnd;

Expand Down Expand Up @@ -259,6 +262,7 @@ void UserConfigManager::mappingJsonToStruct(JsonDocument doc)
userConfig.displayBrightnessNight = doc["display"]["brightnessNight"];
userConfig.displayNightClock = doc["display"]["nightClock"];
userConfig.displayNightMode = doc["display"]["nightMode"];
userConfig.displayNightModeOfflineTrigger = doc["display"]["nightModeOfflineTrigger"].as<bool>();
userConfig.displayNightmodeStart = doc["display"]["nightmodeStart"];
userConfig.displayNightmodeEnd = doc["display"]["nightmodeEnd"];

Expand Down
4 changes: 2 additions & 2 deletions src/display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ void Display::drawScreen()
drawMainDTUOnline();
else if (dtuConnection.dtuConnectState == DTU_STATE_CLOUD_PAUSE)
drawMainDTUOnline(true);
else if (lastDisplayData.remoteDisplayActive)
drawMainDTUOnline();
// else if (lastDisplayData.remoteDisplayActive)
// drawMainDTUOnline();
else
drawMainDTUOffline();

Expand Down
Loading

0 comments on commit 37c4386

Please sign in to comment.