Skip to content

Commit

Permalink
Serial refactor. Default 8-bit ECHO to int, not char (MarlinFirmware#…
Browse files Browse the repository at this point in the history
…20985)

Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
  • Loading branch information
2 people authored and zillarob committed Mar 11, 2021
1 parent c0929cd commit 8312324
Showing 1 changed file with 0 additions and 26 deletions.
26 changes: 0 additions & 26 deletions Marlin/src/HAL/STM32F1/MarlinSerial.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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 Serial1Class<MarlinSerial> MSerialT;
Expand Down

0 comments on commit 8312324

Please sign in to comment.