From 0286f90f29b570b9dd8cb747ad1f0bc96f957ef1 Mon Sep 17 00:00:00 2001 From: Thomas Ballmann Date: Wed, 11 Mar 2020 21:19:08 +0100 Subject: [PATCH] weekday bugfix #20 --- README.md | 9 ++++- app/src/App.vue | 61 ++++++++++++++++++++++++++++++---- app/src/assets/app.css | 3 ++ app/src/views/Dashboard.vue | 2 +- app/src/views/Settings.vue | 19 ++++++++--- app/vue.config.js | 2 +- assets/wi-cloud.svg | 13 ++++++++ assets/wi-cloudy.svg | 18 ++++++++++ assets/wi-day-cloudy.svg | 26 +++++++++++++++ assets/wi-day-sunny.svg | 27 +++++++++++++++ assets/wi-fog.svg | 18 ++++++++++ assets/wi-lightning.svg | 9 +++++ assets/wi-night-alt-cloudy.svg | 19 +++++++++++ assets/wi-night-clear.svg | 13 ++++++++ assets/wi-showers.svg | 31 +++++++++++++++++ assets/wi-snow.svg | 27 +++++++++++++++ assets/wi-sprinkle.svg | 20 +++++++++++ include/datetime.h | 2 +- platformio.ini | 8 ++--- src/app.cpp | 18 ++++++++++ src/cloud.cpp | 1 - src/display.cpp | 6 +++- src/faceCalendar.cpp | 10 ++++-- src/playlist.cpp | 2 +- 24 files changed, 340 insertions(+), 24 deletions(-) create mode 100644 app/src/assets/app.css create mode 100644 assets/wi-cloud.svg create mode 100644 assets/wi-cloudy.svg create mode 100644 assets/wi-day-cloudy.svg create mode 100644 assets/wi-day-sunny.svg create mode 100644 assets/wi-fog.svg create mode 100644 assets/wi-lightning.svg create mode 100644 assets/wi-night-alt-cloudy.svg create mode 100644 assets/wi-night-clear.svg create mode 100644 assets/wi-showers.svg create mode 100644 assets/wi-snow.svg create mode 100644 assets/wi-sprinkle.svg diff --git a/README.md b/README.md index 9643d6e..562aef3 100644 --- a/README.md +++ b/README.md @@ -23,4 +23,11 @@ pio run --target erase ## access fs over http > get photos from calendar face -http://192.168.178.65/fs/calendarPhoto.png \ No newline at end of file +http://192.168.178.65/fs/calendarPhoto.png + + +# original +echo "${$(openssl s_client -connect raw.githubusercontent.com:443 2>/dev/null /dev/null - + - - - - + + + + @@ -28,13 +28,61 @@ paperdash.io - display + Weather + + + + +
+ + 40 + +
+ + + + + + + Weather + + + 6° Salzburg + + + + + + + + + + Calendar + + + 8. March 2020 + + + + 19% + + + + + + + + diff --git a/assets/wi-cloudy.svg b/assets/wi-cloudy.svg new file mode 100644 index 0000000..c3eaf41 --- /dev/null +++ b/assets/wi-cloudy.svg @@ -0,0 +1,18 @@ + + + + + diff --git a/assets/wi-day-cloudy.svg b/assets/wi-day-cloudy.svg new file mode 100644 index 0000000..cf63543 --- /dev/null +++ b/assets/wi-day-cloudy.svg @@ -0,0 +1,26 @@ + + + + + diff --git a/assets/wi-day-sunny.svg b/assets/wi-day-sunny.svg new file mode 100644 index 0000000..eafcd77 --- /dev/null +++ b/assets/wi-day-sunny.svg @@ -0,0 +1,27 @@ + + + + + diff --git a/assets/wi-fog.svg b/assets/wi-fog.svg new file mode 100644 index 0000000..cf06f8f --- /dev/null +++ b/assets/wi-fog.svg @@ -0,0 +1,18 @@ + + + + + diff --git a/assets/wi-lightning.svg b/assets/wi-lightning.svg new file mode 100644 index 0000000..0709cf3 --- /dev/null +++ b/assets/wi-lightning.svg @@ -0,0 +1,9 @@ + + + + + diff --git a/assets/wi-night-alt-cloudy.svg b/assets/wi-night-alt-cloudy.svg new file mode 100644 index 0000000..fcd1496 --- /dev/null +++ b/assets/wi-night-alt-cloudy.svg @@ -0,0 +1,19 @@ + + + + + diff --git a/assets/wi-night-clear.svg b/assets/wi-night-clear.svg new file mode 100644 index 0000000..053b2de --- /dev/null +++ b/assets/wi-night-clear.svg @@ -0,0 +1,13 @@ + + + + + diff --git a/assets/wi-showers.svg b/assets/wi-showers.svg new file mode 100644 index 0000000..3cb7e31 --- /dev/null +++ b/assets/wi-showers.svg @@ -0,0 +1,31 @@ + + + + + diff --git a/assets/wi-snow.svg b/assets/wi-snow.svg new file mode 100644 index 0000000..56afebf --- /dev/null +++ b/assets/wi-snow.svg @@ -0,0 +1,27 @@ + + + + + diff --git a/assets/wi-sprinkle.svg b/assets/wi-sprinkle.svg new file mode 100644 index 0000000..c26b207 --- /dev/null +++ b/assets/wi-sprinkle.svg @@ -0,0 +1,20 @@ + + + + + diff --git a/include/datetime.h b/include/datetime.h index 12de111..8d042bf 100644 --- a/include/datetime.h +++ b/include/datetime.h @@ -9,7 +9,7 @@ struct datetime_struct : tm { uint8_t month_num; - uint8_t day_offset; // 1st day of the month offset, Monday = 0 + uint8_t day_offset; // 1st day of the month offset, Monday = 1, Sunnday = 0 uint8_t days_in_month; }; diff --git a/platformio.ini b/platformio.ini index c3d663d..d0e05f8 100644 --- a/platformio.ini +++ b/platformio.ini @@ -13,13 +13,13 @@ board_build.partitions = no_ota.csv ;upload_port = 192.168.178.60 # lolin32 -;upload_speed = 921600 -;upload_port = /dev/cu.SLAB_USBtoUART +upload_speed = 921600 +upload_port = /dev/cu.SLAB_USBtoUART # lolin32 lite -upload_speed = 115200 +;upload_speed = 115200 ;upload_port = /dev/cu.wchusbserial1460 -upload_port = /dev/cu.wchusbserial1410 +;upload_port = /dev/cu.wchusbserial1410 lib_deps = diff --git a/src/app.cpp b/src/app.cpp index eef6f67..b578886 100644 --- a/src/app.cpp +++ b/src/app.cpp @@ -7,8 +7,10 @@ #include "playlist.h" #include "image.h" #include "display.h" +#include "datetime.h" #include "faceWeather.h" #include "faceCalendar.h" +#include "download.h" AsyncWebServer server(80); @@ -303,6 +305,7 @@ void setupApiFace() void setupApiUpdate() { server.on("/api/update", HTTP_GET, [](AsyncWebServerRequest *request) { + /* int params = request->params(); for (int i = 0; i < params; i++) { @@ -320,6 +323,14 @@ void setupApiUpdate() Serial.printf("
  • GET[%s]: %s
  • ", p->name().c_str(), p->value().c_str()); } } + */ + + if (request->hasParam("datetime")) + { + Serial.println("update datetime..."); + + updateDateTime(); + } if (request->hasParam("weather")) { @@ -335,6 +346,13 @@ void setupApiUpdate() updateCalendarData(); } + if (request->hasParam("file")) + { + Serial.println("file..."); + + downloadFile(request->getParam("url")->value().c_str(), request->getParam("file")->value().c_str()); + } + request->send(200, "application/ld+json; charset=utf-8", "{}"); }); } \ No newline at end of file diff --git a/src/cloud.cpp b/src/cloud.cpp index 1b7b1be..833eaf5 100644 --- a/src/cloud.cpp +++ b/src/cloud.cpp @@ -33,7 +33,6 @@ HTTPClient http; updateInterval(10); - SPIFFS.begin(); http.useHTTP10(true); // http1.1 chunked übertragung funktioniert irgendwie nicht http.setTimeout(7000); diff --git a/src/display.cpp b/src/display.cpp index fdd4441..5cdd9f2 100644 --- a/src/display.cpp +++ b/src/display.cpp @@ -51,7 +51,11 @@ void displayWriteFramebuffer(uint8_t bitmap[]) void displayFlush() { display.nextPage(); - saveScreen(); + // TODO setting ? + if (true) + { + saveScreen(); + } } void printSplash() diff --git a/src/faceCalendar.cpp b/src/faceCalendar.cpp index db925f6..92d0b43 100644 --- a/src/faceCalendar.cpp +++ b/src/faceCalendar.cpp @@ -26,7 +26,8 @@ const char faceCalendarPicture[] = "/calendarPhoto.png"; void setupFaceCalendar() { - downloadRandomePicture(); + //downloadRandomePicture(); + //downloadFile("https://images.unsplash.com/photo-1582225764554-a82806fe9f30?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjExMDM0OH0&w=390&h=384&fm=png&fit=crop&duotone=000000,FFFFFF", "/tom"); } void loopFaceCalendar() @@ -98,9 +99,13 @@ bool downloadRandomePicture() /** * download and update calendar data + * @todo is not working */ bool updateCalendarData() { + //downloadFile("https://images.unsplash.com/photo-1582225764554-a82806fe9f30?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjExMDM0OH0&w=390&h=384&fm=png&fit=crop&duotone=000000,FFFFFF", "/tom"); + return false; + if (downloadRandomePicture()) { //readWeatherData(); @@ -158,7 +163,8 @@ void display_calender() display.setCursor(20, 220); // skip week days from previous month - for (uint8_t d = 1; d < now.day_offset; d++) + uint8_t skip = (now.day_offset == 0 ? 7 : now.day_offset); + for (uint8_t d = 1; d < skip; d++) { display.print(" "); } diff --git a/src/playlist.cpp b/src/playlist.cpp index c07b07c..414923b 100644 --- a/src/playlist.cpp +++ b/src/playlist.cpp @@ -16,7 +16,7 @@ typedef FaceAndName FaceAndNameList[]; // List of faces to cycle through FaceAndNameList faces = { - {loopFaceWeather, "Weather"}, + //{loopFaceWeather, "Weather"}, {loopFaceCalendar, "Calendar"}, };