Update hasp_conf.h defines

This commit is contained in:
fvanroie 2020-02-10 21:48:11 +01:00
parent 2c57e9d068
commit e4e3fdfc2c
7 changed files with 120 additions and 78 deletions

View File

@ -83,7 +83,7 @@ typedef int16_t lv_coord_t;
# define LV_MEM_SIZE (12U * 1024U) // 4KB # define LV_MEM_SIZE (12U * 1024U) // 4KB
#endif #endif
#ifndef LV_MEM_SIZE #ifndef LV_MEM_SIZE
# define LV_MEM_SIZE (40 * 1024U) // 40KB # define LV_MEM_SIZE (48 * 1024U) // 40KB
#endif #endif
/* Complier prefix for a big array declaration */ /* Complier prefix for a big array declaration */
@ -246,7 +246,7 @@ typedef void * lv_indev_drv_user_data_t; /*Type of user data in the i
* LV_LOG_LEVEL_ERROR Only critical issue, when the system may fail * LV_LOG_LEVEL_ERROR Only critical issue, when the system may fail
* LV_LOG_LEVEL_NONE Do not log anything * LV_LOG_LEVEL_NONE Do not log anything
*/ */
# define LV_LOG_LEVEL LV_LOG_LEVEL_NONE # define LV_LOG_LEVEL LV_LOG_LEVEL_WARN
/* 1: Print the log with 'printf'; /* 1: Print the log with 'printf';
* 0: user need to register a callback with `lv_log_register_print_cb`*/ * 0: user need to register a callback with `lv_log_register_print_cb`*/
@ -338,7 +338,7 @@ typedef void * lv_indev_drv_user_data_t; /*Type of user data in the i
* #define LV_FONT_CUSTOM_DECLARE LV_FONT_DECLARE(my_font_1) \ * #define LV_FONT_CUSTOM_DECLARE LV_FONT_DECLARE(my_font_1) \
* LV_FONT_DECLARE(my_font_2) * LV_FONT_DECLARE(my_font_2)
*/ */
#define LV_FONT_CUSTOM_DECLARE static lv_font_t *my_font[5]; #define LV_FONT_CUSTOM_DECLARE static lv_font_t *defaultFont;
/*Always set a default font from the built-in fonts*/ /*Always set a default font from the built-in fonts*/
#define LV_FONT_DEFAULT &lv_font_unscii_8 #define LV_FONT_DEFAULT &lv_font_unscii_8

View File

