diff --git a/include/cloud.h b/include/cloud.h deleted file mode 100644 index 59670cb..0000000 --- a/include/cloud.h +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef CLOUD_H -#define CLOUD_H - -#define config_PullServer "http://paperdash.sonic.da-tom.com/gateway.php/" - -void setupCloud(); -void loopCloud(); - -bool pullData(); - -#endif \ No newline at end of file diff --git a/include/imageWBMP.h b/include/imageWBMP.h deleted file mode 100644 index d3fa54a..0000000 --- a/include/imageWBMP.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef IMAGE_WBMP_H -#define IMAGE_WBMP_H - -#include - -// @see https://en.wikipedia.org/wiki/Wireless_Application_Protocol_Bitmap_Format -// 0 0 133 0 131 0 -const char ImageHeaderWBMP[] = "\x0\x0\x85\x0\x83\x0"; - -void setupImageWBMP(); - -void wbmpOpenFramebuffer(); -void wbmpWriteFramebuffer(int offset, uint8_t bitmap[], int c); -void wbmpFlushFramebuffer(); - -#endif \ No newline at end of file diff --git a/src/app.cpp b/lib/app/app.cpp similarity index 100% rename from src/app.cpp rename to lib/app/app.cpp diff --git a/include/app.h b/lib/app/app.h similarity index 100% rename from include/app.h rename to lib/app/app.h diff --git a/src/datetime.cpp b/lib/datetime/datetime.cpp similarity index 100% rename from src/datetime.cpp rename to lib/datetime/datetime.cpp diff --git a/include/datetime.h b/lib/datetime/datetime.h similarity index 100% rename from include/datetime.h rename to lib/datetime/datetime.h diff --git a/src/device.cpp b/lib/device/device.cpp similarity index 100% rename from src/device.cpp rename to lib/device/device.cpp diff --git a/include/device.h b/lib/device/device.h similarity index 100% rename from include/device.h rename to lib/device/device.h diff --git a/src/display.cpp b/lib/display/display.cpp similarity index 100% rename from src/display.cpp rename to lib/display/display.cpp diff --git a/include/display.h b/lib/display/display.h similarity index 100% rename from include/display.h rename to lib/display/display.h diff --git a/src/download.cpp b/lib/download/download.cpp similarity index 100% rename from src/download.cpp rename to lib/download/download.cpp diff --git a/include/download.h b/lib/download/download.h similarity index 100% rename from include/download.h rename to lib/download/download.h diff --git a/src/faceCalendar.cpp b/lib/face/faceCalendar.cpp similarity index 99% rename from src/faceCalendar.cpp rename to lib/face/faceCalendar.cpp index 15c7efb..27534f6 100644 --- a/src/faceCalendar.cpp +++ b/lib/face/faceCalendar.cpp @@ -1,11 +1,9 @@ #include #include #include -#include #include "faceCalendar.h" #include "display.h" #include "datetime.h" -#include "tools.h" #include "image.h" #include "download.h" #include "faceWeather.h" diff --git a/include/faceCalendar.h b/lib/face/faceCalendar.h similarity index 100% rename from include/faceCalendar.h rename to lib/face/faceCalendar.h diff --git a/src/faceWeather.cpp b/lib/face/faceWeather.cpp similarity index 100% rename from src/faceWeather.cpp rename to lib/face/faceWeather.cpp diff --git a/include/faceWeather.h b/lib/face/faceWeather.h similarity index 100% rename from include/faceWeather.h rename to lib/face/faceWeather.h diff --git a/src/faceWeatherIcons.cpp b/lib/face/faceWeatherIcons.cpp similarity index 100% rename from src/faceWeatherIcons.cpp rename to lib/face/faceWeatherIcons.cpp diff --git a/include/faceWeatherIcons.h b/lib/face/faceWeatherIcons.h similarity index 100% rename from include/faceWeatherIcons.h rename to lib/face/faceWeatherIcons.h diff --git a/src/image.cpp b/lib/image/image.cpp similarity index 100% rename from src/image.cpp rename to lib/image/image.cpp diff --git a/include/image.h b/lib/image/image.h similarity index 100% rename from include/image.h rename to lib/image/image.h diff --git a/src/imageJPEG.cpp b/lib/image/imageJPEG.cpp similarity index 100% rename from src/imageJPEG.cpp rename to lib/image/imageJPEG.cpp diff --git a/include/imageJPEG.h b/lib/image/imageJPEG.h similarity index 100% rename from include/imageJPEG.h rename to lib/image/imageJPEG.h diff --git a/src/imagePNG.cpp b/lib/image/imagePNG.cpp similarity index 100% rename from src/imagePNG.cpp rename to lib/image/imagePNG.cpp diff --git a/include/imagePNG.h b/lib/image/imagePNG.h similarity index 100% rename from include/imagePNG.h rename to lib/image/imagePNG.h diff --git a/src/playlist.cpp b/lib/playlist/playlist.cpp similarity index 100% rename from src/playlist.cpp rename to lib/playlist/playlist.cpp diff --git a/include/playlist.h b/lib/playlist/playlist.h similarity index 100% rename from include/playlist.h rename to lib/playlist/playlist.h diff --git a/src/settings.cpp b/lib/settings/settings.cpp similarity index 100% rename from src/settings.cpp rename to lib/settings/settings.cpp diff --git a/include/settings.h b/lib/settings/settings.h similarity index 100% rename from include/settings.h rename to lib/settings/settings.h diff --git a/src/wlan.cpp b/lib/wlan/wlan.cpp similarity index 100% rename from src/wlan.cpp rename to lib/wlan/wlan.cpp diff --git a/include/wlan.h b/lib/wlan/wlan.h similarity index 100% rename from include/wlan.h rename to lib/wlan/wlan.h diff --git a/src/cloud.cpp b/src/cloud.cpp deleted file mode 100644 index 833eaf5..0000000 --- a/src/cloud.cpp +++ /dev/null @@ -1,267 +0,0 @@ -#include -#include -#include -#include - -#include "settings.h" -#include "device.h" -#include "display.h" - -#include "imageWBMP.h" -#include "imagePNG.h" - -unsigned long requestInterval = 1000; // 1 sec -unsigned long previousTime = 0; - -// runtime data -const char *setting_HeaderKeys[] = { - // update deep sleep interval - "X-DeepSleepInterval", - // execute firmware update url - "X-UpdateFirmware"}; - - -void requestCloud(); -bool isCloudSetupComplete(); -void updateInterval(unsigned long interval); - -void setupCloud() -{ -HTTPClient http; - - Serial.println("setup cloud"); - - updateInterval(10); - - - http.useHTTP10(true); // http1.1 chunked übertragung funktioniert irgendwie nicht - http.setTimeout(7000); - http.collectHeaders(setting_HeaderKeys, sizeof(setting_HeaderKeys) / sizeof(char *)); - - if (isCloudSetupComplete()) - { - //config_Url = NVS.getString("cloud_server"); // + "/" + NVS.getString("cloud_uuid"); - //config_Url = "http://paperdash.sonic.da-tom.com/api/device/22805938-2280-8022-3822-385980225980/image.png"; - Serial.println(" cloud setup complete"); - } - - Serial.println("setup cloud - done"); -} - -void loopCloud() -{ - if (isCloudSetupComplete()) - { - if (NVS.getString("device_mode") == "passive") - { - Serial.println("requestCloud()"); - - Serial.println("passive, after this, we go to deep sleep and startover here again"); - } - else - { - unsigned long currentTime = millis(); - - if (currentTime - previousTime >= requestInterval) - { - /* Update the timing for the next time around */ - previousTime = currentTime; - - Serial.println("requestCloud()"); - requestCloud(); - } - } - } -} - -bool isCloudSetupComplete() -{ - return NVS.getString("cloud.url") != ""; // && NVS.getString("cloud_uuid") != ""; -} - -/** - * interval in seconds - */ -void updateInterval(unsigned long interval) -{ - //Serial.print("updateInterval: "); - //Serial.println(interval); - - // update config - Serial.println("###### config update"); - Serial.println(" set deep sleep interval from: " + String(deviceGetSleepInterval()) + " to " + interval); - Serial.println("###### config update"); - - // active wait state - requestInterval = interval * 1000; - - // passive deep sleep state - deviceSetSleepInterval(interval); -} - -/** - * 1. neue config daten über den http header laden - * 2. neues bild vom server laden und anzeigen sofern vorhanden - * @return bool true on new data to display - */ -void requestCloud() -{ - /* -HTTPClient http; - - String config_Url = NVS.getString("cloud.url"); - - Serial.println(config_Url); - http.begin(config_Url); - int httpCode = http.GET(); - if (httpCode != HTTP_CODE_OK && httpCode != HTTP_CODE_NOT_MODIFIED) - { - Serial.printf("[HTTP] GET... failed, error: %s\n", http.errorToString(httpCode != HTTP_CODE_OK && httpCode).c_str()); - } - else - { - // update poll interval - String DeepSleepInterval = http.header("X-DeepSleepInterval"); - if (false && DeepSleepInterval.toInt() == 0) - { - // disable deep sleep - //Serial.println("###### deep sleep disabled"); - //deviceSetSleepInterval(0); - } - else if (DeepSleepInterval.toInt() > 5 && DeepSleepInterval.toInt() != deviceGetSleepInterval()) - { - updateInterval(DeepSleepInterval.toInt()); - } - - // update to new firmware - String UpdateFirmware = http.header("UpdateFirmware"); - if (UpdateFirmware.length() > 0) - { - Serial.println("TODO update firmware..."); - } - - if (httpCode == HTTP_CODE_OK) - { - // update image - - // track duration - long startMills = millis(); - - // get lenght of document (is -1 when Server sends no Content-Length header) - int len = http.getSize(); - - // create buffer for read - uint8_t buff[128] = {0}; - - // get tcp stream - WiFiClient *stream = http.getStreamPtr(); - - // reset image buffer - size_t imageFormat = 0; - - // persist image to display - File file = SPIFFS.open("/currentImage.tmp", FILE_WRITE); - if (!file) - { - Serial.println("Failed to open file for writing"); - } - - // read all data from server - while (http.connected() && (len > 0 || len == -1)) - { - // get available data size - size_t size = stream->available(); - - if (size) - { - // read up to 128 byte - int c = stream->readBytes(buff, ((size > sizeof(buff)) ? sizeof(buff) : size)); - - // write to storage - if (file) - { - file.write(buff, c); - } - - // initial detect format - if (imageFormat == 0) - { - if (memcmp(buff, ImageHeaderWBMP, sizeof(ImageHeaderWBMP) - 1) == 0) - { - Serial.println(" image format: WBMP"); - imageFormat = 2; - - wbmpOpenFramebuffer(); - } - else if (memcmp(buff, ImageHeaderPNG, sizeof(ImageHeaderPNG) - 1) == 0) - { - Serial.println(" image format: PNG"); - imageFormat = 3; - - pngOpenFramebuffer(); - } - else - { - imageFormat = 1; - Serial.println(" unkown image format. first header are:"); - Serial.println(buff[0]); - Serial.println(buff[1]); - Serial.println(buff[2]); - Serial.println(buff[3]); - Serial.println(buff[4]); - Serial.println(buff[5]); - } - } - - // write display frame - switch (imageFormat) - { - // WBMP - case 2: - wbmpWriteFramebuffer(0, buff, c); - break; - // PNG - case 3: - pngWriteFramebuffer(0, buff, c); - break; - } - - if (len > 0) - { - len -= c; - } - } - - delay(1); - } - - // done - if (file) - { - file.close(); - SPIFFS.remove("/currentImage.bin"); - SPIFFS.rename("/currentImage.tmp", "/currentImage.bin"); - } - - // update display - switch (imageFormat) - { - // WBMP - case 2: - wbmpFlushFramebuffer(); - break; - // PNG - case 3: - pngFlushFramebuffer(); - break; - } - - Serial.print("update completed in: "); - Serial.println(millis() - startMills); - } - } - - // clean up - http.end(); - */ -} \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index bfae634..7bb4a33 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4,15 +4,11 @@ #include "wlan.h" #include "display.h" #include "settings.h" -//#include "cloud.h" #include "datetime.h" #include "playlist.h" #include "app.h" #include "image.h" -void gotoDeepSleep(); -String getWakeupReason(); - void setup() { // put your setup code here, to run once: @@ -31,8 +27,6 @@ void setup() setupDisplay(); setupSettings(); - setupDevice(); - setupImage(); setupWlan(); @@ -40,8 +34,6 @@ void setup() { setupDateTime(); setupPlaylist(); - - //setupCloud(); } setupApp(); @@ -52,17 +44,12 @@ void setup() void loop() { - // put your main code here, to run repeatedly: - if (WiFi.isConnected()) { loopDateTime(); loopPlaylist(); - //loopCloud(); } loopApp(); - - //loopDevice(); } \ No newline at end of file