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 Български"],
"desc": ""
},
"Contrast": {
"text2": ["Screen", "Contrast"],
"Brightness": {
"text2": ["Screen", "Brightness"],
"desc": "Adjust the contrast/brightness of the OLED screen"
},
"ColourInversion": {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -45,7 +45,7 @@ I2C_CLASS::I2C_REG OLED_Setup_Array[] = {
{0x80, 0x14, 0}, /*Charge Pump settings*/
{0x80, 0xDA, 0}, /*Set VCOM Pins hardware config*/
{0x80, 0x02, 0}, /*Combination 2*/
{0x80, 0x81, 0}, /*Contrast*/
{0x80, 0x81, 0}, /*Brightness*/
{0x80, 0x00, 0}, /*^0*/
{0x80, 0xD9, 0}, /*Set pre-charge period*/
{0x80, 0xF1, 0}, /*Pre charge period*/
@@ -362,7 +362,7 @@ void OLED::setRotation(bool leftHanded) {
screenBuffer[9] = inLeftHandedMode ? 0xC8 : 0xC0;
}
void OLED::setContrast(uint8_t contrast) {
void OLED::setBrightness(uint8_t contrast) {
OLED_Setup_Array[15].val = contrast;
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
// Get the current rotation of the LCD
static bool getRotation() { return inLeftHandedMode; }
static void setContrast(uint8_t contrast);
static void setBrightness(uint8_t contrast);
static void setInverseDisplay(bool inverted);
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

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
PDNegTimeout = 32, // PD timeout in 100ms steps
OLEDInversion = 33, // Invert the colours on the display
OLEDContrast = 34, // Contrast for the OLED display
OLEDBrightness = 34, // Brightness for the OLED display
//
SettingsOptionsLength = 35, //

View File

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

View File

@@ -76,7 +76,7 @@ static const SettingConstants settingsConstants[(int)SettingsOptions::SettingsOp
{0, 0xFFFF, 0, 41431 /*EN*/}, // UILanguage
{0, 51, 1, 0}, // PDNegTimeout
{0, 2, 1, 0}, // OLEDInversion
{7, 256, 0x08, 51}, // OLEDContrast
{7, 256, 0x08, 51}, // OLEDBrightness
};
static_assert((sizeof(settingsConstants) / sizeof(SettingConstants)) == ((int)SettingsOptions::SettingsOptionsLength));
@@ -144,7 +144,7 @@ bool nextSettingValue(const enum SettingsOptions option) {
} else {
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) {

View File

@@ -199,7 +199,7 @@ const menuitem UIMenu[] = {
SettingsOptions::ReverseButtonTempChangeEnabled}, /* Reverse Temp change buttons + - */
{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::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*/
{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) {
OLED::drawArea(0, 0, 16, 16, brightnessIcon);
OLED::setCursor(5 * FONT_12_WIDTH - 2, 0);
OLED::printNumber(getSettingValue(SettingsOptions::OLEDContrast), 3, FontStyle::LARGE);
OLED::setContrast(getSettingValue(SettingsOptions::OLEDContrast));
// printShortDescription(SettingsItemIndex::Brightness, 7);
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;
}
static bool settings_displayInvertColor(void) {
OLED::drawArea(0, 0, 24, 16, invertDisplayIcon);
OLED::setCursor(7 * FONT_12_WIDTH - 2, 0);
// printShortDescription(SettingsItemIndex::ColourInversion, 7);
OLED::drawCheckbox(getSettingValue(SettingsOptions::OLEDInversion));
// While not optimal to apply this here, it is _very_ convienient
OLED::setInverseDisplay(getSettingValue(SettingsOptions::OLEDInversion));
return false;
}

View File

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