From 136657c8464c3e3c1c02dff5c0c810cd1435c7c3 Mon Sep 17 00:00:00 2001 From: Thomas Basler Date: Sat, 8 Feb 2025 00:56:22 +0100 Subject: [PATCH] Change datatype for display pins from uint8_t to gpio_num_t This also changes the behavior of undefined pins... They are now introduced as -1 (255 is still compatible) --- include/PinMapping.h | 8 ++++---- src/Display_Graphic.cpp | 6 +++++- src/PinMapping.cpp | 8 ++++---- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/include/PinMapping.h b/include/PinMapping.h index 5ed64c40..aa5096b0 100644 --- a/include/PinMapping.h +++ b/include/PinMapping.h @@ -45,10 +45,10 @@ struct PinMapping_t { #endif uint8_t display_type; - uint8_t display_data; - uint8_t display_clk; - uint8_t display_cs; - uint8_t display_reset; + gpio_num_t display_data; + gpio_num_t display_clk; + gpio_num_t display_cs; + gpio_num_t display_reset; gpio_num_t led[PINMAPPING_LED_COUNT]; }; diff --git a/src/Display_Graphic.cpp b/src/Display_Graphic.cpp index f2126d39..80214003 100644 --- a/src/Display_Graphic.cpp +++ b/src/Display_Graphic.cpp @@ -53,7 +53,11 @@ void DisplayGraphicClass::init(Scheduler& scheduler) _display_type = static_cast(pin.display_type); if (isValidDisplay()) { auto constructor = display_types[_display_type]; - _display = constructor(pin.display_reset, pin.display_clk, pin.display_data, pin.display_cs); + _display = constructor( + pin.display_reset == GPIO_NUM_NC ? 255U : static_cast(pin.display_reset), + pin.display_clk == GPIO_NUM_NC ? 255U : static_cast(pin.display_clk), + pin.display_data == GPIO_NUM_NC ? 255U : static_cast(pin.display_data), + pin.display_cs == GPIO_NUM_NC ? 255U : static_cast(pin.display_cs)); if (_display_type == DisplayType_t::ST7567_GM12864I_59N) { _display->setI2CAddress(0x3F << 1); } diff --git a/src/PinMapping.cpp b/src/PinMapping.cpp index 71f1d9fa..9fab3332 100644 --- a/src/PinMapping.cpp +++ b/src/PinMapping.cpp @@ -14,19 +14,19 @@ #endif #ifndef DISPLAY_DATA -#define DISPLAY_DATA 255U +#define DISPLAY_DATA GPIO_NUM_NC #endif #ifndef DISPLAY_CLK -#define DISPLAY_CLK 255U +#define DISPLAY_CLK GPIO_NUM_NC #endif #ifndef DISPLAY_CS -#define DISPLAY_CS 255U +#define DISPLAY_CS GPIO_NUM_NC #endif #ifndef DISPLAY_RESET -#define DISPLAY_RESET 255U +#define DISPLAY_RESET GPIO_NUM_NC #endif #ifndef LED0