diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 0000000..dd84ea7 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,38 @@ +--- +name: Bug report +about: Create a report to help us improve +title: '' +labels: '' +assignees: '' + +--- + +**Describe the bug** +A clear and concise description of what the bug is. + +**To Reproduce** +Steps to reproduce the behavior: +1. Go to '...' +2. Click on '....' +3. Scroll down to '....' +4. See error + +**Expected behavior** +A clear and concise description of what you expected to happen. + +**Screenshots** +If applicable, add screenshots to help explain your problem. + +**Desktop (please complete the following information):** + - OS: [e.g. iOS] + - Browser [e.g. chrome, safari] + - Version [e.g. 22] + +**Smartphone (please complete the following information):** + - Device: [e.g. iPhone6] + - OS: [e.g. iOS8.1] + - Browser [e.g. stock browser, safari] + - Version [e.g. 22] + +**Additional context** +Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 0000000..bbcbbe7 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,20 @@ +--- +name: Feature request +about: Suggest an idea for this project +title: '' +labels: '' +assignees: '' + +--- + +**Is your feature request related to a problem? Please describe.** +A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] + +**Describe the solution you'd like** +A clear and concise description of what you want to happen. + +**Describe alternatives you've considered** +A clear and concise description of any alternative solutions or features you've considered. + +**Additional context** +Add any other context or screenshots about the feature request here. diff --git a/.github/workflows/feature_build.yml b/.github/workflows/feature_build.yml index ac39fdf..855715e 100644 --- a/.github/workflows/feature_build.yml +++ b/.github/workflows/feature_build.yml @@ -52,6 +52,7 @@ jobs: - name: Upload artifacts uses: actions/upload-artifact@v4 with: + name: dtuGateway_snapshot_${{ env.CURRENT_VERSIONNUMBER }} path: | .pio/build/dtuGateway_snapshot_${{ env.CURRENT_VERSIONNUMBER }}.bin .pio/build/dtuGateway_ESP32_snapshot_${{ env.CURRENT_VERSIONNUMBER }}.bin diff --git a/doc/images/dtuGateay_OLED.jpg b/doc/images/dtuGateay_OLED.jpg new file mode 100644 index 0000000..ce35225 Binary files /dev/null and b/doc/images/dtuGateay_OLED.jpg differ diff --git a/doc/images/dtuGateay_OLED_firstStart.jpg b/doc/images/dtuGateay_OLED_firstStart.jpg new file mode 100644 index 0000000..e8ef1ed Binary files /dev/null and b/doc/images/dtuGateay_OLED_firstStart.jpg differ diff --git a/doc/images/roundTFT.jpg b/doc/images/roundTFT.jpg new file mode 100644 index 0000000..9ac93bf Binary files /dev/null and b/doc/images/roundTFT.jpg differ diff --git a/doc/images/roundTFT_firstSTart.jpg b/doc/images/roundTFT_firstSTart.jpg new file mode 100644 index 0000000..0c33a37 Binary files /dev/null and b/doc/images/roundTFT_firstSTart.jpg differ diff --git a/include/Config.h b/include/Config.h index 43e7dc5..3c8f979 100644 --- a/include/Config.h +++ b/include/Config.h @@ -2,40 +2,66 @@ #ifndef CONFIG_H #define CONFIG_H -#include #include +#include +#include -#define EEPROM_INIT_PATTERN 0xAA +#define CONFIG_FILE_PATH "/userconfig.json" struct UserConfig { - char dtuSsid[64]; - char dtuPassword[64]; - char wifiSsid[64]; - char wifiPassword[64]; - char dtuHostIp[16]; - char openhabHostIp[16]; - char openItemPrefix[32]; - boolean openhabActive; - char mqttBrokerIp[16]; - int mqttBrokerPort; - char mqttBrokerUser[64]; - char mqttBrokerPassword[64]; - char mqttBrokerMainTopic[32]; - boolean mqttActive; - int dtuCloudPauseTime; - boolean dtuCloudPauseActive; - int dtuUpdateTime; - boolean wifiAPstart; - int selectedUpdateChannel; // 0 - release 1 - snapshot - byte eepromInitialized; // specific pattern to determine floating state in EEPROM from Factory + char dtuSsid[64] = "DTUBI-12345678"; + char dtuPassword[64] = "dtubiPassword"; + + char wifiSsid[64] = "mySSID"; + char wifiPassword[64] = "myPassword"; + + char dtuHostIpDomain[128] = "192.168.0.254"; + int dtuCloudPauseTime = 40; + boolean dtuCloudPauseActive = true; + int dtuUpdateTime = 31; + + char openhabHostIpDomain[128] = "192.168.1.100"; + char openItemPrefix[32] = "inverter"; + boolean openhabActive = 0; + + char mqttBrokerIpDomain[128] = "192.168.1.100"; + int mqttBrokerPort = 1883; + boolean mqttUseTLS = false; + char mqttBrokerUser[64] = "dtuuser"; + char mqttBrokerPassword[64] = "dtupass"; + char mqttBrokerMainTopic[32] = "dtu_12345678"; + boolean mqttHAautoDiscoveryON = false; + boolean mqttActive = false; + + uint8_t displayConnected = 0; // OLED default + + boolean wifiAPstart = true; + int selectedUpdateChannel = 0; // 0 - release 1 - snapshot + int timezoneOffest = 7200; // default CEST }; extern UserConfig userConfig; -void saveConfigToEEPROM(); -void loadConfigFromEEPROM(); -void initializeEEPROM(); -void printEEPROMdata(); +// Define the UserConfigManager class +class UserConfigManager { + public: + UserConfigManager(const char *filePath = CONFIG_FILE_PATH, const UserConfig &defaultConfig = UserConfig()); + bool begin(); + bool loadConfig(UserConfig &config); + void saveConfig(const UserConfig &config); + void resetConfig(); + void printConfigdata(); + // String getWebHandler(keyAndValue_t* keyValueWebClient, unsigned int size); + String getWebHandler(JsonDocument doc); + + + private: + const char *filePath; + UserConfig defaultConfig; + JsonDocument mappingStructToJson(); + void mappingJsonToStruct(JsonDocument doc); + String createWebPage(bool updated); +}; #endif // CONFIG_H \ No newline at end of file diff --git a/include/display.h b/include/display.h new file mode 100644 index 0000000..4019864 --- /dev/null +++ b/include/display.h @@ -0,0 +1,47 @@ +#ifndef DISPLAY_H +#define DISPLAY_H + +#include + +// OLED display + +#define BRIGHTNESS_MIN 50 +#define BRIGHTNESS_MAX 250 + +struct DisplayData { + int16_t totalPower=0; // indicate current power (W) + float totalYieldDay=0.0f; // indicate day yield (Wh) + float totalYieldTotal=0.0f; // indicate total yield (kWh) + const char *formattedTime=nullptr; + const char *version=nullptr; + uint8_t powerLimit=0; + uint8_t rssiGW=0; + uint8_t rssiDTU=0; +}; + +class Display { + public: + Display(); + void setup(); + void renderScreen(String time, String version); + void drawFactoryMode(String version, String apName, String ip); + private: + void drawScreen(); + void drawHeader(); + void drawFooter(); + + void drawMainDTUOnline(bool pause=false); + void drawMainDTUOffline(); + + void screenSaver(); + void checkChangedValues(); + // private member variables + DisplayData lastDisplayData; + uint8_t brightness=BRIGHTNESS_MIN; + u8g2_uint_t offset_x = 0; // shifting for anti burn in effect + u8g2_uint_t offset_y = 0; // shifting for anti burn in effect + bool valueChanged = false; + uint16_t displayTicks = 0; // local timer state machine +}; + +#endif // DISPLAY_H \ No newline at end of file diff --git a/include/displayTFT.h b/include/displayTFT.h new file mode 100644 index 0000000..ec6899a --- /dev/null +++ b/include/displayTFT.h @@ -0,0 +1,57 @@ +#ifndef DISPLAYTFT_H +#define DISPLAYTFT_H + +#include +#include + +// TFT display + +#define BRIGHTNESS_MIN 50 +#define BRIGHTNESS_MAX 250 + +#define DARKER_GREY 0x18E3 +#define SPECIAL_BLUE 0x24ae + +struct DisplayDataTFT { + int16_t totalPower=0; // indicate current power (W) + float totalYieldDay=0.0f; // indicate day yield (Wh) + float totalYieldTotal=0.0f; // indicate total yield (kWh) + const char *formattedTime=nullptr; + const char *version=nullptr; + uint8_t powerLimit=0; + uint8_t rssiGW=0; + uint8_t rssiDTU=0; + bool stateWasOffline=false; + bool stateWasCloudPause=true; + bool stateWasNormal=false; +}; + +class DisplayTFT { + public: + DisplayTFT(); + void setup(); + void renderScreen(String time, String version); + void drawFactoryMode(String version, String apName, String ip); + private: + void drawScreen(String version, String time); + void drawHeader(String version); + void drawFooter(String time); + + void drawMainDTUOnline(bool pause=false); + void drawMainDTUOffline(); + + void screenSaver(); + void checkChangedValues(); + + void drawIcon(const uint16_t *icon, int16_t x, int16_t y, int16_t w, int16_t h); + + // private member variables + DisplayDataTFT lastDisplayData; + uint8_t brightness=BRIGHTNESS_MIN; + uint8_t offset_x = 0; // shifting for anti burn in effect + uint8_t offset_y = 0; // shifting for anti burn in effect + bool valueChanged = false; + uint16_t displayTicks = 0; // local timer state machine +}; + +#endif // DISPLAYTFT_H \ No newline at end of file diff --git a/include/dtuInterface.h b/include/dtuInterface.h index cdf4b37..08156f2 100644 --- a/include/dtuInterface.h +++ b/include/dtuInterface.h @@ -79,7 +79,7 @@ struct inverterData extern inverterData globalData; extern CRC16 crc; -void dtuConnectionEstablish(WiFiClient *localDtuClient, char localDtuHostIp[16], uint16_t localDtuPort = 10081); +void dtuConnectionEstablish(WiFiClient *localDtuClient, char localdtuHostIpDomain[16], uint16_t localDtuPort = 10081); void dtuConnectionStop(WiFiClient *localDtuClient, uint8_t tgtState); void dtuConnectionHandleError(WiFiClient *localDtuClient, unsigned long locTimeSec, uint8_t errorState = DTU_ERROR_NO_ERROR); diff --git a/include/index_html.h b/include/index_html.h index 1b17f48..25de69e 100644 --- a/include/index_html.h +++ b/include/index_html.h @@ -4,7 +4,7 @@ const char INDEX_HTML[] PROGMEM = R"=====( - HoymilesGW + dtuGateway @@ -19,7 +19,7 @@ const char INDEX_HTML[] PROGMEM = R"=====( +