Code cleanup

This commit is contained in:
fvanroie 2021-01-20 17:55:14 +01:00
parent bb6e5c5938
commit ee01ad0c0d
8 changed files with 47 additions and 49 deletions

View File

@ -101,19 +101,20 @@
#include <Arduino.h> #include <Arduino.h>
#if HASP_USE_SPIFFS > 0 #if HASP_USE_SPIFFS > 0
#if defined(ARDUINO_ARCH_ESP32) // #if defined(ARDUINO_ARCH_ESP32)
#include "SPIFFS.h" // #include "SPIFFS.h"
#endif // #endif
#include <FS.h> // Include the SPIFFS library // #include <FS.h> // Include the SPIFFS library
#include "hasp_filesystem.h" #include "hasp_filesystem.h"
#endif #endif
#if HASP_USE_LITTLEFS > 0 #if HASP_USE_LITTLEFS > 0
#if defined(ARDUINO_ARCH_ESP32) // #if defined(ARDUINO_ARCH_ESP32)
#include "LITTLEFS.h" // #include "LITTLEFS.h"
#elif defined(ARDUINO_ARCH_ESP8266) // #elif defined(ARDUINO_ARCH_ESP8266)
#include <FS.h> // Include the FS library // #include <FS.h> // Include the FS library
#endif // #include <LittleFS.h>
// #endif
#include "hasp_filesystem.h" #include "hasp_filesystem.h"
#endif #endif

View File

@ -377,10 +377,10 @@ typedef void* lv_font_user_data_t;
/*Always set a default font from the built-in fonts*/ /*Always set a default font from the built-in fonts*/
#if LV_HIGH_RESOURCE_MCU>0 #if LV_HIGH_RESOURCE_MCU>0
// #define LV_FONT_CUSTOM_DECLARE LV_FONT_DECLARE(lv_font_montserrat_16); // #define LV_FONT_CUSTOM_DECLARE LV_FONT_DECLARE(lv_font_montserrat_16);
#define LV_FONT_CUSTOM_DECLARE LV_FONT_DECLARE(robotocondensed_regular_28_nokern) \ #define LV_FONT_CUSTOM_DECLARE LV_FONT_DECLARE(robotocondensed_regular_12_nokern) \
LV_FONT_DECLARE(robotocondensed_regular_22_nokern) \ LV_FONT_DECLARE(robotocondensed_regular_22_nokern) \
LV_FONT_DECLARE(robotocondensed_regular_16_nokern) \ LV_FONT_DECLARE(robotocondensed_regular_16_nokern) \
LV_FONT_DECLARE(robotocondensed_regular_12_nokern) \ LV_FONT_DECLARE(robotocondensed_regular_28_nokern) \
#define LV_FONT_DEFAULT &robotocondensed_regular_16_nokern //&lv_font_montserrat_16 #define LV_FONT_DEFAULT &robotocondensed_regular_16_nokern //&lv_font_montserrat_16
#else #else

View File

@ -20,9 +20,7 @@ bool IRAM_ATTR FT5206_getXY(int16_t * touchX, int16_t * touchY, bool debug)
*touchY = tp.y; *touchY = tp.y;
if(debug) { if(debug) {
char tempString[128]; Log.verbose(TAG_DRVR, F("FT5206 touched x: %d y: %d\n"), tp.x, tp.y);
sprintf(tempString, F("FT5206 touched x: %d y: %d\n"), tp.x, tp.y); // TODO: literal string
Serial.print(tempString);
} }
return true; return true;

View File

@ -503,7 +503,7 @@ void hasp_background(uint16_t pageid, uint16_t imageid)
void haspGetVersion(char * version, size_t len) void haspGetVersion(char * version, size_t len)
{ {
snprintf_P(version, len, "%u.%u.%u", HASP_VERSION_MAJOR, HASP_VERSION_MINOR, HASP_VERSION_REVISION); snprintf_P(version, len, PSTR("%u.%u.%u"), HASP_VER_MAJ, HASP_VER_MIN, HASP_VER_REV);
} }
void haspClearPage(uint16_t pageid) void haspClearPage(uint16_t pageid)

View File

@ -120,7 +120,7 @@ void debugPrintHaspHeader(Print * output)
" Home Automation Switch Plate\r\n" " Home Automation Switch Plate\r\n"
" Open Hardware edition v")); " Open Hardware edition v"));
char buffer[32]; char buffer[32];
snprintf_P(buffer, sizeof(buffer), PSTR("%u.%u.%u"), HASP_VERSION_MAJOR, HASP_VERSION_MINOR, HASP_VERSION_REVISION); haspGetVersion(buffer, sizeof(buffer));
output->println(buffer); output->println(buffer);
output->println(); output->println();
} }
@ -648,7 +648,7 @@ void debugPreSetup(JsonObject settings)
Serial.flush(); Serial.flush();
Log.trace(TAG_DEBG, F("Serial started at %u baud"), baudrate); Log.trace(TAG_DEBG, F("Serial started at %u baud"), baudrate);
Log.trace(TAG_DEBG, F("Environment: " PIOENV_STR)); Log.trace(TAG_DEBG, F("Environment: " PIOENV));
} }
} }

