Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update DGUS and fix bugs #16317

Merged
merged 4 commits into from
Jan 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 4 additions & 2 deletions Marlin/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -2025,9 +2025,11 @@
//=============================================================================

//
// DGUS Touch Display with DWIN OS
// DGUS Touch Display with DWIN OS. (Choose one.)
//
//#define DGUS_LCD
//#define DGUS_LCD_UI_ORIGIN
//#define DGUS_LCD_UI_FYSETC
//#define DGUS_LCD_UI_HIPRECY

//
// Touch-screen LCD for Malyan M200 printers
Expand Down
38 changes: 38 additions & 0 deletions Marlin/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -1243,6 +1243,44 @@

#endif // HAS_GRAPHICAL_LCD

//
// Additional options for DGUS / DWIN displays
//
#if HAS_DGUS_LCD
#define DGUS_SERIAL_PORT 2
#define DGUS_BAUDRATE 115200

#define DGUS_RX_BUFFER_SIZE 128
#define DGUS_TX_BUFFER_SIZE 48
//#define DGUS_SERIAL_STATS_RX_BUFFER_OVERRUNS // Fix Rx overrun situation (Currently only for AVR)

#define DGUS_UPDATE_INTERVAL_MS 500 // (ms) Interval between automatic screen updates
#define BOOTSCREEN_TIMEOUT 3000 // (ms) Duration to display the boot screen

#if EITHER(DGUS_LCD_UI_FYSETC, DGUS_LCD_UI_HIPRECY)
#define DGUS_PRINT_FILENAME // Display the filename during printing
#define DGUS_PREHEAT_UI // Display a preheat screen during heatup

#if ENABLED(DGUS_LCD_UI_FYSETC)
//#define DUGS_UI_MOVE_DIS_OPTION // Disabled by default for UI_FYSETC
#else
#define DUGS_UI_MOVE_DIS_OPTION // Enabled by default for UI_HIPRECY
#endif

#define DGUS_FILAMENT_LOADUNLOAD
#if ENABLED(DGUS_FILAMENT_LOADUNLOAD)
#define DGUS_FILAMENT_PURGE_LENGTH 10
#define DGUS_FILAMENT_LOAD_LENGTH_PER_TIME 0.5 // (mm) Adjust in proportion to DGUS_UPDATE_INTERVAL_MS
#endif

#define DGUS_UI_WAITING // Show a "waiting" screen between some screens
#if ENABLED(DGUS_UI_WAITING)
#define DGUS_UI_WAITING_STATUS 10
#define DGUS_UI_WAITING_STATUS_PERIOD 8 // Increase to slower waiting status looping
#endif
#endif
#endif // HAS_DGUS_LCD

//
// Touch UI for the FTDI Embedded Video Engine (EVE)
//
Expand Down
13 changes: 13 additions & 0 deletions Marlin/src/HAL/HAL_AVR/HAL.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,19 @@ typedef int8_t pin_t;
#endif
#endif

#ifdef DGUS_SERIAL_PORT
#if !WITHIN(DGUS_SERIAL_PORT, -1, 3)
#error "DGUS_SERIAL_PORT must be from -1 to 3. Please update your configuration."
#elif DGUS_SERIAL_PORT == SERIAL_PORT
#error "DGUS_SERIAL_PORT must be different than SERIAL_PORT. Please update your configuration."
#elif defined(SERIAL_PORT_2) && DGUS_SERIAL_PORT == SERIAL_PORT_2
#error "DGUS_SERIAL_PORT must be different than SERIAL_PORT_2. Please update your configuration."
#endif
#define DGUS_SERIAL internalDgusSerial

#define DGUS_SERIAL_GET_TX_BUFFER_FREE DGUS_SERIAL.get_tx_buffer_free
#endif

// ------------------------
// Public functions
// ------------------------
Expand Down
27 changes: 27 additions & 0 deletions Marlin/src/HAL/HAL_AVR/MarlinSerial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -757,6 +757,33 @@

#endif

#ifdef DGUS_SERIAL_PORT

template<typename Cfg>
typename MarlinSerial<Cfg>::ring_buffer_pos_t MarlinSerial<Cfg>::get_tx_buffer_free() {
const ring_buffer_pos_t t = tx_buffer.tail, // next byte to send.
h = tx_buffer.head; // next pos for queue.
int ret = t - h - 1;
if (ret < 0) ret += Cfg::TX_SIZE + 1;
return ret;
}

ISR(SERIAL_REGNAME(USART,DGUS_SERIAL_PORT,_RX_vect)) {
MarlinSerial<MarlinInternalSerialCfg<DGUS_SERIAL_PORT>>::store_rxd_char();
}

