From 8e54aa4e3cbff6905d99456b958dfc63523113ed Mon Sep 17 00:00:00 2001 From: Serhiy-K <52166448+Serhiy-K@users.noreply.github.com> Date: Sat, 10 Oct 2020 13:01:46 +0300 Subject: [PATCH] Fixes for TFTGLCD Panel, FastIO (#19614) --- Marlin/src/HAL/STM32/fastio.h | 10 +++++----- Marlin/src/lcd/TFTGLCD/ultralcd_TFTGLCD.cpp | 12 ++++++------ Marlin/src/lcd/menu/menu_advanced.cpp | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Marlin/src/HAL/STM32/fastio.h b/Marlin/src/HAL/STM32/fastio.h index ea28b8f3bfaae..7d02062b53747 100644 --- a/Marlin/src/HAL/STM32/fastio.h +++ b/Marlin/src/HAL/STM32/fastio.h @@ -51,15 +51,15 @@ void FastIO_init(); // Must be called before using fast io macros #if defined(STM32F0xx) || defined(STM32F1xx) || defined(STM32F3xx) || defined(STM32L0xx) || defined(STM32L4xx) #define _WRITE(IO, V) do { \ - if (V) FastIOPortMap[STM_PORT(digitalPinToPinName(IO))]->BSRR = _BV32(STM_PIN(digitalPinToPinName(IO))) ; \ - else FastIOPortMap[STM_PORT(digitalPinToPinName(IO))]->BRR = _BV32(STM_PIN(digitalPinToPinName(IO))) ; \ + if (V) FastIOPortMap[STM_PORT(digitalPin[IO])]->BSRR = _BV32(digitalPinToPinName(IO) & 0x1F) ; \ + else FastIOPortMap[STM_PORT(digitalPin[IO])]->BRR = _BV32(digitalPinToPinName(IO) & 0x1F) ; \ }while(0) #else - #define _WRITE(IO, V) (FastIOPortMap[STM_PORT(digitalPinToPinName(IO))]->BSRR = _BV32(STM_PIN(digitalPinToPinName(IO)) + ((V) ? 0 : 16))) + #define _WRITE(IO, V) (FastIOPortMap[STM_PORT(digitalPin[IO])]->BSRR = _BV32(digitalPinToPinName(IO) + ((V) ? 0 : 16))) #endif -#define _READ(IO) bool(READ_BIT(FastIOPortMap[STM_PORT(digitalPinToPinName(IO))]->IDR, _BV32(STM_PIN(digitalPinToPinName(IO))))) -#define _TOGGLE(IO) (FastIOPortMap[STM_PORT(digitalPinToPinName(IO))]->ODR ^= _BV32(STM_PIN(digitalPinToPinName(IO)))) +#define _READ(IO) bool(READ_BIT(FastIOPortMap[STM_PORT(digitalPin[IO])]->IDR, _BV32(digitalPinToPinName(IO) & 0x1F))) +#define _TOGGLE(IO) (FastIOPortMap[STM_PORT(digitalPin[IO])]->ODR ^= _BV32(digitalPinToPinName(IO) & 0x1F)) #define _GET_MODE(IO) #define _SET_MODE(IO,M) pinMode(IO, M) diff --git a/Marlin/src/lcd/TFTGLCD/ultralcd_TFTGLCD.cpp b/Marlin/src/lcd/TFTGLCD/ultralcd_TFTGLCD.cpp index a66c8e1c8ab81..b5789091dc2fb 100644 --- a/Marlin/src/lcd/TFTGLCD/ultralcd_TFTGLCD.cpp +++ b/Marlin/src/lcd/TFTGLCD/ultralcd_TFTGLCD.cpp @@ -115,7 +115,8 @@ enum Commands { // based on Smoothieware commands GET_LCD_ROW = 0xE0, // for detect panel GET_LCD_COL, // reserved for compatibility with Smoothieware, not used LCD_PUT, // write one line to LCD - INIT_SCREEN = 0xFE, // clear panel buffer + CLR_SCREEN, + INIT_SCREEN = 0xFE // clear panel buffer }; static unsigned char framebuffer[FBSIZE]; @@ -311,7 +312,7 @@ void MarlinUI::init_lcd() { t = 0; #if ENABLED(TFTGLCD_PANEL_SPI) // SPI speed must be less 10MHz - SET_OUTPUT(TFTGLCD_CS); + _SET_OUTPUT(TFTGLCD_CS); WRITE(TFTGLCD_CS, HIGH); spiInit(TERN(__STM32F1__, SPI_QUARTER_SPEED, SPI_FULL_SPEED)); WRITE(TFTGLCD_CS, LOW); @@ -859,14 +860,13 @@ void MarlinUI::draw_status_screen() { void MenuEditItemBase::draw_edit_screen(PGM_P const pstr, 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.setCursor(0, y); + lcd.setCursor(0, MIDDLE_Y); lcd.write(COLOR_EDIT); lcd_put_u8str_P(pstr); if (value != nullptr) { lcd.write(':'); - lcd.setCursor((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 lcd.print(value); lcd.write(' '); lcd.print_line(); diff --git a/Marlin/src/lcd/menu/menu_advanced.cpp b/Marlin/src/lcd/menu/menu_advanced.cpp index efb361f810d97..642d9d84d94f1 100644 --- a/Marlin/src/lcd/menu/menu_advanced.cpp +++ b/Marlin/src/lcd/menu/menu_advanced.cpp @@ -490,7 +490,7 @@ void menu_backlash(); #if ENABLED(PROBE_OFFSET_WIZARD) SUBMENU(MSG_PROBE_WIZARD, goto_probe_offset_wizard); #endif - + END_MENU(); } #endif