Update License header

This commit is contained in:
fvanroie 2021-02-23 01:37:38 +01:00
parent 28f420be1c
commit 8b25b87b3f
81 changed files with 422 additions and 421 deletions

View File

@ -1,4 +1,4 @@
/* MIT License - Copyright (c) 2020 Francis Van Roie /* MIT License - Copyright (c) 2019-2021 Francis Van Roie
For full license information read the LICENSE file in the project folder */ For full license information read the LICENSE file in the project folder */
/*************************************************** /***************************************************

View File

@ -1,4 +1,4 @@
/* MIT License - Copyright (c) 2020 Francis Van Roie /* MIT License - Copyright (c) 2019-2021 Francis Van Roie
For full license information read the LICENSE file in the project folder */ For full license information read the LICENSE file in the project folder */
#include "device.h" #include "device.h"

View File

@ -1,4 +1,4 @@
/* MIT License - Copyright (c) 2020 Francis Van Roie /* MIT License - Copyright (c) 2019-2021 Francis Van Roie
For full license information read the LICENSE file in the project folder */ For full license information read the LICENSE file in the project folder */
#ifndef HASP_DEVICE_H #ifndef HASP_DEVICE_H

View File

@ -1,4 +1,4 @@
/* MIT License - Copyright (c) 2020 Francis Van Roie /* MIT License - Copyright (c) 2019-2021 Francis Van Roie
For full license information read the LICENSE file in the project folder */ For full license information read the LICENSE file in the project folder */
#if defined(ESP32) #if defined(ESP32)

View File

@ -1,4 +1,4 @@
/* MIT License - Copyright (c) 2020 Francis Van Roie /* MIT License - Copyright (c) 2019-2021 Francis Van Roie
For full license information read the LICENSE file in the project folder */ For full license information read the LICENSE file in the project folder */
#ifndef HASP_DEVICE_ESP32_H #ifndef HASP_DEVICE_ESP32_H

View File

@ -1,4 +1,4 @@
/* MIT License - Copyright (c) 2020 Francis Van Roie /* MIT License - Copyright (c) 2019-2021 Francis Van Roie
For full license information read the LICENSE file in the project folder */ For full license information read the LICENSE file in the project folder */
#include "lanbonl8.h" #include "lanbonl8.h"

View File

@ -1,4 +1,4 @@
/* MIT License - Copyright (c) 2020 Francis Van Roie /* MIT License - Copyright (c) 2019-2021 Francis Van Roie
For full license information read the LICENSE file in the project folder */ For full license information read the LICENSE file in the project folder */
#ifndef HASP_DEVICE_LANBONL8_H #ifndef HASP_DEVICE_LANBONL8_H

View File

@ -1,4 +1,4 @@
/* MIT License - Copyright (c) 2020 Francis Van Roie /* MIT License - Copyright (c) 2019-2021 Francis Van Roie
For full license information read the LICENSE file in the project folder */ For full license information read the LICENSE file in the project folder */
#include "m5stackcore2.h" #include "m5stackcore2.h"

View File

@ -1,4 +1,4 @@
/* MIT License - Copyright (c) 2020 Francis Van Roie /* MIT License - Copyright (c) 2019-2021 Francis Van Roie
For full license information read the LICENSE file in the project folder */ For full license information read the LICENSE file in the project folder */
#ifndef HASP_DEVICE_M5STACKCORE2_H #ifndef HASP_DEVICE_M5STACKCORE2_H

View File

@ -1,4 +1,4 @@
/* MIT License - Copyright (c) 2020 Francis Van Roie /* MIT License - Copyright (c) 2019-2021 Francis Van Roie
For full license information read the LICENSE file in the project folder */ For full license information read the LICENSE file in the project folder */
#if defined(ESP8266) #if defined(ESP8266)

View File

@ -1,4 +1,4 @@
/* MIT License - Copyright (c) 2020 Francis Van Roie /* MIT License - Copyright (c) 2019-2021 Francis Van Roie
For full license information read the LICENSE file in the project folder */ For full license information read the LICENSE file in the project folder */
#ifndef HASP_DEVICE_ESP8266_H #ifndef HASP_DEVICE_ESP8266_H

View File

@ -1,4 +1,4 @@
/* MIT License - Copyright (c) 2020 Francis Van Roie /* MIT License - Copyright (c) 2019-2021 Francis Van Roie
For full license information read the LICENSE file in the project folder */ For full license information read the LICENSE file in the project folder */
#if defined(WINDOWS) #if defined(WINDOWS)

View File

@ -1,4 +1,4 @@
/* MIT License - Copyright (c) 2020 Francis Van Roie /* MIT License - Copyright (c) 2019-2021 Francis Van Roie
For full license information read the LICENSE file in the project folder */ For full license information read the LICENSE file in the project folder */
#ifndef HASP_DEVICE_WINDOWS_H #ifndef HASP_DEVICE_WINDOWS_H

View File

@ -1,4 +1,4 @@
/* MIT License - Copyright (c) 2020 Francis Van Roie /* MIT License - Copyright (c) 2019-2021 Francis Van Roie
For full license information read the LICENSE file in the project folder */ For full license information read the LICENSE file in the project folder */
#include "hasp_drv_display.h" #include "hasp_drv_display.h"

View File

@ -1,4 +1,4 @@
/* MIT License - Copyright (c) 2020 Francis Van Roie /* MIT License - Copyright (c) 2019-2021 Francis Van Roie
For full license information read the LICENSE file in the project folder */ For full license information read the LICENSE file in the project folder */
#ifndef HASP_DRV_DISPLAY_H #ifndef HASP_DRV_DISPLAY_H
@ -8,12 +8,12 @@
// Select Display Driver // Select Display Driver
#if defined(USE_FSMC) #if defined(USE_FSMC)
#include "fsmc_ili9341.h" #include "fsmc_ili9341.h"
#else #else
#include "tft_espi_drv.h" #include "tft_espi_drv.h"
#endif #endif
void drv_display_init(lv_disp_drv_t * disp_drv, uint8_t rotation, bool invert_display); void drv_display_init(lv_disp_drv_t* disp_drv, uint8_t rotation, bool invert_display);
void drv_display_flush_cb(lv_disp_drv_t * disp, const lv_area_t * area, lv_color_t * color_p); void drv_display_flush_cb(lv_disp_drv_t* disp, const lv_area_t* area, lv_color_t* color_p);
#endif #endif

View File

@ -1,4 +1,4 @@
/* MIT License - Copyright (c) 2020 Francis Van Roie /* MIT License - Copyright (c) 2019-2021 Francis Van Roie
For full license information read the LICENSE file in the project folder */ For full license information read the LICENSE file in the project folder */
#include "hasp_drv_touch.h" #include "hasp_drv_touch.h"

View File

@ -1,4 +1,4 @@
/* MIT License - Copyright (c) 2020 Francis Van Roie /* MIT License - Copyright (c) 2019-2021 Francis Van Roie
For full license information read the LICENSE file in the project folder */ For full license information read the LICENSE file in the project folder */
#ifndef HASP_DRV_TOUCH_H #ifndef HASP_DRV_TOUCH_H
@ -7,11 +7,11 @@
#include "lvgl.h" #include "lvgl.h"
#ifndef TOUCH_DRIVER #ifndef TOUCH_DRIVER
#define TOUCH_DRIVER -1 // No Touch #define TOUCH_DRIVER -1 // No Touch
#endif #endif
void drv_touch_init(uint8_t rotation); void drv_touch_init(uint8_t rotation);
bool drv_touch_read(lv_indev_drv_t * indev_driver, lv_indev_data_t * data); bool drv_touch_read(lv_indev_drv_t* indev_driver, lv_indev_data_t* data);
void drv_touch_loop(); void drv_touch_loop();
#endif #endif

View File

@ -1,4 +1,4 @@
/* MIT License - Copyright (c) 2020 Francis Van Roie /* MIT License - Copyright (c) 2019-2021 Francis Van Roie
For full license information read the LICENSE file in the project folder */ For full license information read the LICENSE file in the project folder */
#ifndef HASP_BASE_TFT_DRIVER_H #ifndef HASP_BASE_TFT_DRIVER_H

View File

@ -1,4 +1,4 @@
/* MIT License - Copyright (c) 2020 Francis Van Roie /* MIT License - Copyright (c) 2019-2021 Francis Van Roie
For full license information read the LICENSE file in the project folder */ For full license information read the LICENSE file in the project folder */
#ifndef HASP_SDL2_DRIVER_H #ifndef HASP_SDL2_DRIVER_H

View File

@ -1,4 +1,4 @@
/* MIT License - Copyright (c) 2020 Francis Van Roie /* MIT License - Copyright (c) 2019-2021 Francis Van Roie
For full license information read the LICENSE file in the project folder */ For full license information read the LICENSE file in the project folder */
#ifdef ARDUINO #ifdef ARDUINO

View File

@ -1,4 +1,4 @@
/* MIT License - Copyright (c) 2020 Francis Van Roie /* MIT License - Copyright (c) 2019-2021 Francis Van Roie
For full license information read the LICENSE file in the project folder */ For full license information read the LICENSE file in the project folder */
#ifndef HASP_TFTESPI_DRIVER_H #ifndef HASP_TFTESPI_DRIVER_H

View File

@ -1,4 +1,4 @@
/* MIT License - Copyright (c) 2020 Francis Van Roie /* MIT License - Copyright (c) 2019-2021 Francis Van Roie
For full license information read the LICENSE file in the project folder */ For full license information read the LICENSE file in the project folder */
/********************* /*********************

View File

@ -1,4 +1,4 @@
/* MIT License - Copyright (c) 2020 Francis Van Roie /* MIT License - Copyright (c) 2019-2021 Francis Van Roie
For full license information read the LICENSE file in the project folder */ For full license information read the LICENSE file in the project folder */
#ifndef TFT_ESPI_DRV_H #ifndef TFT_ESPI_DRV_H

View File

@ -1,4 +1,4 @@
/* MIT License - Copyright (c) 2020 Francis Van Roie /* MIT License - Copyright (c) 2019-2021 Francis Van Roie
For full license information read the LICENSE file in the project folder */ For full license information read the LICENSE file in the project folder */
#ifndef HASP_DRV_FT5206_H #ifndef HASP_DRV_FT5206_H
@ -10,7 +10,7 @@
#include "hasp_debug.h" // for TAG_DRVR #include "hasp_debug.h" // for TAG_DRVR
bool FT5206_getXY(int16_t * touchX, int16_t * touchY, bool debug); bool FT5206_getXY(int16_t* touchX, int16_t* touchY, bool debug);
void FT5206_init(); void FT5206_init();
#endif #endif

View File

@ -1,4 +1,4 @@
/* MIT License - Copyright (c) 2020 Francis Van Roie /* MIT License - Copyright (c) 2019-2021 Francis Van Roie
For full license information read the LICENSE file in the project folder */ For full license information read the LICENSE file in the project folder */
#ifndef HASP_DRV_FT6336U_H #ifndef HASP_DRV_FT6336U_H
@ -8,7 +8,7 @@
#include "hasp_debug.h" // for TAG_DRVR #include "hasp_debug.h" // for TAG_DRVR
bool FT6336U_getXY(int16_t * touchX, int16_t * touchY, bool debug); bool FT6336U_getXY(int16_t* touchX, int16_t* touchY, bool debug);
void FT6336U_init(); void FT6336U_init();
#endif #endif

View File

@ -1,4 +1,4 @@
/* MIT License - Copyright (c) 2020 Francis Van Roie /* MIT License - Copyright (c) 2019-2021 Francis Van Roie
For full license information read the LICENSE file in the project folder */ For full license information read the LICENSE file in the project folder */
#ifndef HASP_DRV_911_H #ifndef HASP_DRV_911_H
@ -8,7 +8,7 @@
#include "hasp_debug.h" // for TAG_DRVR #include "hasp_debug.h" // for TAG_DRVR
bool GT911_getXY(int16_t * touchX, int16_t * touchY, bool debug); bool GT911_getXY(int16_t* touchX, int16_t* touchY, bool debug);
void GT911_init(); void GT911_init();
void GT911_loop(); void GT911_loop();

View File

@ -1,4 +1,4 @@
/* MIT License - Copyright (c) 2020 Francis Van Roie /* MIT License - Copyright (c) 2019-2021 Francis Van Roie
For full license information read the LICENSE file in the project folder */ For full license information read the LICENSE file in the project folder */
#ifndef HASP_DRV_XPT2046B_H #ifndef HASP_DRV_XPT2046B_H
@ -6,18 +6,18 @@
#if TOUCH_DRIVER == 0x2046B #if TOUCH_DRIVER == 0x2046B
#include "XPT2046_Touchscreen.h" #include "XPT2046_Touchscreen.h"
#define XPT2046_HOR_RES TFT_WIDTH #define XPT2046_HOR_RES TFT_WIDTH
#define XPT2046_VER_RES TFT_HEIGHT #define XPT2046_VER_RES TFT_HEIGHT
#define XPT2046_X_MIN 200 #define XPT2046_X_MIN 200
#define XPT2046_Y_MIN 200 #define XPT2046_Y_MIN 200
#define XPT2046_X_MAX 3800 #define XPT2046_X_MAX 3800
#define XPT2046_Y_MAX 3800 #define XPT2046_Y_MAX 3800
#define XPT2046_AVG 4 #define XPT2046_AVG 4
#define XPT2046_INV 0 #define XPT2046_INV 0
bool XPT2046_getXY(int16_t * touchX, int16_t * touchY, bool debug); bool XPT2046_getXY(int16_t* touchX, int16_t* touchY, bool debug);
void XPT2046_init(); void XPT2046_init();
#endif #endif

View File

