1
0
forked from me/IronOS

Contrast -> Brightness

As it makes a little more sense in a 1 bit display
This commit is contained in:
Ben V. Brown
2021-09-12 19:14:45 +10:00
parent 87a96bcff7
commit 4b2f350b35
37 changed files with 76 additions and 69 deletions

View File

@@ -202,8 +202,8 @@
"text2": ["Език:", " BG Български"], "text2": ["Език:", " BG Български"],
"desc": "" "desc": ""
}, },
"Contrast": { "Brightness": {
"text2": ["Screen", "Contrast"], "text2": ["Screen", "Brightness"],
"desc": "Adjust the contrast/brightness of the OLED screen" "desc": "Adjust the contrast/brightness of the OLED screen"
}, },
"ColourInversion": { "ColourInversion": {

View File

@@ -201,8 +201,8 @@
"text2": ["Řeč:", " CS Český"], "text2": ["Řeč:", " CS Český"],
"desc": "" "desc": ""
}, },
"Contrast": { "Brightness": {
"text2": ["Screen", "Contrast"], "text2": ["Screen", "Brightness"],
"desc": "Adjust the contrast/brightness of the OLED screen" "desc": "Adjust the contrast/brightness of the OLED screen"
}, },
"ColourInversion": { "ColourInversion": {

View File

@@ -201,8 +201,8 @@
"text2": ["Sprog :", " DA Dansk"], "text2": ["Sprog :", " DA Dansk"],
"desc": "" "desc": ""
}, },
"Contrast": { "Brightness": {
"text2": ["Screen", "Contrast"], "text2": ["Screen", "Brightness"],
"desc": "Adjust the contrast/brightness of the OLED screen" "desc": "Adjust the contrast/brightness of the OLED screen"
}, },
"ColourInversion": { "ColourInversion": {

View File

@@ -202,8 +202,8 @@
"text2": ["Sprache:", " DE Deutsch"], "text2": ["Sprache:", " DE Deutsch"],
"desc": "" "desc": ""
}, },
"Contrast": { "Brightness": {
"text2": ["Screen", "Contrast"], "text2": ["Screen", "Brightness"],
"desc": "Adjust the contrast/brightness of the OLED screen" "desc": "Adjust the contrast/brightness of the OLED screen"
}, },
"ColourInversion": { "ColourInversion": {

View File

@@ -202,8 +202,8 @@
"text2": ["Language:", " EN English"], "text2": ["Language:", " EN English"],
"desc": "Current firmware language" "desc": "Current firmware language"
}, },
"Contrast": { "Brightness": {
"text2": ["Screen", "Contrast"], "text2": ["Screen", "Brightness"],
"desc": "Adjust the contrast/brightness of the OLED screen" "desc": "Adjust the contrast/brightness of the OLED screen"
}, },
"ColourInversion": { "ColourInversion": {

View File

@@ -202,8 +202,8 @@
"text2": ["Language:", " ES Castellano"], "text2": ["Language:", " ES Castellano"],
"desc": "" "desc": ""
}, },
"Contrast": { "Brightness": {
"text2": ["Screen", "Contrast"], "text2": ["Screen", "Brightness"],
"desc": "Adjust the contrast/brightness of the OLED screen" "desc": "Adjust the contrast/brightness of the OLED screen"
}, },
"ColourInversion": { "ColourInversion": {

View File

@@ -200,8 +200,8 @@
"text2": ["Kieli:", " FI Suomi"], "text2": ["Kieli:", " FI Suomi"],
"desc": "" "desc": ""
}, },
"Contrast": { "Brightness": {
"text2": ["Screen", "Contrast"], "text2": ["Screen", "Brightness"],
"desc": "Adjust the contrast/brightness of the OLED screen" "desc": "Adjust the contrast/brightness of the OLED screen"
}, },
"ColourInversion": { "ColourInversion": {

View File

@@ -201,8 +201,8 @@
"text2": ["Langue :", " FR Français"], "text2": ["Langue :", " FR Français"],
"desc": "" "desc": ""
}, },
"Contrast": { "Brightness": {
"text2": ["Screen", "Contrast"], "text2": ["Screen", "Brightness"],
"desc": "Adjust the contrast/brightness of the OLED screen" "desc": "Adjust the contrast/brightness of the OLED screen"
}, },
"ColourInversion": { "ColourInversion": {

View File

@@ -201,8 +201,8 @@
"text2": ["Jezik:", " HR Hrvatski"], "text2": ["Jezik:", " HR Hrvatski"],
"desc": "" "desc": ""
}, },
"Contrast": { "Brightness": {
"text2": ["Screen", "Contrast"], "text2": ["Screen", "Brightness"],
"desc": "Adjust the contrast/brightness of the OLED screen" "desc": "Adjust the contrast/brightness of the OLED screen"
}, },
"ColourInversion": { "ColourInversion": {

View File

@@ -201,8 +201,8 @@
"text2": ["Nyelv:", " HU Magyar"], "text2": ["Nyelv:", " HU Magyar"],
"desc": "" "desc": ""
}, },
"Contrast": { "Brightness": {
"text2": ["Screen", "Contrast"], "text2": ["Screen", "Brightness"],
"desc": "Adjust the contrast/brightness of the OLED screen" "desc": "Adjust the contrast/brightness of the OLED screen"
}, },
"ColourInversion": { "ColourInversion": {

View File

@@ -201,8 +201,8 @@
"text2": ["Lingua:", " IT Italiano"], "text2": ["Lingua:", " IT Italiano"],
"desc": "" "desc": ""
}, },
"Contrast": { "Brightness": {
"text2": ["Screen", "Contrast"], "text2": ["Screen", "Brightness"],
"desc": "Adjust the contrast/brightness of the OLED screen" "desc": "Adjust the contrast/brightness of the OLED screen"
}, },
"ColourInversion": { "ColourInversion": {

View File

@@ -202,8 +202,8 @@
"text2": "言語: 日本語", "text2": "言語: 日本語",
"desc": "" "desc": ""
}, },
"Contrast": { "Brightness": {
"text2": ["Screen", "Contrast"], "text2": ["Screen", "Brightness"],
"desc": "Adjust the contrast/brightness of the OLED screen" "desc": "Adjust the contrast/brightness of the OLED screen"
}, },
"ColourInversion": { "ColourInversion": {

View File

@@ -201,8 +201,8 @@
"text2": ["Kalba:", " LT Lietuvių"], "text2": ["Kalba:", " LT Lietuvių"],
"desc": "" "desc": ""
}, },
"Contrast": { "Brightness": {
"text2": ["Screen", "Contrast"], "text2": ["Screen", "Brightness"],
"desc": "Adjust the contrast/brightness of the OLED screen" "desc": "Adjust the contrast/brightness of the OLED screen"
}, },
"ColourInversion": { "ColourInversion": {

View File

@@ -201,8 +201,8 @@
"text2": ["Spraak :", " NL Nederlands"], "text2": ["Spraak :", " NL Nederlands"],
"desc": "" "desc": ""
}, },
"Contrast": { "Brightness": {
"text2": ["Screen", "Contrast"], "text2": ["Screen", "Brightness"],
"desc": "Adjust the contrast/brightness of the OLED screen" "desc": "Adjust the contrast/brightness of the OLED screen"
}, },
"ColourInversion": { "ColourInversion": {

View File

@@ -201,8 +201,8 @@
"text2": ["Spraak:", " NL_BE Vlaams"], "text2": ["Spraak:", " NL_BE Vlaams"],
"desc": "" "desc": ""
}, },
"Contrast": { "Brightness": {
"text2": ["Screen", "Contrast"], "text2": ["Screen", "Brightness"],
"desc": "Adjust the contrast/brightness of the OLED screen" "desc": "Adjust the contrast/brightness of the OLED screen"
}, },
"ColourInversion": { "ColourInversion": {

View File

@@ -201,8 +201,8 @@
"text2": ["Språk:", " NO Norsk"], "text2": ["Språk:", " NO Norsk"],
"desc": "" "desc": ""
}, },
"Contrast": { "Brightness": {
"text2": ["Screen", "Contrast"], "text2": ["Screen", "Brightness"],
"desc": "Adjust the contrast/brightness of the OLED screen" "desc": "Adjust the contrast/brightness of the OLED screen"
}, },
"ColourInversion": { "ColourInversion": {

View File

@@ -202,8 +202,8 @@
"text2": ["Język :", " PL Polski"], "text2": ["Język :", " PL Polski"],
"desc": "" "desc": ""
}, },
"Contrast": { "Brightness": {
"text2": ["Screen", "Contrast"], "text2": ["Screen", "Brightness"],
"desc": "Adjust the contrast/brightness of the OLED screen" "desc": "Adjust the contrast/brightness of the OLED screen"
}, },
"ColourInversion": { "ColourInversion": {

View File

@@ -201,8 +201,8 @@
"text2": ["Idioma :", " PT Português"], "text2": ["Idioma :", " PT Português"],
"desc": "" "desc": ""
}, },
"Contrast": { "Brightness": {
"text2": ["Screen", "Contrast"], "text2": ["Screen", "Brightness"],
"desc": "Adjust the contrast/brightness of the OLED screen" "desc": "Adjust the contrast/brightness of the OLED screen"
}, },
"ColourInversion": { "ColourInversion": {

View File

@@ -201,8 +201,8 @@
"text2": ["Язык:", " RU Русский"], "text2": ["Язык:", " RU Русский"],
"desc": "" "desc": ""
}, },
"Contrast": { "Brightness": {
"text2": ["Screen", "Contrast"], "text2": ["Screen", "Brightness"],
"desc": "Adjust the contrast/brightness of the OLED screen" "desc": "Adjust the contrast/brightness of the OLED screen"
}, },
"ColourInversion": { "ColourInversion": {

View File

@@ -201,8 +201,8 @@
"text2": ["Jazyk:", " SK Slovenčina"], "text2": ["Jazyk:", " SK Slovenčina"],
"desc": "" "desc": ""
}, },
"Contrast": { "Brightness": {
"text2": ["Screen", "Contrast"], "text2": ["Screen", "Brightness"],
"desc": "Adjust the contrast/brightness of the OLED screen" "desc": "Adjust the contrast/brightness of the OLED screen"
}, },
"ColourInversion": { "ColourInversion": {

View File

@@ -201,8 +201,8 @@
"text2": ["Jezik:", " SL Slovenščina"], "text2": ["Jezik:", " SL Slovenščina"],
"desc": "" "desc": ""
}, },
"Contrast": { "Brightness": {
"text2": ["Screen", "Contrast"], "text2": ["Screen", "Brightness"],
"desc": "Adjust the contrast/brightness of the OLED screen" "desc": "Adjust the contrast/brightness of the OLED screen"
}, },
"ColourInversion": { "ColourInversion": {

View File

@@ -201,8 +201,8 @@
"text2": ["Jезик:", " SR Српски"], "text2": ["Jезик:", " SR Српски"],
"desc": "" "desc": ""
}, },
"Contrast": { "Brightness": {
"text2": ["Screen", "Contrast"], "text2": ["Screen", "Brightness"],
"desc": "Adjust the contrast/brightness of the OLED screen" "desc": "Adjust the contrast/brightness of the OLED screen"
}, },
"ColourInversion": { "ColourInversion": {

View File

@@ -201,8 +201,8 @@
"text2": ["Jezik:", " SR Srpski"], "text2": ["Jezik:", " SR Srpski"],
"desc": "" "desc": ""
}, },
"Contrast": { "Brightness": {
"text2": ["Screen", "Contrast"], "text2": ["Screen", "Brightness"],
"desc": "Adjust the contrast/brightness of the OLED screen" "desc": "Adjust the contrast/brightness of the OLED screen"
}, },
"ColourInversion": { "ColourInversion": {

View File

@@ -195,8 +195,8 @@
"text2": ["Språk:", " SV Svenska"], "text2": ["Språk:", " SV Svenska"],
"desc": "" "desc": ""
}, },
"Contrast": { "Brightness": {
"text2": ["Screen", "Contrast"], "text2": ["Screen", "Brightness"],
"desc": "Adjust the contrast/brightness of the OLED screen" "desc": "Adjust the contrast/brightness of the OLED screen"
}, },
"ColourInversion": { "ColourInversion": {

View File

@@ -213,8 +213,8 @@
"text2": ["Dil:", " TR Türkçe"], "text2": ["Dil:", " TR Türkçe"],
"desc": "" "desc": ""
}, },
"Contrast": { "Brightness": {
"text2": ["Screen", "Contrast"], "text2": ["Screen", "Brightness"],
"desc": "Adjust the contrast/brightness of the OLED screen" "desc": "Adjust the contrast/brightness of the OLED screen"
}, },
"ColourInversion": { "ColourInversion": {

View File

@@ -201,8 +201,8 @@
"text2": ["Мова:", " UK Українська"], "text2": ["Мова:", " UK Українська"],
"desc": "" "desc": ""
}, },
"Contrast": { "Brightness": {
"text2": ["Screen", "Contrast"], "text2": ["Screen", "Brightness"],
"desc": "Adjust the contrast/brightness of the OLED screen" "desc": "Adjust the contrast/brightness of the OLED screen"
}, },
"ColourInversion": { "ColourInversion": {

View File

@@ -202,8 +202,8 @@
"text2": "語言: 廣東話", "text2": "語言: 廣東話",
"desc": "" "desc": ""
}, },
"Contrast": { "Brightness": {
"text2": ["Screen", "Contrast"], "text2": ["Screen", "Brightness"],
"desc": "Adjust the contrast/brightness of the OLED screen" "desc": "Adjust the contrast/brightness of the OLED screen"
}, },
"ColourInversion": { "ColourInversion": {

View File

@@ -202,8 +202,8 @@
"text2": "语言:简体中文", "text2": "语言:简体中文",
"desc": "" "desc": ""
}, },
"Contrast": { "Brightness": {
"text2": ["Screen", "Contrast"], "text2": ["Screen", "Brightness"],
"desc": "Adjust the contrast/brightness of the OLED screen" "desc": "Adjust the contrast/brightness of the OLED screen"
}, },
"ColourInversion": { "ColourInversion": {

View File

@@ -203,8 +203,8 @@
"text2": "語言:正體中文", "text2": "語言:正體中文",
"desc": "" "desc": ""
}, },
"Contrast": { "Brightness": {
"text2": ["Screen", "Contrast"], "text2": ["Screen", "Brightness"],
"desc": "Adjust the contrast/brightness of the OLED screen" "desc": "Adjust the contrast/brightness of the OLED screen"
}, },
"ColourInversion": { "ColourInversion": {

View File

@@ -355,7 +355,7 @@ var def =
"maxLen2": 15 "maxLen2": 15
}, },
{ {
"id": "Contrast", "id": "Brightness",
"maxLen": 7, "maxLen": 7,
"maxLen2": 15 "maxLen2": 15
}, },

