Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement OLED::drawUnavailableIcon() to simplify duplicated calls #1947

Merged
merged 1 commit into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions source/Core/Drivers/OLED.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ class OLED {
static void drawBattery(uint8_t state) { drawSymbol(3 + (state > 10 ? 10 : state)); }
// Draws a checkbox
static void drawCheckbox(bool state) { drawSymbol((state) ? 16 : 17); }
inline static void drawUnavailableIcon() { drawArea(OLED_WIDTH - 16 - 2, 0, 16, 16, UnavailableIcon); }
static void debugNumber(int32_t val, FontStyle fontStyle);
static void drawHex(uint32_t x, FontStyle fontStyle, uint8_t digits);
static void drawSymbol(uint8_t symbolID); // Used for drawing symbols of a predictable width
Expand Down
32 changes: 14 additions & 18 deletions source/Core/Src/settingsGUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -522,11 +522,7 @@ static void displayQCInputV(void) {

static void displayPDNegTimeout(void) {
auto value = getSettingValue(SettingsOptions::PDNegTimeout);
if (value == 0) {
OLED::drawArea(OLED_WIDTH - 16 - 2, 0, 16, 16, UnavailableIcon);
} else {
OLED::printNumber(value, 2, FontStyle::LARGE);
}
value ? OLED::printNumber(value, 2, FontStyle::LARGE) : OLED::drawUnavailableIcon();
}

static void displayUSBPDMode(void) {
Expand Down Expand Up @@ -583,14 +579,14 @@ static void displayBoostTemp(void) {
if (getSettingValue(SettingsOptions::BoostTemp)) {
OLED::printNumber(getSettingValue(SettingsOptions::BoostTemp), 3, FontStyle::LARGE);
} else {
OLED::drawArea(OLED_WIDTH - 16 - 2, 0, 16, 16, UnavailableIcon);
OLED::drawUnavailableIcon();
}
}

static void displayAutomaticStartMode(void) {
switch (getSettingValue(SettingsOptions::AutoStartMode)) {
case autoStartMode_t::NO:
OLED::drawArea(OLED_WIDTH - 16 - 2, 0, 16, 16, UnavailableIcon);
OLED::drawUnavailableIcon();
break;
case autoStartMode_t::SOLDER:
OLED::print(translatedString(Tr->SettingStartSolderingChar), FontStyle::LARGE);
Expand All @@ -602,7 +598,7 @@ static void displayAutomaticStartMode(void) {
OLED::print(translatedString(Tr->SettingStartSleepOffChar), FontStyle::LARGE);
break;
default:
OLED::drawArea(OLED_WIDTH - 16 - 2, 0, 16, 16, UnavailableIcon);
OLED::drawUnavailableIcon();
break;
}
}
Expand All @@ -614,7 +610,7 @@ static void displayTempChangeLongStep(void) { OLED::printNumber(getSettingValue(
static void displayLockingMode(void) {
switch (getSettingValue(SettingsOptions::LockingMode)) {
case 0:
OLED::drawArea(OLED_WIDTH - 16 - 2, 0, 16, 16, UnavailableIcon);
OLED::drawUnavailableIcon();
break;
case 1:
OLED::print(translatedString(Tr->SettingLockBoostChar), FontStyle::LARGE);
Expand All @@ -623,7 +619,7 @@ static void displayLockingMode(void) {
OLED::print(translatedString(Tr->SettingLockFullChar), FontStyle::LARGE);
break;
default:
OLED::drawArea(OLED_WIDTH - 16 - 2, 0, 16, 16, UnavailableIcon);
OLED::drawUnavailableIcon();
break;
}
}
Expand Down Expand Up @@ -683,7 +679,7 @@ static void displaySensitivity(void) {
if (getSettingValue(SettingsOptions::Sensitivity)) {
OLED::printNumber(getSettingValue(SettingsOptions::Sensitivity), 1, FontStyle::LARGE, false);
} else {
OLED::drawArea(OLED_WIDTH - 16 - 2, 0, 16, 16, UnavailableIcon);
OLED::drawUnavailableIcon();
}
}
static bool showSleepOptions(void) { return getSettingValue(SettingsOptions::Sensitivity) > 0; }
Expand Down Expand Up @@ -712,7 +708,7 @@ static void displaySleepTemp(void) { OLED::printNumber(getSettingValue(SettingsO

static void displaySleepTime(void) {
if (getSettingValue(SettingsOptions::SleepTime) == 0) {
OLED::drawArea(OLED_WIDTH - 16 - 2, 0, 16, 16, UnavailableIcon);
OLED::drawUnavailableIcon();
} else if (getSettingValue(SettingsOptions::SleepTime) < 6) {
OLED::printNumber(getSettingValue(SettingsOptions::SleepTime) * 10, 2, FontStyle::LARGE);
OLED::print(LargeSymbolSeconds, FontStyle::LARGE);
Expand All @@ -726,7 +722,7 @@ static void displaySleepTime(void) {

static void displayShutdownTime(void) {
if (getSettingValue(SettingsOptions::ShutdownTime) == 0) {
OLED::drawArea(OLED_WIDTH - 16 - 2, 0, 16, 16, UnavailableIcon);
OLED::drawUnavailableIcon();
} else {
OLED::printNumber(getSettingValue(SettingsOptions::ShutdownTime), 2, FontStyle::LARGE);
OLED::print(LargeSymbolMinutes, FontStyle::LARGE);
Expand All @@ -738,7 +734,7 @@ static void displayHallEffect(void) {
if (getSettingValue(SettingsOptions::HallEffectSensitivity)) {
OLED::printNumber(getSettingValue(SettingsOptions::HallEffectSensitivity), 1, FontStyle::LARGE, false);
} else {
OLED::drawArea(OLED_WIDTH - 16 - 2, 0, 16, 16, UnavailableIcon);
OLED::drawUnavailableIcon();
}
}
static bool showHallEffect(void) { return getHallSensorFitted(); }
Expand Down Expand Up @@ -836,7 +832,7 @@ static void displayAnimationSpeed(void) {
OLED::print(translatedString(Tr->SettingFastChar), FontStyle::LARGE);
break;
default:
OLED::drawArea(OLED_WIDTH - 16 - 2, 0, 16, 16, UnavailableIcon);
OLED::drawUnavailableIcon();
break;
}
}
Expand All @@ -859,7 +855,7 @@ static void displayInvertColor(void) {
static void displayLogoTime(void) {
switch (getSettingValue(SettingsOptions::LOGOTime)) {
case logoMode_t::SKIP:
OLED::drawArea(OLED_WIDTH - 16 - 2, 0, 16, 16, UnavailableIcon);
OLED::drawUnavailableIcon();
break;
case logoMode_t::ONETIME:
OLED::drawArea(OLED_WIDTH - 16 - 2, 0, 16, 16, RepeatOnce);
Expand All @@ -884,7 +880,7 @@ static void displayBluetoothLE(void) { OLED::drawCheckbox(getSettingValue(Settin

static void displayPowerLimit(void) {
if (getSettingValue(SettingsOptions::PowerLimit) == 0) {
OLED::drawArea(OLED_WIDTH - 16 - 2, 0, 16, 16, UnavailableIcon);
OLED::drawUnavailableIcon();
} else {
OLED::printNumber(getSettingValue(SettingsOptions::PowerLimit), 3, FontStyle::LARGE);
OLED::print(LargeSymbolWatts, FontStyle::LARGE);
Expand Down Expand Up @@ -952,7 +948,7 @@ static void displayPowerPulse(void) {
OLED::print(LargeSymbolDot, FontStyle::LARGE);
OLED::printNumber(getSettingValue(SettingsOptions::KeepAwakePulse) % 10, 1, FontStyle::LARGE);
} else {
OLED::drawArea(OLED_WIDTH - 16 - 2, 0, 16, 16, UnavailableIcon);
OLED::drawUnavailableIcon();
}
}

Expand Down