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 kpishere committed Feb 19, 2021
1 parent ec0ffc2 commit 8e54aa4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
10 changes: 5 additions & 5 deletions Marlin/src/HAL/STM32/fastio.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
12 changes: 6 additions & 6 deletions Marlin/src/lcd/TFTGLCD/ultralcd_TFTGLCD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/lcd/menu/menu_advanced.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ void menu_backlash();
#if ENABLED(PROBE_OFFSET_WIZARD)
SUBMENU(MSG_PROBE_WIZARD, goto_probe_offset_wizard);
#endif

END_MENU();
}
#endif
Expand Down

0 comments on commit 8e54aa4

Please sign in to comment.