@ -1,6 +1,7 @@
/********************* /*********************
* INCLUDES * INCLUDES
*********************/ *********************/
#include "hasp_conf.h"
#include <Arduino.h> #include <Arduino.h>
#include "ArduinoJson.h" #include "ArduinoJson.h"
@ -8,11 +9,12 @@
#include "lv_conf.h" #include "lv_conf.h"
#include "lv_theme_hasp.h" #include "lv_theme_hasp.h"
#include "lv_objx/lv_roller.h" #include "lv_objx/lv_roller.h"
#if HASP_USE_QRCODE != 0
#include "lv_qrcode.h" #include "lv_qrcode.h"
#endif
#include "hasp_conf.h" #if HASP_USE_SPIFFS
#if LV_USE_HASP_SPIFFS
#if defined(ARDUINO_ARCH_ESP32) #if defined(ARDUINO_ARCH_ESP32)
//#include "lv_zifont.h" //#include "lv_zifont.h"
#include "SPIFFS.h" #include "SPIFFS.h"
@ -39,7 +41,7 @@
uint8_t haspStartPage = 0; uint8_t haspStartPage = 0;
uint8_t haspThemeId = 0; uint8_t haspThemeId = 0;
uint16_t haspThemeHue = 200; uint16_t haspThemeHue = 200;
char haspPagesPath[32] = "/pages.jsonl\0"; char haspPagesPath[32] = "/pages.jsonl";
char haspZiFontPath[32]; char haspZiFontPath[32];
/********************** /**********************
@ -86,15 +88,16 @@ static const char * btnm_map2[] = {"0", "1", "\n", "2", "3", "\n", "4", "5",
"\n", "6", "7", "\n", "P1", "P2", "P3", ""}; "\n", "6", "7", "\n", "P1", "P2", "P3", ""};
*/ */
static lv_font_t * haspFonts[6];
#if defined(ARDUINO_ARCH_ESP8266) #if defined(ARDUINO_ARCH_ESP8266)
static lv_obj_t * pages[4]; static lv_obj_t * pages[4];
static lv_style_t labelStyles[6]; static lv_font_t * haspFonts[4];
static lv_style_t rollerStyles[6]; static lv_style_t labelStyles[4];
static lv_style_t rollerStyles[4];
#else #else
static lv_obj_t * pages[12]; static lv_obj_t * pages[12];
static lv_style_t labelStyles[6]; static lv_font_t * haspFonts[8];
static lv_style_t rollerStyles[6]; static lv_style_t labelStyles[8];
static lv_style_t rollerStyles[8];
#endif #endif
uint16_t current_page = 0; uint16_t current_page = 0;
// uint16_t current_style = 0; // uint16_t current_style = 0;
@ -151,11 +154,8 @@ lv_obj_t * FindObjFromId(lv_obj_t * parent, uint8_t objid)
if(child->user_data && (lv_obj_user_data_t)objid == child->user_data) return child; // object found if(child->user_data && (lv_obj_user_data_t)objid == child->user_data) return child; // object found
/* check grandchildren */ /* check grandchildren */
// if(lv_obj_count_children(child) > 0) // tells the number of children on an object
//{
lv_obj_t * grandchild = FindObjFromId(child, objid); lv_obj_t * grandchild = FindObjFromId(child, objid);
if(grandchild) return grandchild; if(grandchild) return grandchild;
//}
/* next sibling */ /* next sibling */
child = lv_obj_get_child(parent, child); child = lv_obj_get_child(parent, child);
@ -188,7 +188,7 @@ void haspGetAttr(String hmiAttribute)
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
void haspProcessInput() void haspProcessInput()
{ {
#if LV_USE_HASP_MQTT > 0 #if HASP_USE_MQTT > 0
// mqttSend(topic, value); // mqttSend(topic, value);
#endif #endif
} }
@ -203,7 +203,7 @@ void haspSendNewEvent(lv_obj_t * obj, uint8_t val)
// sprintf_P(buffer, PSTR("HASP: Send p[%u].b[%u].event=%d"), pageid, objid, val); // sprintf_P(buffer, PSTR("HASP: Send p[%u].b[%u].event=%d"), pageid, objid, val);
// debugPrintln(buffer); // debugPrintln(buffer);
#if LV_USE_HASP_MQTT > 0 #if HASP_USE_MQTT > 0
mqttSendNewEvent(pageid, objid, val); mqttSendNewEvent(pageid, objid, val);
#endif #endif
} }
@ -219,7 +219,7 @@ void haspSendNewValue(lv_obj_t * obj, int32_t val)
// sprintf_P(buffer, PSTR("HASP: Send p[%u].b[%u].val=%d"), pageid, objid, val); // sprintf_P(buffer, PSTR("HASP: Send p[%u].b[%u].val=%d"), pageid, objid, val);
// debugPrintln(buffer); // debugPrintln(buffer);
#if LV_USE_HASP_MQTT > 0 #if HASP_USE_MQTT > 0
mqttSendNewValue(pageid, objid, val); mqttSendNewValue(pageid, objid, val);
#endif #endif
} }
@ -235,7 +235,7 @@ void haspSendNewValue(lv_obj_t * obj, String txt)
// sprintf_P(buffer, PSTR("HASP: Send p[%u].b[%u].txt='%s'"), pageid, objid, txt.c_str()); // sprintf_P(buffer, PSTR("HASP: Send p[%u].b[%u].txt='%s'"), pageid, objid, txt.c_str());
// debugPrintln(buffer); // debugPrintln(buffer);
#if LV_USE_HASP_MQTT > 0 #if HASP_USE_MQTT > 0
mqttSendNewValue(pageid, objid, txt); mqttSendNewValue(pageid, objid, txt);
#endif #endif
} }
@ -251,7 +251,7 @@ void haspSendNewValue(lv_obj_t * obj, const char * txt)
// sprintf_P(buffer, PSTR("HASP: Send p[%u].b[%u].txt='%s'"), pageid, objid, txt); // sprintf_P(buffer, PSTR("HASP: Send p[%u].b[%u].txt='%s'"), pageid, objid, txt);
// debugPrintln(buffer); // debugPrintln(buffer);
#if LV_USE_HASP_MQTT > 0 #if HASP_USE_MQTT > 0
mqttSendNewValue(pageid, objid, txt); mqttSendNewValue(pageid, objid, txt);
#endif #endif
} }
@ -644,9 +644,16 @@ void haspDisplayAP(const char * ssid, const char * pass)
char buffer[64]; char buffer[64];
sprintf_P(buffer, PSTR("WIFI:S:%s;T:WPA;P:%s;;"), ssid, pass); sprintf_P(buffer, PSTR("WIFI:S:%s;T:WPA;P:%s;;"), ssid, pass);
lv_obj_t * qr = lv_qrcode_create(lv_disp_get_layer_sys(NULL), 150, LV_COLOR_BLACK, LV_COLOR_WHITE); /*Clear all screens*/
for(uint8_t i = 0; i < (sizeof pages / sizeof *pages); i++) {
lv_obj_clean(pages[i]);
}
#if HASP_USE_QRCODE != 0
lv_obj_t * qr = lv_qrcode_create(lv_disp_get_layer_sys(NULL), 120, LV_COLOR_BLACK, LV_COLOR_WHITE);
lv_obj_align(qr, NULL, LV_ALIGN_CENTER, 0, 10); lv_obj_align(qr, NULL, LV_ALIGN_CENTER, 0, 10);
lv_qrcode_update(qr, buffer, strlen(buffer)); lv_qrcode_update(qr, buffer, strlen(buffer));
#endif
lv_obj_t * panel = lv_cont_create(lv_disp_get_layer_sys(NULL), NULL); lv_obj_t * panel = lv_cont_create(lv_disp_get_layer_sys(NULL), NULL);
lv_obj_set_style(panel, &lv_style_pretty); lv_obj_set_style(panel, &lv_style_pretty);
@ -764,66 +771,66 @@ void haspSetup(JsonObject settings)
// static lv_font_t * // static lv_font_t *
// my_font = (lv_font_t *)lv_mem_alloc(sizeof(lv_font_t)); // my_font = (lv_font_t *)lv_mem_alloc(sizeof(lv_font_t));
my_font[0] = (lv_font_t *)lv_mem_alloc(sizeof(lv_font_t)); defaultFont = (lv_font_t *)lv_mem_alloc(sizeof(lv_font_t));
lv_zifont_init(); lv_zifont_init();
if(lv_zifont_font_init(my_font[0], haspZiFontPath, 24) != 0) { if(lv_zifont_font_init(defaultFont, haspZiFontPath, 24) != 0) {
errorPrintln(String(F("HASP: %sFailed to set the custom font to ")) + String(haspZiFontPath)); errorPrintln(String(F("HASP: %sFailed to set the custom font to ")) + String(haspZiFontPath));
my_font[0] = NULL; // Use default font defaultFont = NULL; // Use default font
} }
lv_theme_t * th; lv_theme_t * th;
switch(haspThemeId) { switch(haspThemeId) {
#if LV_USE_THEME_ALIEN == 1 #if LV_USE_THEME_ALIEN == 1
case 1: case 1:
th = lv_theme_alien_init(haspThemeHue, my_font[0]); th = lv_theme_alien_init(haspThemeHue, defaultFont);
break; break;
#endif #endif
#if LV_USE_THEME_NIGHT == 1 #if LV_USE_THEME_NIGHT == 1
case 2: case 2:
th = lv_theme_night_init(haspThemeHue, my_font[0]); // heavy th = lv_theme_night_init(haspThemeHue, defaultFont); // heavy
break; break;
#endif #endif
#if LV_USE_THEME_MONO == 1 #if LV_USE_THEME_MONO == 1
case 3: case 3:
th = lv_theme_mono_init(haspThemeHue, my_font[0]); // lightweight th = lv_theme_mono_init(haspThemeHue, defaultFont); // lightweight
break; break;
#endif #endif
#if LV_USE_THEME_MATERIAL == 1 #if LV_USE_THEME_MATERIAL == 1
case 4: case 4:
th = lv_theme_material_init(haspThemeHue, my_font[0]); th = lv_theme_material_init(haspThemeHue, defaultFont);
break; break;
#endif #endif
#if LV_USE_THEME_ZEN == 1 #if LV_USE_THEME_ZEN == 1
case 5: case 5:
th = lv_theme_zen_init(haspThemeHue, my_font[0]); // lightweight th = lv_theme_zen_init(haspThemeHue, defaultFont); // lightweight
break; break;
#endif #endif
#if LV_USE_THEME_NEMO == 1 #if LV_USE_THEME_NEMO == 1
case 6: case 6:
th = lv_theme_nemo_init(haspThemeHue, my_font[0]); // heavy th = lv_theme_nemo_init(haspThemeHue, defaultFont); // heavy
break; break;
#endif #endif
#if LV_USE_THEME_TEMPL == 1 #if LV_USE_THEME_TEMPL == 1
case 7: case 7:
th = lv_theme_templ_init(haspThemeHue, my_font[0]); // lightweight, not for production... th = lv_theme_templ_init(haspThemeHue, defaultFont); // lightweight, not for production...
break; break;
#endif #endif
#if LV_USE_THEME_HASP == 1 #if LV_USE_THEME_HASP == 1
case 8: case 8:
th = lv_theme_hasp_init(haspThemeHue, my_font[0]); th = lv_theme_hasp_init(haspThemeHue, defaultFont);
break; break;
#endif #endif
case 0: case 0:
#if LV_USE_THEME_DEFAULT == 1 #if LV_USE_THEME_DEFAULT == 1
th = lv_theme_default_init(haspThemeHue, my_font[0]); th = lv_theme_default_init(haspThemeHue, defaultFont);
#else #else
th = lv_theme_hasp_init(512, my_font[0]); th = lv_theme_hasp_init(512, defaultFont);
#endif #endif
break; break;
default: default:
th = lv_theme_hasp_init(512, my_font[0]); th = lv_theme_hasp_init(512, defaultFont);
debugPrintln(F("HASP: Unknown theme selected")); debugPrintln(F("HASP: Unknown theme selected"));
} }
@ -1003,6 +1010,9 @@ static void btn_event_handler(lv_obj_t * obj, lv_event_t event)
uint8_t pageid = 0; uint8_t pageid = 0;
lv_obj_user_data_t objid; lv_obj_user_data_t objid;
char buffer[64];
sprintf(buffer, PSTR("HASP: "));
if(!FindIdFromObj(obj, &pageid, &objid)) { if(!FindIdFromObj(obj, &pageid, &objid)) {
errorPrintln(F("HASP: %sEvent for unknown object")); errorPrintln(F("HASP: %sEvent for unknown object"));
return; return;
@ -1010,58 +1020,56 @@ static void btn_event_handler(lv_obj_t * obj, lv_event_t event)
switch(event) { switch(event) {
case LV_EVENT_PRESSED: case LV_EVENT_PRESSED:
debugPrintln(F("HASP: Pressed Down")); strcat_P(buffer, PSTR("Pressed Down"));
debugPrintln(buffer);
eventid = 1; eventid = 1;
break; break;
case LV_EVENT_CLICKED: case LV_EVENT_CLICKED:
debugPrintln(F("HASP: Released Up")); strcat_P(buffer, PSTR("Released Up"));
debugPrintln(buffer);
// UP = the same object was release then was pressed and press was not lost! // UP = the same object was release then was pressed and press was not lost!
eventid = 0; eventid = 0;
break; break;
case LV_EVENT_SHORT_CLICKED: case LV_EVENT_SHORT_CLICKED:
debugPrintln(F("HASP: Short Click")); strcat_P(buffer, PSTR("Short Click"));
debugPrintln(buffer);
eventid = 2; eventid = 2;
break; break;
case LV_EVENT_PRESSING:
// printf("Pressing\n"); // Constant press events, do not send !
return;
case LV_EVENT_LONG_PRESSED: case LV_EVENT_LONG_PRESSED:
debugPrintln(F("HASP: Long Press")); strcat_P(buffer, PSTR("Long Press"));
debugPrintln(buffer);
eventid = 3; eventid = 3;
break; break;
case LV_EVENT_LONG_PRESSED_REPEAT: case LV_EVENT_LONG_PRESSED_REPEAT:
debugPrintln(F("HASP: Long Press Repeat")); strcat_P(buffer, PSTR("Long Hold"));
debugPrintln(buffer);
eventid = 4; eventid = 4;
break; break;
case LV_EVENT_PRESS_LOST: case LV_EVENT_PRESS_LOST:
debugPrintln(F("HASP: Press Lost")); strcat_P(buffer, PSTR("Lost Press"));
debugPrintln(buffer);
eventid = 9; eventid = 9;
break; break;
case LV_EVENT_PRESSING:
case LV_EVENT_FOCUSED:
case LV_EVENT_DEFOCUSED:
case LV_EVENT_RELEASED: case LV_EVENT_RELEASED:
// printf("p[%u].b[%u].val = %u", pageid, objid, 512);
// printf("Released\n\n"); // Not used, is also fired when dragged
return; return;
/*
lv_obj_t * child = lv_obj_get_child(obj, NULL);
if(child) lv_obj_get_type(child, &buf);
printf("obj eight %s -> ", buf.type[0]);
*/
break;
case LV_EVENT_VALUE_CHANGED: case LV_EVENT_VALUE_CHANGED:
debugPrintln(F("HASP: Value Changed Event occured")); strcat_P(buffer, PSTR("Value Changed"));
debugPrintln(buffer);
return; return;
default: default:
debugPrintln(F("HASP: Unknown Event occured")); sprintf(buffer, PSTR("HASP: Unknown Event %d occured"), event);
debugPrintln(buffer);
return; return;
} }
@ -1115,19 +1123,6 @@ static void roller_event_handler(lv_obj_t * obj, lv_event_t event)
} }
/////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////////
void haspReboot(bool write_config)
{
mqttStop(); // Stop the MQTT Client first
if(write_config) configWriteConfig();
debugStop();
delay(250);
wifiStop();
debugPrintln(F("HASP: Properly Rebooting the MCU now!"));
debugPrintln(F("-------------------------------------"));
ESP.restart();
delay(5000);
}
void haspSetNodename(String name) void haspSetNodename(String name)
{} {}
@ -1323,6 +1318,7 @@ void haspNewObject(const JsonObject & config)
lv_ddlist_set_selected(obj, val); lv_ddlist_set_selected(obj, val);
lv_ddlist_set_fix_width(obj, width); lv_ddlist_set_fix_width(obj, width);
lv_ddlist_set_draw_arrow(obj, true); lv_ddlist_set_draw_arrow(obj, true);
lv_ddlist_set_anim_time(obj, 250);
lv_obj_set_top(obj, true); lv_obj_set_top(obj, true);
// lv_obj_align(obj, NULL, LV_ALIGN_IN_TOP_MID, 0, 20); // lv_obj_align(obj, NULL, LV_ALIGN_IN_TOP_MID, 0, 20);
lv_obj_set_event_cb(obj, ddlist_event_handler); lv_obj_set_event_cb(obj, ddlist_event_handler);

