From b081a6da562c88cbe7c1c2efb40fb62ae9dc2407 Mon Sep 17 00:00:00 2001 From: Kevin Hester Date: Fri, 23 Oct 2020 18:00:43 +0800 Subject: [PATCH] ppr1 st7567 lcd kinda works now --- docs/software/nrf52-TODO.md | 8 +++++++- src/configuration.h | 1 + src/graphics/Screen.h | 4 ++++ src/main.cpp | 25 +++++++++++++++---------- src/main.h | 1 - variants/ppr1/variant.h | 1 + 6 files changed, 28 insertions(+), 12 deletions(-) diff --git a/docs/software/nrf52-TODO.md b/docs/software/nrf52-TODO.md index 257862c3b..4fc5d3b70 100644 --- a/docs/software/nrf52-TODO.md +++ b/docs/software/nrf52-TODO.md @@ -5,7 +5,13 @@ ## RAK815 -TODO: +### PPR1 TODO + +* Test GPS +* make ST7567Wire driver less ugly +* leave LCD screen on most of the time (because it needs little power) + +### general nrf52 TODO: - enter SDS state at correct time (to protect battery or loss of phone contact) - show screen on eink when we enter SDS state (with app info and say sleeping) diff --git a/src/configuration.h b/src/configuration.h index 504a7aad8..a810aff1b 100644 --- a/src/configuration.h +++ b/src/configuration.h @@ -139,6 +139,7 @@ along with this program. If not, see . // ----------------------------------------------------------------------------- #define SSD1306_ADDRESS 0x3C +#define ST7567_ADDRESS 0x3F // The SH1106 controller is almost, but not quite, the same as SSD1306 // Define this if you know you have that controller or your "SSD1306" misbehaves. diff --git a/src/graphics/Screen.h b/src/graphics/Screen.h index b2f90e840..056798544 100644 --- a/src/graphics/Screen.h +++ b/src/graphics/Screen.h @@ -6,6 +6,8 @@ #ifdef USE_SH1106 #include +#elif defined(USE_ST7567) +#include #else #include #endif @@ -250,6 +252,8 @@ class Screen : public concurrency::OSThread EInkDisplay dispdev; #elif defined(USE_SH1106) SH1106Wire dispdev; +#elif defined(USE_ST7567) + ST7567Wire dispdev; #else SSD1306Wire dispdev; #endif diff --git a/src/main.cpp b/src/main.cpp index 922e1dd3e..960d42828 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -50,7 +50,9 @@ meshtastic::GPSStatus *gpsStatus = new meshtastic::GPSStatus(); // Global Node status meshtastic::NodeStatus *nodeStatus = new meshtastic::NodeStatus(); -bool ssd1306_found; +/// The I2C address of our display (if found) +uint8_t screen_found; + bool axp192_found; Router *router = NULL; // Users of router don't care what sort of subclass implements that API @@ -72,9 +74,13 @@ void scanI2Cdevice(void) nDevices++; if (addr == SSD1306_ADDRESS) { - ssd1306_found = true; + screen_found = addr; DEBUG_MSG("ssd1306 display found\n"); } + if (addr == ST7567_ADDRESS) { + screen_found = addr; + DEBUG_MSG("st7567 display found\n"); + } #ifdef AXP192_SLAVE_ADDRESS if (addr == AXP192_SLAVE_ADDRESS) { axp192_found = true; @@ -247,7 +253,7 @@ void setup() #endif #ifdef PIN_LCD_RESET - // FIXME - move this someplace better + // FIXME - move this someplace better, LCD is at address 0x3F pinMode(PIN_LCD_RESET, OUTPUT); digitalWrite(PIN_LCD_RESET, 0); delay(20); @@ -270,7 +276,7 @@ void setup() #ifndef NO_ESP32 // Don't init display if we don't have one or we are waking headless due to a timer event if (wakeCause == ESP_SLEEP_WAKEUP_TIMER) - ssd1306_found = false; // forget we even have the hardware + screen_found = 0; // forget we even have the hardware esp32Setup(); #endif @@ -296,11 +302,11 @@ void setup() #endif // Initialize the screen first so we can show the logo while we start up everything else. - screen = new graphics::Screen(SSD1306_ADDRESS); + screen = new graphics::Screen(screen_found); readFromRTC(); // read the main CPU RTC at first (in case we can't get GPS time) -// If we don't have bidirectional comms, we can't even try talking to UBLOX + // If we don't have bidirectional comms, we can't even try talking to UBLOX UBloxGPS *ublox = NULL; #ifdef GPS_TX_PIN // Init GPS - first try ublox @@ -332,7 +338,7 @@ void setup() gpsStatus->observe(&gps->newStatus); else DEBUG_MSG("Warning: No GPS found - running without GPS\n"); - + nodeStatus->observe(&nodeDB.newStatus); service.init(); @@ -342,11 +348,11 @@ void setup() #if defined(ST7735_CS) || defined(HAS_EINK) screen->setup(); #else - if (ssd1306_found) + if (screen_found) screen->setup(); #endif - screen->print("Started...\n"); + screen->print("Started...\n"); // We have now loaded our saved preferences from flash @@ -401,7 +407,6 @@ void setup() // Initialize Wifi initWifi(); - if (!rIf) recordCriticalError(ErrNoRadio); diff --git a/src/main.h b/src/main.h index bb2635188..edb50d0d7 100644 --- a/src/main.h +++ b/src/main.h @@ -6,7 +6,6 @@ #include "graphics/Screen.h" extern bool axp192_found; -extern bool ssd1306_found; extern bool isCharging; extern bool isUSBPowered; diff --git a/variants/ppr1/variant.h b/variants/ppr1/variant.h index e0ca6ec19..b3a3e1b8e 100644 --- a/variants/ppr1/variant.h +++ b/variants/ppr1/variant.h @@ -117,6 +117,7 @@ static const uint8_t AREF = PIN_AREF; // LCD #define PIN_LCD_RESET 23 // active low, pulse low for 20ms at boot +#define USE_ST7567 /* * SPI Interfaces