View File

@@ -45,7 +45,7 @@ I2C_CLASS::I2C_REG OLED_Setup_Array[] = {
{0x80, 0x14, 0}, /*Charge Pump settings*/ {0x80, 0x14, 0}, /*Charge Pump settings*/
{0x80, 0xDA, 0}, /*Set VCOM Pins hardware config*/ {0x80, 0xDA, 0}, /*Set VCOM Pins hardware config*/
{0x80, 0x02, 0}, /*Combination 2*/ {0x80, 0x02, 0}, /*Combination 2*/
{0x80, 0x81, 0}, /*Contrast*/ {0x80, 0x81, 0}, /*Brightness*/
{0x80, 0x00, 0}, /*^0*/ {0x80, 0x00, 0}, /*^0*/
{0x80, 0xD9, 0}, /*Set pre-charge period*/ {0x80, 0xD9, 0}, /*Set pre-charge period*/
{0x80, 0xF1, 0}, /*Pre charge period*/ {0x80, 0xF1, 0}, /*Pre charge period*/
@@ -362,7 +362,7 @@ void OLED::setRotation(bool leftHanded) {
screenBuffer[9] = inLeftHandedMode ? 0xC8 : 0xC0; screenBuffer[9] = inLeftHandedMode ? 0xC8 : 0xC0;
} }
void OLED::setContrast(uint8_t contrast) { void OLED::setBrightness(uint8_t contrast) {
OLED_Setup_Array[15].val = contrast; OLED_Setup_Array[15].val = contrast;
I2C_CLASS::writeRegistersBulk(DEVICEADDR_OLED, &OLED_Setup_Array[14], 2); I2C_CLASS::writeRegistersBulk(DEVICEADDR_OLED, &OLED_Setup_Array[14], 2);
} }

