Skip to content

Commit

Permalink
Merge pull request #58 from ohAnd/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
ohAnd authored Oct 17, 2024
2 parents 37c4386 + f1906c7 commit 7c90095
Show file tree
Hide file tree
Showing 11 changed files with 63 additions and 29 deletions.
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"files.associations": {
"ranges": "cpp",
"string": "cpp",
"map": "cpp"
"map": "cpp",
"cmath": "cpp"
}
}
19 changes: 10 additions & 9 deletions include/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,22 @@ struct UserConfig
boolean mqttHAautoDiscoveryON = false;
boolean mqttActive = false;

boolean remoteDisplayActive = false; // remote display to get data from mqtt
boolean remoteDisplayActive = false; // remote display to get data from mqtt

uint8_t displayConnected = 0; // OLED default
uint16_t displayOrientation = 0; // OLED 0,180 degrees - TFT 0,90,180,270 degrees
uint8_t displayConnected = 0; // OLED default
uint16_t displayOrientation = 0; // OLED 0,180 degrees - TFT 0,90,180,270 degrees
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 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
uint16_t displayNightmodeStart = 1320; // 22:00 = 22 * 60 = 1320
uint16_t displayNightmodeEnd = 360; // 06:00 = 6 * 60 = 360
boolean displayTFTsecondsRing = true; // TFT display seconds ring

boolean wifiAPstart = true;
int selectedUpdateChannel = 0; // 0 - release 1 - snapshot
int timezoneOffest = 7200; // default CEST
int selectedUpdateChannel = 0; // 0 - release 1 - snapshot
int timezoneOffest = 7200; // default CEST
};

extern UserConfig userConfig;
Expand Down
11 changes: 11 additions & 0 deletions include/base/platformData.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,17 @@ struct baseDataStruct
boolean esp32 = false;
String espUniqueName = String(AP_NAME_START) + "_" + chipID;

#if defined(ESP8266)
String chipType = "ESP8266";
#warning "setting chipType for ESP8266"
#elif CONFIG_IDF_TARGET_ESP32
String chipType = "ESP32";
#warning "setting chipType for ESP32"
#elif CONFIG_IDF_TARGET_ESP32S2
String chipType = "ESP32 S2 (LOLIN S2 Mini)";
#warning "setting chipType for ESP32S2"
#endif

const char *fwVersion = VERSION;
const char *fwBuildDate = BUILDTIME;

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.150_localDev"
#define BUILDTIME "09.10.2024 - 09:02:52"
#define BUILDTIMESTAMP "1728457372"
#define VERSION "2.0.189_localDev"
#define BUILDTIME "16.10.2024 - 23:11:41"
#define BUILDTIMESTAMP "1729113101"
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.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"
"version": "2.0.189_localDev",
"versiondate": "16.10.2024 - 23:11:41",
"linksnapshot": "https://github.com/ohAnd/dtuGateway/releases/download/snapshot/dtuGateway_snapshot_2.0.189_localDev.bin",
"link": "https://github.com/ohAnd/dtuGateway/releases/latest/download/dtuGateway_release_2.0.189_localDev.bin"
}
3 changes: 3 additions & 0 deletions include/web/index_html.h
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,8 @@ const char INDEX_HTML[] PROGMEM = R"=====(
</div>
<div class="popup" id="updateMenu">
<h2>Update</h2>
<h6 id="chipType">controller architecture type: ...</h6>
<hr>
<div style="padding-bottom: 10px;">
<div style="padding-bottom: 10px;"></div>
Expand Down Expand Up @@ -668,6 +670,7 @@ const char INDEX_HTML[] PROGMEM = R"=====(
$('#rssitext_dtu').html(wifiDTUPercent + '%');
$('#firmware').html("fw version: " + data.firmware.version);
$('#chipType').html("controller architecture type: " + data.chipType);
if (data.firmware.selectedUpdateChannel == 0) { $("#relChanStable").addClass("selected"); $("#relChanSnapshot").removeClass("selected"); }
else { $("#relChanStable").removeClass("selected"); $("#relChanSnapshot").addClass("selected"); }
Expand Down
3 changes: 3 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ So I decided to put this abstraction in an **ESP8266** to have a stable abstract
- 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
- TFT display only: enable/ disable the seconds ring (red) - if diabled only the static ring is visible and in nightmode there is no ring displayed
- example settings:

