LVGL UI G-code console (#20755)
This commit is contained in:
@ -82,14 +82,14 @@ typedef int8_t pin_t;
|
||||
|
||||
// Serial ports
|
||||
#ifdef USBCON
|
||||
#include "../../core/serial_hook.h"
|
||||
#include "../../core/serial_hook.h"
|
||||
typedef ForwardSerial0Type< decltype(Serial) > DefaultSerial;
|
||||
extern DefaultSerial MSerial;
|
||||
#ifdef BLUETOOTH
|
||||
typedef ForwardSerial0Type< decltype(bluetoothSerial) > BTSerial;
|
||||
extern BTSerial btSerial;
|
||||
#endif
|
||||
|
||||
|
||||
#define MYSERIAL0 TERN(BLUETOOTH, btSerial, MSerial)
|
||||
#else
|
||||
#if !WITHIN(SERIAL_PORT, -1, 3)
|
||||
|
@ -611,7 +611,7 @@ MSerialT customizedSerial1(MSerialT::HasEmergencyParser);
|
||||
|
||||
template class MarlinSerial< LCDSerialCfg<LCD_SERIAL_PORT> >;
|
||||
MSerialT4 lcdSerial(MSerialT4::HasEmergencyParser);
|
||||
|
||||
|
||||
#if HAS_DGUS_LCD
|
||||
template<typename Cfg>
|
||||
typename MarlinSerial<Cfg>::ring_buffer_pos_t MarlinSerial<Cfg>::get_tx_buffer_free() {
|
||||
|
@ -238,11 +238,11 @@
|
||||
static constexpr bool MAX_RX_QUEUED = ENABLED(SERIAL_STATS_MAX_RX_QUEUED);
|
||||
};
|
||||
|
||||
typedef Serial0Type< MarlinSerial< MarlinSerialCfg<SERIAL_PORT> > > MSerialT;
|
||||
typedef Serial0Type< MarlinSerial< MarlinSerialCfg<SERIAL_PORT> > > MSerialT;
|
||||
extern MSerialT customizedSerial1;
|
||||
|
||||
#ifdef SERIAL_PORT_2
|
||||
typedef Serial0Type< MarlinSerial< MarlinSerialCfg<SERIAL_PORT_2> > > MSerialT2;
|
||||
typedef Serial0Type< MarlinSerial< MarlinSerialCfg<SERIAL_PORT_2> > > MSerialT2;
|
||||
extern MSerialT2 customizedSerial2;
|
||||
#endif
|
||||
|
||||
@ -262,7 +262,7 @@
|
||||
static constexpr bool RX_OVERRUNS = false;
|
||||
};
|
||||
|
||||
typedef Serial0Type< MarlinSerial< MMU2SerialCfg<MMU2_SERIAL_PORT> > > MSerialT3;
|
||||
typedef Serial0Type< MarlinSerial< MMU2SerialCfg<MMU2_SERIAL_PORT> > > MSerialT3;
|
||||
extern MSerial3 mmuSerial;
|
||||
#endif
|
||||
|
||||
@ -292,7 +292,7 @@
|
||||
};
|
||||
|
||||
|
||||
typedef Serial0Type< MarlinSerial< LCDSerialCfg<LCD_SERIAL_PORT> > > MSerialT4;
|
||||
typedef Serial0Type< MarlinSerial< LCDSerialCfg<LCD_SERIAL_PORT> > > MSerialT4;
|
||||
extern MSerialT4 lcdSerial;
|
||||
#endif
|
||||
|
||||
|
@ -39,7 +39,7 @@
|
||||
|
||||
#ifdef USBCON
|
||||
#include <USBSerial.h>
|
||||
#include "../../core/serial_hook.h"
|
||||
#include "../../core/serial_hook.h"
|
||||
typedef ForwardSerial0Type< decltype(SerialUSB) > DefaultSerial;
|
||||
extern DefaultSerial MSerial;
|
||||
#endif
|
||||
|
@ -163,7 +163,6 @@
|
||||
GPIO_InitStruct.Pin = GPIO_PIN_2;
|
||||
HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
|
||||
|
||||
|
||||
#if DISABLED(STM32F1xx)
|
||||
// TODO: use __HAL_RCC_SDIO_RELEASE_RESET() and __HAL_RCC_SDIO_CLK_ENABLE();
|
||||
RCC->APB2RSTR &= ~RCC_APB2RSTR_SDIORST_Msk; // take SDIO out of reset
|
||||
|
@ -28,6 +28,10 @@
|
||||
#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
|
||||
|
||||
@ -45,6 +49,28 @@ 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;
|
||||
|
Reference in New Issue
Block a user