diff --git a/include/hasp_conf.h b/include/hasp_conf.h index 14366c88..3ba35170 100644 --- a/include/hasp_conf.h +++ b/include/hasp_conf.h @@ -48,7 +48,7 @@ #include "hasp_spiffs.h" #if defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_ARCH_ESP8266) -//#include "lv_zifont.h" +#include "lv_zifont.h" #endif #endif diff --git a/lib/ArduinoLog/ArduinoLog.cpp b/lib/ArduinoLog/ArduinoLog.cpp index d9ad7e06..c7265fd0 100644 --- a/lib/ArduinoLog/ArduinoLog.cpp +++ b/lib/ArduinoLog/ArduinoLog.cpp @@ -129,7 +129,6 @@ void Logging::print(Print * logOutput, const char * format, va_list args) ++format; printFormat(logOutput, *format, (va_list *)&args); } else { - //_logOutput->print(*format); logOutput->print(*format); } } diff --git a/lib/lvgl b/lib/lvgl index 549c75c0..1cf1721a 160000 --- a/lib/lvgl +++ b/lib/lvgl @@ -1 +1 @@ -Subproject commit 549c75c07fbabc5c6799ef5d676875eadd5874e6 +Subproject commit 1cf1721aa3e693ae37ea1809b7b7656b7c0cf85b diff --git a/platformio_override-template.ini b/platformio_override-template.ini index 85445451..92f106ae 100644 --- a/platformio_override-template.ini +++ b/platformio_override-template.ini @@ -1,7 +1,7 @@ -; Copy this file and rename it to platform_override.ini -; ONLY edit platform_override.ini to make local changes to the parameters +; Copy this file and rename it to platformio_override.ini +; ONLY edit platformio_override.ini to make local changes to the parameters ; -; The platform_override.ini file is not overwritten or monitored by git +; The platformio_override.ini file is not overwritten or monitored by git [override] diff --git a/src/hasp_attribute.cpp b/src/hasp_attribute.cpp index de69758f..4a110d65 100644 --- a/src/hasp_attribute.cpp +++ b/src/hasp_attribute.cpp @@ -588,11 +588,7 @@ static void hasp_process_obj_attribute_val(lv_obj_t * obj, const char * attr, co return update ? lv_slider_set_value(obj, intval, LV_ANIM_ON) : hasp_out_int(obj, attr, lv_slider_get_value(obj)); } else if(check_obj_type(objtype, LV_HASP_LED)) { - if(update) { - return is_true(payload) ? lv_led_on(obj) : lv_led_off(obj); - } else { - // return hasp_out_int(obj, attr, lv_led_get_state(obj)); - } + return update ? lv_led_set_bright(obj, (uint8_t)val) : hasp_out_int(obj, attr, lv_led_get_bright(obj)); } else if(check_obj_type(objtype, LV_HASP_GAUGE)) { return update ? lv_gauge_set_value(obj, 0, intval) : hasp_out_int(obj, attr, lv_gauge_get_value(obj, 0)); } else if(check_obj_type(objtype, LV_HASP_ROLLER)) { @@ -782,16 +778,6 @@ void hasp_process_obj_attribute(lv_obj_t * obj, const char * attr_p, const char } break; // not a options object - case ATTR_BRIGHTNESS: - if(check_obj_type(obj, LV_HASP_LED)) { - if(update) { - lv_led_set_bright(obj, (uint8_t)val); - } else { - hasp_out_int(obj, attr, lv_led_get_bright(obj)); - } - return; - } - // default: // hasp_local_style_attr(obj, attr, payload, update); } diff --git a/src/hasp_attribute.h b/src/hasp_attribute.h index e2fc932d..6171e1e3 100644 --- a/src/hasp_attribute.h +++ b/src/hasp_attribute.h @@ -212,7 +212,6 @@ _HASP_ATTRIBUTE(SCALE_END_LINE_WIDTH, scale_end_line_width, lv_style_int_t) #define ATTR_Y 121 #define ATTR_W 119 #define ATTR_H 104 -#define ATTR_BRIGHTNESS 10 // LED #define ATTR_OPTIONS 29886 #define ATTR_ENABLED 28193 #define ATTR_OPACITY 10155 diff --git a/src/hasp_dispatch.cpp b/src/hasp_dispatch.cpp index 132966f7..7255a41c 100644 --- a/src/hasp_dispatch.cpp +++ b/src/hasp_dispatch.cpp @@ -55,7 +55,8 @@ void dispatchOutput(int output, bool state) #elif defined(STM32F4xx) digitalWrite(HASP_OUTPUT_PIN, state); #else - analogWrite(pin, state ? 1023 : 0); + digitalWrite(D1, state); + // analogWrite(pin, state ? 1023 : 0); #endif } } @@ -298,7 +299,7 @@ void dispatchReboot(bool saveConfig) Log.verbose(F("-------------------------------------")); Log.notice(F("STOP: Properly Rebooting the MCU now!")); Serial.flush(); - //halRestart(); + halRestart(); } void dispatch_button(uint8_t id, const char * event) diff --git a/src/hasp_gpio.cpp b/src/hasp_gpio.cpp index cf3ceee9..c412482c 100644 --- a/src/hasp_gpio.cpp +++ b/src/hasp_gpio.cpp @@ -87,10 +87,10 @@ void gpioAddButton(uint8_t pin, uint8_t input_mode, uint8_t default_state, uint8 ButtonConfig * buttonConfig = button[i]->getButtonConfig(); buttonConfig->setEventHandler(gpio_event_cb); buttonConfig->setFeature(ButtonConfig::kFeatureClick); - buttonConfig->setFeature(ButtonConfig::kFeatureDoubleClick); + buttonConfig->clearFeature(ButtonConfig::kFeatureDoubleClick); buttonConfig->setFeature(ButtonConfig::kFeatureLongPress); - buttonConfig->setFeature(ButtonConfig::kFeatureRepeatPress); - buttonConfig->setFeature(ButtonConfig::kFeatureSuppressClickBeforeDoubleClick); + buttonConfig->clearFeature(ButtonConfig::kFeatureRepeatPress); + buttonConfig->clearFeature(ButtonConfig::kFeatureSuppressClickBeforeDoubleClick); // Causes annoying pauses Log.verbose(F("GPIO: Button%d created on pin %d (channel %d) mode %d default %d"), i, pin, channel, input_mode,default_state); gpioUsedInputCount = i + 1; @@ -107,6 +107,10 @@ void gpioSetup() aceButtonSetup(); //gpioConfig[0] = PD15 * 256 + 5 + (INPUT << 3); +#if defined(ARDUINO_ARCH_ESP8266) + gpioAddButton(D2, INPUT_PULLUP, HIGH, 1); + pinMode(D1, OUTPUT); +#endif for(uint8_t i = 0; i < HASP_NUM_GPIO_CONFIG; i++) { uint8_t pin = (gpioConfig[i] >> 8) & 0xFF; @@ -122,9 +126,11 @@ void gpioSetup() case 2: input_mode = INPUT_PULLUP; break; +#ifndef ARDUINO_ARCH_ESP8266 case 3: input_mode = INPUT_PULLDOWN; break; +#endif default: input_mode = INPUT; } @@ -132,7 +138,7 @@ void gpioSetup() switch(gpiotype) { case HASP_GPIO_SWITCH: case HASP_GPIO_BUTTON: - gpioAddButton(pin, input_mode, default_state, channel); + // gpioAddButton(pin, input_mode, default_state, channel); break; case HASP_GPIO_RELAY: diff --git a/src/hasp_hal.cpp b/src/hasp_hal.cpp index 83e7a363..672e7ba5 100644 --- a/src/hasp_hal.cpp +++ b/src/hasp_hal.cpp @@ -11,15 +11,6 @@ #if defined(ARDUINO_ARCH_ESP32) #include // needed to get the ResetInfo -void halRestart(void) -{ -#if defined(ESP32) || defined(ESP8266) - ESP.restart(); -#else - NVIC_SystemReset(); -#endif -} - // Compatibility function for ESP8266 getRestInfo String esp32ResetReason(uint8_t cpuid) { @@ -90,6 +81,15 @@ String esp32ResetReason(uint8_t cpuid) } #endif +void halRestart(void) +{ +#if defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_ARCH_ESP8266) + ESP.restart(); +#else + NVIC_SystemReset(); +#endif +} + String halGetResetInfo() { #if defined(ARDUINO_ARCH_ESP32) diff --git a/src/hasp_hal.h b/src/hasp_hal.h index 23ac6501..97f85f0a 100644 --- a/src/hasp_hal.h +++ b/src/hasp_hal.h @@ -3,12 +3,12 @@ #include +void halRestart(void); uint8_t halGetHeapFragmentation(void); String halGetResetInfo(void); size_t halGetMaxFreeBlock(void); size_t halGetFreeHeap(void); String halGetCoreVersion(void); String halGetChipModel(); -void halRestart(void); #endif \ No newline at end of file diff --git a/src/hasp_http.cpp b/src/hasp_http.cpp index 9bb9c5ab..d6bb718c 100644 --- a/src/hasp_http.cpp +++ b/src/hasp_http.cpp @@ -1278,6 +1278,11 @@ void webHandleConfig() httpMessage += F("

