mirror of
https://github.com/MarekZegare4/MeshCore-Solo.git
synced 2026-07-26 14:58:12 +00:00
- Context menus (PopupMenu, Nearby/QuickMsg call sites) go back to centring on screen; the header's discoverable-menu glyph stays, but dropping the popup out of its corner looked bad on some screens. - Unread pill badge digit wasn't centred: Adafruit_GFX's classic built-in font (SH1106/SSD1306) always pads a measured string by one trailing advance column regardless of the glyph drawn, so centring on the raw width left 1px more slack on the right than the left. New DisplayDriver:: textWidthTrailingGap() (0 by default) corrects for it on those two backends. - On-device room Logout: mirrors the app's CMD_LOGOUT (drops keep-alive tracking, forgets the saved password) so a room can be deliberately signed out of from the Room options menu, not just re-logged-in. Not build-verified — no PlatformIO toolchain available this session.
62 lines
1.9 KiB
C++
62 lines
1.9 KiB
C++
#pragma once
|
|
|
|
#include "DisplayDriver.h"
|
|
#include <Wire.h>
|
|
#include <Adafruit_GFX.h>
|
|
#define SSD1306_NO_SPLASH
|
|
#include <Adafruit_SSD1306.h>
|
|
#include <helpers/RefCountedDigitalPin.h>
|
|
|
|
#ifndef PIN_OLED_RESET
|
|
#define PIN_OLED_RESET 21 // Reset pin # (or -1 if sharing Arduino reset pin)
|
|
#endif
|
|
|
|
#ifndef DISPLAY_ADDRESS
|
|
#define DISPLAY_ADDRESS 0x3C
|
|
#endif
|
|
|
|
class SSD1306Display : public DisplayDriver {
|
|
Adafruit_SSD1306 display;
|
|
bool _isOn;
|
|
uint8_t _color;
|
|
int _text_sz = 1;
|
|
RefCountedDigitalPin* _peripher_power;
|
|
|
|
bool i2c_probe(TwoWire& wire, uint8_t addr);
|
|
public:
|
|
SSD1306Display(RefCountedDigitalPin* peripher_power=NULL) : DisplayDriver(128, 64),
|
|
display(128, 64, &Wire, PIN_OLED_RESET),
|
|
_peripher_power(peripher_power)
|
|
{
|
|
_isOn = false;
|
|
}
|
|
bool begin();
|
|
|
|
int getCharWidth() const override { return 6 * _text_sz; }
|
|
int getLineHeight() const override { return 8 * _text_sz; }
|
|
// Classic Adafruit_GFX built-in font pads every measured string by one
|
|
// trailing advance column (see DisplayDriver::textWidthTrailingGap()).
|
|
int textWidthTrailingGap() const override { return 1; }
|
|
|
|
bool isOn() override { return _isOn; }
|
|
void turnOn() override;
|
|
void turnOff() override;
|
|
void clear() override;
|
|
void startFrame(Color bkg = DARK) override;
|
|
void setTextSize(int sz) override;
|
|
void setColor(Color c) override;
|
|
void setCursor(int x, int y) override;
|
|
void print(const char* str) override;
|
|
void fillRect(int x, int y, int w, int h) override;
|
|
void drawRect(int x, int y, int w, int h) override;
|
|
void drawXbm(int x, int y, const uint8_t* bits, int w, int h) override;
|
|
uint16_t getTextWidth(const char* str) override;
|
|
void endFrame() override;
|
|
|
|
#ifdef ENABLE_SCREENSHOT
|
|
const uint8_t* getBuffer() override { return display.getBuffer(); }
|
|
uint16_t getBufferSize() override { return (uint16_t)((width() * height()) / 8); }
|
|
uint8_t getDisplayType() override { return 0; }
|
|
#endif
|
|
};
|