View File

@ -1,15 +1,15 @@
#include "hasp_conf.h"
#include <Arduino.h> #include <Arduino.h>
#include "ArduinoJson.h" #include "ArduinoJson.h"
#if defined(ARDUINO_ARCH_ESP8266) #if defined(ARDUINO_ARCH_ESP8266)
#include <SoftwareSerial.h>
#include <ESP8266WiFi.h> #include <ESP8266WiFi.h>
#else #else
#include <Wifi.h> #include <Wifi.h>
#endif #endif
#include <WiFiUdp.h> #include <WiFiUdp.h>
#include <Syslog.h>
#include "hasp_hal.h"
#include "hasp_debug.h" #include "hasp_debug.h"
#include "hasp_config.h" #include "hasp_config.h"
@ -17,6 +17,9 @@
#include "user_config_override.h" #include "user_config_override.h"
#endif #endif
#if HASP_USE_SYSLOG != 0
#include <Syslog.h>
#ifndef SYSLOG_SERVER #ifndef SYSLOG_SERVER
#define SYSLOG_SERVER "" #define SYSLOG_SERVER ""
#endif #endif
@ -39,6 +42,7 @@ WiFiUDP syslogClient;
// Create a new empty syslog instance // Create a new empty syslog instance
Syslog syslog(syslogClient, debugSyslogHost.c_str(), debugSyslogPort, debugAppName.c_str(), debugAppName.c_str(), Syslog syslog(syslogClient, debugSyslogHost.c_str(), debugSyslogPort, debugAppName.c_str(), debugAppName.c_str(),
LOG_LOCAL0); LOG_LOCAL0);
#endif
void debugSetup() void debugSetup()
{ {
@ -54,10 +58,12 @@ void debugSetup()
// prepare syslog configuration here (can be anywhere before first call of // prepare syslog configuration here (can be anywhere before first call of
// log/logf method) // log/logf method)
#if HASP_USE_SYSLOG != 0
syslog.server(debugSyslogHost.c_str(), debugSyslogPort); syslog.server(debugSyslogHost.c_str(), debugSyslogPort);
syslog.deviceHostname(debugAppName.c_str()); syslog.deviceHostname(debugAppName.c_str());
syslog.appName(debugAppName.c_str()); syslog.appName(debugAppName.c_str());
syslog.defaultPriority(LOG_LOCAL0); syslog.defaultPriority(LOG_LOCAL0);
#endif
} }
void debugLoop() void debugLoop()
@ -65,11 +71,21 @@ void debugLoop()
void serialPrintln(String debugText) void serialPrintln(String debugText)
{ {
String debugTimeText = String debugTimeText((char *)0);
"[+" + String(float(millis()) / 1000, 3) + "s] " + String(ESP.getFreeHeap()) + " " + debugText; debugTimeText.reserve(128);
debugTimeText = F("[");
debugTimeText += String(float(millis()) / 1000, 3);
debugTimeText += F("s] ");
debugTimeText += ESP.getFreeHeap();
debugTimeText += F(" ");
debugTimeText += halGetHeapFragmentation();
debugTimeText += F(" ");
debugTimeText += debugText;
Serial.println(debugTimeText); Serial.println(debugTimeText);
} }
#if HASP_USE_SYSLOG != 0
void syslogSend(uint8_t log, const char * debugText) void syslogSend(uint8_t log, const char * debugText)
{ {
if(WiFi.isConnected() && debugSyslogHost != "") { if(WiFi.isConnected() && debugSyslogHost != "") {
@ -85,6 +101,7 @@ void syslogSend(uint8_t log, const char * debugText)
} }
} }
} }
#endif
void debugStop() void debugStop()
{ {

View File

@ -1,13 +1,16 @@
#include "hasp_conf.h"
#include <Arduino.h> #include <Arduino.h>
#if defined(ARDUINO_ARCH_ESP8266) #if defined(ARDUINO_ARCH_ESP8266)
#include <SoftwareSerial.h>
#include <ESP8266WiFi.h> #include <ESP8266WiFi.h>
#else #else
#include <Wifi.h> #include <Wifi.h>
#endif #endif
#include <WiFiUdp.h> #include <WiFiUdp.h>
#if HASP_USE_SYSLOG != 0
#include <Syslog.h> #include <Syslog.h>
#endif
#include "hasp_log.h" #include "hasp_log.h"
#include "hasp_debug.h" #include "hasp_debug.h"
@ -15,7 +18,10 @@
void debugPrintln(String debugText) void debugPrintln(String debugText)
{ {
serialPrintln(debugText); serialPrintln(debugText);
#if HASP_USE_SYSLOG != 0
syslogSend(0, debugText.c_str()); syslogSend(0, debugText.c_str());
#endif
} }
void errorPrintln(String debugText) void errorPrintln(String debugText)
@ -23,7 +29,10 @@ void errorPrintln(String debugText)
char buffer[256]; char buffer[256];
sprintf_P(buffer, debugText.c_str(), PSTR("[ERROR] ")); sprintf_P(buffer, debugText.c_str(), PSTR("[ERROR] "));
serialPrintln(buffer); serialPrintln(buffer);
#if HASP_USE_SYSLOG != 0
syslogSend(2, buffer); syslogSend(2, buffer);
#endif
} }
void warningPrintln(String debugText) void warningPrintln(String debugText)
@ -31,5 +40,8 @@ void warningPrintln(String debugText)
char buffer[256]; char buffer[256];
sprintf_P(buffer, debugText.c_str(), PSTR("[WARNING] ")); sprintf_P(buffer, debugText.c_str(), PSTR("[WARNING] "));
serialPrintln(buffer); serialPrintln(buffer);
#if HASP_USE_SYSLOG != 0
syslogSend(1, buffer); syslogSend(1, buffer);
#endif
} }