"); +#if HASP_USE_GPIO > 0 + httpMessage += + F("

"); +#endif + httpMessage += F("

"); @@ -1489,9 +1494,69 @@ void webHandleHttpConfig() } #endif +//////////////////////////////////////////////////////////////////////////////////////////////////// +void webHandleGpioConfig() +{ // http://plate01/config/gpio + if(!httpIsAuthenticated(F("config/gpio"))) return; + + DynamicJsonDocument settings(256); + debugGetConfig(settings.to()); + + String httpMessage((char *)0); + httpMessage.reserve(HTTP_PAGE_SIZE); + httpMessage += F("

"); + httpMessage += httpGetNodename(); + httpMessage += F("


"); + + httpMessage += F("
"); + + uint16_t baudrate = settings[FPSTR(F_CONFIG_BAUD)].as(); + httpMessage += F("

Serial Port

Telemetry Period (Seconds, 0=disable) " + "

"); + + httpMessage += F("Syslog Hostame (optional)
Syslog Port (optional) Syslog Facility
Syslog Protocol () == 0) httpMessage += F(" checked"); + httpMessage += F(">IETF (RFC 5424)   () == 1) httpMessage += F(" checked"); + httpMessage += F(">BSD (RFC 3164)"); + + httpMessage += F("

"); + + httpMessage += + PSTR("

"); + + webSendPage(httpGetNodename(), httpMessage.length(), false); + webServer.sendContent(httpMessage); + httpMessage.clear(); + webSendFooter(); +} + //////////////////////////////////////////////////////////////////////////////////////////////////// void webHandleDebugConfig() -{ // http://plate01/config/http +{ // http://plate01/config/debug if(!httpIsAuthenticated(F("config/debug"))) return; DynamicJsonDocument settings(256); @@ -1851,6 +1916,9 @@ void httpSetup() #endif #if HASP_USE_WIFI > 0 webServer.on(F("/config/wifi"), webHandleWifiConfig); +#endif +#if HASP_USE_GPIO > 0 + webServer.on(F("/config/gpio"), webHandleGpioConfig); #endif webServer.on(F("/screenshot"), webHandleScreenshot); webServer.on(F("/saveConfig"), webHandleSaveConfig); diff --git a/src/hasp_slave.cpp b/src/hasp_slave.cpp index 08e62f6a..0a4eed71 100644 --- a/src/hasp_slave.cpp +++ b/src/hasp_slave.cpp @@ -1,6 +1,8 @@ /********************* * INCLUDES *********************/ +#if HASP_USE_SLAVE>0 + #include "hasp_slave.h" #include #include "ArduinoJson.h" @@ -130,11 +132,11 @@ void TASMO_EVERY_SECOND(void) { if (ledstate) { ledstate = false; - digitalWrite(HASP_OUTPUT_PIN, 1); + //digitalWrite(HASP_OUTPUT_PIN, 1); // Log.verbose(F("LED OFF")); } else { ledstate = true; - digitalWrite(HASP_OUTPUT_PIN, 0); + //digitalWrite(HASP_OUTPUT_PIN, 0); // Log.verbose(F("LED ON")); } } @@ -158,4 +160,6 @@ void slaveLoop(void) // TASMO_EVERY_SECOND(); // } -} \ No newline at end of file +} + +#endif \ No newline at end of file diff --git a/src/hasp_spiffs.cpp b/src/hasp_spiffs.cpp index fdd64f8a..8522b7f3 100644 --- a/src/hasp_spiffs.cpp +++ b/src/hasp_spiffs.cpp @@ -14,7 +14,7 @@ void spiffsInfo() { // Get all information of your SPIFFS -#if defined(ARDUINO_ARCH_ESP8266) +#if 0 FSInfo fs_info; SPIFFS.info(fs_info); diff --git a/src/hasp_tft.cpp b/src/hasp_tft.cpp index ba8f74f8..1f246d01 100644 --- a/src/hasp_tft.cpp +++ b/src/hasp_tft.cpp @@ -87,7 +87,7 @@ void tftShowConfig(TFT_eSPI & tft) Log.verbose(F("TFT: CPU freq. : %i MHz"), ESP.getCpuFreqMHz()); #else Log.verbose(F("TFT: Processor : STM%x"), tftSetup.esp); - Log.verbose(F("TFT: CPU freq. : %i MHz"), F_CPU/1000/1000); + Log.verbose(F("TFT: CPU freq. : %i MHz"), F_CPU / 1000 / 1000); #endif #if defined(ARDUINO_ARCH_ESP8266) @@ -156,14 +156,10 @@ void tftShowConfig(TFT_eSPI & tft) tftPinInfo(F("TFT_D7"), tftSetup.pin_tft_d7); if(tftSetup.serial == 1) { - char buffer[8]; - snprintf_P(buffer, sizeof(buffer), "%4.2f", (float)tftSetup.tft_spi_freq / 10.0f); - Log.verbose(F("TFT: Display SPI freq. : %s MHz"), buffer); + Log.verbose(F("TFT: Display SPI freq. : %d.%d MHz"), tftSetup.tft_spi_freq / 10, tftSetup.tft_spi_freq % 10); } if(tftSetup.pin_tch_cs != -1) { - char buffer[8]; - snprintf_P(buffer, sizeof(buffer), "%4.2f", (float)tftSetup.tch_spi_freq / 10.0f); - Log.verbose(F("TFT: Touch SPI freq. : %s MHz"), buffer); + Log.verbose(F("TFT: Touch SPI freq. : %d.%d MHz"), tftSetup.tch_spi_freq / 10, tftSetup.tch_spi_freq % 10); } }