From 23beb50a1ef7f387a6e748e99eae4cfdf005e22f Mon Sep 17 00:00:00 2001 From: Uladzimir Bely Date: Sun, 19 Apr 2026 07:12:29 +0300 Subject: [PATCH 1/4] Fix analog joystik. After commits 8d8b640 and e07a949, analogRead() returns values in the range 0..4095, since PushButton.cpp continues working in 0..1023. This causes incorrect (too big) thresholdNS and thresholdEW values and joystick doesn't work (stucks in one direction). Fixes issue #24. --- src/userInterface/UserInterface.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/userInterface/UserInterface.cpp b/src/userInterface/UserInterface.cpp index a77c776..274e372 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); From dc248bc048b977b7bdb92d718d76f93086be2bc8 Mon Sep 17 00:00:00 2001 From: Uladzimir Bely Date: Sun, 19 Apr 2026 07:19:38 +0300 Subject: [PATCH 2/4] Remove useless 2s delay when not in debug mode. Most probably, this delay is usefull just when debugging. But in normal case it just prolongues SHC boot time (and first picture on the screen). Leave it only if debug is ON. --- SmartHandController.ino | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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); From 7c570c0b3224f4a08d609f15c285eaa79ae9ce47 Mon Sep 17 00:00:00 2001 From: Uladzimir Bely Date: Sun, 19 Apr 2026 07:52:54 +0300 Subject: [PATCH 3/4] Speedup OLED initialization Remove useless delay before display initialization. --- src/userInterface/UserInterface.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/userInterface/UserInterface.cpp b/src/userInterface/UserInterface.cpp index 274e372..d202500 100644 --- a/src/userInterface/UserInterface.cpp +++ b/src/userInterface/UserInterface.cpp @@ -146,7 +146,6 @@ 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); From 86c3cb79f535fbe2eb9a8940e1b0eb77b4322e5e Mon Sep 17 00:00:00 2001 From: Uladzimir Bely Date: Mon, 27 Apr 2026 11:59:38 +0300 Subject: [PATCH 4/4] ESP32: Improve software SPI display support ESP32 has enough free pins to specify software SPI pinout. --- src/pinmaps/Pins.Esp32.h | 14 +++++++++++++- src/userInterface/UserInterface.cpp | 6 +++--- 2 files changed, 16 insertions(+), 4 deletions(-) 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 d202500..78f5859 100644 --- a/src/userInterface/UserInterface.cpp +++ b/src/userInterface/UserInterface.cpp @@ -147,11 +147,11 @@ void UI::init(const char version[], const KeyPad::Pin pins[7], const int SerialB //choose a 128x64 display supported by U8G2lib (if not listed below there are many many others in u8g2 library example Sketches) 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();