debuginput task in taskmanager
This commit is contained in:
@ -49,6 +49,7 @@ set(headers
|
||||
cloudtexthelpers.h
|
||||
controller.h
|
||||
debugcolorhelpers.h
|
||||
debuginputhandler.h
|
||||
debugtexthelpers.h
|
||||
displays/bmsdisplay.h
|
||||
displays/calibratedisplay.h
|
||||
@ -186,7 +187,6 @@ set(headers
|
||||
rotary.h
|
||||
screens.h
|
||||
serial.h
|
||||
serialhandler.h
|
||||
settings.h
|
||||
settingspersister.h
|
||||
settingsutils.h
|
||||
@ -264,6 +264,7 @@ set(sources
|
||||
cloudtexthelpers.cpp
|
||||
controller.cpp
|
||||
debugcolorhelpers.cpp
|
||||
debuginputhandler.cpp
|
||||
debugtexthelpers.cpp
|
||||
displays/bmsdisplay.cpp
|
||||
displays/calibratedisplay.cpp
|
||||
@ -402,7 +403,6 @@ set(sources
|
||||
rotary.cpp
|
||||
screens.cpp
|
||||
serial.cpp
|
||||
serialhandler.cpp
|
||||
settings.cpp
|
||||
settingspersister.cpp
|
||||
settingsutils.cpp
|
||||
|
127
main/debuginputhandler.cpp
Normal file
127
main/debuginputhandler.cpp
Normal file
@ -0,0 +1,127 @@
|
||||
#include "debuginputhandler.h"
|
||||
|
||||
// Arduino includes
|
||||
#include <HardwareSerial.h>
|
||||
|
||||
// 3rdparty lib includes
|
||||
#include <tftinstance.h>
|
||||
|
||||
// local includes
|
||||
#include "globals.h"
|
||||
#include "utils.h"
|
||||
#include "screens.h"
|
||||
#include "buttons.h"
|
||||
|
||||
using namespace espgui;
|
||||
|
||||
//wl_status_t last_status;
|
||||
//IPAddress last_ip;
|
||||
|
||||
void initDebugInput()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
//Serial.setDebugOutput(true);
|
||||
}
|
||||
|
||||
void handleDebugInput()
|
||||
{
|
||||
//const auto status = WiFi.status();
|
||||
//if (last_status != status)
|
||||
//{
|
||||
//Serial.print("Status changed to: ");
|
||||
//Serial.println(to_string(status).c_str());
|
||||
//last_status = status;
|
||||
//}
|
||||
|
||||
//const auto ip = WiFi.localIP();
|
||||
//if (last_ip != ip)
|
||||
//{
|
||||
//Serial.print("IP changed to: ");
|
||||
//Serial.println(to_string(ip).c_str());
|
||||
//last_ip = ip;
|
||||
//}
|
||||
|
||||
while(Serial.available())
|
||||
{
|
||||
const auto c = Serial.read();
|
||||
|
||||
switch (c)
|
||||
{
|
||||
case 'i':
|
||||
case 'I':
|
||||
tft.init();
|
||||
break;
|
||||
case 'p':
|
||||
case 'P':
|
||||
{
|
||||
const auto firstPower = controllers.front.command.poweroff;
|
||||
for (Controller &controller : controllers)
|
||||
controller.command.poweroff = !firstPower;
|
||||
break;
|
||||
}
|
||||
case 'l':
|
||||
case 'L':
|
||||
{
|
||||
const auto firstLed = controllers.front.command.led;
|
||||
for (Controller &controller : controllers)
|
||||
controller.command.led = !firstLed;
|
||||
break;
|
||||
}
|
||||
case 'r':
|
||||
case 'R':
|
||||
loadSettings();
|
||||
break;
|
||||
case 's':
|
||||
case 'S':
|
||||
saveSettings();
|
||||
break;
|
||||
case '0':
|
||||
case '1':
|
||||
case '2':
|
||||
case '3':
|
||||
case '4':
|
||||
case '5':
|
||||
case '6':
|
||||
case '7':
|
||||
case '8':
|
||||
case '9':
|
||||
for (Controller &controller : controllers)
|
||||
controller.command.buzzer.freq = c-'0';
|
||||
break;
|
||||
case 'A':
|
||||
InputDispatcher::rotate(-1);
|
||||
break;
|
||||
case 'B':
|
||||
InputDispatcher::rotate(1);
|
||||
break;
|
||||
case 'C':
|
||||
InputDispatcher::confirmButton(true);
|
||||
InputDispatcher::confirmButton(false);
|
||||
break;
|
||||
case 'D':
|
||||
InputDispatcher::backButton(true);
|
||||
InputDispatcher::backButton(false);
|
||||
break;
|
||||
case 'z':
|
||||
case 'Z':
|
||||
#ifndef LEDSTRIP_WRONG_DIRECTION
|
||||
InputDispatcher::blinkLeftButton(true);
|
||||
InputDispatcher::blinkLeftButton(false);
|
||||
#else
|
||||
InputDispatcher::blinkRightButton(true);
|
||||
InputDispatcher::blinkRightButton(false);
|
||||
#endif
|
||||
break;
|
||||
case 'u':
|
||||
case 'U':
|
||||
#ifndef LEDSTRIP_WRONG_DIRECTION
|
||||
InputDispatcher::blinkRightButton(true);
|
||||
InputDispatcher::blinkRightButton(false);
|
||||
#else
|
||||
InputDispatcher::blinkLeftButton(true);
|
||||
InputDispatcher::blinkLeftButton(false);
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
@ -3,4 +3,5 @@
|
||||
//extern wl_status_t last_status;
|
||||
//extern IPAddress last_ip;
|
||||
|
||||
void handleSerial();
|
||||
void initDebugInput();
|
||||
void handleDebugInput();
|
@ -25,7 +25,6 @@ using namespace std::chrono_literals;
|
||||
#include "macros_bobbycar.h"
|
||||
#include "globals.h"
|
||||
#include "screens.h"
|
||||
#include "serialhandler.h"
|
||||
#ifdef FEATURE_OTA
|
||||
#include "ota.h"
|
||||
#include "displays/menus/selectbuildservermenu.h"
|
||||
@ -79,10 +78,6 @@ std::optional<espchrono::millis_clock::time_point> lastLedstripUpdate;
|
||||
|
||||
extern "C" void app_main()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
//Serial.setDebugOutput(true);
|
||||
//Serial.println("setup()");
|
||||
|
||||
#ifdef FEATURE_LEDBACKLIGHT
|
||||
pinMode(PINS_LEDBACKLIGHT, OUTPUT);
|
||||
digitalWrite(PINS_LEDBACKLIGHT, ledBacklightInverted ? LOW : HIGH);
|
||||
@ -260,8 +255,6 @@ extern "C" void app_main()
|
||||
controller.parser.update();
|
||||
#endif
|
||||
|
||||
handleSerial();
|
||||
|
||||
#ifdef FEATURE_OTA
|
||||
handleOta();
|
||||
#endif
|
||||
|
@ -44,6 +44,7 @@
|
||||
#ifdef FEATURE_CAN
|
||||
#include "can.h"
|
||||
#endif
|
||||
#include "debuginputhandler.h"
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
@ -85,6 +86,7 @@ espcpputils::SchedulerTask schedulerTasksArr[] {
|
||||
#ifdef FEATURE_CAN
|
||||
espcpputils::SchedulerTask { "can", can::initCan, can::parseCanInput, 50ms },
|
||||
#endif
|
||||
espcpputils::SchedulerTask { "debuginput", initDebugInput, handleDebugInput, 50ms },
|
||||
};
|
||||
} // namespace
|
||||
|
||||
|
Reference in New Issue
Block a user