View File

@@ -62,7 +62,7 @@ public:
static void setRotation(bool leftHanded); // Set the rotation for the screen static void setRotation(bool leftHanded); // Set the rotation for the screen
// Get the current rotation of the LCD // Get the current rotation of the LCD
static bool getRotation() { return inLeftHandedMode; } static bool getRotation() { return inLeftHandedMode; }
static void setContrast(uint8_t contrast); static void setBrightness(uint8_t contrast);
static void setInverseDisplay(bool inverted); static void setInverseDisplay(bool inverted);
static int16_t getCursorX() { return cursor_x; } static int16_t getCursorX() { return cursor_x; }
static void print(const char *string, FontStyle fontStyle); // Draw a string to the current location, with selected font static void print(const char *string, FontStyle fontStyle); // Draw a string to the current location, with selected font

View File

@@ -48,7 +48,7 @@ enum SettingsOptions {
UILanguage = 31, // Selected UI Language code, null-terminated *only if* the length is less than 8 chars UILanguage = 31, // Selected UI Language code, null-terminated *only if* the length is less than 8 chars
PDNegTimeout = 32, // PD timeout in 100ms steps PDNegTimeout = 32, // PD timeout in 100ms steps
OLEDInversion = 33, // Invert the colours on the display OLEDInversion = 33, // Invert the colours on the display
OLEDContrast = 34, // Contrast for the OLED display OLEDBrightness = 34, // Brightness for the OLED display
// //
SettingsOptionsLength = 35, // SettingsOptionsLength = 35, //

View File

@@ -59,7 +59,7 @@ enum class SettingsItemIndex : uint8_t {
PowerPulseWait, PowerPulseWait,
PowerPulseDuration, PowerPulseDuration,
LanguageSwitch, LanguageSwitch,
Contrast, Brightness,
ColourInversion, ColourInversion,
NUM_ITEMS, NUM_ITEMS,
}; };