View File

@ -5,7 +5,7 @@
#include "hasp_log.h" #include "hasp_log.h"
#include "hasp_spiffs.h" #include "hasp_spiffs.h"
#if LV_USE_HASP_SPIFFS #if HASP_USE_SPIFFS
#if defined(ARDUINO_ARCH_ESP32) #if defined(ARDUINO_ARCH_ESP32)
#include "SPIFFS.h" #include "SPIFFS.h"
#endif #endif
@ -40,7 +40,7 @@ void spiffsSetup()
{ {
// no SPIFFS settings, as settings depend on SPIFFS // no SPIFFS settings, as settings depend on SPIFFS
#if LV_USE_HASP_SPIFFS #if HASP_USE_SPIFFS
char msg[64]; char msg[64];
#if defined(ARDUINO_ARCH_ESP8266) #if defined(ARDUINO_ARCH_ESP8266)
if(!SPIFFS.begin()) { if(!SPIFFS.begin()) {
@ -58,4 +58,17 @@ void spiffsSetup()
} }
void spiffsLoop() void spiffsLoop()
{} {}
String spiffsFormatBytes(size_t bytes)
{
if(bytes < 1024) {
return String(bytes) + "B";
} else if(bytes < (1024 * 1024)) {
return String(bytes / 1024.0) + "KB";
} else if(bytes < (1024 * 1024 * 1024)) {
return String(bytes / 1024.0 / 1024.0) + "MB";
} else {
return String(bytes / 1024.0 / 1024.0 / 1024.0) + "GB";
}
}

View File

@ -1,8 +1,12 @@
#ifndef HASP_SPIFFS_H #ifndef HASP_SPIFFS_H
#define HASP_SPIFFS_H #define HASP_SPIFFS_H
#include <Arduino.h>
void spiffsSetup(void); void spiffsSetup(void);
void spiffsLoop(void); void spiffsLoop(void);
void spiffsList(); void spiffsList();
String spiffsFormatBytes(size_t bytes);
#endif #endif

View File

@ -150,7 +150,7 @@ void wifiSetup(JsonObject settings)
debugPrintln(buffer); debugPrintln(buffer);
sprintf_P(buffer, PSTR("WIFI: AP IP address : %s"), IP.toString().c_str()); sprintf_P(buffer, PSTR("WIFI: AP IP address : %s"), IP.toString().c_str());
debugPrintln(buffer); debugPrintln(buffer);
haspDisplayAP(apSsdid.c_str(), "haspadmin"); // haspDisplayAP(apSsdid.c_str(), "haspadmin");
httpReconnect(); httpReconnect();
return; return;
} }