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()