Move serial input from gui to debug

This commit is contained in:
fvanroie 2020-05-04 00:42:01 +02:00
parent 9ff231532c
commit b24d8b077a
4 changed files with 34 additions and 33 deletions

View File

@ -48,7 +48,7 @@
#include "hasp_spiffs.h"
#if defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_ARCH_ESP8266)
#include "lv_zifont.h"
//#include "lv_zifont.h"
#endif
#endif

View File

@ -71,6 +71,8 @@ Syslog * syslog;
#endif // USE_SYSLOG
// Serial Settings
uint8_t serialInputIndex = 0; // Empty buffer
char serialInputBuffer[1024];
uint16_t debugSerialBaud = SERIAL_SPEED / 10; // Multiplied by 10
bool debugSerialStarted = false;
bool debugAnsiCodes = true;
@ -378,7 +380,26 @@ void debugLvgl(lv_log_level_t level, const char * file, uint32_t line, const cha
#endif
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()
{

View File

@ -76,9 +76,6 @@ static uint8_t guiRotation = TFT_ROTATION;
static Ticker tick; /* timer for interrupt handler */
#else
static Ticker tick(lv_tick_handler,guiTickPeriod);
uint8_t serialInputIndex = 0; // Empty buffer
char serialInputBuffer[1024];
#endif
static TFT_eSPI tft; // = TFT_eSPI(); /* TFT instance */
static uint16_t calData[5] = {0, 65535, 0, 65535, 0};
@ -817,26 +814,8 @@ void IRAM_ATTR guiLoop()
{
#if defined(STM32F4xx)
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
//lv_tick_handler();
lv_task_handler(); /* let the GUI do its work */
guiCheckSleep();

View File

@ -109,6 +109,7 @@ void loop()
guiLoop();
/* Application Loops */
// haspLoop();
debugLoop();
#if HASP_USE_GPIO
gpioLoop();