From 6d0904c96c3a490d09962016cb5bc72c0767ef24 Mon Sep 17 00:00:00 2001 From: fvanroie Date: Fri, 12 Jun 2020 13:32:55 +0200 Subject: [PATCH] Move getPinName to gpioName --- src/hasp_tft.cpp | 48 ++---------------------------------------------- 1 file changed, 2 insertions(+), 46 deletions(-) diff --git a/src/hasp_tft.cpp b/src/hasp_tft.cpp index 8453042e..20b61278 100644 --- a/src/hasp_tft.cpp +++ b/src/hasp_tft.cpp @@ -7,13 +7,12 @@ #include "hasp_tft.h" #include "hasp_hal.h" +#include "hasp_gpio.h" // PinNames #if defined(ARDUINO_ARCH_ESP8266) ADC_MODE(ADC_VCC); // tftShowConfig measures the voltage on the pin #endif -int8_t getPinName(int8_t pin); - void tftSetup(TFT_eSPI & tft) { tftShowConfig(tft); @@ -41,7 +40,7 @@ void tftPinInfo(const __FlashStringHelper * pinfunction, int8_t pin) { if(pin != -1) { char buffer[64]; - snprintf_P(buffer, sizeof(buffer), PSTR("TFT: %-11s: D%02d (GPIO %02d)"), pinfunction, getPinName(pin), pin); + snprintf_P(buffer, sizeof(buffer), PSTR("TFT: %-11s: %s (GPIO %02d)"), pinfunction, gpioName(pin).c_str(), pin); Log.verbose(buffer); } } @@ -133,47 +132,4 @@ void tftShowConfig(TFT_eSPI & tft) } } -// Get pin name for ESP8266 -int8_t getPinName(int8_t pin) -{ -// For ESP32 and STM32 pin labels on boards use the GPIO number -#ifndef ARDUINO_ARCH_ESP8266 - return pin; -#endif - - // For ESP8266 the pin labels are not the same as the GPIO number - // These are for the NodeMCU pin definitions: - // GPIO Dxx - switch(pin) { - case 16: - return 0; - case 5: - return 1; - case 4: - return 2; - case 0: - return 3; - case 2: - return 4; - case 14: - return 5; - case 12: - return 6; - case 13: - return 7; - case 15: - return 8; - case 3: - return 9; - case 1: - return 10; - case 9: - return 11; - case 10: - return 12; - default: - return -1; // Invalid pin - } -} - #endif