mirror of
https://github.com/meshtastic/firmware.git
synced 2025-04-26 18:09:04 +00:00
Autodetect OLED Controller 1306/1106 (#1317)
* Autodetect OLED Controller 1306/1106 and make #define NO_SCREEN work again * fix epaper with autodetect * Try kicking CI - NFC
This commit is contained in:
parent
47524d58d7
commit
cef1614770
@ -40,7 +40,7 @@ build_flags = -Wno-missing-field-initializers
|
|||||||
monitor_speed = 921600
|
monitor_speed = 921600
|
||||||
|
|
||||||
lib_deps =
|
lib_deps =
|
||||||
https://github.com/meshtastic/esp8266-oled-ssd1306.git#d90231dedbb2f52bd7a32fb8ed8edec52cf4a8cb ; ESP8266_SSD1306
|
https://github.com/meshtastic/esp8266-oled-ssd1306.git ; ESP8266_SSD1306
|
||||||
mathertel/OneButton@^2.0.3 ; OneButton library for non-blocking button debounce
|
mathertel/OneButton@^2.0.3 ; OneButton library for non-blocking button debounce
|
||||||
1202 ; CRC32, explicitly needed because dependency is missing in the ble ota update lib
|
1202 ; CRC32, explicitly needed because dependency is missing in the ble ota update lib
|
||||||
https://github.com/meshtastic/arduino-fsm.git
|
https://github.com/meshtastic/arduino-fsm.git
|
||||||
|
@ -3,6 +3,27 @@
|
|||||||
#include <Wire.h>
|
#include <Wire.h>
|
||||||
|
|
||||||
#ifndef NO_WIRE
|
#ifndef NO_WIRE
|
||||||
|
uint8_t oled_probe(byte addr)
|
||||||
|
{
|
||||||
|
uint8_t r = 0;
|
||||||
|
uint8_t o_probe = 0;
|
||||||
|
Wire.beginTransmission(addr);
|
||||||
|
Wire.write(0x00);
|
||||||
|
Wire.endTransmission();
|
||||||
|
Wire.requestFrom((int)addr, 1);
|
||||||
|
if (Wire.available()) {
|
||||||
|
r = Wire.read();
|
||||||
|
}
|
||||||
|
r &= 0x0f;
|
||||||
|
if (r == 0x08) {
|
||||||
|
o_probe = 2; // SH1106
|
||||||
|
} else if ( r == 0x06 || r == 0x07) {
|
||||||
|
o_probe = 1; // SSD1306
|
||||||
|
}
|
||||||
|
DEBUG_MSG("0x%x subtype probed\n", r);
|
||||||
|
return o_probe;
|
||||||
|
}
|
||||||
|
|
||||||
void scanI2Cdevice(void)
|
void scanI2Cdevice(void)
|
||||||
{
|
{
|
||||||
byte err, addr;
|
byte err, addr;
|
||||||
@ -17,7 +38,14 @@ void scanI2Cdevice(void)
|
|||||||
|
|
||||||
if (addr == SSD1306_ADDRESS) {
|
if (addr == SSD1306_ADDRESS) {
|
||||||
screen_found = addr;
|
screen_found = addr;
|
||||||
|
screen_model = oled_probe(addr);
|
||||||
|
if (screen_model == 1){
|
||||||
DEBUG_MSG("ssd1306 display found\n");
|
DEBUG_MSG("ssd1306 display found\n");
|
||||||
|
} else if (screen_model == 2){
|
||||||
|
DEBUG_MSG("sh1106 display found\n");
|
||||||
|
} else {
|
||||||
|
DEBUG_MSG("unknown display found\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (addr == ST7567_ADDRESS) {
|
if (addr == ST7567_ADDRESS) {
|
||||||
screen_found = addr;
|
screen_found = addr;
|
||||||
|
@ -131,6 +131,11 @@ void EInkDisplay::sendCommand(uint8_t com)
|
|||||||
// Drop all commands to device (we just update the buffer)
|
// Drop all commands to device (we just update the buffer)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EInkDisplay::setDetected(uint8_t detected)
|
||||||
|
{
|
||||||
|
(void)detected;
|
||||||
|
}
|
||||||
|
|
||||||
// Connect to the display
|
// Connect to the display
|
||||||
bool EInkDisplay::connect()
|
bool EInkDisplay::connect()
|
||||||
{
|
{
|
||||||
|
@ -34,6 +34,12 @@ class EInkDisplay : public OLEDDisplay
|
|||||||
*/
|
*/
|
||||||
bool forceDisplay(uint32_t msecLimit = 1000);
|
bool forceDisplay(uint32_t msecLimit = 1000);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* shim to make the abstraction happy
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void setDetected(uint8_t detected);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// the header size of the buffer used, e.g. for the SPI command header
|
// the header size of the buffer used, e.g. for the SPI command header
|
||||||
virtual int getBufferOffset(void) override { return 0; }
|
virtual int getBufferOffset(void) override { return 0; }
|
||||||
|
@ -765,6 +765,10 @@ void Screen::setup()
|
|||||||
// is never found when probing i2c and therefore we don't call setup and never want to do (invalid) accesses to this device.
|
// is never found when probing i2c and therefore we don't call setup and never want to do (invalid) accesses to this device.
|
||||||
useDisplay = true;
|
useDisplay = true;
|
||||||
|
|
||||||
|
#ifdef AutoOLEDWire_h
|
||||||
|
dispdev.setDetected(screen_model);
|
||||||
|
#endif
|
||||||
|
|
||||||
// I think this is not needed - redundant with ui.init
|
// I think this is not needed - redundant with ui.init
|
||||||
// dispdev.resetOrientation();
|
// dispdev.resetOrientation();
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@ class Screen
|
|||||||
void print(const char*){}
|
void print(const char*){}
|
||||||
void adjustBrightness(){}
|
void adjustBrightness(){}
|
||||||
void doDeepSleep() {}
|
void doDeepSleep() {}
|
||||||
|
void forceDisplay() {}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -24,12 +25,11 @@ class Screen
|
|||||||
|
|
||||||
#include "../configuration.h"
|
#include "../configuration.h"
|
||||||
|
|
||||||
#ifdef USE_SH1106
|
#ifdef USE_ST7567
|
||||||
#include <SH1106Wire.h>
|
|
||||||
#elif defined(USE_ST7567)
|
|
||||||
#include <ST7567Wire.h>
|
#include <ST7567Wire.h>
|
||||||
#else
|
#else
|
||||||
#include <SSD1306Wire.h>
|
// the SH1106/SSD1306 variant is auto-detected
|
||||||
|
#include <AutoOLEDWire.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "EInkDisplay2.h"
|
#include "EInkDisplay2.h"
|
||||||
@ -301,12 +301,10 @@ class Screen : public concurrency::OSThread
|
|||||||
TFTDisplay dispdev;
|
TFTDisplay dispdev;
|
||||||
#elif defined(HAS_EINK)
|
#elif defined(HAS_EINK)
|
||||||
EInkDisplay dispdev;
|
EInkDisplay dispdev;
|
||||||
#elif defined(USE_SH1106)
|
|
||||||
SH1106Wire dispdev;
|
|
||||||
#elif defined(USE_ST7567)
|
#elif defined(USE_ST7567)
|
||||||
ST7567Wire dispdev;
|
ST7567Wire dispdev;
|
||||||
#else
|
#else
|
||||||
SSD1306Wire dispdev;
|
AutoOLEDWire dispdev;
|
||||||
#endif
|
#endif
|
||||||
/// UI helper for rendering to frames and switching between them
|
/// UI helper for rendering to frames and switching between them
|
||||||
OLEDDisplayUi ui;
|
OLEDDisplayUi ui;
|
||||||
|
@ -70,6 +70,7 @@ meshtastic::NodeStatus *nodeStatus = new meshtastic::NodeStatus();
|
|||||||
|
|
||||||
/// The I2C address of our display (if found)
|
/// The I2C address of our display (if found)
|
||||||
uint8_t screen_found;
|
uint8_t screen_found;
|
||||||
|
uint8_t screen_model;
|
||||||
|
|
||||||
bool axp192_found;
|
bool axp192_found;
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#include "graphics/Screen.h"
|
#include "graphics/Screen.h"
|
||||||
|
|
||||||
extern uint8_t screen_found;
|
extern uint8_t screen_found;
|
||||||
|
extern uint8_t screen_model;
|
||||||
extern bool axp192_found;
|
extern bool axp192_found;
|
||||||
extern bool isCharging;
|
extern bool isCharging;
|
||||||
extern bool isUSBPowered;
|
extern bool isUSBPowered;
|
||||||
|
Loading…
Reference in New Issue
Block a user