diff --git a/ESPixelStick/src/WebMgr.cpp b/ESPixelStick/src/WebMgr.cpp index 1d4e9ce07..b787d657d 100644 --- a/ESPixelStick/src/WebMgr.cpp +++ b/ESPixelStick/src/WebMgr.cpp @@ -31,10 +31,6 @@ #include #include -#include -#include -#include - #ifdef SUPPORT_SENSOR_DS18B20 #include "service/SensorDS18B20.h" #endif // def SUPPORT_SENSOR_DS18B20 @@ -159,6 +155,23 @@ void c_WebMgr::init () ProcessXJRequest (request); }); + webServer.on ("/settime", HTTP_POST | HTTP_GET | HTTP_OPTIONS, [this](AsyncWebServerRequest* request) + { + // DEBUG_V("/settime"); + // DEBUG_V(String("URL: ") + request->url()); + if(HTTP_OPTIONS == request->method()) + { + request->send (200); + } + else + { + String newDate = request->url ().substring (String (F("/settime/")).length ()); + // DEBUG_V (String ("newDate: ") + String (newDate)); + ProcessSetTimeRequest (time_t(newDate.toInt())); + request->send (200); + } + }); + // Reboot handler webServer.on ("/X6", HTTP_POST | HTTP_OPTIONS, [](AsyncWebServerRequest* request) { @@ -279,7 +292,7 @@ void c_WebMgr::init () else { // DEBUG_V (String ("url: ") + String (request->url ())); - String filename = request->url ().substring (String ("/file/delete").length ()); + String filename = request->url ().substring (String (F("/file/delete")).length ()); // DEBUG_V (String ("filename: ") + String (filename)); FileMgr.DeleteSdFile(filename); request->send (200); @@ -629,6 +642,7 @@ void c_WebMgr::ProcessXJRequest (AsyncWebServerRequest* client) system[F ("freeheap")] = ESP.getFreeHeap (); system[F ("uptime")] = millis (); + system[F ("currenttime")] = now (); system[F ("SDinstalled")] = FileMgr.SdCardIsInstalled (); system[F ("DiscardedRxData")] = DiscardedRxData; @@ -659,6 +673,7 @@ void c_WebMgr::ProcessXJRequest (AsyncWebServerRequest* client) if(WebJsonDoc.overflowed()) { logcon(F("ERROR: Status Doc is too small")); + client->send (401, CN_applicationSLASHjson, F("Internal Error. Status Buffer is too small.")); } else { @@ -671,6 +686,18 @@ void c_WebMgr::ProcessXJRequest (AsyncWebServerRequest* client) } // ProcessXJRequest +//----------------------------------------------------------------------------- +void c_WebMgr::ProcessSetTimeRequest (time_t DateTime) +{ + // DEBUG_START; + + // DEBUG_V(String("DateTime: ") + String(DateTime)); + setTime(DateTime); + // DEBUG_V(String("now: ") + String(now())); + + // DEBUG_END; +} // ProcessSetTimeRequest + //----------------------------------------------------------------------------- void c_WebMgr::FirmwareUpload (AsyncWebServerRequest* request, String filename, diff --git a/ESPixelStick/src/WebMgr.hpp b/ESPixelStick/src/WebMgr.hpp index 476cdca49..15ca63445 100644 --- a/ESPixelStick/src/WebMgr.hpp +++ b/ESPixelStick/src/WebMgr.hpp @@ -76,7 +76,8 @@ class c_WebMgr void GetOptions (); void ProcessXJRequest (AsyncWebServerRequest * client); - + void ProcessSetTimeRequest (time_t DateTime); + void GetDeviceOptions (); void GetInputOptions (); void GetOutputOptions (); diff --git a/ESPixelStick/src/output/OutputPixel.cpp b/ESPixelStick/src/output/OutputPixel.cpp index 7b57351c3..cb586535c 100644 --- a/ESPixelStick/src/output/OutputPixel.cpp +++ b/ESPixelStick/src/output/OutputPixel.cpp @@ -388,6 +388,7 @@ void c_OutputPixel::StartNewFrame () FrameAppendDataCurrentIndex = 0; SentPixelsCount = 0; PixelIntensityCurrentIndex = 0; + PixelIntensityCurrentColor = 0; PrependNullPixelCurrentCount = 0; AppendNullPixelCurrentCount = 0; PixelPrependDataCurrentIndex = 0; @@ -447,6 +448,8 @@ uint32_t IRAM_ATTR c_OutputPixel::FramePrependData() } // PixelIntensityCurrentIndex = 0; // PixelPrependDataCurrentIndex = 0; + // PixelIntensityCurrentColor = 0; + } return response; } @@ -476,6 +479,7 @@ uint32_t IRAM_ATTR c_OutputPixel::PixelPrependNulls() // pixel is complete. Move to the next one PixelIntensityCurrentIndex = 0; PixelPrependDataCurrentIndex = 0; + PixelIntensityCurrentColor = 0; if (++PrependNullPixelCurrentCount < PrependNullPixelCount) { @@ -504,6 +508,9 @@ uint32_t IRAM_ATTR c_OutputPixel::PixelSendPrependIntensity() // pixel prepend goes here if (PixelPrependDataCurrentIndex >= PixelPrependDataSize) { + // reset the prepend index for the next pixel + PixelPrependDataCurrentIndex = 0; + #ifdef SUPPORT_OutputType_GECE if (OutputType == OTYPE_t::OutputType_GECE) { @@ -589,6 +596,7 @@ uint32_t IRAM_ATTR c_OutputPixel::PixelAppendNulls() // pixel is complete. Move to the next one PixelIntensityCurrentIndex = 0; PixelPrependDataCurrentIndex = 0; + PixelIntensityCurrentColor = 0; if (++AppendNullPixelCurrentCount < AppendNullPixelCount) { @@ -665,6 +673,7 @@ uint32_t IRAM_ATTR c_OutputPixel::GetIntensityData() PixelPrependDataCurrentIndex = 0; PixelIntensityCurrentIndex = 0; AppendNullPixelCurrentCount = 0; + PixelIntensityCurrentColor = 0; FrameStateFuncPtr = &c_OutputPixel::PixelAppendNulls; } @@ -681,6 +690,12 @@ uint32_t IRAM_ATTR c_OutputPixel::GetIntensityData() FrameStateFuncPtr = &c_OutputPixel::FrameDone; } } + // are we at the end of a pixel and are we prepending pixel data? + else if(++PixelIntensityCurrentColor >= NumIntensityBytesPerPixel) + { + PixelIntensityCurrentColor = 0; + SetStartingSendPixelState(); + } return response; } diff --git a/ESPixelStick/src/output/OutputPixel.hpp b/ESPixelStick/src/output/OutputPixel.hpp index e2cc1a6f1..ae8f577da 100644 --- a/ESPixelStick/src/output/OutputPixel.hpp +++ b/ESPixelStick/src/output/OutputPixel.hpp @@ -45,6 +45,7 @@ class c_OutputPixel : public c_OutputCommon uint32_t pixel_count = 100; uint32_t SentPixelsCount = 0; uint32_t PixelIntensityCurrentIndex = 0; + uint32_t PixelIntensityCurrentColor = 0; uint8_t * pFramePrependData = nullptr; uint32_t FramePrependDataSize = 0; diff --git a/ESPixelStick/src/output/OutputSpi.hpp b/ESPixelStick/src/output/OutputSpi.hpp index 5ed874119..e74b60fdc 100644 --- a/ESPixelStick/src/output/OutputSpi.hpp +++ b/ESPixelStick/src/output/OutputSpi.hpp @@ -24,6 +24,7 @@ #include "../ESPixelStick.h" #ifdef SUPPORT_SPI_OUTPUT + #include "OutputPixel.hpp" #include #include diff --git a/ESPixelStick/src/platformDefinitions/GPIO_Defs_ESP32_LoLin_D32_PRO.hpp b/ESPixelStick/src/platformDefinitions/GPIO_Defs_ESP32_LoLin_D32_PRO.hpp index f5f6b45db..2d066389b 100644 --- a/ESPixelStick/src/platformDefinitions/GPIO_Defs_ESP32_LoLin_D32_PRO.hpp +++ b/ESPixelStick/src/platformDefinitions/GPIO_Defs_ESP32_LoLin_D32_PRO.hpp @@ -23,14 +23,11 @@ #define DEFAULT_RMT_1_GPIO gpio_num_t::GPIO_NUM_13 #define DEFAULT_RMT_2_GPIO gpio_num_t::GPIO_NUM_12 -#define DEFAULT_RMT_3_GPIO gpio_num_t::GPIO_NUM_14 -#define DEFAULT_RMT_4_GPIO gpio_num_t::GPIO_NUM_32 -#define DEFAULT_RMT_5_GPIO gpio_num_t::GPIO_NUM_33 // SPI Output #define SUPPORT_SPI_OUTPUT -#define DEFAULT_SPI_DATA_GPIO gpio_num_t::GPIO_NUM_16 -#define DEFAULT_SPI_CLOCK_GPIO gpio_num_t::GPIO_NUM_17 +#define DEFAULT_SPI_DATA_GPIO gpio_num_t::GPIO_NUM_27 +#define DEFAULT_SPI_CLOCK_GPIO gpio_num_t::GPIO_NUM_32 #define DEFAULT_I2C_SDA gpio_num_t::GPIO_NUM_3 #define DEFAULT_I2C_SCL gpio_num_t::GPIO_NUM_5 @@ -42,7 +39,7 @@ #define SD_CARD_CLK_PIN gpio_num_t::GPIO_NUM_18 #define SD_CARD_CS_PIN gpio_num_t::GPIO_NUM_4 -#define DEFAULT_RELAY_GPIO gpio_num_t::GPIO_NUM_1 +#define DEFAULT_RELAY_GPIO gpio_num_t::GPIO_NUM_14 // Output Types // Not Finished - #define SUPPORT_OutputType_TLS3001 diff --git a/html/index.html b/html/index.html index 0abaa08d3..d978c47bf 100644 --- a/html/index.html +++ b/html/index.html @@ -64,6 +64,10 @@ Up Time + + Current Time + + Flash Total diff --git a/html/script.js b/html/script.js index 248374bd6..647ab08bf 100644 --- a/html/script.js +++ b/html/script.js @@ -320,10 +320,21 @@ $(function () { DocumentIsHidden = true; } else { DocumentIsHidden = false; + SetServerTime(); } }); + + SetServerTime(); }); +function SetServerTime() +{ + // console.info("SetServerTime"); + let CurrentDate = Math.floor((new Date()).getTime() / 1000); + // console.info("CurrentDate: " + CurrentDate); + SendCommand('settime/' + (CurrentDate)); +} // SetServerTime + function ProcessLocalConfig(data) { // console.info(data); let ParsedLocalConfig = JSON.parse(data); @@ -641,6 +652,10 @@ function ProcessGetFileListResponse(JsonConfigData) { // console.info("not last. Ask for the next chunk"); RequestListOfFiles(JsonConfigData.last); } + else + { + SetServerTime(); + } } // end expected file ID } // ProcessGetFileListResponse @@ -1796,6 +1811,17 @@ function ProcessReceivedJsonStatusMessage(JsonStat) { str += ("0" + date.getUTCSeconds()).slice(-2); $('#x_uptime').text(str); + date = new Date(1000 * System.currenttime); + // console.info("DateMS: " + date.getMilliseconds()); + $('#x_currenttime').text(date.toUTCString()); + let CurrDate = new Date(); + // console.info("CurrDateMS: " + CurrDate); + let Delta = Math.abs(CurrDate.getTime() - date.getTime())/1000; + // console.info("DeltaS: " + Delta); + if(Delta > 5) + { + SetServerTime(); + } if ({}.hasOwnProperty.call(System, 'used')) { $('#i_size').removeClass("hidden"); $('#x_size').removeClass("hidden"); diff --git a/platformio.ini b/platformio.ini index f8e37c4bb..cc37ae742 100644 --- a/platformio.ini +++ b/platformio.ini @@ -160,7 +160,6 @@ build_flags = ${esp32git.build_flags} -D BOARD_NAME='"d32_pro"' -D BOARD_ESP32_LOLIN_D32_PRO - -D BOARD_HAS_PSRAM -mfix-esp32-psram-cache-issue -mfix-esp32-psram-cache-strategy=memw ; -D CONFIG_ESP_SYSTEM_PANIC_GDBSTUB -O0 -ggdb3 -g3 @@ -176,7 +175,6 @@ build_flags = ${esp32git.build_flags} -D BOARD_NAME='"d32_pro_eth"' -D BOARD_ESP32_LOLIN_D32_PRO_ETH - -D BOARD_HAS_PSRAM -mfix-esp32-psram-cache-issue -mfix-esp32-psram-cache-strategy=memw @@ -193,7 +191,6 @@ build_flags = -fexceptions build_unflags = -fno-exceptions - -D BOARD_HAS_PSRAM -mfix-esp32-psram-cache-issue -mfix-esp32-psram-cache-strategy=memw @@ -219,9 +216,6 @@ build_flags = ${esp32git.build_flags} -D BOARD_NAME='"d1_mini32"' -D BOARD_ESP32_D1_MINI - -D BOARD_HAS_PSRAM - -mfix-esp32-psram-cache-issue - -mfix-esp32-psram-cache-strategy=memw ; Generic Wemos D1 Mini 32 [env:d1_mini32_eth] @@ -231,9 +225,6 @@ build_flags = ${esp32git.build_flags} -D BOARD_NAME='"d1_mini32_eth"' -D BOARD_ESP32_D1_MINI_ETH - -D BOARD_HAS_PSRAM - -mfix-esp32-psram-cache-issue - -mfix-esp32-psram-cache-strategy=memw ; WT 32 ETH 01 [env:esp32_wt32eth01] @@ -244,9 +235,6 @@ build_flags = -D BOARD_NAME='"esp32_wt32eth01"' -D BOARD_ESP32_WT32ETH01 -I ./.pio/packages/framework-arduinoespressif32/libraries/Ethernet/src -; -D BOARD_HAS_PSRAM -; -mfix-esp32-psram-cache-issue -; -mfix-esp32-psram-cache-strategy=memw [env:esp32_quinled_dig_octa] extends = esp32git @@ -436,6 +424,3 @@ build_flags = -D BOARD_NAME='"esp32_wasatch"' -D BOARD_ESP32_WT32ETH01_WASATCH -I ./.pio/packages/framework-arduinoespressif32/libraries/Ethernet/src -; -D BOARD_HAS_PSRAM -; -mfix-esp32-psram-cache-issue -; -mfix-esp32-psram-cache-strategy=memw