Merge remote-tracking branch 'upstream/0.1.0-dev' into 0.1.0-dev

This commit is contained in:
arovak 2020-05-02 21:51:04 +02:00
commit a913bb86d4
14 changed files with 109 additions and 50 deletions

View File

@ -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

View File

@ -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);
}
}

@ -1 +1 @@
Subproject commit 549c75c07fbabc5c6799ef5d676875eadd5874e6
Subproject commit 1cf1721aa3e693ae37ea1809b7b7656b7c0cf85b

View File

@ -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]

View File

@ -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);
}

View File

@ -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

View File

@ -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)

View File

@ -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:

View File

@ -11,15 +11,6 @@
#if defined(ARDUINO_ARCH_ESP32)
#include <rom/rtc.h> // 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)

View File

@ -3,12 +3,12 @@
#include <Arduino.h>
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

View File

@ -1278,6 +1278,11 @@ void webHandleConfig()
httpMessage +=
F("<p><form method='get' action='/config/hasp'><button type='submit'>HASP Settings</button></form></p>");
#if HASP_USE_GPIO > 0
httpMessage +=
F("<p><form method='get' action='/config/gpio'><button type='submit'>GPIO Settings</button></form></p>");
#endif
httpMessage +=
F("<p><form method='get' action='/config/debug'><button type='submit'>Debug Settings</button></form></p>");
@ -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<JsonObject>());
String httpMessage((char *)0);
httpMessage.reserve(HTTP_PAGE_SIZE);
httpMessage += F("<h1>");
httpMessage += httpGetNodename();
httpMessage += F("</h1><hr>");
httpMessage += F("<form method='POST' action='/config'>");
uint16_t baudrate = settings[FPSTR(F_CONFIG_BAUD)].as<uint16_t>();
httpMessage += F("<p><b>Serial Port</b> <select id='baud' name='baud'>");
httpMessage += getOption(1, F("Disabled"), baudrate == 1); // Don't use 0 here which is default 115200
httpMessage += getOption(960, F("9600"), baudrate == 960);
httpMessage += getOption(1920, F("19200"), baudrate == 1920);
httpMessage += getOption(3840, F("38400"), baudrate == 3840);
httpMessage += getOption(5760, F("57600"), baudrate == 5760);
httpMessage += getOption(7488, F("74880"), baudrate == 7488);
httpMessage += getOption(11520, F("115200"), baudrate == 11520);
httpMessage += F("</select></p><p><b>Telemetry Period</b> <i><small>(Seconds, 0=disable)</small></i> "
"<input id='teleperiod' required name='teleperiod' type='number' min='0' max='65535' value='");
httpMessage += settings[FPSTR(F_DEBUG_TELEPERIOD)].as<String>();
httpMessage += F("'></p>");
httpMessage += F("<b>Syslog Hostame</b> <i><small>(optional)</small></i><input id='host' "
"name='host' maxlength=31 placeholder='logserver' value='");
httpMessage += settings[FPSTR(F_CONFIG_HOST)].as<String>();
httpMessage += F("'><br/><b>Syslog Port</b> <i><small>(optional)</small></i> <input id='port' required "
"name='port' type='number' min='0' max='65535' value='");
httpMessage += settings[FPSTR(F_CONFIG_PORT)].as<String>();
httpMessage += F("'><b>Syslog Facility</b> <select id='log' name='log'>");
uint8_t logid = settings[FPSTR(F_CONFIG_LOG)].as<uint8_t>();
for(uint8_t i = 0; i < 8; i++) {
httpMessage += getOption(i, String(F("Local")) + i, i == logid);
}
httpMessage += F("</select></br><b>Syslog Protocol</b> <input id='proto' name='proto' type='radio' value='0'");
if(settings[FPSTR(F_CONFIG_PROTOCOL)].as<uint8_t>() == 0) httpMessage += F(" checked");
httpMessage += F(">IETF (RFC 5424) &nbsp; <input id='proto' name='proto' type='radio' value='1'");
if(settings[FPSTR(F_CONFIG_PROTOCOL)].as<uint8_t>() == 1) httpMessage += F(" checked");
httpMessage += F(">BSD (RFC 3164)");
httpMessage += F("</p><p><button type='submit' name='save' value='debug'>Save Settings</button></p></form>");
httpMessage +=
PSTR("<p><form method='get' action='/config'><button type='submit'>Configuration</button></form></p>");
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);

View File

@ -1,6 +1,8 @@
/*********************
* INCLUDES
*********************/
#if HASP_USE_SLAVE>0
#include "hasp_slave.h"
#include <Arduino.h>
#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();
// }
}
}
#endif

View File

@ -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);

View File

@ -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);
}
}