From 1c53e3b1fb8dea4465ac6ff79e73bb9317752d81 Mon Sep 17 00:00:00 2001 From: Tuomas Kuosmanen Date: Wed, 31 Jan 2024 00:01:49 +0200 Subject: [PATCH] added setContrast method for the oled --- GNC255/GNC255.cpp | 10 +++++++++- GNC255/GNC255.h | 2 ++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/GNC255/GNC255.cpp b/GNC255/GNC255.cpp index ddb2af0..c81aed8 100644 --- a/GNC255/GNC255.cpp +++ b/GNC255/GNC255.cpp @@ -110,6 +110,9 @@ void GNC255::set(int16_t messageID, const char *data) case 5: // set COM/NAV mode setMode(strcmp(data, "0") == 0); break; + case 6: // set contrast (brightness) of OLED + setContrast(atoi(data)); + break; default: break; } @@ -164,4 +167,9 @@ void GNC255::_renderLabel(const char *text, Label label, Position offset, bool u _oledDisplay->print(text); if (update) _oledDisplay->sendBuffer(); -} \ No newline at end of file +} + +void GNC255::setContrast(uint8_t displayContrast) +{ + _oledDisplay->setContrast(displayContrast); +} diff --git a/GNC255/GNC255.h b/GNC255/GNC255.h index f197f45..00a9888 100644 --- a/GNC255/GNC255.h +++ b/GNC255/GNC255.h @@ -44,6 +44,7 @@ class GNC255 bool _hasChanged; char activeFrequency[8] = "123.456"; char standbyFrequency[8] = "123.456"; + uint8_t displayContrast = 32; void _update(); void _stop(); @@ -53,4 +54,5 @@ class GNC255 void updateActiveLabel(const char *frequency); void updateStandbyLabel(const char *frequency); void _renderLabel(const char *text, Label label, Position offset, bool update = false); + void setContrast(uint8_t displayContrast); };