Skip to content

Commit

Permalink
Fixes for TFTGLCD Panel, FastIO (#19614)
Browse files Browse the repository at this point in the history
  • Loading branch information
Serhiy-K authored and thinkyhead committed Oct 10, 2020
1 parent 406f836 commit 6fdaaf3
Show file tree
Hide file tree
Showing 12 changed files with 112 additions and 162 deletions.
18 changes: 9 additions & 9 deletions Marlin/src/HAL/STM32/fastio.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,19 @@ 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(digitalPin[IO])]->BSRR = _BV32(STM_PIN(digitalPin[IO])) ; \
else FastIOPortMap[STM_PORT(digitalPin[IO])]->BRR = _BV32(STM_PIN(digitalPin[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(digitalPin[IO])]->BSRR = _BV32(STM_PIN(digitalPin[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(digitalPin[IO])]->IDR, _BV32(STM_PIN(digitalPin[IO]))))
#define _TOGGLE(IO) (FastIOPortMap[STM_PORT(digitalPin[IO])]->ODR ^= _BV32(STM_PIN(digitalPin[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)
#define _SET_OUTPUT(IO) pinMode(IO, OUTPUT) /*!< Output Push Pull Mode & GPIO_NOPULL */
#define _SET_OUTPUT(IO) pinMode(IO, OUTPUT) //!< Output Push Pull Mode & GPIO_NOPULL
#define _SET_OUTPUT_OD(IO) pinMode(IO, OUTPUT_OPEN_DRAIN)

#define WRITE(IO,V) _WRITE(IO,V)
Expand All @@ -73,9 +73,9 @@ void FastIO_init(); // Must be called before using fast io macros
#define OUT_WRITE(IO,V) do{ _SET_OUTPUT(IO); WRITE(IO,V); }while(0)
#define OUT_WRITE_OD(IO,V) do{ _SET_OUTPUT_OD(IO); WRITE(IO,V); }while(0)

#define SET_INPUT(IO) _SET_MODE(IO, INPUT) /*!< Input Floating Mode */
#define SET_INPUT_PULLUP(IO) _SET_MODE(IO, INPUT_PULLUP) /*!< Input with Pull-up activation */
#define SET_INPUT_PULLDOWN(IO) _SET_MODE(IO, INPUT_PULLDOWN) /*!< Input with Pull-down activation */
#define SET_INPUT(IO) _SET_MODE(IO, INPUT) //!< Input Floating Mode
#define SET_INPUT_PULLUP(IO) _SET_MODE(IO, INPUT_PULLUP) //!< Input with Pull-up activation
#define SET_INPUT_PULLDOWN(IO) _SET_MODE(IO, INPUT_PULLDOWN) //!< Input with Pull-down activation
#define SET_OUTPUT(IO) OUT_WRITE(IO, LOW)
#define SET_PWM(IO) _SET_MODE(IO, PWM)

Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/core/language.h
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@
#define LCD_STR_C STR_C
#define LCD_STR_E STR_E

#if HAS_MARLINUI_HD44780
#if EITHER(HAS_MARLINUI_HD44780, IS_TFTGLCD_PANEL)

// Custom characters defined in the first 8 characters of the LCD
#define LCD_STR_BEDTEMP "\x00" // Print only as a char. This will have 'unexpected' results when used in a string!
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/core/utility.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class restorer {
inline void restore() { ref_ = val_; }
};

#define REMEMBER(N,X,V...) restorer<typeof(X)> restorer_##N(X, ##V)
#define REMEMBER(N,X,V...) restorer<__typeof__(X)> restorer_##N(X, ##V)
#define RESTORE(N) restorer_##N.restore()

// Converts from an uint8_t in the range of 0-255 to an uint8_t
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/inc/Conditionals_LCD.h
Original file line number Diff line number Diff line change
Expand Up @@ -226,9 +226,9 @@
#define LCD_PROGRESS_BAR
#endif
#if ENABLED(TFTGLCD_PANEL_I2C)
#define LCD_USE_I2C_BUZZER // Enable buzzer on LCD for I2C and SPI buses (LiquidTWI2 not required)
#define LCD_I2C_ADDRESS 0x27 // Must be equal to panel's I2C slave addres
#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
#define STD_ENCODER_STEPS_PER_MENU_ITEM 1
#define LCD_WIDTH 20 // 20 or 24 chars in line
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/inc/Conditionals_post.h
Original file line number Diff line number Diff line change
Expand Up @@ -2457,7 +2457,7 @@
/**
* Buzzer/Speaker
*/
#if PIN_EXISTS(BEEPER) || ANY(LCD_USE_I2C_BUZZER, PCA9632_BUZZER, IS_TFTGLCD_PANEL)
#if PIN_EXISTS(BEEPER) || ANY(LCD_USE_I2C_BUZZER, PCA9632_BUZZER)
#define HAS_BUZZER 1
#if PIN_EXISTS(BEEPER)
#define USE_BEEPER 1
Expand Down
Loading

0 comments on commit 6fdaaf3

Please sign in to comment.