@ -1,4 +1,4 @@
/* MIT License - Copyright (c) 2020 Francis Van Roie /* MIT License - Copyright (c) 2019-2021 Francis Van Roie
For full license information read the LICENSE file in the project folder */ For full license information read the LICENSE file in the project folder */
#include "hasp_hal.h" #include "hasp_hal.h"
@ -26,7 +26,7 @@ String esp32ResetReason(uint8_t cpuid)
} }
RESET_REASON reason = rtc_get_reset_reason(cpuid); RESET_REASON reason = rtc_get_reset_reason(cpuid);
String resetReason((char *)0); String resetReason((char*)0);
resetReason.reserve(128); resetReason.reserve(128);
resetReason += F("CPU"); resetReason += F("CPU");
@ -102,7 +102,7 @@ void halRestartMcu(void)
String halGetResetInfo() String halGetResetInfo()
{ {
#if defined(ARDUINO_ARCH_ESP32) #if defined(ARDUINO_ARCH_ESP32)
String resetReason((char *)0); String resetReason((char*)0);
resetReason.reserve(128); resetReason.reserve(128);
resetReason += String(esp32ResetReason(0)); resetReason += String(esp32ResetReason(0));
@ -129,7 +129,7 @@ String halGetCoreVersion()
String halGetChipModel() String halGetChipModel()
{ {
String model((char *)0); String model((char*)0);
model.reserve(128); model.reserve(128);
#if defined(STM32F4xx) #if defined(STM32F4xx)
@ -181,7 +181,7 @@ int freeHighMemory()
{ {
char top; char top;
#ifdef __arm__ #ifdef __arm__
return &top - reinterpret_cast<char *>(sbrk(0)); return &top - reinterpret_cast<char*>(sbrk(0));
#elif defined(CORE_TEENSY) || (ARDUINO > 103 && ARDUINO != 151) #elif defined(CORE_TEENSY) || (ARDUINO > 103 && ARDUINO != 151)
return &top - __brkval; return &top - __brkval;
#else // __arm__ #else // __arm__
@ -254,12 +254,12 @@ uint8_t halGetHeapFragmentation()
#endif #endif
} }
String halGetMacAddress(int start, const char * seperator) String halGetMacAddress(int start, const char* seperator)
{ {
byte mac[6]; byte mac[6];
#if defined(STM32F4xx) #if defined(STM32F4xx)
uint8_t * mac_p = nullptr; uint8_t* mac_p = nullptr;
#if HASP_USE_ETHERNET > 0 #if HASP_USE_ETHERNET > 0
#if USE_BUILTIN_ETHERNET > 0 #if USE_BUILTIN_ETHERNET > 0
mac_p = Ethernet.MACAddress(); mac_p = Ethernet.MACAddress();
@ -272,7 +272,7 @@ String halGetMacAddress(int start, const char * seperator)
WiFi.macAddress(mac); WiFi.macAddress(mac);
#endif #endif
String cMac((char *)0); String cMac((char*)0);
cMac.reserve(32); cMac.reserve(32);
for(int i = start; i < 6; ++i) { for(int i = start; i < 6; ++i) {

View File

@ -1,4 +1,4 @@
/* MIT License - Copyright (c) 2020 Francis Van Roie /* MIT License - Copyright (c) 2019-2021 Francis Van Roie
For full license information read the LICENSE file in the project folder */ For full license information read the LICENSE file in the project folder */
#ifndef HASP_HAL_H #ifndef HASP_HAL_H
@ -13,7 +13,7 @@ String halGetResetInfo(void);
// size_t halGetFreeHeap(void); // size_t halGetFreeHeap(void);
String halGetCoreVersion(void); String halGetCoreVersion(void);
String halGetChipModel(); String halGetChipModel();
String halGetMacAddress(int start, const char * seperator); String halGetMacAddress(int start, const char* seperator);
// uint16_t halGetCpuFreqMHz(void); // uint16_t halGetCpuFreqMHz(void);
String halDisplayDriverName(void); String halDisplayDriverName(void);
String halGpioName(uint8_t gpio); String halGpioName(uint8_t gpio);

View File

@ -1,4 +1,4 @@
/* MIT License - Copyright (c) 2020 Francis Van Roie /* MIT License - Copyright (c) 2019-2021 Francis Van Roie
For full license information read the LICENSE file in the project folder */ For full license information read the LICENSE file in the project folder */
#ifdef ARDUINO #ifdef ARDUINO

View File

@ -1,4 +1,4 @@
/* MIT License - Copyright (c) 2020 Francis Van Roie /* MIT License - Copyright (c) 2019-2021 Francis Van Roie
For full license information read the LICENSE file in the project folder */ For full license information read the LICENSE file in the project folder */
#ifndef HASP_H #ifndef HASP_H

View File

@ -1,13 +1,13 @@
/* MIT License - Copyright (c) 2020 Francis Van Roie /* MIT License - Copyright (c) 2019-2021 Francis Van Roie
For full license information read the LICENSE file in the project folder */ For full license information read the LICENSE file in the project folder */
#ifdef ARDUINO #ifdef ARDUINO
#include "ArduinoLog.h" #include "ArduinoLog.h"
#endif #endif
#include "lvgl.h" #include "lvgl.h"
#if LVGL_VERSION_MAJOR != 7 #if LVGL_VERSION_MAJOR != 7
#include "../lv_components.h" #include "../lv_components.h"
#endif #endif
#include "hasp.h" #include "hasp.h"
@ -18,8 +18,8 @@
#include "hasp_parser.h" #include "hasp_parser.h"
LV_FONT_DECLARE(unscii_8_icon); LV_FONT_DECLARE(unscii_8_icon);
extern lv_font_t * haspFonts[8]; extern lv_font_t* haspFonts[8];
extern const char ** btnmatrix_default_map; // memory pointer to lvgl default btnmatrix map extern const char** btnmatrix_default_map; // memory pointer to lvgl default btnmatrix map
#if 0 #if 0
static bool attribute_lookup_lv_property(uint16_t hash, uint8_t * prop) static bool attribute_lookup_lv_property(uint16_t hash, uint8_t * prop)
@ -111,20 +111,20 @@ static bool attribute_lookup_lv_property(uint16_t hash, uint8_t * prop)
{ATTR_TRANSITION_PATH, LV_STYLE_TRANSITION_PATH & LV_STYLE_PROP_ALL}, {ATTR_TRANSITION_PATH, LV_STYLE_TRANSITION_PATH & LV_STYLE_PROP_ALL},
{ATTR_VALUE_STR, LV_STYLE_VALUE_STR & LV_STYLE_PROP_ALL}, {ATTR_VALUE_STR, LV_STYLE_VALUE_STR & LV_STYLE_PROP_ALL},
#if LV_USE_SHADOW #if LV_USE_SHADOW
{ATTR_SHADOW_WIDTH, LV_STYLE_SHADOW_WIDTH & LV_STYLE_PROP_ALL}, {ATTR_SHADOW_WIDTH, LV_STYLE_SHADOW_WIDTH & LV_STYLE_PROP_ALL},
{ATTR_SHADOW_OFS_X, LV_STYLE_SHADOW_OFS_X & LV_STYLE_PROP_ALL}, {ATTR_SHADOW_OFS_X, LV_STYLE_SHADOW_OFS_X & LV_STYLE_PROP_ALL},
{ATTR_SHADOW_OFS_Y, LV_STYLE_SHADOW_OFS_Y & LV_STYLE_PROP_ALL}, {ATTR_SHADOW_OFS_Y, LV_STYLE_SHADOW_OFS_Y & LV_STYLE_PROP_ALL},
{ATTR_SHADOW_SPREAD, LV_STYLE_SHADOW_SPREAD & LV_STYLE_PROP_ALL}, {ATTR_SHADOW_SPREAD, LV_STYLE_SHADOW_SPREAD & LV_STYLE_PROP_ALL},
{ATTR_SHADOW_COLOR, LV_STYLE_SHADOW_COLOR & LV_STYLE_PROP_ALL}, {ATTR_SHADOW_COLOR, LV_STYLE_SHADOW_COLOR & LV_STYLE_PROP_ALL},
{ATTR_SHADOW_OPA, LV_STYLE_SHADOW_OPA & LV_STYLE_PROP_ALL}, {ATTR_SHADOW_OPA, LV_STYLE_SHADOW_OPA & LV_STYLE_PROP_ALL},
#endif #endif
#if LV_USE_BLEND_MODES && LV_USE_SHADOW #if LV_USE_BLEND_MODES && LV_USE_SHADOW
{ATTR_SHADOW_BLEND_MODE, LV_STYLE_SHADOW_BLEND_MODE & LV_STYLE_PROP_ALL}, {ATTR_SHADOW_BLEND_MODE, LV_STYLE_SHADOW_BLEND_MODE & LV_STYLE_PROP_ALL},
#endif #endif
#if LV_USE_BLEND_MODES #if LV_USE_BLEND_MODES
{ATTR_BG_BLEND_MODE, LV_STYLE_BG_BLEND_MODE & LV_STYLE_PROP_ALL}, {ATTR_BG_BLEND_MODE, LV_STYLE_BG_BLEND_MODE & LV_STYLE_PROP_ALL},
{ATTR_PATTERN_BLEND_MODE, LV_STYLE_PATTERN_BLEND_MODE & LV_STYLE_PROP_ALL}, {ATTR_PATTERN_BLEND_MODE, LV_STYLE_PATTERN_BLEND_MODE & LV_STYLE_PROP_ALL},
{ATTR_IMAGE_BLEND_MODE, LV_STYLE_IMAGE_BLEND_MODE & LV_STYLE_PROP_ALL}, {ATTR_IMAGE_BLEND_MODE, LV_STYLE_IMAGE_BLEND_MODE & LV_STYLE_PROP_ALL},
@ -133,7 +133,7 @@ static bool attribute_lookup_lv_property(uint16_t hash, uint8_t * prop)
{ATTR_OUTLINE_BLEND_MODE, LV_STYLE_OUTLINE_BLEND_MODE & LV_STYLE_PROP_ALL}, {ATTR_OUTLINE_BLEND_MODE, LV_STYLE_OUTLINE_BLEND_MODE & LV_STYLE_PROP_ALL},
{ATTR_VALUE_BLEND_MODE, LV_STYLE_VALUE_BLEND_MODE & LV_STYLE_PROP_ALL}, {ATTR_VALUE_BLEND_MODE, LV_STYLE_VALUE_BLEND_MODE & LV_STYLE_PROP_ALL},
{ATTR_TEXT_BLEND_MODE, LV_STYLE_TEXT_BLEND_MODE & LV_STYLE_PROP_ALL}, {ATTR_TEXT_BLEND_MODE, LV_STYLE_TEXT_BLEND_MODE & LV_STYLE_PROP_ALL},
#endif #endif
}; };
for(uint32_t i = 0; i < sizeof(props) / sizeof(props[0]); i++) { for(uint32_t i = 0; i < sizeof(props) / sizeof(props[0]); i++) {
@ -185,9 +185,9 @@ static bool attribute_update_lv_property(lv_obj_t * obj, const char * attr_p, ui
#endif #endif
// OK - this function is missing in lvgl // OK - this function is missing in lvgl
static uint8_t my_roller_get_visible_row_count(lv_obj_t * roller) static uint8_t my_roller_get_visible_row_count(lv_obj_t* roller)
{ {
const lv_font_t * font = lv_obj_get_style_text_font(roller, LV_ROLLER_PART_BG); const lv_font_t* font = lv_obj_get_style_text_font(roller, LV_ROLLER_PART_BG);
lv_style_int_t line_space = lv_obj_get_style_text_line_space(roller, LV_ROLLER_PART_BG); lv_style_int_t line_space = lv_obj_get_style_text_line_space(roller, LV_ROLLER_PART_BG);
lv_coord_t h = lv_obj_get_height(roller); lv_coord_t h = lv_obj_get_height(roller);
@ -198,32 +198,32 @@ static uint8_t my_roller_get_visible_row_count(lv_obj_t * roller)
} }
// OK - this function is missing in lvgl // OK - this function is missing in lvgl
static inline int16_t my_arc_get_rotation(lv_obj_t * arc) static inline int16_t my_arc_get_rotation(lv_obj_t* arc)
{ {
lv_arc_ext_t * ext = (lv_arc_ext_t *)lv_obj_get_ext_attr(arc); lv_arc_ext_t* ext = (lv_arc_ext_t*)lv_obj_get_ext_attr(arc);
return ext->rotation_angle; return ext->rotation_angle;
} }
// OK - this function is missing in lvgl // OK - this function is missing in lvgl
static inline int16_t my_chart_get_min_value(lv_obj_t * chart) static inline int16_t my_chart_get_min_value(lv_obj_t* chart)
{ {
lv_chart_ext_t * ext = (lv_chart_ext_t *)lv_obj_get_ext_attr(chart); lv_chart_ext_t* ext = (lv_chart_ext_t*)lv_obj_get_ext_attr(chart);
return ext->ymin[LV_CHART_AXIS_PRIMARY_Y]; return ext->ymin[LV_CHART_AXIS_PRIMARY_Y];
} }
// OK - this function is missing in lvgl // OK - this function is missing in lvgl
static inline int16_t my_chart_get_max_value(lv_obj_t * chart) static inline int16_t my_chart_get_max_value(lv_obj_t* chart)
{ {
lv_chart_ext_t * ext = (lv_chart_ext_t *)lv_obj_get_ext_attr(chart); lv_chart_ext_t* ext = (lv_chart_ext_t*)lv_obj_get_ext_attr(chart);
return ext->ymax[LV_CHART_AXIS_PRIMARY_Y]; return ext->ymax[LV_CHART_AXIS_PRIMARY_Y];
} }
lv_chart_series_t * my_chart_get_series(lv_obj_t * chart, uint8_t ser_num) lv_chart_series_t* my_chart_get_series(lv_obj_t* chart, uint8_t ser_num)
{ {
lv_chart_ext_t * ext = (lv_chart_ext_t *)lv_obj_get_ext_attr(chart); lv_chart_ext_t* ext = (lv_chart_ext_t*)lv_obj_get_ext_attr(chart);
lv_chart_series_t * ser = (lv_chart_series_t *)_lv_ll_get_tail(&ext->series_ll); lv_chart_series_t* ser = (lv_chart_series_t*)_lv_ll_get_tail(&ext->series_ll);
while(ser_num > 0 && ser) { while(ser_num > 0 && ser) {
ser = (lv_chart_series_t *)_lv_ll_get_prev(&ext->series_ll, ser); ser = (lv_chart_series_t*)_lv_ll_get_prev(&ext->series_ll, ser);
ser_num--; ser_num--;
} }
return ser; return ser;
@ -234,11 +234,11 @@ lv_chart_series_t * my_chart_get_series(lv_obj_t * chart, uint8_t ser_num)
* @param obj pointer to a object * @param obj pointer to a object
* @param text '\0' terminated character string. NULL to refresh with the current text. * @param text '\0' terminated character string. NULL to refresh with the current text.
*/ */
void my_obj_set_value_str_txt(lv_obj_t * obj, uint8_t part, lv_state_t state, const char * text) void my_obj_set_value_str_txt(lv_obj_t* obj, uint8_t part, lv_state_t state, const char* text)
{ {
// LOG_VERBOSE(TAG_ATTR, F("%s %d"), __FILE__, __LINE__); // LOG_VERBOSE(TAG_ATTR, F("%s %d"), __FILE__, __LINE__);
const void * value_str_p = lv_obj_get_style_value_str(obj, part); const void* value_str_p = lv_obj_get_style_value_str(obj, part);
lv_obj_invalidate(obj); lv_obj_invalidate(obj);
if(text == NULL || text[0] == 0) { if(text == NULL || text[0] == 0) {
@ -257,13 +257,13 @@ void my_obj_set_value_str_txt(lv_obj_t * obj, uint8_t part, lv_state_t state, co
/*Allocate space for the new text*/ /*Allocate space for the new text*/
// LOG_VERBOSE(TAG_ATTR, F("%s %d"), __FILE__, __LINE__); // LOG_VERBOSE(TAG_ATTR, F("%s %d"), __FILE__, __LINE__);
value_str_p = (char *)lv_mem_alloc(len); value_str_p = (char*)lv_mem_alloc(len);
LV_ASSERT_MEM(value_str_p); LV_ASSERT_MEM(value_str_p);
if(value_str_p == NULL) return; if(value_str_p == NULL) return;
// LOG_VERBOSE(TAG_ATTR, F("%s %d"), __FILE__, __LINE__); // LOG_VERBOSE(TAG_ATTR, F("%s %d"), __FILE__, __LINE__);
strncpy((char *)value_str_p, text, len); strncpy((char*)value_str_p, text, len);
lv_obj_set_style_local_value_str(obj, part, state, (char *)value_str_p); lv_obj_set_style_local_value_str(obj, part, state, (char*)value_str_p);
// LOG_VERBOSE(TAG_ATTR, F("%s %d"), __FILE__, __LINE__); // LOG_VERBOSE(TAG_ATTR, F("%s %d"), __FILE__, __LINE__);
return; return;
} }
@ -294,17 +294,17 @@ void my_obj_set_value_str_txt(lv_obj_t * obj, uint8_t part, lv_state_t state, co
/*Allocate space for the new text*/ /*Allocate space for the new text*/
value_str_p = lv_mem_alloc(len); value_str_p = lv_mem_alloc(len);
LV_ASSERT_MEM(value_str_p); LV_ASSERT_MEM(value_str_p);
if(value_str_p != NULL) strcpy((char *)value_str_p, text); if(value_str_p != NULL) strcpy((char*)value_str_p, text);
lv_obj_set_style_local_value_str(obj, part, state, (char *)value_str_p); lv_obj_set_style_local_value_str(obj, part, state, (char*)value_str_p);
} }
// LOG_VERBOSE(TAG_ATTR, F("%s %d"), __FILE__, __LINE__); // LOG_VERBOSE(TAG_ATTR, F("%s %d"), __FILE__, __LINE__);
} }
void my_btnmatrix_map_clear(lv_obj_t * obj) void my_btnmatrix_map_clear(lv_obj_t* obj)
{ {
lv_btnmatrix_ext_t * ext = (lv_btnmatrix_ext_t *)lv_obj_get_ext_attr(obj); lv_btnmatrix_ext_t* ext = (lv_btnmatrix_ext_t*)lv_obj_get_ext_attr(obj);
const char ** map_p_tmp = ext->map_p; // store current pointer const char** map_p_tmp = ext->map_p; // store current pointer
LOG_VERBOSE(TAG_ATTR, "%s %d %x btn_cnt: %d", __FILE__, __LINE__, map_p_tmp, ext->btn_cnt); LOG_VERBOSE(TAG_ATTR, "%s %d %x btn_cnt: %d", __FILE__, __LINE__, map_p_tmp, ext->btn_cnt);
@ -326,9 +326,9 @@ void my_btnmatrix_map_clear(lv_obj_t * obj)
} }
} }
static void my_btnmatrix_map_create(lv_obj_t * obj, const char * payload) static void my_btnmatrix_map_create(lv_obj_t* obj, const char* payload)
{ {
const char ** map_p = lv_btnmatrix_get_map_array(obj); const char** map_p = lv_btnmatrix_get_map_array(obj);
// Create new map // Create new map
// Reserve memory for JsonDocument // Reserve memory for JsonDocument
@ -343,8 +343,8 @@ static void my_btnmatrix_map_create(lv_obj_t * obj, const char * payload)
JsonArray arr = map_doc.as<JsonArray>(); // Parse payload JsonArray arr = map_doc.as<JsonArray>(); // Parse payload
size_t tot_len = sizeof(char *) * (arr.size() + 1); size_t tot_len = sizeof(char*) * (arr.size() + 1);
const char ** map_data_str = (const char **)lv_mem_alloc(tot_len); const char** map_data_str = (const char**)lv_mem_alloc(tot_len);
if(map_data_str == NULL) { if(map_data_str == NULL) {
LOG_ERROR(TAG_ATTR, F("Out of memory while creating button map")); LOG_ERROR(TAG_ATTR, F("Out of memory while creating button map"));
return; return;
@ -355,12 +355,12 @@ static void my_btnmatrix_map_create(lv_obj_t * obj, const char * payload)
tot_len = 0; tot_len = 0;
for(JsonVariant btn : arr) { for(JsonVariant btn : arr) {
// tot_len += btn.as<String>().length() + 1; // tot_len += btn.as<String>().length() + 1;
tot_len += strlen(btn.as<const char *>()) + 1; tot_len += strlen(btn.as<const char*>()) + 1;
} }
tot_len++; // trailing '\0' tot_len++; // trailing '\0'
LOG_VERBOSE(TAG_ATTR, F("Array Size = %d, Map Length = %d"), arr.size(), tot_len); LOG_VERBOSE(TAG_ATTR, F("Array Size = %d, Map Length = %d"), arr.size(), tot_len);
char * buffer_addr = (char *)lv_mem_alloc(tot_len); char* buffer_addr = (char*)lv_mem_alloc(tot_len);
if(buffer_addr == NULL) { if(buffer_addr == NULL) {
lv_mem_free(map_data_str); lv_mem_free(map_data_str);
LOG_ERROR(TAG_ATTR, F("Out of memory while creating button map")); LOG_ERROR(TAG_ATTR, F("Out of memory while creating button map"));
@ -378,12 +378,12 @@ static void my_btnmatrix_map_create(lv_obj_t * obj, const char * payload)
LOG_VERBOSE(TAG_ATTR, F("%s %d lbl addr: %x"), __FILE__, __LINE__, buffer_addr); LOG_VERBOSE(TAG_ATTR, F("%s %d lbl addr: %x"), __FILE__, __LINE__, buffer_addr);
for(JsonVariant btn : arr) { for(JsonVariant btn : arr) {
// size_t len = btn.as<String>().length() + 1; // size_t len = btn.as<String>().length() + 1;
size_t len = strlen(btn.as<const char *>()) + 1; size_t len = strlen(btn.as<const char*>()) + 1;
LOG_VERBOSE(TAG_ATTR, F(D_BULLET "Adding button: %s (%d bytes) %x"), btn.as<const char *>(), len, LOG_VERBOSE(TAG_ATTR, F(D_BULLET "Adding button: %s (%d bytes) %x"), btn.as<const char*>(), len,
buffer_addr + pos); buffer_addr + pos);
// LOG_VERBOSE(TAG_ATTR, F(D_BULLET "Adding button: %s (%d bytes) %x"), btn.as<String>().c_str(), len, // LOG_VERBOSE(TAG_ATTR, F(D_BULLET "Adding button: %s (%d bytes) %x"), btn.as<String>().c_str(), len,
// buffer_addr + pos); // buffer_addr + pos);
memccpy(buffer_addr + pos, btn.as<const char *>(), 0, len); // Copy the label text into the buffer memccpy(buffer_addr + pos, btn.as<const char*>(), 0, len); // Copy the label text into the buffer
// memccpy(buffer_addr + pos, btn.as<String>().c_str(), 0, len); // Copy the label text into the buffer // memccpy(buffer_addr + pos, btn.as<String>().c_str(), 0, len); // Copy the label text into the buffer
map_data_str[index++] = buffer_addr + pos; // save pointer to the label in the array map_data_str[index++] = buffer_addr + pos; // save pointer to the label in the array
pos += len; pos += len;
@ -395,17 +395,17 @@ static void my_btnmatrix_map_create(lv_obj_t * obj, const char * payload)
LOG_VERBOSE(TAG_ATTR, F("%s %d"), __FILE__, __LINE__); LOG_VERBOSE(TAG_ATTR, F("%s %d"), __FILE__, __LINE__);
} }
void line_clear_points(lv_obj_t * obj) void line_clear_points(lv_obj_t* obj)
{ {
lv_line_ext_t * ext = (lv_line_ext_t *)lv_obj_get_ext_attr(obj); lv_line_ext_t* ext = (lv_line_ext_t*)lv_obj_get_ext_attr(obj);
if(ext->point_array && (ext->point_num > 0)) { if(ext->point_array && (ext->point_num > 0)) {
const lv_point_t * ptr = ext->point_array; const lv_point_t* ptr = ext->point_array;
lv_line_set_points(obj, NULL, 0); lv_line_set_points(obj, NULL, 0);
lv_mem_free(ptr); lv_mem_free(ptr);
} }
} }
static void line_set_points(lv_obj_t * obj, const char * payload) static void line_set_points(lv_obj_t* obj, const char* payload)
{ {
line_clear_points(obj); // delete pointmap line_clear_points(obj); // delete pointmap
@ -422,8 +422,8 @@ static void line_set_points(lv_obj_t * obj, const char * payload)
JsonArray arr = doc.as<JsonArray>(); // Parse payload JsonArray arr = doc.as<JsonArray>(); // Parse payload
size_t tot_len = sizeof(lv_point_t *) * (arr.size()); size_t tot_len = sizeof(lv_point_t*) * (arr.size());
lv_point_t * point_arr = (lv_point_t *)lv_mem_alloc(tot_len); lv_point_t* point_arr = (lv_point_t*)lv_mem_alloc(tot_len);
if(point_arr == NULL) { if(point_arr == NULL) {
LOG_ERROR(TAG_ATTR, F("Out of memory while creating line points")); LOG_ERROR(TAG_ATTR, F("Out of memory while creating line points"));
return; return;
@ -454,7 +454,7 @@ static inline lv_color_t haspLogColor(lv_color_t color)
return color; return color;
} }
static lv_font_t * haspPayloadToFont(const char * payload) static lv_font_t* haspPayloadToFont(const char* payload)
{ {
uint8_t var = atoi(payload); uint8_t var = atoi(payload);
@ -470,25 +470,25 @@ static lv_font_t * haspPayloadToFont(const char * payload)
#ifndef ARDUINO_ARCH_ESP8266 #ifndef ARDUINO_ARCH_ESP8266
#ifdef LV_FONT_CUSTOM_12 #ifdef LV_FONT_CUSTOM_12
case 12: case 12:
return LV_THEME_DEFAULT_FONT_SMALL; return LV_THEME_DEFAULT_FONT_SMALL;
#endif #endif
#ifdef LV_FONT_CUSTOM_16 #ifdef LV_FONT_CUSTOM_16
case 16: case 16:
return LV_THEME_DEFAULT_FONT_NORMAL; return LV_THEME_DEFAULT_FONT_NORMAL;
#endif #endif
#ifdef LV_FONT_CUSTOM_22 #ifdef LV_FONT_CUSTOM_22
case 22: case 22:
return LV_THEME_DEFAULT_FONT_SUBTITLE; return LV_THEME_DEFAULT_FONT_SUBTITLE;
#endif #endif
#ifdef LV_FONT_CUSTOM_28 #ifdef LV_FONT_CUSTOM_28
case 28: case 28:
return LV_THEME_DEFAULT_FONT_TITLE; return LV_THEME_DEFAULT_FONT_TITLE;
#endif #endif
#endif #endif
@ -497,27 +497,27 @@ static lv_font_t * haspPayloadToFont(const char * payload)
} }
} }
static void gauge_format_10(lv_obj_t * gauge, char * buf, int bufsize, int32_t value) static void gauge_format_10(lv_obj_t* gauge, char* buf, int bufsize, int32_t value)
{ {
snprintf(buf, bufsize, PSTR("%d"), value / 10); snprintf(buf, bufsize, PSTR("%d"), value / 10);
} }
static void gauge_format_100(lv_obj_t * gauge, char * buf, int bufsize, int32_t value) static void gauge_format_100(lv_obj_t* gauge, char* buf, int bufsize, int32_t value)
{ {
snprintf(buf, bufsize, PSTR("%d"), value / 100); snprintf(buf, bufsize, PSTR("%d"), value / 100);
} }
static void gauge_format_1k(lv_obj_t * gauge, char * buf, int bufsize, int32_t value) static void gauge_format_1k(lv_obj_t* gauge, char* buf, int bufsize, int32_t value)
{ {
snprintf(buf, bufsize, PSTR("%d"), value / 1000); snprintf(buf, bufsize, PSTR("%d"), value / 1000);
} }
static void gauge_format_10k(lv_obj_t * gauge, char * buf, int bufsize, int32_t value) static void gauge_format_10k(lv_obj_t* gauge, char* buf, int bufsize, int32_t value)
{ {
snprintf(buf, bufsize, PSTR("%d"), value / 10000); snprintf(buf, bufsize, PSTR("%d"), value / 10000);
} }
static void hasp_process_label_long_mode(lv_obj_t * obj, const char * payload, bool update) static void hasp_process_label_long_mode(lv_obj_t* obj, const char* payload, bool update)
{ {
if(update) { if(update) {
lv_label_long_mode_t mode = LV_LABEL_LONG_EXPAND; lv_label_long_mode_t mode = LV_LABEL_LONG_EXPAND;
@ -545,10 +545,10 @@ static void hasp_process_label_long_mode(lv_obj_t * obj, const char * payload, b
} }
// OK // OK
lv_obj_t * FindButtonLabel(lv_obj_t * btn) lv_obj_t* FindButtonLabel(lv_obj_t* btn)
{ {
if(btn) { if(btn) {
lv_obj_t * label = lv_obj_get_child_back(btn, NULL); lv_obj_t* label = lv_obj_get_child_back(btn, NULL);
#if 1 #if 1
if(label) { if(label) {
if(check_obj_type(label, LV_HASP_LABEL)) { if(check_obj_type(label, LV_HASP_LABEL)) {
@ -558,7 +558,7 @@ lv_obj_t * FindButtonLabel(lv_obj_t * btn)
if(label) { if(label) {
lv_obj_type_t list; lv_obj_type_t list;
lv_obj_get_type(label, &list); lv_obj_get_type(label, &list);
const char * objtype = list.type[0]; const char* objtype = list.type[0];
if(check_obj_type(objtype, LV_HASP_LABEL)) { if(check_obj_type(objtype, LV_HASP_LABEL)) {
return label; return label;
@ -575,23 +575,23 @@ lv_obj_t * FindButtonLabel(lv_obj_t * btn)
} }
// OK // OK
static inline void haspSetLabelText(lv_obj_t * obj, const char * value) static inline void haspSetLabelText(lv_obj_t* obj, const char* value)
{ {
lv_obj_t * label = FindButtonLabel(obj); lv_obj_t* label = FindButtonLabel(obj);
if(label) { if(label) {
lv_label_set_text(label, value); lv_label_set_text(label, value);
} }
} }
// OK // OK
static bool haspGetLabelText(lv_obj_t * obj, char ** text) static bool haspGetLabelText(lv_obj_t* obj, char** text)
{ {
if(!obj) { if(!obj) {
LOG_WARNING(TAG_ATTR, F("Button not defined")); LOG_WARNING(TAG_ATTR, F("Button not defined"));
return false; return false;
} }
lv_obj_t * label = lv_obj_get_child_back(obj, NULL); lv_obj_t* label = lv_obj_get_child_back(obj, NULL);
if(label) { if(label) {
#if 1 #if 1
if(check_obj_type(label, LV_HASP_LABEL)) { if(check_obj_type(label, LV_HASP_LABEL)) {
@ -615,8 +615,8 @@ static bool haspGetLabelText(lv_obj_t * obj, char ** text)
return false; return false;
} }
static void hasp_attribute_get_part_state(lv_obj_t * obj, const char * attr_in, char * attr_out, uint8_t & part, static void hasp_attribute_get_part_state(lv_obj_t* obj, const char* attr_in, char* attr_out, uint8_t& part,
uint8_t & state) uint8_t& state)
{ {
int len = strlen(attr_in); int len = strlen(attr_in);
if(len <= 0 || len >= 32) { if(len <= 0 || len >= 32) {
@ -668,7 +668,7 @@ static void hasp_attribute_get_part_state(lv_obj_t * obj, const char * attr_in,
(LV_SLIDER_PART_BG != LV_SWITCH_PART_BG) || (LV_SLIDER_PART_INDIC != LV_ARC_PART_INDIC) || \ (LV_SLIDER_PART_BG != LV_SWITCH_PART_BG) || (LV_SLIDER_PART_INDIC != LV_ARC_PART_INDIC) || \
(LV_SLIDER_PART_KNOB != LV_ARC_PART_KNOB) || (LV_SLIDER_PART_BG != LV_ARC_PART_BG) || \ (LV_SLIDER_PART_KNOB != LV_ARC_PART_KNOB) || (LV_SLIDER_PART_BG != LV_ARC_PART_BG) || \
(LV_SLIDER_PART_INDIC != LV_BAR_PART_INDIC) || (LV_SLIDER_PART_BG != LV_BAR_PART_BG) (LV_SLIDER_PART_INDIC != LV_BAR_PART_INDIC) || (LV_SLIDER_PART_BG != LV_BAR_PART_BG)
#error "LV_SLIDER, LV_BAR, LV_ARC, LV_SWITCH parts should match!" #error "LV_SLIDER, LV_BAR, LV_ARC, LV_SWITCH parts should match!"
#endif #endif
if(check_obj_type(obj, LV_HASP_SLIDER) || check_obj_type(obj, LV_HASP_SWITCH) || check_obj_type(obj, LV_HASP_ARC) || if(check_obj_type(obj, LV_HASP_SLIDER) || check_obj_type(obj, LV_HASP_SWITCH) || check_obj_type(obj, LV_HASP_ARC) ||
@ -719,7 +719,7 @@ static void hasp_attribute_get_part_state(lv_obj_t * obj, const char * attr_in,
* @param update bool: change/set the value if true, dispatch/get value if false * @param update bool: change/set the value if true, dispatch/get value if false
* @note setting a value won't return anything, getting will dispatch the value * @note setting a value won't return anything, getting will dispatch the value
*/ */
static void hasp_local_style_attr(lv_obj_t * obj, const char * attr_p, uint16_t attr_hash, const char * payload, static void hasp_local_style_attr(lv_obj_t* obj, const char* attr_p, uint16_t attr_hash, const char* payload,
bool update) bool update)
{ {
char attr[32]; char attr[32];
@ -857,7 +857,7 @@ static void hasp_local_style_attr(lv_obj_t * obj, const char * attr_p, uint16_t
return; return;
} }
case ATTR_TEXT_FONT: { case ATTR_TEXT_FONT: {
lv_font_t * font = haspPayloadToFont(payload); lv_font_t* font = haspPayloadToFont(payload);
if(font) { if(font) {
uint8_t count = 3; uint8_t count = 3;
if(check_obj_type(obj, LV_HASP_ROLLER)) count = my_roller_get_visible_row_count(obj); if(check_obj_type(obj, LV_HASP_ROLLER)) count = my_roller_get_visible_row_count(obj);
@ -1015,7 +1015,7 @@ static void hasp_local_style_attr(lv_obj_t * obj, const char * attr_p, uint16_t
return; return;
} }
case ATTR_VALUE_FONT: { case ATTR_VALUE_FONT: {
lv_font_t * font = haspPayloadToFont(payload); lv_font_t* font = haspPayloadToFont(payload);
if(font) { if(font) {
return lv_obj_set_style_local_value_font(obj, part, state, font); return lv_obj_set_style_local_value_font(obj, part, state, font);
} else { } else {
@ -1058,14 +1058,14 @@ static void hasp_local_style_attr(lv_obj_t * obj, const char * attr_p, uint16_t
LOG_WARNING(TAG_ATTR, F(D_ATTRIBUTE_UNKNOWN " (%d)"), attr_p, attr_hash); LOG_WARNING(TAG_ATTR, F(D_ATTRIBUTE_UNKNOWN " (%d)"), attr_p, attr_hash);
} }
static void hasp_process_arc_attribute(lv_obj_t * obj, const char * attr_p, uint16_t attr_hash, const char * payload, static void hasp_process_arc_attribute(lv_obj_t* obj, const char* attr_p, uint16_t attr_hash, const char* payload,
bool update) bool update)
{ {
// We already know it's a arc object // We already know it's a arc object
int16_t intval = atoi(payload); int16_t intval = atoi(payload);
uint16_t val = atoi(payload); uint16_t val = atoi(payload);
char * attr = (char *)attr_p; char* attr = (char*)attr_p;
if(*attr == '.') attr++; // strip leading '.' if(*attr == '.') attr++; // strip leading '.'
switch(attr_hash) { switch(attr_hash) {
@ -1102,7 +1102,7 @@ static void hasp_process_arc_attribute(lv_obj_t * obj, const char * attr_p, uint
LOG_WARNING(TAG_ATTR, F(D_ATTRIBUTE_UNKNOWN), attr_p); LOG_WARNING(TAG_ATTR, F(D_ATTRIBUTE_UNKNOWN), attr_p);
} }
static void hasp_process_lmeter_attribute(lv_obj_t * obj, const char * attr_p, uint16_t attr_hash, const char * payload, static void hasp_process_lmeter_attribute(lv_obj_t* obj, const char* attr_p, uint16_t attr_hash, const char* payload,
bool update) bool update)
{ {
// We already know it's a linemeter object // We already know it's a linemeter object
@ -1112,7 +1112,7 @@ static void hasp_process_lmeter_attribute(lv_obj_t * obj, const char * attr_p, u
uint16_t line_count = lv_linemeter_get_line_count(obj); uint16_t line_count = lv_linemeter_get_line_count(obj);
uint16_t angle = lv_linemeter_get_scale_angle(obj); uint16_t angle = lv_linemeter_get_scale_angle(obj);
char * attr = (char *)attr_p; char* attr = (char*)attr_p;
if(*attr == '.') attr++; // strip leading '.' if(*attr == '.') attr++; // strip leading '.'
switch(attr_hash) { switch(attr_hash) {
@ -1134,7 +1134,7 @@ static void hasp_process_lmeter_attribute(lv_obj_t * obj, const char * attr_p, u
LOG_WARNING(TAG_ATTR, F(D_ATTRIBUTE_UNKNOWN), attr_p); LOG_WARNING(TAG_ATTR, F(D_ATTRIBUTE_UNKNOWN), attr_p);
} }
static void hasp_process_gauge_attribute(lv_obj_t * obj, const char * attr_p, uint16_t attr_hash, const char * payload, static void hasp_process_gauge_attribute(lv_obj_t* obj, const char* attr_p, uint16_t attr_hash, const char* payload,
bool update) bool update)
{ {
// We already know it's a gauge object // We already know it's a gauge object
@ -1145,7 +1145,7 @@ static void hasp_process_gauge_attribute(lv_obj_t * obj, const char * attr_p, ui
uint16_t line_count = lv_gauge_get_line_count(obj); uint16_t line_count = lv_gauge_get_line_count(obj);
uint16_t angle = lv_gauge_get_scale_angle(obj); uint16_t angle = lv_gauge_get_scale_angle(obj);
char * attr = (char *)attr_p; char* attr = (char*)attr_p;
if(*attr == '.') attr++; // strip leading '.' if(*attr == '.') attr++; // strip leading '.'
switch(attr_hash) { switch(attr_hash) {
@ -1193,7 +1193,7 @@ static void hasp_process_gauge_attribute(lv_obj_t * obj, const char * attr_p, ui
// ##################### Common Attributes ######################################################## // ##################### Common Attributes ########################################################
static void hasp_process_obj_attribute_txt(lv_obj_t * obj, const char * attr, const char * payload, bool update) static void hasp_process_obj_attribute_txt(lv_obj_t* obj, const char* attr, const char* payload, bool update)
{ {
/* Attributes depending on objecttype */ /* Attributes depending on objecttype */
// lv_obj_type_t list; // lv_obj_type_t list;
@ -1204,7 +1204,7 @@ static void hasp_process_obj_attribute_txt(lv_obj_t * obj, const char * attr, co
if(update) { if(update) {
haspSetLabelText(obj, payload); haspSetLabelText(obj, payload);
} else { } else {
char * text = NULL; char* text = NULL;
if(haspGetLabelText(obj, &text) && text) hasp_out_str(obj, attr, text); if(haspGetLabelText(obj, &text) && text) hasp_out_str(obj, attr, text);
} }
return; return;
@ -1235,7 +1235,7 @@ static void hasp_process_obj_attribute_txt(lv_obj_t * obj, const char * attr, co
LOG_WARNING(TAG_ATTR, F(D_ATTRIBUTE_UNKNOWN), attr); LOG_WARNING(TAG_ATTR, F(D_ATTRIBUTE_UNKNOWN), attr);
} }
bool hasp_process_obj_attribute_val(lv_obj_t * obj, const char * attr, const char * payload, bool update) bool hasp_process_obj_attribute_val(lv_obj_t* obj, const char* attr, const char* payload, bool update)
{ {
int16_t intval = atoi(payload); int16_t intval = atoi(payload);
@ -1283,7 +1283,7 @@ bool hasp_process_obj_attribute_val(lv_obj_t * obj, const char * attr, const cha
return true; return true;
} }
static void hasp_process_obj_attribute_range(lv_obj_t * obj, const char * attr, const char * payload, bool update, static void hasp_process_obj_attribute_range(lv_obj_t* obj, const char* attr, const char* payload, bool update,
bool set_min, bool set_max) bool set_min, bool set_max)
{ {
int16_t val = atoi(payload); int16_t val = atoi(payload);
@ -1355,7 +1355,7 @@ static void hasp_process_obj_attribute_range(lv_obj_t * obj, const char * attr,
* @param update bool: change/set the value if true, dispatch/get value if false * @param update bool: change/set the value if true, dispatch/get value if false
* @note setting a value won't return anything, getting will dispatch the value * @note setting a value won't return anything, getting will dispatch the value
*/ */
void hasp_process_obj_attribute(lv_obj_t * obj, const char * attr_p, const char * payload, bool update) void hasp_process_obj_attribute(lv_obj_t* obj, const char* attr_p, const char* payload, bool update)
{ {
// unsigned long start = millis(); // unsigned long start = millis();
if(!obj) { if(!obj) {
@ -1364,7 +1364,7 @@ void hasp_process_obj_attribute(lv_obj_t * obj, const char * attr_p, const char
} }
int16_t val = atoi(payload); int16_t val = atoi(payload);
char * attr = (char *)attr_p; char* attr = (char*)attr_p;
if(*attr == '.') attr++; // strip leading '.' if(*attr == '.') attr++; // strip leading '.'
uint16_t attr_hash = Utilities::get_sdbm(attr); uint16_t attr_hash = Utilities::get_sdbm(attr);
@ -1471,7 +1471,8 @@ void hasp_process_obj_attribute(lv_obj_t * obj, const char * attr_p, const char
break; // attribute_found break; // attribute_found
case ATTR_ENABLED: case ATTR_ENABLED:
update ? lv_obj_set_click(obj, Utilities::is_true(payload)) : hasp_out_int(obj, attr, lv_obj_get_click(obj)); update ? lv_obj_set_click(obj, Utilities::is_true(payload))
: hasp_out_int(obj, attr, lv_obj_get_click(obj));
break; // attribute_found break; // attribute_found
case ATTR_SRC: case ATTR_SRC:
@ -1483,7 +1484,7 @@ void hasp_process_obj_attribute(lv_obj_t * obj, const char * attr_p, const char
case LV_IMG_SRC_FILE: case LV_IMG_SRC_FILE:
return hasp_out_str(obj, attr, lv_img_get_file_name(obj)); return hasp_out_str(obj, attr, lv_img_get_file_name(obj));
case LV_IMG_SRC_SYMBOL: case LV_IMG_SRC_SYMBOL:
return hasp_out_str(obj, attr, (char *)lv_img_get_src(obj)); return hasp_out_str(obj, attr, (char*)lv_img_get_src(obj));
default: default:
return; return;
} }
@ -1521,7 +1522,7 @@ void hasp_process_obj_attribute(lv_obj_t * obj, const char * attr_p, const char
case ATTR_ALIGN: case ATTR_ALIGN:
if(check_obj_type(obj, LV_HASP_BUTTON)) { if(check_obj_type(obj, LV_HASP_BUTTON)) {
lv_obj_t * label = FindButtonLabel(obj); lv_obj_t* label = FindButtonLabel(obj);
if(label == NULL) if(label == NULL)
goto attribute_not_found; goto attribute_not_found;
else else
@ -1540,7 +1541,7 @@ void hasp_process_obj_attribute(lv_obj_t * obj, const char * attr_p, const char
case ATTR_MODE: case ATTR_MODE:
if(check_obj_type(obj, LV_HASP_BUTTON)) { if(check_obj_type(obj, LV_HASP_BUTTON)) {
lv_obj_t * label = FindButtonLabel(obj); lv_obj_t* label = FindButtonLabel(obj);
if(label) { if(label) {
hasp_process_label_long_mode(label, payload, update); hasp_process_label_long_mode(label, payload, update);
lv_obj_set_width(label, lv_obj_get_width(obj)); lv_obj_set_width(label, lv_obj_get_width(obj));
@ -1575,7 +1576,7 @@ void hasp_process_obj_attribute(lv_obj_t * obj, const char * attr_p, const char
} }
} else if(check_obj_type(obj, LV_HASP_ROLLER)) { } else if(check_obj_type(obj, LV_HASP_ROLLER)) {
if(update) { if(update) {
lv_roller_ext_t * ext = (lv_roller_ext_t *)lv_obj_get_ext_attr(obj); lv_roller_ext_t* ext = (lv_roller_ext_t*)lv_obj_get_ext_attr(obj);
lv_roller_set_options(obj, payload, ext->mode); lv_roller_set_options(obj, payload, ext->mode);
} else { } else {
hasp_out_str(obj, attr, lv_roller_get_options(obj)); hasp_out_str(obj, attr, lv_roller_get_options(obj));

View File

@ -1,4 +1,4 @@
/* MIT License - Copyright (c) 2020 Francis Van Roie /* MIT License - Copyright (c) 2019-2021 Francis Van Roie
For full license information read the LICENSE file in the project folder */ For full license information read the LICENSE file in the project folder */
#ifndef HASP_ATTR_SET_H #ifndef HASP_ATTR_SET_H
@ -6,7 +6,7 @@
#include "lvgl.h" #include "lvgl.h"
#if LVGL_VERSION_MAJOR != 7 #if LVGL_VERSION_MAJOR != 7
#include "../lv_components.h" #include "../lv_components.h"
#endif #endif
#include "hasp_conf.h" #include "hasp_conf.h"
@ -18,14 +18,14 @@ extern "C" {
#endif #endif
// test // test
lv_chart_series_t * my_chart_get_series(lv_obj_t * chart, uint8_t ser_num); lv_chart_series_t* my_chart_get_series(lv_obj_t* chart, uint8_t ser_num);
void my_obj_set_value_str_txt(lv_obj_t * obj, uint8_t part, lv_state_t state, const char * text); void my_obj_set_value_str_txt(lv_obj_t* obj, uint8_t part, lv_state_t state, const char* text);
void my_btnmatrix_map_clear(lv_obj_t * obj); void my_btnmatrix_map_clear(lv_obj_t* obj);
void line_clear_points(lv_obj_t * obj); void line_clear_points(lv_obj_t* obj);
void hasp_process_obj_attribute(lv_obj_t * obj, const char * attr_p, const char * payload, bool update); void hasp_process_obj_attribute(lv_obj_t* obj, const char* attr_p, const char* payload, bool update);
bool hasp_process_obj_attribute_val(lv_obj_t * obj, const char * attr, const char * payload, bool update); bool hasp_process_obj_attribute_val(lv_obj_t* obj, const char* attr, const char* payload, bool update);
#ifdef __cplusplus #ifdef __cplusplus
} /* extern "C" */ } /* extern "C" */
@ -37,8 +37,8 @@ bool hasp_process_obj_attribute_val(lv_obj_t * obj, const char * attr, const cha
#define hasp_out_color hasp_send_obj_attribute_color #define hasp_out_color hasp_send_obj_attribute_color
#define _HASP_ATTRIBUTE(prop_name, func_name, value_type) \ #define _HASP_ATTRIBUTE(prop_name, func_name, value_type) \
static inline void attribute_##func_name(lv_obj_t * obj, uint8_t part, lv_state_t state, bool update, \ static inline void attribute_##func_name(lv_obj_t* obj, uint8_t part, lv_state_t state, bool update, \
const char * attr, value_type val) \ const char* attr, value_type val) \
{ \ { \
if(update) { \ if(update) { \
return lv_obj_set_style_local_##func_name(obj, part, state, (value_type)val); \ return lv_obj_set_style_local_##func_name(obj, part, state, (value_type)val); \

View File

@ -1,4 +1,4 @@
/* MIT License - Copyright (c) 2020 Francis Van Roie /* MIT License - Copyright (c) 2019-2021 Francis Van Roie
For full license information read the LICENSE file in the project folder */ For full license information read the LICENSE file in the project folder */
#include <stdint.h> #include <stdint.h>

View File

@ -1,4 +1,4 @@
/* MIT License - Copyright (c) 2020 Francis Van Roie /* MIT License - Copyright (c) 2019-2021 Francis Van Roie
For full license information read the LICENSE file in the project folder */ For full license information read the LICENSE file in the project folder */
#ifndef HASP_DISPATCH_H #ifndef HASP_DISPATCH_H

View File

@ -1,4 +1,4 @@
/* MIT License - Copyright (c) 2020 Francis Van Roie /* MIT License - Copyright (c) 2019-2021 Francis Van Roie
For full license information read the LICENSE file in the project folder */ For full license information read the LICENSE file in the project folder */
/* ******************************************************************************************** /* ********************************************************************************************

View File

@ -1,4 +1,4 @@
/* MIT License - Copyright (c) 2020 Francis Van Roie /* MIT License - Copyright (c) 2019-2021 Francis Van Roie
For full license information read the LICENSE file in the project folder */ For full license information read the LICENSE file in the project folder */
#ifndef HASP_OBJECT_H #ifndef HASP_OBJECT_H
@ -60,27 +60,27 @@ enum lv_hasp_obj_type_t {
LV_HASP_MASK = 63, // placeholder LV_HASP_MASK = 63, // placeholder
}; };
void hasp_new_object(const JsonObject & config, uint8_t & saved_page_id); void hasp_new_object(const JsonObject& config, uint8_t& saved_page_id);
lv_obj_t * hasp_find_obj_from_parent_id(lv_obj_t * parent, uint8_t objid); lv_obj_t* hasp_find_obj_from_parent_id(lv_obj_t* parent, uint8_t objid);
// lv_obj_t * hasp_find_obj_from_page_id(uint8_t pageid, uint8_t objid); // lv_obj_t * hasp_find_obj_from_page_id(uint8_t pageid, uint8_t objid);
bool hasp_find_id_from_obj(lv_obj_t * obj, uint8_t * pageid, uint8_t * objid); bool hasp_find_id_from_obj(lv_obj_t* obj, uint8_t* pageid, uint8_t* objid);
// bool check_obj_type_str(const char * lvobjtype, lv_hasp_obj_type_t haspobjtype); // bool check_obj_type_str(const char * lvobjtype, lv_hasp_obj_type_t haspobjtype);
bool check_obj_type(lv_obj_t * obj, lv_hasp_obj_type_t haspobjtype); bool check_obj_type(lv_obj_t* obj, lv_hasp_obj_type_t haspobjtype);
void hasp_object_tree(lv_obj_t * parent, uint8_t pageid, uint16_t level); void hasp_object_tree(lv_obj_t* parent, uint8_t pageid, uint16_t level);
void hasp_object_delete(lv_obj_t * obj); void hasp_object_delete(lv_obj_t* obj);
void hasp_send_obj_attribute_str(lv_obj_t * obj, const char * attribute, const char * data); void hasp_send_obj_attribute_str(lv_obj_t* obj, const char* attribute, const char* data);
void hasp_send_obj_attribute_int(lv_obj_t * obj, const char * attribute, int32_t val); void hasp_send_obj_attribute_int(lv_obj_t* obj, const char* attribute, int32_t val);
void hasp_send_obj_attribute_color(lv_obj_t * obj, const char * attribute, lv_color_t color); void hasp_send_obj_attribute_color(lv_obj_t* obj, const char* attribute, lv_color_t color);
void hasp_process_attribute(uint8_t pageid, uint8_t objid, const char * attr, const char * payload); void hasp_process_attribute(uint8_t pageid, uint8_t objid, const char* attr, const char* payload);
void object_set_group_state(uint8_t groupid, uint8_t eventid, lv_obj_t * src_obj); void object_set_group_state(uint8_t groupid, uint8_t eventid, lv_obj_t* src_obj);
void generic_event_handler(lv_obj_t * obj, lv_event_t event); void generic_event_handler(lv_obj_t* obj, lv_event_t event);
void toggle_event_handler(lv_obj_t * obj, lv_event_t event); void toggle_event_handler(lv_obj_t* obj, lv_event_t event);
void slider_event_handler(lv_obj_t * obj, lv_event_t event); void slider_event_handler(lv_obj_t* obj, lv_event_t event);
void wakeup_event_handler(lv_obj_t * obj, lv_event_t event); void wakeup_event_handler(lv_obj_t* obj, lv_event_t event);
#define HASP_OBJ_BAR 1971 #define HASP_OBJ_BAR 1971
#define HASP_OBJ_BTN 3164 #define HASP_OBJ_BTN 3164

View File

@ -1,4 +1,4 @@
/* MIT License - Copyright (c) 2020 Francis Van Roie /* MIT License - Copyright (c) 2019-2021 Francis Van Roie
For full license information read the LICENSE file in the project folder */ For full license information read the LICENSE file in the project folder */
#include <cstdlib> #include <cstdlib>
@ -13,13 +13,13 @@
#include "hasp_parser.h" #include "hasp_parser.h"
#include "hasp_utilities.h" #include "hasp_utilities.h"
bool Parser::haspPayloadToColor(const char * payload, lv_color32_t & color) bool Parser::haspPayloadToColor(const char* payload, lv_color32_t& color)
{ {
/* HEX format #rrggbb or #rgb */ /* HEX format #rrggbb or #rgb */
if(*payload == '#') { if(*payload == '#') {
if(strlen(payload) >= 8) return false; if(strlen(payload) >= 8) return false;
char * pEnd; char* pEnd;
long color_int = strtol(payload + 1, &pEnd, HEX); long color_int = strtol(payload + 1, &pEnd, HEX);
if(pEnd - payload == 7) { // #rrbbgg if(pEnd - payload == 7) { // #rrbbgg

View File

@ -1,4 +1,4 @@
/* MIT License - Copyright (c) 2020 Francis Van Roie /* MIT License - Copyright (c) 2019-2021 Francis Van Roie
For full license information read the LICENSE file in the project folder */ For full license information read the LICENSE file in the project folder */
#ifndef HASP_PARSER_H #ifndef HASP_PARSER_H
@ -10,7 +10,7 @@
class Parser { class Parser {
public: public:
static bool haspPayloadToColor(const char * payload, lv_color32_t & color); static bool haspPayloadToColor(const char* payload, lv_color32_t& color);
}; };
/* Named COLOR attributes */ /* Named COLOR attributes */

View File

@ -1,4 +1,4 @@
/* MIT License - Copyright (c) 2020 Francis Van Roie /* MIT License - Copyright (c) 2019-2021 Francis Van Roie
For full license information read the LICENSE file in the project folder */ For full license information read the LICENSE file in the project folder */
#ifndef HASP_UTILITIES_H #ifndef HASP_UTILITIES_H

View File

@ -1,29 +1,29 @@
/* MIT License - Copyright (c) 2020 Francis Van Roie /* MIT License - Copyright (c) 2019-2021 Francis Van Roie
For full license information read the LICENSE file in the project folder */ For full license information read the LICENSE file in the project folder */
#if HASP_USE_CONFIG > 0 #if HASP_USE_CONFIG > 0
#include "ArduinoJson.h" #include "ArduinoJson.h"
#include "StreamUtils.h" // For EEPromStream #include "StreamUtils.h" // For EEPromStream
#include "hasp_conf.h" #include "hasp_conf.h"
#include "hasp_config.h" #include "hasp_config.h"
#include "hasp_debug.h" #include "hasp_debug.h"
#include "hasp_gui.h" #include "hasp_gui.h"
//#include "hasp_ota.h" included in conf //#include "hasp_ota.h" included in conf
//#include "hasp_filesystem.h" included in conf //#include "hasp_filesystem.h" included in conf
//#include "hasp_telnet.h" included in conf //#include "hasp_telnet.h" included in conf
//#include "hasp_gpio.h" included in conf //#include "hasp_gpio.h" included in conf
//#include "hasp_eeprom.h" //#include "hasp_eeprom.h"
#include "hasp/hasp.h" #include "hasp/hasp.h"
#include "hasp/hasp_dispatch.h" #include "hasp/hasp_dispatch.h"
#if HASP_USE_EEPROM > 0 #if HASP_USE_EEPROM > 0
#include "EEPROM.h" #include "EEPROM.h"
#endif #endif
extern uint16_t dispatchTelePeriod; extern uint16_t dispatchTelePeriod;
extern uint32_t dispatchLastMillis; extern uint32_t dispatchLastMillis;
@ -31,7 +31,7 @@ extern uint32_t dispatchLastMillis;
extern gui_conf_t gui_settings; extern gui_conf_t gui_settings;
extern dispatch_conf_t dispatch_settings; extern dispatch_conf_t dispatch_settings;
void confDebugSet(const __FlashStringHelper * fstr_name) void confDebugSet(const __FlashStringHelper* fstr_name)
{ {
/*char buffer[128]; /*char buffer[128];
snprintf_P(buffer, sizeof(buffer), PSTR(" * %s set"), name); snprintf_P(buffer, sizeof(buffer), PSTR(" * %s set"), name);
@ -39,7 +39,7 @@ void confDebugSet(const __FlashStringHelper * fstr_name)
LOG_VERBOSE(TAG_CONF, F(D_BULLET "%S set"), fstr_name); LOG_VERBOSE(TAG_CONF, F(D_BULLET "%S set"), fstr_name);
} }
bool configSet(int8_t & value, const JsonVariant & setting, const __FlashStringHelper * fstr_name) bool configSet(int8_t& value, const JsonVariant& setting, const __FlashStringHelper* fstr_name)
{ {
if(!setting.isNull()) { if(!setting.isNull()) {
int8_t val = setting.as<int8_t>(); int8_t val = setting.as<int8_t>();
@ -51,7 +51,7 @@ bool configSet(int8_t & value, const JsonVariant & setting, const __FlashStringH
} }
return false; return false;
} }
bool configSet(uint8_t & value, const JsonVariant & setting, const __FlashStringHelper * fstr_name) bool configSet(uint8_t& value, const JsonVariant& setting, const __FlashStringHelper* fstr_name)
{ {
if(!setting.isNull()) { if(!setting.isNull()) {
uint8_t val = setting.as<uint8_t>(); uint8_t val = setting.as<uint8_t>();
@ -63,7 +63,7 @@ bool configSet(uint8_t & value, const JsonVariant & setting, const __FlashString
} }
return false; return false;
} }
bool configSet(uint16_t & value, const JsonVariant & setting, const __FlashStringHelper * fstr_name) bool configSet(uint16_t& value, const JsonVariant& setting, const __FlashStringHelper* fstr_name)
{ {
if(!setting.isNull()) { if(!setting.isNull()) {
uint16_t val = setting.as<uint16_t>(); uint16_t val = setting.as<uint16_t>();
@ -76,31 +76,31 @@ bool configSet(uint16_t & value, const JsonVariant & setting, const __FlashStrin
return false; return false;
} }
void configStartDebug(bool setupdebug, String & configFile) void configStartDebug(bool setupdebug, String& configFile)
{ {
if(setupdebug) { if(setupdebug) {
debugStart(); // Debug started, now we can use it; HASP header sent debugStart(); // Debug started, now we can use it; HASP header sent
#if HASP_USE_SPIFFS > 0 || HASP_USE_LITTLEFS > 0 #if HASP_USE_SPIFFS > 0 || HASP_USE_LITTLEFS > 0
LOG_INFO(TAG_CONF, F("SPI flash FS mounted")); LOG_INFO(TAG_CONF, F("SPI flash FS mounted"));
filesystemInfo(); filesystemInfo();
filesystemList(); filesystemList();
#endif #endif
} }
#if HASP_USE_SPIFFS > 0 || HASP_USE_LITTLEFS > 0 #if HASP_USE_SPIFFS > 0 || HASP_USE_LITTLEFS > 0
LOG_TRACE(TAG_CONF, F(D_FILE_LOADING), configFile.c_str()); LOG_TRACE(TAG_CONF, F(D_FILE_LOADING), configFile.c_str());
#else #else
LOG_TRACE(TAG_CONF, F(D_FILE_LOADING), "EEPROM"); LOG_TRACE(TAG_CONF, F(D_FILE_LOADING), "EEPROM");
#endif #endif
} }
void configRead(JsonDocument & settings, bool setupdebug = false) void configRead(JsonDocument& settings, bool setupdebug = false)
{ {
String configFile((char *)0); String configFile((char*)0);
configFile.reserve(32); configFile.reserve(32);
configFile = String(FPSTR(FP_HASP_CONFIG_FILE)); configFile = String(FPSTR(FP_HASP_CONFIG_FILE));
DeserializationError error; DeserializationError error;
#if HASP_USE_SPIFFS > 0 || HASP_USE_LITTLEFS > 0 #if HASP_USE_SPIFFS > 0 || HASP_USE_LITTLEFS > 0
File file = HASP_FS.open(configFile, "r"); File file = HASP_FS.open(configFile, "r");
if(file) { if(file) {
@ -123,8 +123,8 @@ void configRead(JsonDocument & settings, bool setupdebug = false)
// show settings in log // show settings in log
String output; String output;
serializeJson(settings, output); serializeJson(settings, output);
String passmask = F(D_PASSWORD_MASK); String passmask = F(D_PASSWORD_MASK);
const __FlashStringHelper * pass = F("pass"); const __FlashStringHelper* pass = F("pass");
output.replace(settings[FPSTR(FP_HTTP)][pass].as<String>(), passmask); output.replace(settings[FPSTR(FP_HTTP)][pass].as<String>(), passmask);
output.replace(settings[FPSTR(FP_MQTT)][pass].as<String>(), passmask); output.replace(settings[FPSTR(FP_MQTT)][pass].as<String>(), passmask);
output.replace(settings[FPSTR(FP_WIFI)][pass].as<String>(), passmask); output.replace(settings[FPSTR(FP_WIFI)][pass].as<String>(), passmask);
@ -135,14 +135,14 @@ void configRead(JsonDocument & settings, bool setupdebug = false)
return; return;
} }
} }
#else #else
#if HASP_USE_EEPROM > 0 #if HASP_USE_EEPROM > 0
EepromStream eepromStream(0, 1024); EepromStream eepromStream(0, 1024);
error = deserializeJson(settings, eepromStream); error = deserializeJson(settings, eepromStream);
#endif #endif
#endif #endif
// File does not exist or error reading file // File does not exist or error reading file
if(setupdebug) { if(setupdebug) {
@ -150,9 +150,9 @@ void configRead(JsonDocument & settings, bool setupdebug = false)
} }
configStartDebug(setupdebug, configFile); configStartDebug(setupdebug, configFile);
#if HASP_USE_SPIFFS > 0 || HASP_USE_LITTLEFS > 0 #if HASP_USE_SPIFFS > 0 || HASP_USE_LITTLEFS > 0
LOG_ERROR(TAG_CONF, F(D_FILE_LOAD_FAILED), configFile.c_str()); LOG_ERROR(TAG_CONF, F(D_FILE_LOAD_FAILED), configFile.c_str());
#endif #endif
} }
/* /*
void configBackupToEeprom() void configBackupToEeprom()
@ -186,11 +186,11 @@ void configBackupToEeprom()
*/ */
void configWrite() void configWrite()
{ {
String configFile((char *)0); String configFile((char*)0);
configFile.reserve(32); configFile.reserve(32);
configFile = String(FPSTR(FP_HASP_CONFIG_FILE)); configFile = String(FPSTR(FP_HASP_CONFIG_FILE));
String settingsChanged((char *)0); String settingsChanged((char*)0);
settingsChanged.reserve(128); settingsChanged.reserve(128);
settingsChanged = F(D_CONFIG_CHANGED); settingsChanged = F(D_CONFIG_CHANGED);
@ -210,9 +210,9 @@ void configWrite()
bool writefile = false; bool writefile = false;
bool changed = false; bool changed = false;
const __FlashStringHelper * module; const __FlashStringHelper* module;
#if HASP_USE_WIFI > 0 #if HASP_USE_WIFI > 0
module = FPSTR(FP_WIFI); module = FPSTR(FP_WIFI);
if(settings[module].as<JsonObject>().isNull()) settings.createNestedObject(module); if(settings[module].as<JsonObject>().isNull()) settings.createNestedObject(module);
changed = wifiGetConfig(settings[module]); changed = wifiGetConfig(settings[module]);
@ -221,9 +221,9 @@ void configWrite()
configOutput(settings[module], TAG_WIFI); configOutput(settings[module], TAG_WIFI);
writefile = true; writefile = true;
} }
#endif #endif
#if HASP_USE_MQTT > 0 #if HASP_USE_MQTT > 0
module = FPSTR(FP_MQTT); module = FPSTR(FP_MQTT);
if(settings[module].as<JsonObject>().isNull()) settings.createNestedObject(module); if(settings[module].as<JsonObject>().isNull()) settings.createNestedObject(module);
changed = mqttGetConfig(settings[module]); changed = mqttGetConfig(settings[module]);
@ -232,9 +232,9 @@ void configWrite()
configOutput(settings[module], TAG_MQTT); configOutput(settings[module], TAG_MQTT);
writefile = true; writefile = true;
} }
#endif #endif
#if HASP_USE_TELNET > 0 #if HASP_USE_TELNET > 0
module = F("telnet"); module = F("telnet");
if(settings[module].as<JsonObject>().isNull()) settings.createNestedObject(module); if(settings[module].as<JsonObject>().isNull()) settings.createNestedObject(module);
changed = telnetGetConfig(settings[module]); changed = telnetGetConfig(settings[module]);
@ -243,9 +243,9 @@ void configWrite()
configOutput(settings[module], TAG_TELN); configOutput(settings[module], TAG_TELN);
writefile = true; writefile = true;
} }
#endif #endif
#if HASP_USE_MDNS > 0 #if HASP_USE_MDNS > 0
module = FPSTR(FP_MDNS); module = FPSTR(FP_MDNS);
if(settings[module].as<JsonObject>().isNull()) settings.createNestedObject(module); if(settings[module].as<JsonObject>().isNull()) settings.createNestedObject(module);
changed = mdnsGetConfig(settings[module]); changed = mdnsGetConfig(settings[module]);
@ -254,9 +254,9 @@ void configWrite()
configOutput(settings[module], TAG_MDNS); configOutput(settings[module], TAG_MDNS);
writefile = true; writefile = true;
} }
#endif #endif
#if HASP_USE_HTTP > 0 #if HASP_USE_HTTP > 0
if(settings[FPSTR(FP_HTTP)].as<JsonObject>().isNull()) settings.createNestedObject(F("http")); if(settings[FPSTR(FP_HTTP)].as<JsonObject>().isNull()) settings.createNestedObject(F("http"));
changed = httpGetConfig(settings[FPSTR(FP_HTTP)]); changed = httpGetConfig(settings[FPSTR(FP_HTTP)]);
if(changed) { if(changed) {
@ -264,9 +264,9 @@ void configWrite()
configOutput(settings[FPSTR(FP_HTTP)], TAG_HTTP); configOutput(settings[FPSTR(FP_HTTP)], TAG_HTTP);
writefile = true; writefile = true;
} }
#endif #endif
#if HASP_USE_GPIO > 0 #if HASP_USE_GPIO > 0
module = FPSTR(FP_GPIO); module = FPSTR(FP_GPIO);
if(settings[module].as<JsonObject>().isNull()) settings.createNestedObject(module); if(settings[module].as<JsonObject>().isNull()) settings.createNestedObject(module);
changed = gpioGetConfig(settings[module]); changed = gpioGetConfig(settings[module]);
@ -275,7 +275,7 @@ void configWrite()
configOutput(settings[module], TAG_GPIO); configOutput(settings[module], TAG_GPIO);
writefile = true; writefile = true;
} }
#endif #endif
module = FPSTR(FP_DEBUG); module = FPSTR(FP_DEBUG);
if(settings[module].as<JsonObject>().isNull()) settings.createNestedObject(module); if(settings[module].as<JsonObject>().isNull()) settings.createNestedObject(module);
@ -305,7 +305,7 @@ void configWrite()
// changed |= otaGetConfig(settings[F("ota")].as<JsonObject>()); // changed |= otaGetConfig(settings[F("ota")].as<JsonObject>());
if(writefile) { if(writefile) {
#if HASP_USE_SPIFFS > 0 || HASP_USE_LITTLEFS > 0 #if HASP_USE_SPIFFS > 0 || HASP_USE_LITTLEFS > 0
File file = HASP_FS.open(configFile, "w"); File file = HASP_FS.open(configFile, "w");
if(file) { if(file) {
LOG_TRACE(TAG_CONF, F(D_FILE_SAVING), configFile.c_str()); LOG_TRACE(TAG_CONF, F(D_FILE_SAVING), configFile.c_str());
@ -320,7 +320,7 @@ void configWrite()
} else { } else {
LOG_ERROR(TAG_CONF, F(D_FILE_SAVE_FAILED), configFile.c_str()); LOG_ERROR(TAG_CONF, F(D_FILE_SAVE_FAILED), configFile.c_str());
} }
#endif #endif
// Method 1 // Method 1
// LOG_INFO(TAG_CONF,F("Writing to EEPROM")); // LOG_INFO(TAG_CONF,F("Writing to EEPROM"));
@ -330,7 +330,7 @@ void configWrite()
// bufferedWifiClient.flush(); // <- OPTIONAL // bufferedWifiClient.flush(); // <- OPTIONAL
// eepromStream.flush(); // (for ESP) // eepromStream.flush(); // (for ESP)
#if defined(STM32F4xx) #if defined(STM32F4xx)
// Method 2 // Method 2
LOG_INFO(TAG_CONF, F(F_FILE_SAVING), "EEPROM"); LOG_INFO(TAG_CONF, F(F_FILE_SAVING), "EEPROM");
char buffer[1024 + 128]; char buffer[1024 + 128];
@ -344,7 +344,7 @@ void configWrite()
} else { } else {
LOG_ERROR(TAG_CONF, F(D_FILE_WRITE_FAILED), "EEPROM"); LOG_ERROR(TAG_CONF, F(D_FILE_WRITE_FAILED), "EEPROM");
} }
#endif #endif
} else { } else {
LOG_INFO(TAG_CONF, F(D_CONFIG_NOT_CHANGED)); LOG_INFO(TAG_CONF, F(D_CONFIG_NOT_CHANGED));
@ -361,19 +361,19 @@ void configSetup()
Serial.println(__LINE__); Serial.println(__LINE__);
if(i == 0) { if(i == 0) {
#if HASP_USE_SPIFFS > 0 #if HASP_USE_SPIFFS > 0
EepromStream eepromStream(0, 2048); EepromStream eepromStream(0, 2048);
DeserializationError err = deserializeJson(settings, eepromStream); DeserializationError err = deserializeJson(settings, eepromStream);
#else #else
continue; continue;
#endif #endif
} else { } else {
#if HASP_USE_SPIFFS > 0 || HASP_USE_LITTLEFS > 0 #if HASP_USE_SPIFFS > 0 || HASP_USE_LITTLEFS > 0
if(!filesystemSetup()) { if(!filesystemSetup()) {
LOG_ERROR(TAG_CONF, F("FILE: SPI flash init failed. Unable to mount FS: Using default settings...")); LOG_ERROR(TAG_CONF, F("FILE: SPI flash init failed. Unable to mount FS: Using default settings..."));
return; return;
} }
#endif #endif
configRead(settings, true); configRead(settings, true);
} }
@ -386,35 +386,35 @@ void configSetup()
haspSetConfig(settings[FPSTR(FP_HASP)]); haspSetConfig(settings[FPSTR(FP_HASP)]);
// otaGetConfig(settings[F("ota")]); // otaGetConfig(settings[F("ota")]);
#if HASP_USE_WIFI > 0 #if HASP_USE_WIFI > 0
LOG_INFO(TAG_WIFI, F("Loading WiFi settings")); LOG_INFO(TAG_WIFI, F("Loading WiFi settings"));
wifiSetConfig(settings[FPSTR(FP_WIFI)]); wifiSetConfig(settings[FPSTR(FP_WIFI)]);
#endif #endif
#if HASP_USE_MQTT > 0 #if HASP_USE_MQTT > 0
LOG_INFO(TAG_MQTT, F("Loading MQTT settings")); LOG_INFO(TAG_MQTT, F("Loading MQTT settings"));
mqttSetConfig(settings[FPSTR(FP_MQTT)]); mqttSetConfig(settings[FPSTR(FP_MQTT)]);
#endif #endif
#if HASP_USE_TELNET > 0 #if HASP_USE_TELNET > 0
LOG_INFO(TAG_TELN, F("Loading Telnet settings")); LOG_INFO(TAG_TELN, F("Loading Telnet settings"));
telnetSetConfig(settings[F("telnet")]); telnetSetConfig(settings[F("telnet")]);
#endif #endif
#if HASP_USE_MDNS > 0 #if HASP_USE_MDNS > 0
LOG_INFO(TAG_MDNS, F("Loading MDNS settings")); LOG_INFO(TAG_MDNS, F("Loading MDNS settings"));
mdnsSetConfig(settings[FPSTR(FP_MDNS)]); mdnsSetConfig(settings[FPSTR(FP_MDNS)]);
#endif #endif
#if HASP_USE_HTTP > 0 #if HASP_USE_HTTP > 0
LOG_INFO(TAG_HTTP, F("Loading HTTP settings")); LOG_INFO(TAG_HTTP, F("Loading HTTP settings"));
httpSetConfig(settings[FPSTR(FP_HTTP)]); httpSetConfig(settings[FPSTR(FP_HTTP)]);
#endif #endif
#if HASP_USE_GPIO > 0 #if HASP_USE_GPIO > 0
LOG_INFO(TAG_GPIO, F("Loading GPIO settings")); LOG_INFO(TAG_GPIO, F("Loading GPIO settings"));
gpioSetConfig(settings[FPSTR(FP_GPIO)]); gpioSetConfig(settings[FPSTR(FP_GPIO)]);
#endif #endif
LOG_INFO(TAG_CONF, F(D_CONFIG_LOADED)); LOG_INFO(TAG_CONF, F(D_CONFIG_LOADED));
} }
@ -424,17 +424,17 @@ void configSetup()
void configLoop(void) void configLoop(void)
{} {}
void configOutput(const JsonObject & settings, uint8_t tag) void configOutput(const JsonObject& settings, uint8_t tag)
{ {
String output((char *)0); String output((char*)0);
output.reserve(128); output.reserve(128);
serializeJson(settings, output); serializeJson(settings, output);
String passmask((char *)0); String passmask((char*)0);
passmask.reserve(128); passmask.reserve(128);
passmask = F("\"pass\":\"" D_PASSWORD_MASK "\""); passmask = F("\"pass\":\"" D_PASSWORD_MASK "\"");
String password((char *)0); String password((char*)0);
password.reserve(128); password.reserve(128);
String pass = F("pass"); String pass = F("pass");
@ -471,7 +471,7 @@ void configOutput(const JsonObject & settings, uint8_t tag)
bool configClearEeprom() bool configClearEeprom()
{ {
#if defined(STM32F4xx) #if defined(STM32F4xx)
LOG_TRACE(TAG_CONF, F("Clearing EEPROM")); LOG_TRACE(TAG_CONF, F("Clearing EEPROM"));
char buffer[1024 + 128]; char buffer[1024 + 128];
memset(buffer, 1, sizeof(buffer)); memset(buffer, 1, sizeof(buffer));
@ -486,11 +486,11 @@ bool configClearEeprom()
LOG_ERROR(TAG_CONF, F("Failed to clear to EEPROM")); LOG_ERROR(TAG_CONF, F("Failed to clear to EEPROM"));
return false; return false;
} }
#elif HASP_USE_SPIFFS > 0 || HASP_USE_LITTLEFS > 0 #elif HASP_USE_SPIFFS > 0 || HASP_USE_LITTLEFS > 0
return HASP_FS.format(); return HASP_FS.format();
#else #else
return false; return false;
#endif #endif
} }
#endif // HAS_USE_CONFIG #endif // HAS_USE_CONFIG

View File

@ -1,14 +1,14 @@
/* MIT License - Copyright (c) 2020 Francis Van Roie /* MIT License - Copyright (c) 2019-2021 Francis Van Roie
For full license information read the LICENSE file in the project folder */ For full license information read the LICENSE file in the project folder */
#if HASP_USE_CONFIG > 0 #if HASP_USE_CONFIG > 0
#ifndef HASP_CONFIG_H #ifndef HASP_CONFIG_H
#define HASP_CONFIG_H #define HASP_CONFIG_H
#include "hasp_conf.h" #include "hasp_conf.h"
#include "ArduinoJson.h" #include "ArduinoJson.h"
#include "hasp_debug.h" // for TAG_CONF #include "hasp_debug.h" // for TAG_CONF
/* ===== Default Event Processors ===== */ /* ===== Default Event Processors ===== */
void configSetup(void); void configSetup(void);
@ -19,17 +19,17 @@ void configStop(void);
/* ===== Special Event Processors ===== */ /* ===== Special Event Processors ===== */
void configWrite(void); void configWrite(void);
void configOutput(const JsonObject & settings, uint8_t tag = TAG_CONF); void configOutput(const JsonObject& settings, uint8_t tag = TAG_CONF);
bool configClearEeprom(void); bool configClearEeprom(void);
/* ===== Getter and Setter Functions ===== */ /* ===== Getter and Setter Functions ===== */
bool configSet(int8_t & value, const JsonVariant & setting, const __FlashStringHelper * fstr_name); bool configSet(int8_t& value, const JsonVariant& setting, const __FlashStringHelper* fstr_name);
bool configSet(uint8_t & value, const JsonVariant & setting, const __FlashStringHelper * fstr_name); bool configSet(uint8_t& value, const JsonVariant& setting, const __FlashStringHelper* fstr_name);
bool configSet(uint16_t & value, const JsonVariant & setting, const __FlashStringHelper * fstr_name); bool configSet(uint16_t& value, const JsonVariant& setting, const __FlashStringHelper* fstr_name);
/* ===== Read/Write Configuration ===== */ /* ===== Read/Write Configuration ===== */
void configSetConfig(JsonObject & settings); void configSetConfig(JsonObject& settings);
void configGetConfig(JsonDocument & settings); void configGetConfig(JsonDocument& settings);
/* json keys used in the configfile */ /* json keys used in the configfile */
const char FP_CONFIG_STARTPAGE[] PROGMEM = "startpage"; const char FP_CONFIG_STARTPAGE[] PROGMEM = "startpage";
@ -71,6 +71,6 @@ const char FP_HASP[] PROGMEM = "hasp";
const char FP_GUI[] PROGMEM = "gui"; const char FP_GUI[] PROGMEM = "gui";
const char FP_DEBUG[] PROGMEM = "debug"; const char FP_DEBUG[] PROGMEM = "debug";
#endif #endif
#endif // HASP_USE_CONFIG #endif // HASP_USE_CONFIG

View File

@ -1,4 +1,4 @@
/* MIT License - Copyright (c) 2020 Francis Van Roie /* MIT License - Copyright (c) 2019-2021 Francis Van Roie
For full license information read the LICENSE file in the project folder */ For full license information read the LICENSE file in the project folder */
#ifndef HASP_DEBUG_H #ifndef HASP_DEBUG_H

View File

@ -1,20 +1,20 @@
/* MIT License - Copyright (c) 2020 Francis Van Roie /* MIT License - Copyright (c) 2019-2021 Francis Van Roie
For full license information read the LICENSE file in the project folder */ For full license information read the LICENSE file in the project folder */
#include "hasp_conf.h" // load first #include "hasp_conf.h" // load first
#if HASP_USE_EEPROM > 0 #if HASP_USE_EEPROM > 0
#ifdef ARDUINO #ifdef ARDUINO
#include "Arduino.h" #include "Arduino.h"
#endif #endif
#include "EEPROM.h" #include "EEPROM.h"
void eepromSetup() void eepromSetup()
{ {
#if defined(STM32Fxx) #if defined(STM32Fxx)
eeprom_buffer_fill(); eeprom_buffer_fill();
char buffer[] = "{\"objid\":10,\"id\":1,\"page\":0,\"x\":10,\"y\":45,\"w\":220,\"h\":55,\"toggle\":\"TRUE\"," char buffer[] = "{\"objid\":10,\"id\":1,\"page\":0,\"x\":10,\"y\":45,\"w\":220,\"h\":55,\"toggle\":\"TRUE\","
"\"txt\":\"Toggle Me\"}"; "\"txt\":\"Toggle Me\"}";
@ -22,8 +22,8 @@ void eepromSetup()
uint16_t i; uint16_t i;
for(i = 0; i < size; i++) eeprom_buffered_write_byte(i + 4096, buffer[i]); for(i = 0; i < size; i++) eeprom_buffered_write_byte(i + 4096, buffer[i]);
eeprom_buffered_write_byte(i + 4096, 0); eeprom_buffered_write_byte(i + 4096, 0);
// eeprom_buffer_flush(); // eeprom_buffer_flush();
#endif #endif
// ESP8266 // Don't start at boot, only at write // ESP8266 // Don't start at boot, only at write
// EEPROM.begin(1024); // EEPROM.begin(1024);

View File

@ -1,4 +1,4 @@
/* MIT License - Copyright (c) 2020 Francis Van Roie /* MIT License - Copyright (c) 2019-2021 Francis Van Roie
For full license information read the LICENSE file in the project folder */ For full license information read the LICENSE file in the project folder */
#ifndef HASP_EEPROM_H #ifndef HASP_EEPROM_H
@ -8,7 +8,7 @@
void eepromSetup(void); void eepromSetup(void);
void eepromLoop(void); void eepromLoop(void);
void eepromWrite(uint16_t addr, std::string & data); void eepromWrite(uint16_t addr, std::string& data);
std::string eepromRead(uint16_t addr); std::string eepromRead(uint16_t addr);
#endif #endif

View File

@ -1,20 +1,20 @@
/* MIT License - Copyright (c) 2020 Francis Van Roie /* MIT License - Copyright (c) 2019-2021 Francis Van Roie
For full license information read the LICENSE file in the project folder */ For full license information read the LICENSE file in the project folder */
#include "hasp_conf.h" // include first #include "hasp_conf.h" // include first
#if HASP_USE_SPIFFS > 0 || HASP_USE_LITTLEFS > 0 #if HASP_USE_SPIFFS > 0 || HASP_USE_LITTLEFS > 0
#include <Arduino.h> #include <Arduino.h>
#include "ArduinoJson.h" #include "ArduinoJson.h"
#include "ArduinoLog.h" #include "ArduinoLog.h"
#include "hasp_debug.h" #include "hasp_debug.h"
#include "hasp_filesystem.h" #include "hasp_filesystem.h"
void filesystemInfo() void filesystemInfo()
{ // Get all information of your SPIFFS { // Get all information of your SPIFFS
#if 0 #if 0
FSInfo fs_info; FSInfo fs_info;
SPIFFS.info(fs_info); SPIFFS.info(fs_info);
@ -64,38 +64,38 @@ void filesystemInfo()
Serial.print("Max path lenght: "); Serial.print("Max path lenght: ");
// Serial.println(SPIFFS.maxPathLength()); // Serial.println(SPIFFS.maxPathLength());
#endif #endif
} }
void filesystemList() void filesystemList()
{ {
#if HASP_USE_SPIFFS > 0 #if HASP_USE_SPIFFS > 0
#if defined(ARDUINO_ARCH_ESP8266) #if defined(ARDUINO_ARCH_ESP8266)
if(!SPIFFS.begin()) { if(!SPIFFS.begin()) {
#else #else
if(!SPIFFS.begin(true)) { if(!SPIFFS.begin(true)) {
#endif #endif
LOG_ERROR(TAG_FILE, F("Flash file system not mouted.")); LOG_ERROR(TAG_FILE, F("Flash file system not mouted."));
} else { } else {
LOG_VERBOSE(TAG_FILE, F("Listing files on the internal flash:")); LOG_VERBOSE(TAG_FILE, F("Listing files on the internal flash:"));
#if defined(ARDUINO_ARCH_ESP32) #if defined(ARDUINO_ARCH_ESP32)
File root = SPIFFS.open("/"); File root = SPIFFS.open("/");
File file = root.openNextFile(); File file = root.openNextFile();
while(file) { while(file) {
LOG_VERBOSE(TAG_FILE, F(" * %s (%u bytes)"), file.name(), (uint32_t)file.size()); LOG_VERBOSE(TAG_FILE, F(" * %s (%u bytes)"), file.name(), (uint32_t)file.size());
file = root.openNextFile(); file = root.openNextFile();
} }
#endif #endif
#if defined(ARDUINO_ARCH_ESP8266) #if defined(ARDUINO_ARCH_ESP8266)
Dir dir = SPIFFS.openDir("/"); Dir dir = SPIFFS.openDir("/");
while(dir.next()) { while(dir.next()) {
LOG_VERBOSE(TAG_FILE, F(" * %s (%u bytes)"), dir.fileName().c_str(), (uint32_t)dir.fileSize()); LOG_VERBOSE(TAG_FILE, F(" * %s (%u bytes)"), dir.fileName().c_str(), (uint32_t)dir.fileSize());
} }
#endif #endif
} }
#endif #endif
} }
bool filesystemSetup(void) bool filesystemSetup(void)
@ -106,19 +106,19 @@ bool filesystemSetup(void)
// Logging is defered until debugging has started // Logging is defered until debugging has started
// FS success or failure is printed at that time ! // FS success or failure is printed at that time !
#if HASP_USE_SPIFFS > 0 || HASP_USE_LITTLEFS > 0 #if HASP_USE_SPIFFS > 0 || HASP_USE_LITTLEFS > 0
#if defined(ARDUINO_ARCH_ESP8266) #if defined(ARDUINO_ARCH_ESP8266)
if(!HASP_FS.begin()) { if(!HASP_FS.begin()) {
#else #else
if(!HASP_FS.begin(true)) { if(!HASP_FS.begin(true)) {
#endif #endif
// LOG_ERROR(TAG_FILE, F("SPI flash init failed. Unable to mount FS.")); // LOG_ERROR(TAG_FILE, F("SPI flash init failed. Unable to mount FS."));
return false; return false;
} else { } else {
// LOG_INFO(TAG_FILE, F("SPI Flash FS mounted")); // LOG_INFO(TAG_FILE, F("SPI Flash FS mounted"));
return true; return true;
} }
#endif #endif
return false; return false;
} }

View File

@ -1,4 +1,4 @@
/* MIT License - Copyright (c) 2020 Francis Van Roie /* MIT License - Copyright (c) 2019-2021 Francis Van Roie
For full license information read the LICENSE file in the project folder */ For full license information read the LICENSE file in the project folder */
#ifndef HASP_FILESYSTEM_H #ifndef HASP_FILESYSTEM_H
@ -12,22 +12,22 @@ void filesystemList();
void filesystemInfo(); void filesystemInfo();
#if defined(ARDUINO_ARCH_ESP32) #if defined(ARDUINO_ARCH_ESP32)
#if HASP_USE_SPIFFS > 0 #if HASP_USE_SPIFFS > 0
#include "SPIFFS.h" #include "SPIFFS.h"
#define HASP_FS SPIFFS #define HASP_FS SPIFFS
#elif HASP_USE_LITTLEFS > 0 #elif HASP_USE_LITTLEFS > 0
#include "LITTLEFS.h" #include "LITTLEFS.h"
#define HASP_FS LITTLEFS #define HASP_FS LITTLEFS
#endif #endif
#elif defined(ARDUINO_ARCH_ESP8266) #elif defined(ARDUINO_ARCH_ESP8266)
// included by default // included by default
#include <LittleFS.h> #include <LittleFS.h>
#define HASP_FS LittleFS #define HASP_FS LittleFS
#endif // ARDUINO_ARCH #endif // ARDUINO_ARCH
#if defined(ARDUINO_ARCH_ESP8266) || defined(ARDUINO_ARCH_ESP32) #if defined(ARDUINO_ARCH_ESP8266) || defined(ARDUINO_ARCH_ESP32)
#include <FS.h> #include <FS.h>
#include <Esp.h> #include <Esp.h>
#endif // ARDUINO_ARCH #endif // ARDUINO_ARCH
#endif // HASP_FILESYSTEM_H #endif // HASP_FILESYSTEM_H

View File

@ -1,4 +1,4 @@
/* MIT License - Copyright (c) 2020 Francis Van Roie /* MIT License - Copyright (c) 2019-2021 Francis Van Roie
For full license information read the LICENSE file in the project folder */ For full license information read the LICENSE file in the project folder */
#include "hasp_conf.h" #include "hasp_conf.h"

View File

@ -1,4 +1,4 @@
/* MIT License - Copyright (c) 2020 Francis Van Roie /* MIT License - Copyright (c) 2019-2021 Francis Van Roie
For full license information read the LICENSE file in the project folder */ For full license information read the LICENSE file in the project folder */
#ifndef HASP_GUI_H #ifndef HASP_GUI_H

View File

@ -1,4 +1,4 @@
/* MIT License - Copyright (c) 2020 Francis Van Roie /* MIT License - Copyright (c) 2019-2021 Francis Van Roie
For full license information read the LICENSE file in the project folder */ For full license information read the LICENSE file in the project folder */
#if HASP_USE_CONFIG > 0 #if HASP_USE_CONFIG > 0

View File

@ -1,10 +1,10 @@
/* MIT License - Copyright (c) 2020 Francis Van Roie /* MIT License - Copyright (c) 2019-2021 Francis Van Roie
For full license information read the LICENSE file in the project folder */ For full license information read the LICENSE file in the project folder */
#if HASP_USE_CONFIG > 0 #if HASP_USE_CONFIG > 0
void oobeSetAutoCalibrate(bool cal); void oobeSetAutoCalibrate(bool cal);
bool oobeSetup(); bool oobeSetup();
void oobeFakeSetup(const char *, const char *); // for testing purposes only void oobeFakeSetup(const char*, const char*); // for testing purposes only
#endif // HASP_USE_CONFIG #endif // HASP_USE_CONFIG

View File

@ -1,4 +1,4 @@
/* MIT License - Copyright (c) 2020 Francis Van Roie /* MIT License - Copyright (c) 2019-2021 Francis Van Roie
For full license information read the LICENSE file in the project folder */ For full license information read the LICENSE file in the project folder */
/* =========================================================================== /* ===========================================================================

View File

@ -1,4 +1,4 @@
/* MIT License - Copyright (c) 2020 Francis Van Roie /* MIT License - Copyright (c) 2019-2021 Francis Van Roie
For full license information read the LICENSE file in the project folder */ For full license information read the LICENSE file in the project folder */
#if 0 && ARDUINO #if 0 && ARDUINO

View File

@ -1,4 +1,4 @@
/* MIT License - Copyright (c) 2020 Francis Van Roie /* MIT License - Copyright (c) 2019-2021 Francis Van Roie
For full license information read the LICENSE file in the project folder */ For full license information read the LICENSE file in the project folder */
#ifndef WINDOWS #ifndef WINDOWS

View File

@ -1,4 +1,4 @@
/* MIT License - Copyright (c) 2020 Francis Van Roie /* MIT License - Copyright (c) 2019-2021 Francis Van Roie
For full license information read the LICENSE file in the project folder */ For full license information read the LICENSE file in the project folder */
#ifdef WINDOWS #ifdef WINDOWS

View File

@ -1,4 +1,4 @@
/* MIT License - Copyright (c) 2020 Francis Van Roie /* MIT License - Copyright (c) 2019-2021 Francis Van Roie
For full license information read the LICENSE file in the project folder */ For full license information read the LICENSE file in the project folder */
#ifndef HASP_MQTT_H #ifndef HASP_MQTT_H

View File

@ -1,4 +1,4 @@
/* MIT License - Copyright (c) 2020 Francis Van Roie /* MIT License - Copyright (c) 2019-2021 Francis Van Roie
For full license information read the LICENSE file in the project folder */ For full license information read the LICENSE file in the project folder */
#include "ArduinoJson.h" #include "ArduinoJson.h"

View File

@ -1,4 +1,4 @@
/* MIT License - Copyright (c) 2020 Francis Van Roie /* MIT License - Copyright (c) 2019-2021 Francis Van Roie
For full license information read the LICENSE file in the project folder */ For full license information read the LICENSE file in the project folder */
#ifndef HASP_MQTT_HA_H #ifndef HASP_MQTT_HA_H

View File

@ -1,4 +1,4 @@
/* MIT License - Copyright (c) 2020 Francis Van Roie /* MIT License - Copyright (c) 2019-2021 Francis Van Roie
For full license information read the LICENSE file in the project folder */ For full license information read the LICENSE file in the project folder */
/* Multi threaded asynchronous paho client */ /* Multi threaded asynchronous paho client */

View File

@ -1,4 +1,4 @@
/* MIT License - Copyright (c) 2020 Francis Van Roie /* MIT License - Copyright (c) 2019-2021 Francis Van Roie
For full license information read the LICENSE file in the project folder */ For full license information read the LICENSE file in the project folder */
/* Single threaded synchronous paho client */ /* Single threaded synchronous paho client */

View File

@ -1,4 +1,4 @@
/* MIT License - Copyright (c) 2020 Francis Van Roie /* MIT License - Copyright (c) 2019-2021 Francis Van Roie
For full license information read the LICENSE file in the project folder */ For full license information read the LICENSE file in the project folder */
#include "hasp_conf.h" #include "hasp_conf.h"

View File

@ -1,4 +1,4 @@
/* MIT License - Copyright (c) 2020 Francis Van Roie /* MIT License - Copyright (c) 2019-2021 Francis Van Roie
For full license information read the LICENSE file in the project folder */ For full license information read the LICENSE file in the project folder */
#include "AceButton.h" #include "AceButton.h"
@ -12,13 +12,13 @@
#include "hasp/hasp.h" #include "hasp/hasp.h"
#ifdef ARDUINO_ARCH_ESP8266 #ifdef ARDUINO_ARCH_ESP8266
#define INPUT_PULLDOWN INPUT #define INPUT_PULLDOWN INPUT
#endif #endif
uint8_t gpioUsedInputCount = 0; uint8_t gpioUsedInputCount = 0;
using namespace ace_button; using namespace ace_button;
static AceButton * button[HASP_NUM_INPUTS]; static AceButton* button[HASP_NUM_INPUTS];
// An array of button pins, led pins, and the led states. Cannot be const // An array of button pins, led pins, and the led states. Cannot be const
// because ledState is mutable. // because ledState is mutable.
@ -49,7 +49,7 @@ class TouchConfig : public ButtonConfig {
TouchConfig touchConfig(); TouchConfig touchConfig();
#endif #endif
static void gpio_event_handler(AceButton * button, uint8_t eventType, uint8_t buttonState) static void gpio_event_handler(AceButton* button, uint8_t eventType, uint8_t buttonState)
{ {
uint8_t btnid = button->getId(); uint8_t btnid = button->getId();
uint8_t eventid; uint8_t eventid;
@ -95,7 +95,7 @@ static void gpio_event_handler(AceButton * button, uint8_t eventType, uint8_t bu
void aceButtonSetup(void) void aceButtonSetup(void)
{ {
ButtonConfig * buttonConfig = ButtonConfig::getSystemButtonConfig(); ButtonConfig* buttonConfig = ButtonConfig::getSystemButtonConfig();
buttonConfig->setEventHandler(gpio_event_handler); buttonConfig->setEventHandler(gpio_event_handler);
// Features // Features
@ -128,14 +128,14 @@ void gpioAddButton(uint8_t pin, uint8_t input_mode, uint8_t default_state, uint8
if(!button[i]) { if(!button[i]) {
LOG_TRACE(TAG_GPIO, F("Creating Button%d on pin %d (index %d) mode %d default %d"), i, pin, index, LOG_TRACE(TAG_GPIO, F("Creating Button%d on pin %d (index %d) mode %d default %d"), i, pin, index,
input_mode, default_state); input_mode, default_state);
button[i] = new AceButton(pin, default_state, index); button[i] = new AceButton(pin, default_state, index);
if(button[i]) { if(button[i]) {
// pinMode(pin, input_mode); // pinMode(pin, input_mode);
ButtonConfig * buttonConfig = button[i]->getButtonConfig(); ButtonConfig* buttonConfig = button[i]->getButtonConfig();
buttonConfig->setEventHandler(gpio_event_handler); buttonConfig->setEventHandler(gpio_event_handler);
buttonConfig->setFeature(ButtonConfig::kFeatureClick); buttonConfig->setFeature(ButtonConfig::kFeatureClick);
buttonConfig->clearFeature(ButtonConfig::kFeatureDoubleClick); buttonConfig->clearFeature(ButtonConfig::kFeatureDoubleClick);
@ -146,7 +146,7 @@ void gpioAddButton(uint8_t pin, uint8_t input_mode, uint8_t default_state, uint8
buttonConfig->setFeature(ButtonConfig::kFeatureSuppressAfterClick); buttonConfig->setFeature(ButtonConfig::kFeatureSuppressAfterClick);
LOG_INFO(TAG_GPIO, F("Button%d created on pin %d (index %d) mode %d default %d"), i, pin, index, LOG_INFO(TAG_GPIO, F("Button%d created on pin %d (index %d) mode %d default %d"), i, pin, index,
input_mode, default_state); input_mode, default_state);
gpioUsedInputCount = i + 1; gpioUsedInputCount = i + 1;
return; return;
} }
@ -163,19 +163,19 @@ void gpioAddSwitch(uint8_t pin, uint8_t input_mode, uint8_t default_state, uint8
if(!button[i]) { if(!button[i]) {
LOG_TRACE(TAG_GPIO, F("Creating Switch%d on pin %d (index %d) mode %d default %d"), i, pin, index, LOG_TRACE(TAG_GPIO, F("Creating Switch%d on pin %d (index %d) mode %d default %d"), i, pin, index,
input_mode, default_state); input_mode, default_state);
button[i] = new AceButton(pin, default_state, index); button[i] = new AceButton(pin, default_state, index);
if(button[i]) { if(button[i]) {
// pinMode(pin, input_mode); // pinMode(pin, input_mode);
ButtonConfig * buttonConfig = button[i]->getButtonConfig(); ButtonConfig* buttonConfig = button[i]->getButtonConfig();
buttonConfig->setEventHandler(gpio_event_handler); buttonConfig->setEventHandler(gpio_event_handler);
buttonConfig->setFeature(ButtonConfig::kFeatureSuppressAll); buttonConfig->setFeature(ButtonConfig::kFeatureSuppressAll);
LOG_INFO(TAG_GPIO, F("Button%d switch on pin %d (index %d) mode %d default %d"), i, pin, index, LOG_INFO(TAG_GPIO, F("Button%d switch on pin %d (index %d) mode %d default %d"), i, pin, index,
input_mode, default_state); input_mode, default_state);
gpioUsedInputCount = i + 1; gpioUsedInputCount = i + 1;
return; return;
} }
@ -196,7 +196,7 @@ void gpioAddTouchButton(uint8_t pin, uint8_t input_mode, uint8_t default_state,
if(button[i]) { if(button[i]) {
pinMode(pin, input_mode); pinMode(pin, input_mode);
ButtonConfig * buttonConfig = button[i]->getButtonConfig(); ButtonConfig* buttonConfig = button[i]->getButtonConfig();
buttonConfig->setEventHandler(gpio_event_handler); buttonConfig->setEventHandler(gpio_event_handler);
buttonConfig->setFeature(ButtonConfig::kFeatureClick); buttonConfig->setFeature(ButtonConfig::kFeatureClick);
buttonConfig->clearFeature(ButtonConfig::kFeatureDoubleClick); buttonConfig->clearFeature(ButtonConfig::kFeatureDoubleClick);
@ -206,7 +206,7 @@ void gpioAddTouchButton(uint8_t pin, uint8_t input_mode, uint8_t default_state,
ButtonConfig::kFeatureSuppressClickBeforeDoubleClick); // Causes annoying pauses ButtonConfig::kFeatureSuppressClickBeforeDoubleClick); // Causes annoying pauses
LOG_INFO(TAG_GPIO, F("Button%d created on pin %d (index %d) mode %d default %d"), i, pin, index, LOG_INFO(TAG_GPIO, F("Button%d created on pin %d (index %d) mode %d default %d"), i, pin, index,
input_mode, default_state); input_mode, default_state);
gpioUsedInputCount = i + 1; gpioUsedInputCount = i + 1;
return; return;
} }
@ -472,9 +472,9 @@ bool gpioIsSystemPin(uint8_t gpio)
#ifdef ARDUINO_ARCH_ESP8266 #ifdef ARDUINO_ARCH_ESP8266
if((gpio >= 6) && (gpio <= 11)) return true; // integrated SPI flash if((gpio >= 6) && (gpio <= 11)) return true; // integrated SPI flash
#ifndef TFT_SPI_OVERLAP #ifndef TFT_SPI_OVERLAP
if((gpio >= 12) && (gpio <= 14)) return true; // HSPI if((gpio >= 12) && (gpio <= 14)) return true; // HSPI
#endif #endif
#endif #endif
return false; return false;
@ -505,7 +505,7 @@ bool gpioSavePinConfig(uint8_t config_num, uint8_t pin, uint8_t type, uint8_t gr
gpioConfig[config_num].group = group; gpioConfig[config_num].group = group;
gpioConfig[config_num].gpio_function = pinfunc; gpioConfig[config_num].gpio_function = pinfunc;
LOG_TRACE(TAG_GPIO, F("Saving Pin config #%d pin %d - type %d - group %d - func %d"), config_num, pin, type, LOG_TRACE(TAG_GPIO, F("Saving Pin config #%d pin %d - type %d - group %d - func %d"), config_num, pin, type,
group, pinfunc); group, pinfunc);
return true; return true;
} }
@ -535,7 +535,7 @@ hasp_gpio_config_t gpioGetPinConfig(uint8_t num)
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
#if HASP_USE_CONFIG > 0 #if HASP_USE_CONFIG > 0
bool gpioGetConfig(const JsonObject & settings) bool gpioGetConfig(const JsonObject& settings)
{ {
bool changed = false; bool changed = false;
@ -579,7 +579,7 @@ bool gpioGetConfig(const JsonObject & settings)
* *
* @param[in] settings JsonObject with the config settings. * @param[in] settings JsonObject with the config settings.
**/ **/
bool gpioSetConfig(const JsonObject & settings) bool gpioSetConfig(const JsonObject& settings)
{ {
configOutput(settings); configOutput(settings);
bool changed = false; bool changed = false;

View File

@ -1,4 +1,4 @@
/* MIT License - Copyright (c) 2020 Francis Van Roie /* MIT License - Copyright (c) 2019-2021 Francis Van Roie
For full license information read the LICENSE file in the project folder */ For full license information read the LICENSE file in the project folder */
#ifndef HASP_GPIO_H #ifndef HASP_GPIO_H
@ -36,8 +36,8 @@ int8_t gpioGetFreeConfigId();
hasp_gpio_config_t gpioGetPinConfig(uint8_t num); hasp_gpio_config_t gpioGetPinConfig(uint8_t num);
#if HASP_USE_CONFIG > 0 #if HASP_USE_CONFIG > 0
bool gpioGetConfig(const JsonObject & settings); bool gpioGetConfig(const JsonObject& settings);
bool gpioSetConfig(const JsonObject & settings); bool gpioSetConfig(const JsonObject& settings);
#endif #endif
#define HASP_GPIO_FREE 0x00 #define HASP_GPIO_FREE 0x00

View File

@ -1,4 +1,4 @@
/* MIT License - Copyright (c) 2020 Francis Van Roie /* MIT License - Copyright (c) 2019-2021 Francis Van Roie
For full license information read the LICENSE file in the project folder */ For full license information read the LICENSE file in the project folder */
#include "hasp_conf.h" #include "hasp_conf.h"

View File

@ -1,4 +1,4 @@
/* MIT License - Copyright (c) 2020 Francis Van Roie /* MIT License - Copyright (c) 2019-2021 Francis Van Roie
For full license information read the LICENSE file in the project folder */ For full license information read the LICENSE file in the project folder */
#ifndef HASP_ETHERNET_ESP32_H #ifndef HASP_ETHERNET_ESP32_H
@ -10,6 +10,6 @@ void ethernetSetup();
void ethernetLoop(void); void ethernetLoop(void);
bool ethernetEvery5Seconds(); bool ethernetEvery5Seconds();
void ethernet_get_statusupdate(char * buffer, size_t len); void ethernet_get_statusupdate(char* buffer, size_t len);
#endif #endif

View File

@ -1,4 +1,4 @@
/* MIT License - Copyright (c) 2020 Francis Van Roie /* MIT License - Copyright (c) 2019-2021 Francis Van Roie
For full license information read the LICENSE file in the project folder */ For full license information read the LICENSE file in the project folder */
#include "hasp_conf.h" #include "hasp_conf.h"
@ -13,9 +13,9 @@ IPAddress ip;
void ethernetSetup() void ethernetSetup()
{ {
#if USE_BUILTIN_ETHERNET > 0 #if USE_BUILTIN_ETHERNET > 0
// start Ethernet and UDP // start Ethernet and UDP
LOG_TRACE(TAG_ETH, F("LAN8720 "D_SERVICE_STARTING)); LOG_TRACE(TAG_ETH, F("LAN8720 " D_SERVICE_STARTING));
if(Ethernet.begin() == 0) { if(Ethernet.begin() == 0) {
LOG_TRACE(TAG_ETH, F("Failed to configure Ethernet using DHCP")); LOG_TRACE(TAG_ETH, F("Failed to configure Ethernet using DHCP"));
eth_connected = false; eth_connected = false;
@ -27,7 +27,7 @@ void ethernetSetup()
LOG_TRACE(TAG_ETH, F("MAC Address %s"), halGetMacAddress(0, ":")); LOG_TRACE(TAG_ETH, F("MAC Address %s"), halGetMacAddress(0, ":"));
#else #else
byte mac[6]; byte mac[6];
uint32_t baseUID = (uint32_t)UID_BASE; uint32_t baseUID = (uint32_t)UID_BASE;
mac[0] = 0x00; mac[0] = 0x00;
@ -44,14 +44,14 @@ void ethernetSetup()
Ethernet.setCsPin(W5500_CS); Ethernet.setCsPin(W5500_CS);
Ethernet.setRstPin(W5500_RST); Ethernet.setRstPin(W5500_RST);
Ethernet.setHostname(ethHostname); Ethernet.setHostname(ethHostname);
LOG_TRACE(TAG_ETH, F("W5500 "D_SERVICE_STARTING)); LOG_TRACE(TAG_ETH, F("W5500 " D_SERVICE_STARTING));
if(Ethernet.begin(mac) == 0) { if(Ethernet.begin(mac) == 0) {
LOG_TRACE(TAG_ETH, F("Failed to configure Ethernet using DHCP")); LOG_TRACE(TAG_ETH, F("Failed to configure Ethernet using DHCP"));
} else { } else {
ip = Ethernet.localIP(); ip = Ethernet.localIP();
LOG_TRACE(TAG_ETH, F("DHCP Success got IP %d.%d.%d.%d"), ip[0], ip[1], ip[2], ip[3]); LOG_TRACE(TAG_ETH, F("DHCP Success got IP %d.%d.%d.%d"), ip[0], ip[1], ip[2], ip[3]);
} }
#endif #endif
} }
void ethernetLoop(void) void ethernetLoop(void)
@ -88,22 +88,22 @@ void ethernetLoop(void)
bool ethernetEvery5Seconds() bool ethernetEvery5Seconds()
{ {
bool state; bool state;
#if USE_BUILTIN_ETHERNET > 0 #if USE_BUILTIN_ETHERNET > 0
state = Ethernet.linkStatus() == LinkON; state = Ethernet.linkStatus() == LinkON;
#else #else
state = Ethernet.link() == 1; state = Ethernet.link() == 1;
#endif #endif
LOG_WARNING(TAG_ETH, state ? F(D_NETWORK_ONLINE) : F(D_NETWORK_OFFLINE)); LOG_WARNING(TAG_ETH, state ? F(D_NETWORK_ONLINE) : F(D_NETWORK_OFFLINE));
return state; return state;
} }
void ethernet_get_statusupdate(char * buffer, size_t len) void ethernet_get_statusupdate(char* buffer, size_t len)
{ {
#if USE_BUILTIN_ETHERNET > 0 #if USE_BUILTIN_ETHERNET > 0
bool state = Ethernet.linkStatus() == LinkON; bool state = Ethernet.linkStatus() == LinkON;
#else #else
bool state = Ethernet.link() == 1; bool state = Ethernet.link() == 1;
#endif #endif
IPAddress ip = Ethernet.localIP(); IPAddress ip = Ethernet.localIP();
snprintf_P(buffer, len, PSTR("\"eth\":\"%s\",\"link\":%d,\"ip\":\"%d.%d.%d.%d\","), state ? F("ON") : F("OFF"), 10, snprintf_P(buffer, len, PSTR("\"eth\":\"%s\",\"link\":%d,\"ip\":\"%d.%d.%d.%d\","), state ? F("ON") : F("OFF"), 10,

View File

@ -1,4 +1,4 @@
/* MIT License - Copyright (c) 2020 Francis Van Roie /* MIT License - Copyright (c) 2019-2021 Francis Van Roie
For full license information read the LICENSE file in the project folder */ For full license information read the LICENSE file in the project folder */
#ifndef HASP_ETHERNET_STM32_H #ifndef HASP_ETHERNET_STM32_H
@ -10,6 +10,6 @@ void ethernetSetup();
void ethernetLoop(void); void ethernetLoop(void);
bool ethernetEvery5Seconds(); bool ethernetEvery5Seconds();
void ethernet_get_statusupdate(char * buffer, size_t len); void ethernet_get_statusupdate(char* buffer, size_t len);
#endif #endif

View File

@ -1,4 +1,4 @@
/* MIT License - Copyright (c) 2020 Francis Van Roie /* MIT License - Copyright (c) 2019-2021 Francis Van Roie
For full license information read the LICENSE file in the project folder */ For full license information read the LICENSE file in the project folder */
#include <time.h> #include <time.h>

View File

@ -1,4 +1,4 @@
/* MIT License - Copyright (c) 2020 Francis Van Roie /* MIT License - Copyright (c) 2019-2021 Francis Van Roie
For full license information read the LICENSE file in the project folder */ For full license information read the LICENSE file in the project folder */
#ifndef HASP_NETWORK_H #ifndef HASP_NETWORK_H
@ -15,7 +15,7 @@ void networkStop(void);
/* ===== Special Event Processors ===== */ /* ===== Special Event Processors ===== */
/* ===== Getter and Setter Functions ===== */ /* ===== Getter and Setter Functions ===== */
void network_get_statusupdate(char * buffer, size_t len); void network_get_statusupdate(char* buffer, size_t len);
/* ===== Read/Write Configuration ===== */ /* ===== Read/Write Configuration ===== */

View File

@ -1,4 +1,4 @@
/* MIT License - Copyright (c) 2020 Francis Van Roie /* MIT License - Copyright (c) 2019-2021 Francis Van Roie
For full license information read the LICENSE file in the project folder */ For full license information read the LICENSE file in the project folder */
#include <Arduino.h> #include <Arduino.h>

View File

@ -1,4 +1,4 @@
/* MIT License - Copyright (c) 2020 Francis Van Roie /* MIT License - Copyright (c) 2019-2021 Francis Van Roie
For full license information read the LICENSE file in the project folder */ For full license information read the LICENSE file in the project folder */
#ifndef HASP_WIFI_H #ifndef HASP_WIFI_H
@ -8,16 +8,16 @@
void wifiSetup(); void wifiSetup();
bool wifiShowAP(); bool wifiShowAP();
bool wifiShowAP(char * ssid, char * pass); bool wifiShowAP(char* ssid, char* pass);
bool wifiEvery5Seconds(void); bool wifiEvery5Seconds(void);
void wifiStop(void); void wifiStop(void);
bool wifiValidateSsid(const char * ssid, const char * pass); bool wifiValidateSsid(const char* ssid, const char* pass);
void wifi_get_statusupdate(char * buffer, size_t len); void wifi_get_statusupdate(char* buffer, size_t len);
#if HASP_USE_CONFIG > 0 #if HASP_USE_CONFIG > 0
bool wifiGetConfig(const JsonObject & settings); bool wifiGetConfig(const JsonObject& settings);
bool wifiSetConfig(const JsonObject & settings); bool wifiSetConfig(const JsonObject& settings);
#endif #endif
#endif #endif

View File

@ -1,4 +1,4 @@
/* MIT License - Copyright (c) 2020 Francis Van Roie /* MIT License - Copyright (c) 2019-2021 Francis Van Roie
For full license information read the LICENSE file in the project folder */ For full license information read the LICENSE file in the project folder */
//#include "webServer.h" //#include "webServer.h"

View File

@ -1,4 +1,4 @@
/* MIT License - Copyright (c) 2020 Francis Van Roie /* MIT License - Copyright (c) 2019-2021 Francis Van Roie
For full license information read the LICENSE file in the project folder */ For full license information read the LICENSE file in the project folder */
#ifndef HASP_HTTP_H #ifndef HASP_HTTP_H
@ -22,11 +22,11 @@ void httpEvery5Seconds(void);
void httpStart(void); void httpStart(void);
void httpStop(void); void httpStop(void);
size_t httpClientWrite(const uint8_t * buf, size_t size); // Screenshot Write Data size_t httpClientWrite(const uint8_t* buf, size_t size); // Screenshot Write Data
#if HASP_USE_CONFIG > 0 #if HASP_USE_CONFIG > 0
bool httpGetConfig(const JsonObject & settings); bool httpGetConfig(const JsonObject& settings);
bool httpSetConfig(const JsonObject & settings); bool httpSetConfig(const JsonObject& settings);
#endif // HASP_USE_CONFIG #endif // HASP_USE_CONFIG
#endif #endif

View File

@ -1,4 +1,4 @@
/* MIT License - Copyright (c) 2020 Francis Van Roie /* MIT License - Copyright (c) 2019-2021 Francis Van Roie
For full license information read the LICENSE file in the project folder */ For full license information read the LICENSE file in the project folder */
#include "hasp_conf.h" #include "hasp_conf.h"

View File

@ -1,4 +1,4 @@
/* MIT License - Copyright (c) 2020 Francis Van Roie /* MIT License - Copyright (c) 2019-2021 Francis Van Roie
For full license information read the LICENSE file in the project folder */ For full license information read the LICENSE file in the project folder */
#ifndef HASP_MDNS_H #ifndef HASP_MDNS_H
@ -8,7 +8,7 @@
struct hasp_mdns_config_t struct hasp_mdns_config_t
{ {
uint8_t enable = true; uint8_t enable = true;
}; };
/* ===== Default Event Processors ===== */ /* ===== Default Event Processors ===== */
@ -19,8 +19,8 @@ void mdnsStop(void);
/* ===== Read/Write Configuration ===== */ /* ===== Read/Write Configuration ===== */
#if HASP_USE_CONFIG > 0 #if HASP_USE_CONFIG > 0
bool mdnsGetConfig(const JsonObject & settings); bool mdnsGetConfig(const JsonObject& settings);
bool mdnsSetConfig(const JsonObject & settings); bool mdnsSetConfig(const JsonObject& settings);
#endif #endif
#endif #endif

View File

@ -1,4 +1,4 @@
/* MIT License - Copyright (c) 2020 Francis Van Roie /* MIT License - Copyright (c) 2019-2021 Francis Van Roie
For full license information read the LICENSE file in the project folder */ For full license information read the LICENSE file in the project folder */
#if defined(ARDUINO_ARCH_ESP8266) || defined(ARDUINO_ARCH_ESP32) #if defined(ARDUINO_ARCH_ESP8266) || defined(ARDUINO_ARCH_ESP32)

View File

@ -1,4 +1,4 @@
/* MIT License - Copyright (c) 2020 Francis Van Roie /* MIT License - Copyright (c) 2019-2021 Francis Van Roie
For full license information read the LICENSE file in the project folder */ For full license information read the LICENSE file in the project folder */
#if defined(ARDUINO_ARCH_ESP8266) || defined(ARDUINO_ARCH_ESP32) #if defined(ARDUINO_ARCH_ESP8266) || defined(ARDUINO_ARCH_ESP32)
@ -14,7 +14,7 @@ void otaLoop(void);
void otaEverySecond(void); void otaEverySecond(void);
/* ===== Special Event Processors ===== */ /* ===== Special Event Processors ===== */
void otaHttpUpdate(const char * espOtaUrl); void otaHttpUpdate(const char* espOtaUrl);
#endif #endif
#endif #endif

View File

@ -1,4 +1,4 @@
/* MIT License - Copyright (c) 2020 Francis Van Roie /* MIT License - Copyright (c) 2019-2021 Francis Van Roie
For full license information read the LICENSE file in the project folder */ For full license information read the LICENSE file in the project folder */
#include "hasp_conf.h" #include "hasp_conf.h"
@ -25,7 +25,7 @@ unsigned long updatLedPeriod = 1000; // timer in msec for tele mqtt send
bool ledstate = false; bool ledstate = false;
void slave_send_state(const __FlashStringHelper * subtopic, const char * payload) void slave_send_state(const __FlashStringHelper* subtopic, const char* payload)
{ {
// page = 0 // page = 0
// p[0].b[0].attr = abc // p[0].b[0].attr = abc
@ -37,32 +37,32 @@ void slave_send_state(const __FlashStringHelper * subtopic, const char * payload
char cBuffer[strlen(payload) + 64]; char cBuffer[strlen(payload) + 64];
memset(cBuffer, 0, sizeof(cBuffer)); memset(cBuffer, 0, sizeof(cBuffer));
snprintf_P(cBuffer, sizeof(cBuffer), PSTR("publish %sstate/%s %s"), slaveNodeTopic, subtopic, payload); snprintf_P(cBuffer, sizeof(cBuffer), PSTR("publish %sstate/%s %s"), slaveNodeTopic, subtopic, payload);
slave.ExecuteCommand((char *)cBuffer); slave.ExecuteCommand((char*)cBuffer);
// Log after char buffers are cleared // Log after char buffers are cleared
LOG_TRACE(TAG_TASM, F("TAS PUB: %sstate/%S = %s"), slaveNodeTopic, subtopic, payload); LOG_TRACE(TAG_TASM, F("TAS PUB: %sstate/%S = %s"), slaveNodeTopic, subtopic, payload);
} }
void slave_send_obj_attribute_str(uint8_t pageid, uint8_t btnid, const char * attribute, const char * data) void slave_send_obj_attribute_str(uint8_t pageid, uint8_t btnid, const char* attribute, const char* data)
{ {
char cBuffer[192]; char cBuffer[192];
memset(cBuffer, 0, sizeof(cBuffer)); memset(cBuffer, 0, sizeof(cBuffer));
snprintf_P(cBuffer, sizeof(cBuffer), PSTR("publish %sstate/json {\"p[%u].b[%u].%s\":\"%s\"}"), slaveNodeTopic, snprintf_P(cBuffer, sizeof(cBuffer), PSTR("publish %sstate/json {\"p[%u].b[%u].%s\":\"%s\"}"), slaveNodeTopic,
pageid, btnid, attribute, data); pageid, btnid, attribute, data);
slave.ExecuteCommand((char *)cBuffer); slave.ExecuteCommand((char*)cBuffer);
// Log after char buffers are cleared // Log after char buffers are cleared
LOG_TRACE(TAG_TASM, F("TAS PUB: %sstate/json = {\"p[%u].b[%u].%s\":\"%s\"}"), slaveNodeTopic, pageid, btnid, LOG_TRACE(TAG_TASM, F("TAS PUB: %sstate/json = {\"p[%u].b[%u].%s\":\"%s\"}"), slaveNodeTopic, pageid, btnid,
attribute, data); attribute, data);
} }
void slave_send_input(uint8_t id, const char * payload) void slave_send_input(uint8_t id, const char* payload)
{ {
// LOG_VERBOSE(TAG_TASM,F("MQTT TST: %sstate/input%u = %s"), mqttNodeTopic, id, payload); // to be removed // LOG_VERBOSE(TAG_TASM,F("MQTT TST: %sstate/input%u = %s"), mqttNodeTopic, id, payload); // to be removed
char cBuffer[strlen(payload) + 64]; char cBuffer[strlen(payload) + 64];
memset(cBuffer, 0, sizeof(cBuffer)); memset(cBuffer, 0, sizeof(cBuffer));
snprintf_P(cBuffer, sizeof(cBuffer), PSTR("publish %sstate/input%u %s"), slaveNodeTopic, id, payload); snprintf_P(cBuffer, sizeof(cBuffer), PSTR("publish %sstate/input%u %s"), slaveNodeTopic, id, payload);
slave.ExecuteCommand((char *)cBuffer); slave.ExecuteCommand((char*)cBuffer);
// Log after char buffers are cleared // Log after char buffers are cleared
LOG_TRACE(TAG_TASM, F("TAS PUB: %sstate/input%u = %s"), slaveNodeTopic, id, payload); LOG_TRACE(TAG_TASM, F("TAS PUB: %sstate/input%u = %s"), slaveNodeTopic, id, payload);
@ -85,12 +85,12 @@ void TASMO_TELE_JSON()
halDisplayDriverName().c_str(), (TFT_WIDTH), (TFT_HEIGHT)); halDisplayDriverName().c_str(), (TFT_WIDTH), (TFT_HEIGHT));
strcat(data, buffer); strcat(data, buffer);
} }
slave.sendJSON((char *)data); slave.sendJSON((char*)data);
// slave_send_state(F("statusupdate"), data); // slave_send_state(F("statusupdate"), data);
// debugLastMillis = millis(); // debugLastMillis = millis();
} }
void TASMO_DATA_RECEIVE(char * data) void TASMO_DATA_RECEIVE(char* data)
{ {
LOG_INFO(TAG_TASM, F("Slave IN [%s]"), data); LOG_INFO(TAG_TASM, F("Slave IN [%s]"), data);

View File

@ -1,4 +1,4 @@
/* MIT License - Copyright (c) 2020 Francis Van Roie /* MIT License - Copyright (c) 2019-2021 Francis Van Roie
For full license information read the LICENSE file in the project folder */ For full license information read the LICENSE file in the project folder */
#ifndef HASP_TASMOTACLIENT_H #ifndef HASP_TASMOTACLIENT_H
@ -9,10 +9,10 @@
#define HASP_TASMOTACLIENT_SPEED 57600 #define HASP_TASMOTACLIENT_SPEED 57600
void TASMO_EVERY_SECOND(void); void TASMO_EVERY_SECOND(void);
void TASMO_DATA_RECEIVE(char * data); void TASMO_DATA_RECEIVE(char* data);
void slave_send_state(const __FlashStringHelper * subtopic, const char * payload); void slave_send_state(const __FlashStringHelper* subtopic, const char* payload);
void slave_send_obj_attribute_str(uint8_t pageid, uint8_t btnid, const char * attribute, const char * data); void slave_send_obj_attribute_str(uint8_t pageid, uint8_t btnid, const char* attribute, const char* data);
void slave_send_input(uint8_t id, const char * payload); void slave_send_input(uint8_t id, const char* payload);
void slave_send_statusupdate(); void slave_send_statusupdate();
void slaveSetup(); void slaveSetup();

View File

@ -1,4 +1,4 @@
/* MIT License - Copyright (c) 2020 Francis Van Roie /* MIT License - Copyright (c) 2019-2021 Francis Van Roie
For full license information read the LICENSE file in the project folder */ For full license information read the LICENSE file in the project folder */
#include "hasp_conf.h" #include "hasp_conf.h"

View File

@ -1,4 +1,4 @@
/* MIT License - Copyright (c) 2020 Francis Van Roie /* MIT License - Copyright (c) 2019-2021 Francis Van Roie
For full license information read the LICENSE file in the project folder */ For full license information read the LICENSE file in the project folder */
#ifndef HASP_TELNET_H #ifndef HASP_TELNET_H
@ -23,8 +23,8 @@ void telnetStop(void);
/* ===== Read/Write Configuration ===== */ /* ===== Read/Write Configuration ===== */
#if HASP_USE_CONFIG > 0 #if HASP_USE_CONFIG > 0
bool telnetSetConfig(const JsonObject & settings); bool telnetSetConfig(const JsonObject& settings);
bool telnetGetConfig(const JsonObject & settings); bool telnetGetConfig(const JsonObject& settings);
#endif #endif
#define TELNET_UNAUTHENTICATED 0 #define TELNET_UNAUTHENTICATED 0