mirror of
https://github.com/HASwitchPlate/openHASP.git
synced 2025-07-27 13:16:45 +00:00
Move serial input from gui to debug
This commit is contained in:
parent
9ff231532c
commit
b24d8b077a
@ -48,7 +48,7 @@
|
|||||||
#include "hasp_spiffs.h"
|
#include "hasp_spiffs.h"
|
||||||
|
|
||||||
#if defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_ARCH_ESP8266)
|
#if defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_ARCH_ESP8266)
|
||||||
#include "lv_zifont.h"
|
//#include "lv_zifont.h"
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -71,6 +71,8 @@ Syslog * syslog;
|
|||||||
#endif // USE_SYSLOG
|
#endif // USE_SYSLOG
|
||||||
|
|
||||||
// Serial Settings
|
// Serial Settings
|
||||||
|
uint8_t serialInputIndex = 0; // Empty buffer
|
||||||
|
char serialInputBuffer[1024];
|
||||||
uint16_t debugSerialBaud = SERIAL_SPEED / 10; // Multiplied by 10
|
uint16_t debugSerialBaud = SERIAL_SPEED / 10; // Multiplied by 10
|
||||||
bool debugSerialStarted = false;
|
bool debugSerialStarted = false;
|
||||||
bool debugAnsiCodes = true;
|
bool debugAnsiCodes = true;
|
||||||
@ -96,10 +98,10 @@ String debugHaspHeader()
|
|||||||
header.reserve(256);
|
header.reserve(256);
|
||||||
if(debugAnsiCodes) header += TERM_COLOR_YELLOW;
|
if(debugAnsiCodes) header += TERM_COLOR_YELLOW;
|
||||||
header += F(" _____ _____ _____ _____\r\n"
|
header += F(" _____ _____ _____ _____\r\n"
|
||||||
" | | | _ | __| _ |\r\n"
|
" | | | _ | __| _ |\r\n"
|
||||||
" | | |__ | __|\r\n"
|
" | | |__ | __|\r\n"
|
||||||
" |__|__|__|__|_____|__|\r\n"
|
" |__|__|__|__|_____|__|\r\n"
|
||||||
" Home Automation Switch Plate\r\n");
|
" Home Automation Switch Plate\r\n");
|
||||||
char buffer[128];
|
char buffer[128];
|
||||||
snprintf(buffer, sizeof(buffer), PSTR(" Open Hardware edition v%u.%u.%u\r\n"), HASP_VERSION_MAJOR,
|
snprintf(buffer, sizeof(buffer), PSTR(" Open Hardware edition v%u.%u.%u\r\n"), HASP_VERSION_MAJOR,
|
||||||
HASP_VERSION_MINOR, HASP_VERSION_REVISION);
|
HASP_VERSION_MINOR, HASP_VERSION_REVISION);
|
||||||
@ -232,8 +234,8 @@ static void debugPrintTimestamp(int level, Print * _logOutput)
|
|||||||
_logOutput->printf(PSTR("%03lu]"), millis() % 1000);
|
_logOutput->printf(PSTR("%03lu]"), millis() % 1000);
|
||||||
} else */
|
} else */
|
||||||
{
|
{
|
||||||
uint32_t msecs = millis();
|
uint32_t msecs = millis();
|
||||||
_logOutput->printf(PSTR("[%16d.%03d]"), msecs/1000, msecs%1000 );
|
_logOutput->printf(PSTR("[%16d.%03d]"), msecs / 1000, msecs % 1000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -334,10 +336,10 @@ void debugPreSetup(JsonObject settings)
|
|||||||
if(baudrate >= 9600u) { /* the baudrates are stored divided by 10 */
|
if(baudrate >= 9600u) { /* the baudrates are stored divided by 10 */
|
||||||
|
|
||||||
#if defined(STM32F4xx)
|
#if defined(STM32F4xx)
|
||||||
#ifndef STM32_SERIAL1 // Define what Serial port to use for log output
|
#ifndef STM32_SERIAL1 // Define what Serial port to use for log output
|
||||||
Serial.setRx(PA3); // User Serial2
|
Serial.setRx(PA3); // User Serial2
|
||||||
Serial.setTx(PA2);
|
Serial.setTx(PA2);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
Serial.begin(baudrate); /* prepare for possible serial debug */
|
Serial.begin(baudrate); /* prepare for possible serial debug */
|
||||||
delay(10);
|
delay(10);
|
||||||
@ -378,7 +380,26 @@ void debugLvgl(lv_log_level_t level, const char * file, uint32_t line, const cha
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
void debugLoop()
|
void debugLoop()
|
||||||
{}
|
{
|
||||||
|
while(Serial.available()) {
|
||||||
|
char ch = Serial.read();
|
||||||
|
Serial.print(ch);
|
||||||
|
if(ch == 13 || ch == 10) {
|
||||||
|
serialInputBuffer[serialInputIndex] = 0;
|
||||||
|
if(serialInputIndex > 0) dispatchCommand(serialInputBuffer);
|
||||||
|
serialInputIndex = 0;
|
||||||
|
} else {
|
||||||
|
if(serialInputIndex < sizeof(serialInputBuffer) - 1) {
|
||||||
|
serialInputBuffer[serialInputIndex++] = ch;
|
||||||
|
}
|
||||||
|
serialInputBuffer[serialInputIndex] = 0;
|
||||||
|
if(strcmp(serialInputBuffer, "jsonl=") == 0) {
|
||||||
|
dispatchJsonl(Serial);
|
||||||
|
serialInputIndex = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*void printLocalTime()
|
/*void printLocalTime()
|
||||||
{
|
{
|
||||||
|
@ -76,9 +76,6 @@ static uint8_t guiRotation = TFT_ROTATION;
|
|||||||
static Ticker tick; /* timer for interrupt handler */
|
static Ticker tick; /* timer for interrupt handler */
|
||||||
#else
|
#else
|
||||||
static Ticker tick(lv_tick_handler,guiTickPeriod);
|
static Ticker tick(lv_tick_handler,guiTickPeriod);
|
||||||
uint8_t serialInputIndex = 0; // Empty buffer
|
|
||||||
char serialInputBuffer[1024];
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
static TFT_eSPI tft; // = TFT_eSPI(); /* TFT instance */
|
static TFT_eSPI tft; // = TFT_eSPI(); /* TFT instance */
|
||||||
static uint16_t calData[5] = {0, 65535, 0, 65535, 0};
|
static uint16_t calData[5] = {0, 65535, 0, 65535, 0};
|
||||||
@ -817,26 +814,8 @@ void IRAM_ATTR guiLoop()
|
|||||||
{
|
{
|
||||||
#if defined(STM32F4xx)
|
#if defined(STM32F4xx)
|
||||||
tick.update();
|
tick.update();
|
||||||
|
|
||||||
while(Serial.available()) {
|
|
||||||
char ch = Serial.read();
|
|
||||||
Serial.print(ch);
|
|
||||||
if (ch == 13 ||ch == 10) {
|
|
||||||
serialInputBuffer[serialInputIndex] = 0;
|
|
||||||
if (serialInputIndex>0) dispatchCommand(serialInputBuffer);
|
|
||||||
serialInputIndex=0;
|
|
||||||
}else{
|
|
||||||
if(serialInputIndex < sizeof(serialInputBuffer) - 1) {
|
|
||||||
serialInputBuffer[serialInputIndex++] = ch;
|
|
||||||
}
|
|
||||||
serialInputBuffer[serialInputIndex] = 0;
|
|
||||||
if (strcmp(serialInputBuffer,"jsonl=")==0){
|
|
||||||
dispatchJsonl(Serial);
|
|
||||||
serialInputIndex=0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//lv_tick_handler();
|
//lv_tick_handler();
|
||||||
lv_task_handler(); /* let the GUI do its work */
|
lv_task_handler(); /* let the GUI do its work */
|
||||||
guiCheckSleep();
|
guiCheckSleep();
|
||||||
|
@ -109,6 +109,7 @@ void loop()
|
|||||||
guiLoop();
|
guiLoop();
|
||||||
/* Application Loops */
|
/* Application Loops */
|
||||||
// haspLoop();
|
// haspLoop();
|
||||||
|
debugLoop();
|
||||||
|
|
||||||
#if HASP_USE_GPIO
|
#if HASP_USE_GPIO
|
||||||
gpioLoop();
|
gpioLoop();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user