MarlinUI for SPI/I2C TFT-GLCD character-based display bridge (#19375)

This commit is contained in:
Serhiy-K authored and GitHub committed 2020-09-28 01:52:38 -05:00
1 parent c2c6a679ea
commit 27bdf4b24e
31 files changed
+2516 -53

No files matched your search

File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
+74
View File
@@ -0,0 +1,74 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#pragma once
/**
* Implementation of the LCD display routines for a TFT GLCD displays with external controller.
*/
#include "../../inc/MarlinConfig.h"
#if IS_TFTGLCD_PANEL
#include "../../libs/duration_t.h"
////////////////////////////////////
// Set up button and encode mappings for each panel (into 'buttons' variable)
//
// This is just to map common functions (across different panels) onto the same
// macro name. The mapping is independent of whether the button is directly connected or
// via a shift/i2c register.
////////////////////////////////////
// Create LCD class instance and chipset-specific information
class TFTGLCD {
private:
public:
TFTGLCD();
void clear_buffer();
void setCursor(uint8_t col, uint8_t row);
void write(char c);
void print(const char *line);
void print_line();
void print_screen();
void redraw_screen();
void setContrast(uint16_t contrast);
};
extern TFTGLCD lcd;
#include "../fontutils.h"
#include "../lcdprint.h"
// Use panel encoder - free old encoder pins
#undef BTN_EN1
#undef BTN_EN2
#undef BTN_ENC
#define BTN_EN1 -1
#define BTN_EN2 -1
#define BTN_ENC -1
#ifndef EN_C
#define EN_C 4 //for click
#endif
#endif // IS_TFTGLCD_PANEL
+6 -2
View File
@@ -59,10 +59,14 @@ inline float rounded_mesh_value() {
static void _lcd_mesh_fine_tune(PGM_P const msg) {
ui.defer_status_screen();
if (ubl.encoder_diff) {
mesh_edit_accumulator += ubl.encoder_diff > 0 ? 0.005f : -0.005f;
mesh_edit_accumulator += TERN(IS_TFTGLCD_PANEL,
ubl.encoder_diff * 0.005f / ENCODER_PULSES_PER_STEP,
ubl.encoder_diff > 0 ? 0.005f : -0.005f
);
ubl.encoder_diff = 0;
ui.refresh(LCDVIEW_CALL_REDRAW_NEXT);
TERN(IS_TFTGLCD_PANEL,,ui.refresh(LCDVIEW_CALL_REDRAW_NEXT));
}
TERN_(IS_TFTGLCD_PANEL, ui.refresh(LCDVIEW_CALL_REDRAW_NEXT));
if (ui.should_draw()) {
const float rounded_f = rounded_mesh_value();
+10 -4
View File
@@ -506,7 +506,7 @@ bool MarlinUI::get_blink() {
* This is very display-dependent, so the lcd implementation draws this.
*/
#if ENABLED(LCD_PROGRESS_BAR)
#if ENABLED(LCD_PROGRESS_BAR) && !IS_TFTGLCD_PANEL
millis_t MarlinUI::progress_bar_ms; // = 0
#if PROGRESS_MSG_EXPIRE > 0
millis_t MarlinUI::expire_status_ms; // = 0
@@ -517,7 +517,7 @@ void MarlinUI::status_screen() {
TERN_(HAS_LCD_MENU, ENCODER_RATE_MULTIPLY(false));
#if ENABLED(LCD_PROGRESS_BAR)
#if ENABLED(LCD_PROGRESS_BAR) && !IS_TFTGLCD_PANEL
//
// HD44780 implements the following message blinking and
@@ -915,7 +915,7 @@ void MarlinUI::update() {
const bool encoderPastThreshold = (abs_diff >= epps);
if (encoderPastThreshold || lcd_clicked) {
if (encoderPastThreshold) {
if (encoderPastThreshold && TERN1(IS_TFTGLCD_PANEL, !external_control)) {
#if BOTH(HAS_LCD_MENU, ENCODER_RATE_MULTIPLIER)
@@ -1260,6 +1260,12 @@ void MarlinUI::update() {
TERN(REPRAPWORLD_KEYPAD, keypad_buttons, buttons) = ~val;
#endif
#if IS_TFTGLCD_PANEL
next_button_update_ms = now + (LCD_UPDATE_INTERVAL / 2);
buttons = slow_buttons;
TERN_(AUTO_BED_LEVELING_UBL, external_encoder());
#endif
} // next_button_update_ms
#if HAS_ENCODER_WHEEL
@@ -1331,7 +1337,7 @@ void MarlinUI::update() {
const millis_t ms = millis();
#endif
#if ENABLED(LCD_PROGRESS_BAR)
#if ENABLED(LCD_PROGRESS_BAR) && !IS_TFTGLCD_PANEL
progress_bar_ms = ms;
#if PROGRESS_MSG_EXPIRE > 0
expire_status_ms = persist ? 0 : ms + PROGRESS_MSG_EXPIRE;
+3 -3
View File
@@ -34,7 +34,7 @@
#if EITHER(HAS_LCD_MENU, ULTIPANEL_FEEDMULTIPLY)
#define HAS_ENCODER_ACTION 1
#endif
#if (!HAS_ADC_BUTTONS && ENABLED(NEWPANEL)) || BUTTONS_EXIST(EN1, EN2)
#if ((!HAS_ADC_BUTTONS && ENABLED(NEWPANEL)) || BUTTONS_EXIST(EN1, EN2)) && !IS_TFTGLCD_PANEL
#define HAS_ENCODER_WHEEL 1
#endif
#if HAS_ENCODER_WHEEL || ANY_BUTTON(ENC, BACK, UP, DWN, LFT, RT)
@@ -45,7 +45,7 @@
#endif
// I2C buttons must be read in the main thread
#if EITHER(LCD_I2C_VIKI, LCD_I2C_PANELOLU2)
#if ANY(LCD_I2C_VIKI, LCD_I2C_PANELOLU2, IS_TFTGLCD_PANEL)
#define HAS_SLOW_BUTTONS 1
#endif
@@ -215,7 +215,7 @@
#endif
#if BUTTON_EXISTS(BACK) || HAS_TOUCH_XPT2046
#if BUTTON_EXISTS(BACK) || EITHER(HAS_TOUCH_XPT2046, IS_TFTGLCD_PANEL)
#define BLEN_D 3
#define EN_D _BV(BLEN_D)
#define LCD_BACK_CLICKED() (buttons & EN_D)