inputs: serial: basic serial command inputs
This commit is contained in:
parent
85b42469f9
commit
2c7501f0c2
34
src/inputs/Serial.cpp
Normal file
34
src/inputs/Serial.cpp
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
#include "Serial.h"
|
||||||
|
|
||||||
|
InputEvent
|
||||||
|
Serial::read()
|
||||||
|
{
|
||||||
|
while (Serial.available() > 0) {
|
||||||
|
char nextChar = Serial.read();
|
||||||
|
if (nextChar == '\n') {
|
||||||
|
doCommand();
|
||||||
|
m_buf = "";
|
||||||
|
} else {
|
||||||
|
m_buf += nextChar;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Serial::doCommand() {
|
||||||
|
if (command == "tasks") {
|
||||||
|
Serial.println("Tasks:");
|
||||||
|
auto sched = MainLoop::instance()->scheduler;
|
||||||
|
for(auto task : sched.tasks) {
|
||||||
|
bool isFigment = task->isFigment();
|
||||||
|
if (isFigment) {
|
||||||
|
Serial.println("F " + task->name);
|
||||||
|
} else {
|
||||||
|
Serial.println("T " + task->name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
STATIC_ALLOC(SerialInput);
|
||||||
|
STATIC_TASK(SerialInput);
|
@ -1,12 +1,17 @@
|
|||||||
|
#pragma once
|
||||||
#include "Particle.h"
|
#include "Particle.h"
|
||||||
#include "../Figments/Figments.h"
|
#include "../Figments/Figments.h"
|
||||||
|
|
||||||
class SerialInput: public InputSource {
|
class SerialInput: public InputSource {
|
||||||
public:
|
public:
|
||||||
void onAttach() override {
|
void onStart() override {
|
||||||
//Serial.begin();
|
//Serial.begin();
|
||||||
}
|
}
|
||||||
|
|
||||||
InputEvent read() {
|
InputEvent read();
|
||||||
}
|
|
||||||
|
private:
|
||||||
|
String m_buf;
|
||||||
|
void doCommand();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user