Skip to content

Commit

Permalink
Fixes for TFTGLCD Panel, FastIO (MarlinFirmware#19614)
Browse files Browse the repository at this point in the history
  • Loading branch information
Serhiy-K authored and walterp1982 committed Aug 15, 2022
1 parent 02bd08e commit ce0d8ae
Show file tree
Hide file tree
Showing 9 changed files with 99 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Marlin/src/core/language.h
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,7 @@
#define STR_I ""
#endif

<<<<<<< HEAD
#if HAS_J_AXIS
#if AXIS5_NAME == 'B'
#define STR_J "B"
Expand Down Expand Up @@ -501,6 +502,8 @@
#define STR_W ""
#endif

=======
>>>>>>> 887e2637c0 (Fixes for TFTGLCD Panel, FastIO (#19614))
#if EITHER(HAS_MARLINUI_HD44780, IS_TFTGLCD_PANEL)

// Custom characters defined in the first 8 characters of the LCD
Expand Down
4 changes: 4 additions & 0 deletions Marlin/src/inc/Conditionals_LCD.h
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,11 @@
#define LCD_PROGRESS_BAR
#endif
#if ENABLED(TFTGLCD_PANEL_I2C)
<<<<<<< HEAD
#define LCD_I2C_ADDRESS 0x33 // Must be 0x33 for STM32 main boards and equal to panel's I2C slave address
=======
#define LCD_I2C_ADDRESS 0x27 // Must be equal to panel's I2C slave addres
>>>>>>> 887e2637c0 (Fixes for TFTGLCD Panel, FastIO (#19614))
#endif
#define LCD_USE_I2C_BUZZER // Enable buzzer on LCD, used for both I2C and SPI buses (LiquidTWI2 not required)
#define STD_ENCODER_PULSES_PER_STEP 2
Expand Down
8 changes: 8 additions & 0 deletions Marlin/src/inc/Conditionals_post.h
Original file line number Diff line number Diff line change
Expand Up @@ -3561,6 +3561,7 @@
/**
* Buzzer/Speaker
*/
<<<<<<< HEAD
#if PIN_EXISTS(BEEPER)
#define HAS_BEEPER 1
#endif
Expand All @@ -3569,6 +3570,13 @@
#endif
#if EITHER(HAS_BEEPER, USE_MARLINUI_BUZZER)
#define HAS_SOUND 1
=======
#if PIN_EXISTS(BEEPER) || ANY(LCD_USE_I2C_BUZZER, PCA9632_BUZZER)
#define HAS_BUZZER 1
#if PIN_EXISTS(BEEPER)
#define USE_BEEPER 1
#endif
>>>>>>> 887e2637c0 (Fixes for TFTGLCD Panel, FastIO (#19614))
#endif

#if ENABLED(LCD_USE_I2C_BUZZER)
Expand Down
51 changes: 51 additions & 0 deletions Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@
* and supports color output.
*/

<<<<<<< HEAD:Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp
#if NONE(__AVR__, TARGET_LPC1768, STM32F1, STM32F4xx)
=======
#if NONE(__AVR__, TARGET_LPC1768, __STM32F1__, STM32F4xx)
>>>>>>> 887e2637c0 (Fixes for TFTGLCD Panel, FastIO (#19614)):Marlin/src/lcd/TFTGLCD/ultralcd_TFTGLCD.cpp
#warning "Selected platform not yet tested. Please contribute your good pin mappings."
#endif

Expand Down Expand Up @@ -141,7 +145,11 @@ static uint8_t PanelDetected = 0;
#if ANY(__AVR__, TARGET_LPC1768, __STM32F1__, ARDUINO_ARCH_SAM, __SAMD51__, __MK20DX256__, __MK64FX512__)
#define SPI_SEND_ONE(V) SPI.transfer(V);
#define SPI_SEND_TWO(V) SPI.transfer16(V);
<<<<<<< HEAD:Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp
#elif EITHER(STM32F4xx, STM32F1xx)
=======
#elif defined(STM32F4xx)
>>>>>>> 887e2637c0 (Fixes for TFTGLCD Panel, FastIO (#19614)):Marlin/src/lcd/TFTGLCD/ultralcd_TFTGLCD.cpp
#define SPI_SEND_ONE(V) SPI.transfer(V, SPI_CONTINUE);
#define SPI_SEND_TWO(V) SPI.transfer16(V, SPI_CONTINUE);
#elif defined(ARDUINO_ARCH_ESP32)
Expand All @@ -151,7 +159,11 @@ static uint8_t PanelDetected = 0;

#if ANY(__AVR__, ARDUINO_ARCH_SAM, __SAMD51__, __MK20DX256__, __MK64FX512__)
#define SPI_SEND_SOME(V,L,Z) SPI.transfer(&V[Z], L);
<<<<<<< HEAD:Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp
#elif EITHER(STM32F4xx, STM32F1xx)
=======
#elif defined(STM32F4xx)
>>>>>>> 887e2637c0 (Fixes for TFTGLCD Panel, FastIO (#19614)):Marlin/src/lcd/TFTGLCD/ultralcd_TFTGLCD.cpp
#define SPI_SEND_SOME(V,L,Z) SPI.transfer(&V[Z], L, SPI_CONTINUE);
#elif ANY(TARGET_LPC1768, __STM32F1__, ARDUINO_ARCH_ESP32)
#define SPI_SEND_SOME(V,L,Z) do{ for (uint16_t i = 0; i < L; i++) SPI_SEND_ONE(V[(Z)+i]); }while(0)
Expand Down Expand Up @@ -265,7 +277,11 @@ void TFTGLCD::setContrast(uint16_t contrast) {
extern volatile int8_t encoderDiff;

// Read buttons and encoder states
<<<<<<< HEAD:Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp
uint8_t MarlinUI::read_slow_buttons() {
=======
uint8_t MarlinUI::read_slow_buttons(void) {
>>>>>>> 887e2637c0 (Fixes for TFTGLCD Panel, FastIO (#19614)):Marlin/src/lcd/TFTGLCD/ultralcd_TFTGLCD.cpp
if (!PanelDetected) return 0;
#if ENABLED(TFTGLCD_PANEL_SPI)
uint8_t b = 0;
Expand Down Expand Up @@ -325,7 +341,11 @@ void MarlinUI::init_lcd() {
t = 0;
#if ENABLED(TFTGLCD_PANEL_SPI)
// SPI speed must be less 10MHz
<<<<<<< HEAD:Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp
SET_OUTPUT(TFTGLCD_CS);
=======
_SET_OUTPUT(TFTGLCD_CS);
>>>>>>> 887e2637c0 (Fixes for TFTGLCD Panel, FastIO (#19614)):Marlin/src/lcd/TFTGLCD/ultralcd_TFTGLCD.cpp
WRITE(TFTGLCD_CS, HIGH);
spiInit(TERN(__STM32F1__, SPI_QUARTER_SPEED, SPI_FULL_SPEED));
WRITE(TFTGLCD_CS, LOW);
Expand All @@ -342,7 +362,11 @@ void MarlinUI::init_lcd() {
Wire.endTransmission(); // send buffer
#ifdef __AVR__
Wire.requestFrom((uint8_t)LCD_I2C_ADDRESS, 1, 0, 0, 1);
<<<<<<< HEAD:Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp
#elif ANY(STM32F1, STM32F4xx, TARGET_LPC1768)
=======
#elif ANY(__STM32F1__, STM32F4xx, TARGET_LPC1768)
>>>>>>> 887e2637c0 (Fixes for TFTGLCD Panel, FastIO (#19614)):Marlin/src/lcd/TFTGLCD/ultralcd_TFTGLCD.cpp
Wire.requestFrom(LCD_I2C_ADDRESS, 1);
#endif
t = (uint8_t)Wire.read();
Expand Down Expand Up @@ -626,10 +650,17 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const
lcd.write('%'); lcd.write(percent);
}
else { // For progress bar test
<<<<<<< HEAD:Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp
lcd_moveto(LCD_WIDTH / 2 - 2, MIDDLE_Y);
lcd.print(i16tostr3rj(percent)); lcd.write('%');
lcd.print_line();
lcd_moveto(0, MIDDLE_Y + 1);
=======
lcd.setCursor(LCD_WIDTH / 2 - 2, MIDDLE_Y);
lcd.print(i16tostr3rj(percent)); lcd.write('%');
lcd.print_line();
lcd.setCursor(0, MIDDLE_Y + 1);
>>>>>>> 887e2637c0 (Fixes for TFTGLCD Panel, FastIO (#19614)):Marlin/src/lcd/TFTGLCD/ultralcd_TFTGLCD.cpp
lcd.write('%'); lcd.write(percent);
lcd.print_line();
}
Expand Down Expand Up @@ -983,17 +1014,29 @@ void MarlinUI::draw_status_screen() {

// Low-level draw_edit_screen can be used to draw an edit screen from anyplace
// This line moves to the last line of the screen for UBL plot screen on the panel side
<<<<<<< HEAD:Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp
void MenuEditItemBase::draw_edit_screen(FSTR_P const fstr, const char * const value/*=nullptr*/) {
if (!PanelDetected) return;
ui.encoder_direction_normal();
const uint8_t y = TERN0(AUTO_BED_LEVELING_UBL, ui.external_control) ? LCD_HEIGHT - 1 : MIDDLE_Y;
lcd_moveto(0, y);
=======
void MenuEditItemBase::draw_edit_screen(PGM_P const pstr, const char* const value/*=nullptr*/) {
if (!PanelDetected) return;
ui.encoder_direction_normal();
lcd.setCursor(0, MIDDLE_Y);
>>>>>>> 887e2637c0 (Fixes for TFTGLCD Panel, FastIO (#19614)):Marlin/src/lcd/TFTGLCD/ultralcd_TFTGLCD.cpp
lcd.write(COLOR_EDIT);
lcd_put_u8str(fstr);
if (value) {
lcd.write(':');
<<<<<<< HEAD:Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp
lcd_moveto((LCD_WIDTH - 1) - (utf8_strlen(value) + 1), y); // Right-justified, padded by spaces
lcd.write(' '); // Overwrite char if value gets shorter
=======
lcd.setCursor((LCD_WIDTH - 1) - (utf8_strlen(value) + 1), MIDDLE_Y); // Right-justified, padded by spaces
lcd.write(' '); // Overwrite char if value gets shorter
>>>>>>> 887e2637c0 (Fixes for TFTGLCD Panel, FastIO (#19614)):Marlin/src/lcd/TFTGLCD/ultralcd_TFTGLCD.cpp
lcd.print(value);
lcd.write(' ');
lcd.print_line();
Expand All @@ -1004,6 +1047,7 @@ void MarlinUI::draw_status_screen() {
void MenuItem_confirm::draw_select_screen(FSTR_P const yes, FSTR_P const no, const bool yesno, FSTR_P const pref, const char * const string, FSTR_P const suff) {
if (!PanelDetected) return;
ui.draw_select_screen_prompt(pref, string, suff);
<<<<<<< HEAD:Marlin/src/lcd/TFTGLCD/marlinui_TFTGLCD.cpp
lcd.write(COLOR_EDIT);
if (no) {
lcd_moveto(0, MIDDLE_Y);
Expand All @@ -1013,6 +1057,13 @@ void MarlinUI::draw_status_screen() {
lcd_moveto(LCD_WIDTH - utf8_strlen(yes) - 3, MIDDLE_Y);
lcd.write(yesno ? '[' : ' '); lcd_put_u8str(yes); lcd.write(yesno ? ']' : ' ');
}
=======
lcd.setCursor(0, MIDDLE_Y);
lcd.write(COLOR_EDIT);
lcd.write(yesno ? ' ' : '['); lcd_put_u8str_P(no); lcd.write(yesno ? ' ' : ']');
lcd.setCursor(LCD_WIDTH - utf8_strlen_P(yes) - 3, MIDDLE_Y);
lcd.write(yesno ? '[' : ' '); lcd_put_u8str_P(yes); lcd.write(yesno ? ']' : ' ');
>>>>>>> 887e2637c0 (Fixes for TFTGLCD Panel, FastIO (#19614)):Marlin/src/lcd/TFTGLCD/ultralcd_TFTGLCD.cpp
lcd.print_line();
}

Expand Down
3 changes: 3 additions & 0 deletions Marlin/src/lcd/menu/menu_advanced.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -560,10 +560,13 @@ void menu_backlash();
SUBMENU(MSG_PROBE_WIZARD, goto_probe_offset_wizard);
#endif

<<<<<<< HEAD
#if ENABLED(X_AXIS_TWIST_COMPENSATION)
SUBMENU(MSG_XATC, xatc_wizard_continue);
#endif

=======
>>>>>>> 887e2637c0 (Fixes for TFTGLCD Panel, FastIO (#19614))
END_MENU();
}
#endif
Expand Down
19 changes: 19 additions & 0 deletions Marlin/src/pins/lpc1768/pins_BTT_SKR_V1_4.h
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@
#define TMC_BAUD_RATE 19200
#endif

<<<<<<< HEAD
/** ------ ------
* 1.30 | 1 2 | 0.28 0.17 | 1 2 | 0.15
* 1.18 | 3 4 | 1.19 3.26 | 3 4 | 0.16
Expand All @@ -253,6 +254,24 @@
* GND | 9 10 | 5V GND | 9 10 | --
* ------ ------
* EXP1 EXP2
=======
//
// SD Connection
//
#if SD_CONNECTION_IS(LCD)
#define SS_PIN P0_16
#endif
/**
* _____ _____
* NC | · · | GND 5V | · · | GND
* RESET | · · | 1.31 (SD_DETECT) (LCD_D7) 1.23 | · · | 1.22 (LCD_D6)
* (MOSI) 0.18 | · · | 3.25 (BTN_EN2) (LCD_D5) 1.21 | · · | 1.20 (LCD_D4)
* (SD_SS) 0.16 | · · | 3.26 (BTN_EN1) (LCD_RS) 1.19 | · · | 1.18 (LCD_EN)
* (SCK) 0.15 | · · | 0.17 (MISO) (BTN_ENC) 0.28 | · · | 1.30 (BEEPER)
* ----- -----
* EXP2 EXP1
>>>>>>> 887e2637c0 (Fixes for TFTGLCD Panel, FastIO (#19614))
*/
#define EXP1_01_PIN P1_30
#define EXP1_02_PIN P0_28
Expand Down
4 changes: 4 additions & 0 deletions Marlin/src/pins/lpc1768/pins_BTT_SKR_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,11 @@
//
// LCD / Controller
//
<<<<<<< HEAD
#if !defined(BEEPER_PIN) && HAS_WIRED_LCD && DISABLED(LCD_USE_I2C_BUZZER)
=======
#if HAS_WIRED_LCD && DISABLED(LCD_USE_I2C_BUZZER)
>>>>>>> 887e2637c0 (Fixes for TFTGLCD Panel, FastIO (#19614))
#define BEEPER_PIN P1_30 // (37) not 5V tolerant
#endif

Expand Down
4 changes: 4 additions & 0 deletions Marlin/src/pins/stm32f0/pins_MALYAN_M300.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@
#if NO_EEPROM_SELECTED
#define FLASH_EEPROM_EMULATION
#ifndef MARLIN_EEPROM_SIZE
<<<<<<< HEAD
#define MARLIN_EEPROM_SIZE 0x800U // 2K
=======
#define MARLIN_EEPROM_SIZE 0x800U // 2KB
>>>>>>> 887e2637c0 (Fixes for TFTGLCD Panel, FastIO (#19614))
#endif
#endif

Expand Down
3 changes: 3 additions & 0 deletions Marlin/src/pins/stm32f1/pins_MORPHEUS.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,7 @@
#define LED_PIN PC13
#define SDSS PA3
#define TFTGLCD_CS PA4
<<<<<<< HEAD
#define SD_DETECT_PIN PC14
=======
>>>>>>> 887e2637c0 (Fixes for TFTGLCD Panel, FastIO (#19614))

0 comments on commit ce0d8ae

Please sign in to comment.