ISR(SERIAL_REGNAME(USART,DGUS_SERIAL_PORT,_UDRE_vect)) {
MarlinSerial<MarlinInternalSerialCfg<DGUS_SERIAL_PORT>>::_tx_udr_empty_irq();
}

// Preinstantiate
template class MarlinSerial<MarlinInternalSerialCfg<DGUS_SERIAL_PORT>>;

// Instantiate
MarlinSerial<MarlinInternalSerialCfg<DGUS_SERIAL_PORT>> internalDgusSerial;

#endif

// For AT90USB targets use the UART for BT interfacing
#if defined(USBCON) && ENABLED(BLUETOOTH)
HardwareSerial bluetoothSerial;
Expand Down
20 changes: 20 additions & 0 deletions Marlin/src/HAL/HAL_AVR/MarlinSerial.h
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,9 @@
static ring_buffer_pos_t available();
static void write(const uint8_t c);
static void flushTX();
#ifdef DGUS_SERIAL_PORT
static ring_buffer_pos_t get_tx_buffer_free();
#endif

FORCE_INLINE static uint8_t dropped() { return Cfg::DROPPED_RX ? rx_dropped_bytes : 0; }
FORCE_INLINE static uint8_t buffer_overruns() { return Cfg::RX_OVERRUNS ? rx_buffer_overruns : 0; }
Expand Down Expand Up @@ -292,6 +295,23 @@
extern MarlinSerial<MarlinInternalSerialCfg<INTERNAL_SERIAL_PORT>> internalSerial;
#endif

#ifdef DGUS_SERIAL_PORT
template <uint8_t serial>
struct MarlinInternalSerialCfg {
static constexpr int PORT = serial;
static constexpr unsigned int RX_SIZE = 128;
static constexpr unsigned int TX_SIZE = 48;
static constexpr bool XONOFF = false;
static constexpr bool EMERGENCYPARSER = false;
static constexpr bool DROPPED_RX = false;
static constexpr bool RX_OVERRUNS = bDGUS_SERIAL_STATS_RX_BUFFER_OVERRUNS;
static constexpr bool RX_FRAMING_ERRORS = false;
static constexpr bool MAX_RX_QUEUED = false;
};

extern MarlinSerial<MarlinInternalSerialCfg<DGUS_SERIAL_PORT>> internalDgusSerial;
#endif

// Use the UART for Bluetooth in AT90USB configurations
#if defined(USBCON) && ENABLED(BLUETOOTH)
extern HardwareSerial bluetoothSerial;
Expand Down
21 changes: 21 additions & 0 deletions Marlin/src/HAL/HAL_DUE/HAL.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,27 @@
#define NUM_SERIAL 1
#endif

#ifdef DGUS_SERIAL_PORT
#if DGUS_SERIAL_PORT == SERIAL_PORT
#error "DGUS_SERIAL_PORT must be different from SERIAL_PORT. Please update your configuration."
#elif defined(SERIAL_PORT_2) && DGUS_SERIAL_PORT == SERIAL_PORT_2
#error "DGUS_SERIAL_PORT must be different than SERIAL_PORT_2. Please update your configuration."
#elif DGUS_SERIAL_PORT == -1
#define DGUS_SERIAL internalDgusSerial
#elif DGUS_SERIAL_PORT == 0
#define DGUS_SERIAL Serial
#elif DGUS_SERIAL_PORT == 1
#define DGUS_SERIAL Serial1
#elif DGUS_SERIAL_PORT == 2
#define DGUS_SERIAL Serial2
#elif DGUS_SERIAL_PORT == 3
#define DGUS_SERIAL Serial3
#else
#error "DGUS_SERIAL_PORT must be from -1 to 3. Please update your configuration."
#endif
#endif


#include "MarlinSerial.h"
#include "MarlinSerialUSB.h"

Expand Down
20 changes: 20 additions & 0 deletions Marlin/src/HAL/HAL_LPC1768/HAL.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,26 @@ extern "C" volatile uint32_t _millis;
#define NUM_SERIAL 1
#endif

#ifdef DGUS_SERIAL_PORT
#if DGUS_SERIAL_PORT == SERIAL_PORT
#error "DGUS_SERIAL_PORT must be different than SERIAL_PORT. Please update your configuration."
#elif defined(SERIAL_PORT_2) && DGUS_SERIAL_PORT == SERIAL_PORT_2
#error "DGUS_SERIAL_PORT must be different than SERIAL_PORT_2. Please update your configuration."
#elif DGUS_SERIAL_PORT == -1
#define DGUS_SERIAL UsbSerial
#elif DGUS_SERIAL_PORT == 0
#define DGUS_SERIAL MSerial
#elif DGUS_SERIAL_PORT == 1
#define DGUS_SERIAL MSerial1
#elif DGUS_SERIAL_PORT == 2
#define DGUS_SERIAL MSerial2
#elif DGUS_SERIAL_PORT == 3
#define DGUS_SERIAL MSerial3
#else
#error "DGUS_SERIAL_PORT must be from -1 to 3. Please update your configuration."
#endif
#endif