View File

@@ -76,7 +76,7 @@ static const SettingConstants settingsConstants[(int)SettingsOptions::SettingsOp
{0, 0xFFFF, 0, 41431 /*EN*/}, // UILanguage {0, 0xFFFF, 0, 41431 /*EN*/}, // UILanguage
{0, 51, 1, 0}, // PDNegTimeout {0, 51, 1, 0}, // PDNegTimeout
{0, 2, 1, 0}, // OLEDInversion {0, 2, 1, 0}, // OLEDInversion
{7, 256, 0x08, 51}, // OLEDContrast {7, 256, 0x08, 51}, // OLEDBrightness
}; };
static_assert((sizeof(settingsConstants) / sizeof(SettingConstants)) == ((int)SettingsOptions::SettingsOptionsLength)); static_assert((sizeof(settingsConstants) / sizeof(SettingConstants)) == ((int)SettingsOptions::SettingsOptionsLength));
@@ -144,7 +144,7 @@ bool nextSettingValue(const enum SettingsOptions option) {
} else { } else {
systemSettings.settingsValues[(int)option] += constants.increment; systemSettings.settingsValues[(int)option] += constants.increment;
} }
return systemSettings.settingsValues[(int)option] == constants.max - constants.increment; return (constants.max - systemSettings.settingsValues[(int)option]) < constants.increment;
} }
bool prevSettingValue(const enum SettingsOptions option) { bool prevSettingValue(const enum SettingsOptions option) {

View File

@@ -199,7 +199,7 @@ const menuitem UIMenu[] = {
SettingsOptions::ReverseButtonTempChangeEnabled}, /* Reverse Temp change buttons + - */ SettingsOptions::ReverseButtonTempChangeEnabled}, /* Reverse Temp change buttons + - */
{SETTINGS_DESC(SettingsItemIndex::AnimSpeed), nullptr, settings_displayAnimationSpeed, SettingsOptions::AnimationSpeed}, /*Animation Speed adjustment */ {SETTINGS_DESC(SettingsItemIndex::AnimSpeed), nullptr, settings_displayAnimationSpeed, SettingsOptions::AnimationSpeed}, /*Animation Speed adjustment */
{SETTINGS_DESC(SettingsItemIndex::AnimLoop), nullptr, settings_displayAnimationLoop, SettingsOptions::AnimationLoop}, /*Animation Loop switch */ {SETTINGS_DESC(SettingsItemIndex::AnimLoop), nullptr, settings_displayAnimationLoop, SettingsOptions::AnimationLoop}, /*Animation Loop switch */
{SETTINGS_DESC(SettingsItemIndex::Contrast), nullptr, settings_displayBrightnessLevel, SettingsOptions::OLEDContrast}, /*Brightness Level*/ {SETTINGS_DESC(SettingsItemIndex::Brightness), nullptr, settings_displayBrightnessLevel, SettingsOptions::OLEDBrightness}, /*Brightness Level*/
{SETTINGS_DESC(SettingsItemIndex::ColourInversion), nullptr, settings_displayInvertColor, SettingsOptions::OLEDInversion}, /*Invert screen colour*/ {SETTINGS_DESC(SettingsItemIndex::ColourInversion), nullptr, settings_displayInvertColor, SettingsOptions::OLEDInversion}, /*Invert screen colour*/
{0, nullptr, nullptr, SettingsOptions::SettingsOptionsLength} // end of menu marker. DO NOT REMOVE {0, nullptr, nullptr, SettingsOptions::SettingsOptionsLength} // end of menu marker. DO NOT REMOVE
}; };
@@ -786,15 +786,20 @@ static bool settings_displayPowerPulseDuration(void) {
static bool settings_displayBrightnessLevel(void) { static bool settings_displayBrightnessLevel(void) {
OLED::drawArea(0, 0, 16, 16, brightnessIcon); OLED::drawArea(0, 0, 16, 16, brightnessIcon);
OLED::setCursor(5 * FONT_12_WIDTH - 2, 0); OLED::setCursor(5 * FONT_12_WIDTH - 2, 0);
OLED::printNumber(getSettingValue(SettingsOptions::OLEDContrast), 3, FontStyle::LARGE); // printShortDescription(SettingsItemIndex::Brightness, 7);
OLED::setContrast(getSettingValue(SettingsOptions::OLEDContrast)); OLED::printNumber(getSettingValue(SettingsOptions::OLEDBrightness), 3, FontStyle::LARGE);
// While not optimal to apply this here, it is _very_ convienient
OLED::setBrightness(getSettingValue(SettingsOptions::OLEDBrightness));
return false; return false;
} }
static bool settings_displayInvertColor(void) { static bool settings_displayInvertColor(void) {
OLED::drawArea(0, 0, 24, 16, invertDisplayIcon); OLED::drawArea(0, 0, 24, 16, invertDisplayIcon);
OLED::setCursor(7 * FONT_12_WIDTH - 2, 0); OLED::setCursor(7 * FONT_12_WIDTH - 2, 0);
// printShortDescription(SettingsItemIndex::ColourInversion, 7);
OLED::drawCheckbox(getSettingValue(SettingsOptions::OLEDInversion)); OLED::drawCheckbox(getSettingValue(SettingsOptions::OLEDInversion));
// While not optimal to apply this here, it is _very_ convienient
OLED::setInverseDisplay(getSettingValue(SettingsOptions::OLEDInversion)); OLED::setInverseDisplay(getSettingValue(SettingsOptions::OLEDInversion));
return false; return false;
} }

View File

@@ -799,6 +799,8 @@ void startGUITask(void const *argument) {
prepareTranslations(); prepareTranslations();
OLED::initialize(); // start up the LCD OLED::initialize(); // start up the LCD
OLED::setBrightness(getSettingValue(SettingsOptions::OLEDBrightness));
OLED::setInverseDisplay(getSettingValue(SettingsOptions::OLEDInversion));
uint8_t tempWarningState = 0; uint8_t tempWarningState = 0;
bool buttonLockout = false; bool buttonLockout = false;