Serial refactor. Default 8-bit ECHO to int, not char (#20985)

Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
This commit is contained in:
X-Ryl669
2021-02-08 07:37:24 +01:00
committed by GitHub
parent 1e726fe405
commit e7c711996b
72 changed files with 379 additions and 337 deletions

View File

@ -28,10 +28,6 @@
#include "../../inc/MarlinConfigPre.h"
#include "../../core/serial_hook.h"
#if HAS_TFT_LVGL_UI
extern "C" { extern char public_buf_m[100]; }
#endif
// Increase priority of serial interrupts, to reduce overflow errors
#define UART_IRQ_PRIO 1
@ -49,28 +45,6 @@ struct MarlinSerial : public HardwareSerial {
nvic_irq_set_priority(c_dev()->irq_num, UART_IRQ_PRIO);
}
#endif
#if HAS_TFT_LVGL_UI
// Hook the serial write method to capture the output of GCode command sent via LCD
uint32_t current_wpos;
void (*line_callback)(void *, const char * msg);
void *user_pointer;
void set_hook(void (*hook)(void *, const char *), void * that) { line_callback = hook; user_pointer = that; current_wpos = 0; }
size_t write(uint8_t c) {
if (line_callback) {
if (c == '\n' || current_wpos == sizeof(public_buf_m) - 1) { // End of line, probably end of command anyway
public_buf_m[current_wpos] = 0;
line_callback(user_pointer, public_buf_m);
current_wpos = 0;
}
else
public_buf_m[current_wpos++] = c;
}
return HardwareSerial::write(c);
}
#endif
};
typedef Serial0Type<MarlinSerial> MSerialT;