//
// Interrupts
//
Expand Down
20 changes: 20 additions & 0 deletions Marlin/src/HAL/HAL_SAMD51/HAL.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,26 @@
#define NUM_SERIAL 1
#endif

#ifdef DGUS_SERIAL_PORT
#if DGUS_SERIAL_PORT == SERIAL_PORT
#error "DGUS_SERIAL_PORT must be different than SERIAL_PORT. Please update your configuration."
#elif defined(SERIAL_PORT_2) && DGUS_SERIAL_PORT == SERIAL_PORT_2
#error "DGUS_SERIAL_PORT must be different than SERIAL_PORT_2. Please update your configuration."
#elif DGUS_SERIAL_PORT == -1
#define DGUS_SERIAL Serial
#elif DGUS_SERIAL_PORT == 0
#define DGUS_SERIAL Serial1
#elif DGUS_SERIAL_PORT == 1
#define DGUS_SERIAL Serial2
#elif DGUS_SERIAL_PORT == 2
#define DGUS_SERIAL Serial3
#elif DGUS_SERIAL_PORT == 2
#define DGUS_SERIAL Serial4
#else
#error "DGUS_SERIAL_PORT must be from -1 to 3. Please update your configuration."
#endif
#endif

#endif // ADAFRUIT_GRAND_CENTRAL_M4

typedef int8_t pin_t;
Expand Down
28 changes: 28 additions & 0 deletions Marlin/src/HAL/HAL_STM32/HAL.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,34 @@
#define NUM_SERIAL 1
#endif

#if HAS_DGUS_LCD
#if DGUS_SERIAL_PORT == 0
#error "DGUS_SERIAL_PORT cannot be 0. (Port 0 does not exist.) Please update your configuration."
#elif DGUS_SERIAL_PORT == SERIAL_PORT
#error "DGUS_SERIAL_PORT must be different than SERIAL_PORT. Please update your configuration."
#elif defined(SERIAL_PORT_2) && DGUS_SERIAL_PORT == SERIAL_PORT_2
#error "DGUS_SERIAL_PORT must be different than SERIAL_PORT_2. Please update your configuration."
#elif DGUS_SERIAL_PORT == -1
#define DGUS_SERIAL SerialUSB
#elif DGUS_SERIAL_PORT == 1
#define DGUS_SERIAL Serial1
#elif DGUS_SERIAL_PORT == 2
#define DGUS_SERIAL Serial2
#elif DGUS_SERIAL_PORT == 3
#define DGUS_SERIAL Serial3
#elif DGUS_SERIAL_PORT == 4
#define DGUS_SERIAL Serial4
#elif DGUS_SERIAL_PORT == 5
#define DGUS_SERIAL Serial5
#elif DGUS_SERIAL_PORT == 6
#define DGUS_SERIAL Serial6
#else
#error "DGUS_SERIAL_PORT must be from -1 to 6. Please update your configuration."
#endif

#define DGUS_SERIAL_GET_TX_BUFFER_FREE DGUS_SERIAL.availableForWrite
#endif

#include "timers.h"

