Merge pull request #15 from ytrikoz/platformio

12
This commit is contained in:
Dmitry Borisenko
2020-06-24 01:51:50 +02:00
committed by GitHub
5 changed files with 14 additions and 9 deletions

View File

@@ -255,6 +255,7 @@ extern void do_mqtt_send_settings_to_udp();
extern void Web_server_init();
// iot_firmware
extern void loopSerial();
extern void loopCmd();
extern void loopButton();
extern void loopScenario();

View File

@@ -114,7 +114,7 @@ enum State { ST_INACTIVE,
class Terminal : public Print {
public:
Terminal(Stream *stream = nullptr);
~Terminal();
void setStream(Stream *stream);
void setEOL(EOLType_t code);
void enableControlCodes(bool enabled = true);
@@ -153,7 +153,7 @@ class Terminal : public Print {
uint8_t curX = 0xff;
unsigned long _lastReceived = 0;
State state = ST_INACTIVE;
State state;
Stream *_stream;
EditLine _line;
char _cc_buf[32] = {0};

View File

@@ -250,6 +250,12 @@ void switch_() {
but[switch_number.toInt()] = true;
}
void loopSerial() {
if (term) {
term->loop();
}
}
void loopButton() {
static uint8_t switch_number = 1;
@@ -523,10 +529,6 @@ void serialBegin() {
delete mySerial;
}
if (term) {
delete term;
}
mySerial = new SoftwareSerial(rxPin.toInt(), txPin.toInt());
mySerial->begin(s_speed.toInt());
@@ -538,6 +540,7 @@ void serialBegin() {
term->setOnReadLine([](const char *str) {
String line = String(str);
pm.info("serial read: " + line);
line.replace("#", " ");
order_loop += line + ",";
});
}

View File

@@ -10,14 +10,12 @@ Terminal::Terminal(Stream *stream) : _stream{stream},
_color(false),
_controlCodes(false),
_echo(false),
_eol(CRLF){};
_eol(CRLF) { state = ST_NORMAL; };
void Terminal::setStream(Stream *stream) {
_stream = stream;
}
Terminal::~Terminal() {}
void Terminal::setOnReadLine(TerminalInputEventHandler h) { inputHandler_ = h; }
void Terminal::setOnEvent(TerminalEventHandler h) { eventHandler_ = h; }

View File

@@ -93,6 +93,9 @@ void loop() {
#ifdef UDP_ENABLED
loopUdp();
#endif
loopSerial();
ts.update();
}