diff --git a/SmartHandController.ino b/SmartHandController.ino index dcab405..b50dc2a 100644 --- a/SmartHandController.ino +++ b/SmartHandController.ino @@ -76,8 +76,10 @@ const KeyPad::Pin pins[7]= { void setup(void) { // start debug serial port - if (DEBUG == ON || DEBUG == VERBOSE) SERIAL_DEBUG.begin(SERIAL_DEBUG_BAUD); - delay(2000); + if (DEBUG == ON || DEBUG == VERBOSE) { + SERIAL_DEBUG.begin(SERIAL_DEBUG_BAUD); + delay(2000); + } VF("MSG: Smart Hand Controller "); V(FirmwareVersionMajor); V("."); V(FirmwareVersionMinor); VL(FirmwareVersionPatch); VF("MSG: MCU = "); VLF(MCU_STR); diff --git a/src/pinmaps/Pins.Esp32.h b/src/pinmaps/Pins.Esp32.h index 68dc593..244dcab 100644 --- a/src/pinmaps/Pins.Esp32.h +++ b/src/pinmaps/Pins.Esp32.h @@ -66,6 +66,18 @@ #endif #ifndef DISPLAY_RESET_PIN - #define DISPLAY_RESET_PIN 16 // GPIO16 used to reset some displays, i.e. the SSD1309 + #define DISPLAY_RESET_PIN 16 // GPIO16 used to reset some displays, i.e. the SSD1309 + #endif + #ifndef DISPLAY_DC_PIN + #define DISPLAY_DC_PIN 15 // SPI display data/clock pin + #endif + #ifndef DISPLAY_SS_PIN + #define DISPLAY_SS_PIN 4 // SPI display slave select pin + #endif + #ifndef DISPLAY_MOSI_PIN + #define DISPLAY_MOSI_PIN 21 // SPI display master out slave in pin (ignored for hardware SPI connections) + #endif + #ifndef DISPLAY_SCK_PIN + #define DISPLAY_SCK_PIN 22 // SPI display clock pin for (ignored for hardware SPI connections) #endif #endif diff --git a/src/userInterface/UserInterface.cpp b/src/userInterface/UserInterface.cpp index a77c776..78f5859 100644 --- a/src/userInterface/UserInterface.cpp +++ b/src/userInterface/UserInterface.cpp @@ -119,8 +119,8 @@ void UI::init(const char version[], const KeyPad::Pin pins[7], const int SerialB pinMode(B_PIN1, INPUT_PULLUP); pinMode(B_PIN3, INPUT_PULLUP); delay(100); - int thresholdEW = analogRead(B_PIN1); - int thresholdNS = analogRead(B_PIN3); + int thresholdEW = analogRead(B_PIN1) >> 2; + int thresholdNS = analogRead(B_PIN3) >> 2; keyPad.init(pins, thresholdNS, thresholdEW); #else keyPad.init(pins, 0, 0); @@ -146,13 +146,12 @@ void UI::init(const char version[], const KeyPad::Pin pins[7], const int SerialB #endif //choose a 128x64 display supported by U8G2lib (if not listed below there are many many others in u8g2 library example Sketches) - delay(500); if (model == OLED_SH1106) display = new U8G2_EXT_SH1106_128X64_NONAME_1_HW_I2C(U8G2_R0); else - if (model == OLED_SH1106_4W_SW_SPI) display = new U8G2_EXT_SH1106_128X64_NONAME_1_4W_SW_SPI(U8G2_R0); else - if (model == OLED_SH1106_4W_HW_SPI) display = new U8G2_EXT_SH1106_128X64_NONAME_1_4W_HW_SPI(U8G2_R0); + if (model == OLED_SH1106_4W_SW_SPI) display = new U8G2_EXT_SH1106_128X64_NONAME_1_4W_SW_SPI(U8G2_R0, DISPLAY_SCK_PIN, DISPLAY_MOSI_PIN, DISPLAY_SS_PIN, DISPLAY_DC_PIN, DISPLAY_RESET_PIN); else + if (model == OLED_SH1106_4W_HW_SPI) display = new U8G2_EXT_SH1106_128X64_NONAME_1_4W_HW_SPI(U8G2_R0); else if (model == OLED_SSD1306) display = new U8G2_EXT_SSD1306_128X64_NONAME_F_HW_I2C(U8G2_R0); else if (model == OLED_SSD1309) display = new U8G2_EXT_SSD1309_128X64_NONAME_F_HW_I2C(U8G2_R0); else - if (model == OLED_SSD1309_4W_SW_SPI) display = new U8G2_EXT_SSD1309_128X64_NONAME_F_4W_SW_SPI(U8G2_R0); else + if (model == OLED_SSD1309_4W_SW_SPI) display = new U8G2_EXT_SSD1309_128X64_NONAME_F_4W_SW_SPI(U8G2_R0, DISPLAY_SCK_PIN, DISPLAY_MOSI_PIN, DISPLAY_SS_PIN, DISPLAY_DC_PIN, DISPLAY_RESET_PIN); else if (model == OLED_SSD1309_4W_HW_SPI) display = new U8G2_EXT_SSD1309_128X64_NONAME_F_4W_HW_SPI(U8G2_R0); display->begin();