| setting | value | comment |
Expand All @@ -126,6 +127,7 @@ So I decided to put this abstraction in an **ESP8266** to have a stable abstract
| 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
| displayTFTsecondsRing | true | seconds ring in TFT display is enabled


- display hardware types
Expand Down Expand Up @@ -227,6 +229,7 @@ So I decided to put this abstraction in an **ESP8266** to have a stable abstract
```json
{
"chipid": 123456,
"chipType": "ESP32",
"host": "dtuGateway_123456",
"initMode": 0,
"firmware": {
Expand Down
4 changes: 4 additions & 0 deletions src/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,8 @@ void UserConfigManager::printConfigdata()
Serial.println(userConfig.displayNightmodeStart);
Serial.print(F("display nightmode end: \t\t"));
Serial.println(userConfig.displayNightmodeEnd);
Serial.print(F("display TFT seconds ring: \t"));
Serial.println(userConfig.displayTFTsecondsRing);

Serial.print(F("--------------------------------------\n"));
}
Expand Down Expand Up @@ -221,6 +223,7 @@ JsonDocument UserConfigManager::mappingStructToJson(const UserConfig &config)
doc["display"]["nightModeOfflineTrigger"] = config.displayNightModeOfflineTrigger;
doc["display"]["nightmodeStart"] = config.displayNightmodeStart;
doc["display"]["nightmodeEnd"] = config.displayNightmodeEnd;
doc["display"]["TFTsecondsRing"] = config.displayTFTsecondsRing;

doc["local"]["selectedUpdateChannel"] = config.selectedUpdateChannel;
doc["local"]["wifiAPstart"] = config.wifiAPstart;
Expand Down Expand Up @@ -265,6 +268,7 @@ void UserConfigManager::mappingJsonToStruct(JsonDocument doc)
userConfig.displayNightModeOfflineTrigger = doc["display"]["nightModeOfflineTrigger"].as<bool>();
userConfig.displayNightmodeStart = doc["display"]["nightmodeStart"];
userConfig.displayNightmodeEnd = doc["display"]["nightmodeEnd"];
userConfig.displayTFTsecondsRing = doc["display"]["TFTsecondsRing"].as<bool>();

userConfig.selectedUpdateChannel = doc["local"]["selectedUpdateChannel"];
userConfig.wifiAPstart = doc["local"]["wifiAPstart"];
Expand Down
1 change: 1 addition & 0 deletions src/base/webserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ void DTUwebserver::handleInfojson(AsyncWebServerRequest *request)
{
String JSON = "{";
JSON = JSON + "\"chipid\": " + String(platformData.chipID) + ",";
JSON = JSON + "\"chipType\": \"" + platformData.chipType + "\",";
JSON = JSON + "\"host\": \"" + platformData.espUniqueName + "\",";
JSON = JSON + "\"initMode\": " + userConfig.wifiAPstart + ",";

Expand Down
17 changes: 11 additions & 6 deletions src/display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ void Display::drawScreen()
{
// store last shown value
lastDisplayData.totalYieldDay = dtuGlobalData.grid.dailyEnergy;
lastDisplayData.totalYieldTotal = round(dtuGlobalData.grid.totalEnergy);
lastDisplayData.totalYieldTotal = dtuGlobalData.grid.totalEnergy;
lastDisplayData.rssiGW = dtuGlobalData.wifi_rssi_gateway;
lastDisplayData.rssiDTU = dtuGlobalData.dtuRssi;
lastDisplayData.totalPower = round(dtuGlobalData.grid.power);
Expand Down Expand Up @@ -269,11 +269,16 @@ void Display::drawFooter()
u8g2.drawRFrame(0 + offset_x, 54 + offset_y, 127, 14, 4);
// footer - content
u8g2.setFont(u8g2_font_5x7_tf);
// u8g2.drawStr(3 + offset_x, 57 + offset_y, lastDisplayData.formattedTime);
// u8g2.drawStr(3 + 11 * 4 + offset_x, 57 + offset_y, "FW:");
// u8g2.drawStr(3 + 11 * 4 + 4 * 4 + offset_x, 57 + offset_y, lastDisplayData.version);
u8g2.drawStr(3 + offset_x, 56 + offset_y, ("d: " + String(lastDisplayData.totalYieldDay, 3) + " kWh").c_str());
u8g2.drawStr(3 + 18 * 4 + offset_x, 56 + offset_y, ("t: " + String(lastDisplayData.totalYieldTotal, 0) + " kWh").c_str());

String yieldDay = String(lastDisplayData.totalYieldDay, 3) + " kWh";
u8g2.drawStr(3 + offset_x, 56 + offset_y, String("d:").c_str());
u8g2.drawStr(14 + offset_x, 56 + offset_y, yieldDay.c_str());

String yieldTotal = String(lastDisplayData.totalYieldTotal, 1) + " kWh";
u8g2_uint_t width = u8g2.getUTF8Width(yieldTotal.c_str());
int yieldTotal_xpos = (124 - width);
u8g2.drawStr(yieldTotal_xpos - 11 + offset_x, 56 + offset_y, String("t:").c_str());
u8g2.drawStr(yieldTotal_xpos + offset_x, 56 + offset_y, yieldTotal.c_str());
}

void Display::checkChangedValues()
Expand Down
17 changes: 11 additions & 6 deletions src/displayTFT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ void DisplayTFT::drawScreen(String version, String time)
{
// store last shown value
lastDisplayData.totalYieldDay = dtuGlobalData.grid.dailyEnergy;
lastDisplayData.totalYieldTotal = round(dtuGlobalData.grid.totalEnergy);
lastDisplayData.totalYieldTotal = dtuGlobalData.grid.totalEnergy;
lastDisplayData.rssiGW = dtuGlobalData.wifi_rssi_gateway;
lastDisplayData.rssiDTU = dtuGlobalData.dtuRssi;
lastDisplayData.totalPower = round(dtuGlobalData.grid.power);
Expand Down Expand Up @@ -272,12 +272,14 @@ void DisplayTFT::drawFooter(String time)
tft.drawCentreString(time, 120, 174, 4);

tft.setTextColor(TFT_DARKCYAN, TFT_BLACK);
tft.drawCentreString("day", 85, 215, 1);
tft.drawCentreString("day", 85, 215, 1);
tft.drawCentreString("kWh", 120, 215, 1);
tft.drawCentreString("total", 155, 215, 1);
tft.drawCentreString("yield", 120, 225, 1);
tft.drawCentreString("total", 153, 215, 1);

tft.setTextColor(TFT_CYAN, TFT_BLACK);
tft.drawCentreString(String(lastDisplayData.totalYieldDay, 3) + " kWh", 85, 198, 2);
tft.drawCentreString(String(lastDisplayData.totalYieldTotal, 0) + " kWh", 160, 198, 2);
tft.drawCentreString(String(lastDisplayData.totalYieldDay, 3), 85, 198, 2);
tft.drawCentreString(String(lastDisplayData.totalYieldTotal, 1), 155, 198, 2);
}
else if (userConfig.displayNightClock) // if it is night then show the clock
{
Expand Down Expand Up @@ -305,7 +307,7 @@ void DisplayTFT::drawFooter(String time)
tft.fillScreen(TFT_BLACK);
}

// show second clock ring only if it is not night or it is night and night clock is enabled
// show second clock ring only if generally enabled and if it is not night or it is night and night clock is enabled
if (!isNight || (isNight && userConfig.displayNightClock))
{
uint32_t secActiveRingColor = isNight ? TFT_MAROON : TFT_RED;
Expand All @@ -318,6 +320,9 @@ void DisplayTFT::drawFooter(String time)
int sec = (time.substring(time.lastIndexOf(":") + 1)).toInt();
int secpoint = (sec * 6) + 180;

if(userConfig.displayTFTsecondsRing == false)
sec = 0;

// black circle
if (sec < 31)
{
Expand Down

0 comments on commit 7c90095

Please sign in to comment.