View File

@ -12,24 +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"
#elif HASP_USE_LITTLEFS > 0 #define HASP_FS SPIFFS
#include "LITTLEFS.h" #elif HASP_USE_LITTLEFS > 0
#endif #include "LITTLEFS.h"
#define HASP_FS LITTLEFS
#endif
#elif defined(ARDUINO_ARCH_ESP8266) #elif defined(ARDUINO_ARCH_ESP8266)
// included by default // included by default
#include <LittleFS.h>
#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>
#if HASP_USE_SPIFFS > 0
#define HASP_FS SPIFFS
#elif HASP_USE_LITTLEFS > 0
#define HASP_FS LITTLEFS
#endif // HASP_USE
#endif // ARDUINO_ARCH #endif // ARDUINO_ARCH
#endif // HASP_FILESYSTEM_H #endif // HASP_FILESYSTEM_H

View File

@ -49,7 +49,7 @@ File pFileOut;
#define INVERT_COLORS 0 #define INVERT_COLORS 0
#endif #endif
static void IRAM_ATTR lv_tick_handler(void); // static void IRAM_ATTR lv_tick_handler(void);
static bool guiShowPointer = false; static bool guiShowPointer = false;
static bool guiBacklightIsOn = true; static bool guiBacklightIsOn = true;

View File

@ -4,15 +4,16 @@
#include "hasp_conf.h" #include "hasp_conf.h"
#if HASP_USE_MDNS > 0 #if HASP_USE_MDNS > 0
#if defined(ARDUINO_ARCH_ESP32) #if defined(ARDUINO_ARCH_ESP32)
#include <ESPmDNS.h> #include <ESPmDNS.h>
#elif defined(ARDUINO_ARCH_ESP8266) #elif defined(ARDUINO_ARCH_ESP8266)
#include <ESP8266mDNS.h> #include <ESP8266mDNS.h>
// MDNSResponder::hMDNSService hMDNSService; // MDNSResponder::hMDNSService hMDNSService;
#endif #endif
#include "hasp_config.h" #include "hasp/hasp.h"
#include "hasp_debug.h" #include "hasp_config.h"
#include "hasp_debug.h"
uint8_t mdnsEnabled = true; uint8_t mdnsEnabled = true;
@ -31,17 +32,17 @@ void mdnsStart()
Log.notice(TAG_MDNS, F("Starting MDNS Responder...")); Log.notice(TAG_MDNS, F("Starting MDNS Responder..."));
#if HASP_USE_MQTT > 0 #if HASP_USE_MQTT > 0
String hasp2Node = mqttGetNodename(); String hasp2Node = mqttGetNodename();
#else #else
String hasp2Node = "unknown"; String hasp2Node = "unknown";
#endif #endif
// Setup mDNS service discovery if enabled // Setup mDNS service discovery if enabled
char buffer[32]; char buffer[32];
snprintf_P(buffer, sizeof(buffer), PSTR("%u.%u.%u"), HASP_VERSION_MAJOR, HASP_VERSION_MINOR, HASP_VERSION_REVISION); haspGetVersion(buffer, sizeof(buffer));
uint8_t attempt = 0;
uint8_t attempt = 0;
while(!MDNS.begin(hasp2Node.c_str())) { while(!MDNS.begin(hasp2Node.c_str())) {
if(attempt++ >= 3) { if(attempt++ >= 3) {
Log.error(TAG_MDNS, F("Responder failed to start %s"), hasp2Node.c_str()); Log.error(TAG_MDNS, F("Responder failed to start %s"), hasp2Node.c_str());
@ -68,19 +69,19 @@ void mdnsStart()
void IRAM_ATTR mdnsLoop(void) void IRAM_ATTR mdnsLoop(void)
{ {
#if defined(ARDUINO_ARCH_ESP8266) #if defined(ARDUINO_ARCH_ESP8266)
if(mdnsEnabled) { if(mdnsEnabled) {
MDNS.update(); MDNS.update();
} }
#endif #endif
} }
void mdnsStop() void mdnsStop()
{ {
return; return;
#if HASP_USE_MDNS > 0 #if HASP_USE_MDNS > 0
MDNS.end(); MDNS.end();
#endif #endif
} }
#if HASP_USE_CONFIG > 0 #if HASP_USE_CONFIG > 0