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>
#if HASP_USE_SPIFFS > 0
#if defined(ARDUINO_ARCH_ESP32)
#include "SPIFFS.h"
#endif
#include <FS.h> // Include the SPIFFS library
// #if defined(ARDUINO_ARCH_ESP32)
// #include "SPIFFS.h"
// #endif
// #include <FS.h> // Include the SPIFFS library
#include "hasp_filesystem.h"
#endif
#if HASP_USE_LITTLEFS > 0
#if defined(ARDUINO_ARCH_ESP32)
#include "LITTLEFS.h"
#elif defined(ARDUINO_ARCH_ESP8266)
#include <FS.h> // Include the FS library
#endif
// #if defined(ARDUINO_ARCH_ESP32)
// #include "LITTLEFS.h"
// #elif defined(ARDUINO_ARCH_ESP8266)
// #include <FS.h> // Include the FS library
// #include <LittleFS.h>
// #endif
#include "hasp_filesystem.h"
#endif

View File

@ -377,10 +377,10 @@ typedef void* lv_font_user_data_t;
/*Always set a default font from the built-in fonts*/
#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(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_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
#else

View File

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

View File

@ -503,7 +503,7 @@ void hasp_background(uint16_t pageid, uint16_t imageid)
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)

View File

@ -120,7 +120,7 @@ void debugPrintHaspHeader(Print * output)
" Home Automation Switch Plate\r\n"
" Open Hardware edition v"));
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();
}
@ -648,7 +648,7 @@ void debugPreSetup(JsonObject settings)
Serial.flush();
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();
#if defined(ARDUINO_ARCH_ESP32)
#if HASP_USE_SPIFFS > 0
#include "SPIFFS.h"
#elif HASP_USE_LITTLEFS > 0
#include "LITTLEFS.h"
#endif
#if HASP_USE_SPIFFS > 0
#include "SPIFFS.h"
#define HASP_FS SPIFFS
#elif HASP_USE_LITTLEFS > 0
#include "LITTLEFS.h"
#define HASP_FS LITTLEFS
#endif
#elif defined(ARDUINO_ARCH_ESP8266)
// included by default
// included by default
#include <LittleFS.h>
#define HASP_FS LittleFS
#endif // ARDUINO_ARCH
#if defined(ARDUINO_ARCH_ESP8266) || defined(ARDUINO_ARCH_ESP32)
#include <FS.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
#include <FS.h>
#include <Esp.h>
#endif // ARDUINO_ARCH
#endif // HASP_FILESYSTEM_H

View File

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

View File

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