Yes having the Nextion working as host is definitely the way to go I fully agree ( it is the point c of proposed behavior, points a and b are more for proof of concept and not essential) , that also how it is implemented in marlinkalimbra (
https://www.youtube.com/user/MagoKimbra/videos https://github.com/MagoKimbra/MarlinKimbra)
But unlike paneldue, because of communication protocol of nextion, no "\n" but "0xff 0xff 0xff" and specific format for string, that may bring pollution on the event ON_CONSOLE_LINE_RECEIVED, and also need formatting for sending information back on Nextion, so my understanding it is necessary to add a filter/bridge, that would be the panel module role actually, as I need to teach smoothie to talk to nextion and not being disturbed by it. unlike the duepanel that can use raw commands like any host.
I already coded a filter based on parameter in config file, selecting which serial is the connection to nextion,
in kernel.cpp
switch( __mriPlatform_CommUartIndex() ) {
case 0:
this->serial = new(AHB0) SerialConsole(USBTX, USBRX, this->config->value(uart0_checksum,baud_rate_setting_checksum)->by_default(DEFAULT_SERIAL_BAUD_RATE)->as_number(), THEKERNEL->config->value( serial_checksum, filter_usb_checksum )->by_default("false")->as_bool());
break;
case 1:
this->serial = new(AHB0) SerialConsole( p13, p14, this->config->value(uart0_checksum,baud_rate_setting_checksum)->by_default(DEFAULT_SERIAL_BAUD_RATE)->as_number(), THEKERNEL->config->value( serial_checksum, filter_serial1_checksum )->by_default("false")->as_bool());
break;
case 2:
this->serial = new(AHB0) SerialConsole( p28, p27, this->config->value(uart0_checksum,baud_rate_setting_checksum)->by_default(DEFAULT_SERIAL_BAUD_RATE)->as_number(), THEKERNEL->config->value( serial_checksum, filter_serial2_checksum )->by_default("false")->as_bool());
break;
case 3:
this->serial = new(AHB0) SerialConsole( p9, p10, this->config->value(uart0_checksum,baud_rate_setting_checksum)->by_default(DEFAULT_SERIAL_BAUD_RATE)->as_number(), THEKERNEL->config->value( serial_checksum, filter_serial3_checksum )->by_default("false")->as_bool());
break;
}
I have added a message type parameter with default value :
typedef enum {STANDARD_MSG = 0, NEXTION_MSG = 1} SERIALMESSAGE_TYPE;
struct SerialMessage {
StreamOutput* stream;
std::string message;
SERIALMESSAGE_TYPE type;
};
const SerialMessage DEFAULT_SERIALMESSAGE = { NULL, "", STANDARD_MSG};
I can be wrong as I am discovering smoothy code but was looking the simplest way to do it.
I am just starting so only filtering is implemented currently.