/**
Expand Down
25 changes: 25 additions & 0 deletions Marlin/src/HAL/HAL_STM32F1/HAL.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,31 @@
#define NUM_SERIAL 1
#endif

#ifdef DGUS_SERIAL
#if DGUS_SERIAL_PORT == 0
#error "DGUS_SERIAL_PORT cannot be 0. (Port 0 does not exist.) Please update your configuration."
#elif DGUS_SERIAL_PORT == SERIAL_PORT
#error "DGUS_SERIAL_PORT must be different than SERIAL_PORT. Please update your configuration."
#elif defined(SERIAL_PORT_2) && DGUS_SERIAL_PORT == SERIAL_PORT_2
#error "DGUS_SERIAL_PORT must be different than SERIAL_PORT_2. Please update your configuration."
#elif DGUS_SERIAL_PORT == -1
#define DGUS_SERIAL UsbSerial
#elif DGUS_SERIAL_PORT == 1
#define DGUS_SERIAL MSerial1
#elif DGUS_SERIAL_PORT == 2
#define DGUS_SERIAL MSerial2
#elif DGUS_SERIAL_PORT == 3
#define DGUS_SERIAL MSerial3
#elif DGUS_SERIAL_PORT == 4
#define DGUS_SERIAL MSerial4
#elif DGUS_SERIAL_PORT == 5
#define DGUS_SERIAL MSerial5
#else
#error "DGUS_SERIAL_PORT must be from -1 to 5. Please update your configuration."
#endif
#endif


// Set interrupt grouping for this MCU
void HAL_init();
#define HAL_IDLETASK 1
Expand Down
26 changes: 26 additions & 0 deletions Marlin/src/HAL/HAL_STM32_F4_F7/HAL.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,32 @@
#define NUM_SERIAL 1
#endif

#ifdef DGUS_SERIAL_PORT
#if defined(STM32F4) && DGUS_SERIAL_PORT == 0
#error "DGUS_SERIAL_PORT cannot be 0. (Port 0 does not exist.) Please update your configuration."
#elif DGUS_SERIAL_PORT == SERIAL_PORT
#error "DGUS_SERIAL_PORT must be different than SERIAL_PORT. Please update your configuration."
#elif defined(SERIAL_PORT_2) && DGUS_SERIAL_PORT == SERIAL_PORT_2
#error "DGUS_SERIAL_PORT must be different than SERIAL_PORT_2. Please update your configuration."
#elif DGUS_SERIAL_PORT == -1
#define DGUS_SERIAL SerialUSB
#elif DGUS_SERIAL_PORT == 1
#define DGUS_SERIAL SerialUART1
#elif DGUS_SERIAL_PORT == 2
#define DGUS_SERIAL SerialUART2
#elif DGUS_SERIAL_PORT == 3
#define DGUS_SERIAL SerialUART3
#elif DGUS_SERIAL_PORT == 4
#define DGUS_SERIAL SerialUART4
#elif DGUS_SERIAL_PORT == 5
#define DGUS_SERIAL SerialUART5
#elif DGUS_SERIAL_PORT == 6
#define DGUS_SERIAL SerialUART6
#else
#error "DGUS_SERIAL_PORT must be from -1 to 6. Please update your configuration."
#endif
#endif

/**
* TODO: review this to return 1 for pins that are not analog input
*/
Expand Down
7 changes: 7 additions & 0 deletions Marlin/src/HAL/shared/MarlinSerial.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@
#include "../../inc/MarlinConfigPre.h"

constexpr bool
#if HAS_DGUS_LCD
bDGUS_SERIAL_STATS_RX_BUFFER_OVERRUNS = (false
#if ENABLED(DGUS_SERIAL_STATS_RX_BUFFER_OVERRUNS)
|| true
#endif
),
#endif
bSERIAL_XON_XOFF = (false
#if ENABLED(SERIAL_XON_XOFF)
|| true
Expand Down
5 changes: 5 additions & 0 deletions Marlin/src/gcode/feature/powerloss/M1000.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
#include "../../../feature/power_loss_recovery.h"
#include "../../../module/motion.h"
#include "../../../lcd/ultralcd.h"
#if ENABLED(EXTENSIBLE_UI)
#include "../../../lcd/extensible_ui/ui_api.h"
#endif

#define DEBUG_OUT ENABLED(DEBUG_POWER_LOSS_RECOVERY)
#include "../../../core/debug_out.h"
Expand Down Expand Up @@ -55,6 +58,8 @@ void GcodeSuite::M1000() {
if (parser.seen('S')) {
#if HAS_LCD_MENU
ui.goto_screen(menu_job_recovery);
#elif ENABLED(EXTENSIBLE_UI)
ExtUI::OnPowerLossResume();
#else
SERIAL_ECHO_MSG("Resume requires LCD.");
#endif
Expand Down
7 changes: 7 additions & 0 deletions Marlin/src/gcode/temperature/M303.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
#include "../gcode.h"
#include "../../module/temperature.h"

#if ENABLED(EXTENSIBLE_UI)
#include "../../lcd/extensible_ui/ui_api.h"
#endif

/**
* M303: PID relay autotune
*
Expand All @@ -49,6 +53,9 @@ void GcodeSuite::M303() {
const heater_ind_t e = (heater_ind_t)parser.intval('E');
if (!WITHIN(e, SI, EI)) {
SERIAL_ECHOLNPGM(MSG_PID_BAD_EXTRUDER_NUM);
#if ENABLED(EXTENSIBLE_UI)
ExtUI::OnPidTuning(ExtUI::result_t::PID_BAD_EXTRUDER_NUM);
#endif
return;
}

Expand Down
1 change: 1 addition & 0 deletions Marlin/src/inc/Conditionals_LCD.h
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@
#define HAS_CHARACTER_LCD (HAS_SPI_LCD && !HAS_GRAPHICAL_LCD)
#define HAS_LCD_MENU (ENABLED(ULTIPANEL) && DISABLED(NO_LCD_MENUS))
#define HAS_ADC_BUTTONS ENABLED(ADC_KEYPAD)
#define HAS_DGUS_LCD ANY(DGUS_LCD_UI_ORIGIN, DGUS_LCD_UI_FYSETC, DGUS_LCD_UI_HIPRECY)

/**
* Extruders have some combination of stepper motors and hotends
Expand Down
Loading