Fix buzzer notifications, unread tracking, OLED dimming; remove dead code

- MyMesh: notify() now always fires for channel/contact messages regardless
  of serial connection; called after addChannelMsg so channel index is set
- ChannelHist: fix unread watermark direction (histEntry is newest-first,
  index 0=newest); counter now decrements correctly as user reads messages
- ChannelHist: reset unread to 0 after sending (user is active in channel)
- SH1106Display: add pre-charge register (0xD9) to setBrightness for wider
  dimming range; re-apply contrast+precharge in turnOn(); tune curve
- UITask: remove MsgPreviewScreen dead code (~180 lines, never shown)
- UITask: fix strcpy→snprintf in showAlert()

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Jakub
2026-05-12 08:19:27 +02:00
parent 40f470ebf2
commit 861a65d4b1
5 changed files with 33 additions and 207 deletions

View File

@@ -17,6 +17,9 @@ bool SH1106Display::begin()
void SH1106Display::turnOn()
{
display.oled_command(SH110X_DISPLAYON);
uint8_t pre[] = { 0xD9, _precharge };
display.oled_commandList(pre, 2);
display.setContrast(_contrast);
_isOn = true;
}
@@ -87,11 +90,17 @@ uint16_t SH1106Display::getTextWidth(const char *str)
void SH1106Display::setBrightness(uint8_t level)
{
// OLED contrast is highly non-linear: most perceptible change is in the low range.
// Values are tuned so each step looks visually distinct.
static const uint8_t contrast_values[] = { 8, 30, 80, 160, 255 };
uint8_t contrast = contrast_values[level < 5 ? level : 4];
display.setContrast(contrast);
// Contrast alone has limited effect on some OLED panels; combining with
// pre-charge period (0xD9) gives a wider perceptible dimming range.
// Pre-charge 0x11 = phase1=1,phase2=1 (minimum drive); 0x1F = default.
static const uint8_t contrast_values[] = { 0, 25, 60, 150, 255 };
static const uint8_t precharge_values[] = { 0x11, 0x15, 0x1F, 0x1F, 0x1F };
uint8_t idx = level < 5 ? level : 4;
_contrast = contrast_values[idx];
_precharge = precharge_values[idx];
uint8_t pre[] = { 0xD9, _precharge };
display.oled_commandList(pre, 2);
display.setContrast(_contrast);
}
void SH1106Display::endFrame()

View File

@@ -19,11 +19,13 @@ class SH1106Display : public DisplayDriver
Adafruit_SH1106G display;
bool _isOn;
uint8_t _color;
uint8_t _contrast;
uint8_t _precharge;
bool i2c_probe(TwoWire &wire, uint8_t addr);
public:
SH1106Display() : DisplayDriver(128, 64), display(128, 64, &Wire, PIN_OLED_RESET) { _isOn = false; }
SH1106Display() : DisplayDriver(128, 64), display(128, 64, &Wire, PIN_OLED_RESET) { _isOn = false; _contrast = 255; _precharge = 0x1F; }
bool begin();
bool isOn() override { return _isOn; }