Allow different Serial-port to be used on ESP32
This commit is contained in:
parent
77997c3a63
commit
9137e7dd3d
3 changed files with 12 additions and 8 deletions
|
@ -10,8 +10,9 @@
|
||||||
|
|
||||||
#define NEOPIXELS_PIN 25
|
#define NEOPIXELS_PIN 25
|
||||||
|
|
||||||
console_esp32::console_esp32(std::atomic_uint32_t *const stop_event, bus *const b) :
|
console_esp32::console_esp32(std::atomic_uint32_t *const stop_event, bus *const b, Stream & io_port) :
|
||||||
console(stop_event, b)
|
console(stop_event, b),
|
||||||
|
io_port(io_port)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,8 +24,8 @@ console_esp32::~console_esp32()
|
||||||
int console_esp32::wait_for_char_ll(const short timeout)
|
int console_esp32::wait_for_char_ll(const short timeout)
|
||||||
{
|
{
|
||||||
for(short i=0; i<timeout / 10; i++) {
|
for(short i=0; i<timeout / 10; i++) {
|
||||||
if (Serial.available())
|
if (io_port.available())
|
||||||
return Serial.read();
|
return io_port.read();
|
||||||
|
|
||||||
delay(10);
|
delay(10);
|
||||||
}
|
}
|
||||||
|
@ -34,7 +35,7 @@ int console_esp32::wait_for_char_ll(const short timeout)
|
||||||
|
|
||||||
void console_esp32::put_char_ll(const char c)
|
void console_esp32::put_char_ll(const char c)
|
||||||
{
|
{
|
||||||
Serial.print(c);
|
io_port.print(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
void console_esp32::put_string_lf(const std::string & what)
|
void console_esp32::put_string_lf(const std::string & what)
|
||||||
|
@ -54,7 +55,7 @@ void console_esp32::refresh_virtual_terminal()
|
||||||
|
|
||||||
void console_esp32::panel_update_thread()
|
void console_esp32::panel_update_thread()
|
||||||
{
|
{
|
||||||
Serial.println(F("panel task started"));
|
io_port.println(F("panel task started"));
|
||||||
|
|
||||||
cpu *const c = b->getCpu();
|
cpu *const c = b->getCpu();
|
||||||
|
|
||||||
|
|
|
@ -5,13 +5,16 @@
|
||||||
|
|
||||||
class console_esp32 : public console
|
class console_esp32 : public console
|
||||||
{
|
{
|
||||||
|
private:
|
||||||
|
Stream & io_port;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
int wait_for_char_ll(const short timeout) override;
|
int wait_for_char_ll(const short timeout) override;
|
||||||
|
|
||||||
void put_char_ll(const char c) override;
|
void put_char_ll(const char c) override;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
console_esp32(std::atomic_uint32_t *const stop_event, bus *const b);
|
console_esp32(std::atomic_uint32_t *const stop_event, bus *const b, Stream & io_port);
|
||||||
virtual ~console_esp32();
|
virtual ~console_esp32();
|
||||||
|
|
||||||
void put_string_lf(const std::string & what) override;
|
void put_string_lf(const std::string & what) override;
|
||||||
|
|
|
@ -317,7 +317,7 @@ void setup() {
|
||||||
b->add_cpu(c);
|
b->add_cpu(c);
|
||||||
|
|
||||||
Serial.println(F("Init console"));
|
Serial.println(F("Init console"));
|
||||||
cnsl = new console_esp32(&stop_event, b);
|
cnsl = new console_esp32(&stop_event, b, Serial);
|
||||||
|
|
||||||
Serial.println(F("Start line-frequency interrupt"));
|
Serial.println(F("Start line-frequency interrupt"));
|
||||||
kw11_l *lf = new kw11_l(b, cnsl);
|
kw11_l *lf = new kw11_l(b, cnsl);
|
||||||
|
|
Loading…
Add table
Reference in a new issue