Skip to content

Commit

Permalink
Merge pull request #1143 from discip/patch-2
Browse files Browse the repository at this point in the history
Tackling issue #1140
  • Loading branch information
Ralim authored Dec 26, 2021
2 parents a0eb5b5 + f34fb53 commit bd19d35
Showing 1 changed file with 44 additions and 41 deletions.
85 changes: 44 additions & 41 deletions source/Core/Src/gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ void gui_Menu(const menuitem *menu);

#ifdef POW_DC
static void settings_displayInputVRange(void);
static bool settings_showInputVOptions(void);
static void settings_displayInputMinVRange(void);
#endif
#ifdef POW_QC
Expand All @@ -27,12 +28,13 @@ static void settings_displayQCInputV(void);
static void settings_displayPDNegTimeout(void);
#endif
#ifndef NO_SLEEP_MODE
static void settings_displaySensitivity(void);
static bool settings_showSleepOptions(void);
static bool settings_setSleepTemp(void);
static void settings_displaySleepTemp(void);
static void settings_displaySleepTime(void);
#endif
static void settings_displayShutdownTime(void);
static void settings_displaySensitivity(void);
#endif
static bool settings_setTempF(void);
static void settings_displayTempF(void);
static void settings_displayAdvancedSolderingScreens(void);
Expand All @@ -59,6 +61,7 @@ static void settings_displayReverseButtonTempChangeEnabled(void);
static void settings_displayTempChangeShortStep(void);
static void settings_displayTempChangeLongStep(void);
static void settings_displayPowerPulse(void);
static bool settings_displayAnimationOptions(void);
static void settings_displayAnimationSpeed(void);
static void settings_displayAnimationLoop(void);
static void settings_displayPowerPulseWait(void);
Expand Down Expand Up @@ -153,8 +156,8 @@ const menuitem powerMenu[] = {
* Power Source
*/
#ifdef POW_DC
{SETTINGS_DESC(SettingsItemIndex::DCInCutoff), nullptr, settings_displayInputVRange, nullptr, SettingsOptions::MinDCVoltageCells}, /*Voltage input*/
{SETTINGS_DESC(SettingsItemIndex::MinVolCell), nullptr, settings_displayInputMinVRange, nullptr, SettingsOptions::MinVoltageCells}, /*Minimum voltage input*/
{SETTINGS_DESC(SettingsItemIndex::DCInCutoff), nullptr, settings_displayInputVRange, nullptr, SettingsOptions::MinDCVoltageCells}, /*Voltage input*/
{SETTINGS_DESC(SettingsItemIndex::MinVolCell), nullptr, settings_displayInputMinVRange, settings_showInputVOptions, SettingsOptions::MinVoltageCells}, /*Minimum voltage input*/
#endif
#ifdef POW_QC
{SETTINGS_DESC(SettingsItemIndex::QCMaxVoltage), nullptr, settings_displayQCInputV, nullptr, SettingsOptions::QCIdealVoltage}, /*Voltage input*/
Expand Down Expand Up @@ -199,28 +202,28 @@ const menuitem UIMenu[] = {
{SETTINGS_DESC(SettingsItemIndex::CooldownBlink), nullptr, settings_displayCoolingBlinkEnabled, nullptr, SettingsOptions::CoolingTempBlink}, /*Cooling blink warning*/
{SETTINGS_DESC(SettingsItemIndex::ScrollingSpeed), nullptr, settings_displayScrollSpeed, nullptr, SettingsOptions::DescriptionScrollSpeed}, /*Scroll Speed for descriptions*/
{SETTINGS_DESC(SettingsItemIndex::ReverseButtonTempChange), nullptr, settings_displayReverseButtonTempChangeEnabled, nullptr,
SettingsOptions::ReverseButtonTempChangeEnabled}, /* Reverse Temp change buttons + - */
{SETTINGS_DESC(SettingsItemIndex::AnimSpeed), nullptr, settings_displayAnimationSpeed, nullptr, SettingsOptions::AnimationSpeed}, /*Animation Speed adjustment */
{SETTINGS_DESC(SettingsItemIndex::AnimLoop), nullptr, settings_displayAnimationLoop, nullptr, SettingsOptions::AnimationLoop}, /*Animation Loop switch */
{SETTINGS_DESC(SettingsItemIndex::Brightness), nullptr, settings_displayBrightnessLevel, nullptr, SettingsOptions::OLEDBrightness}, /*Brightness Level*/
{SETTINGS_DESC(SettingsItemIndex::ColourInversion), nullptr, settings_displayInvertColor, nullptr, SettingsOptions::OLEDInversion}, /*Invert screen colour*/
{SETTINGS_DESC(SettingsItemIndex::AdvancedIdle), nullptr, settings_displayAdvancedIDLEScreens, nullptr, SettingsOptions::DetailedIDLE}, /* Advanced idle screen*/
{SETTINGS_DESC(SettingsItemIndex::AdvancedSoldering), nullptr, settings_displayAdvancedSolderingScreens, nullptr, SettingsOptions::DetailedSoldering}, /* Advanced soldering screen*/
{0, nullptr, nullptr, nullptr, SettingsOptions::SettingsOptionsLength} // end of menu marker. DO NOT REMOVE
SettingsOptions::ReverseButtonTempChangeEnabled}, /* Reverse Temp change buttons + - */
{SETTINGS_DESC(SettingsItemIndex::AnimSpeed), nullptr, settings_displayAnimationSpeed, nullptr, SettingsOptions::AnimationSpeed}, /*Animation Speed adjustment */
{SETTINGS_DESC(SettingsItemIndex::AnimLoop), nullptr, settings_displayAnimationLoop, settings_displayAnimationOptions, SettingsOptions::AnimationLoop}, /*Animation Loop switch */
{SETTINGS_DESC(SettingsItemIndex::Brightness), nullptr, settings_displayBrightnessLevel, nullptr, SettingsOptions::OLEDBrightness}, /*Brightness Level*/
{SETTINGS_DESC(SettingsItemIndex::ColourInversion), nullptr, settings_displayInvertColor, nullptr, SettingsOptions::OLEDInversion}, /*Invert screen colour*/
{SETTINGS_DESC(SettingsItemIndex::AdvancedIdle), nullptr, settings_displayAdvancedIDLEScreens, nullptr, SettingsOptions::DetailedIDLE}, /* Advanced idle screen*/
{SETTINGS_DESC(SettingsItemIndex::AdvancedSoldering), nullptr, settings_displayAdvancedSolderingScreens, nullptr, SettingsOptions::DetailedSoldering}, /* Advanced soldering screen*/
{0, nullptr, nullptr, nullptr, SettingsOptions::SettingsOptionsLength} // end of menu marker. DO NOT REMOVE
};
const menuitem PowerSavingMenu[] = {
/*
* Sleep Temp
* Motion Sensitivity
* Sleep Temp
* Sleep Time
* Shutdown Time
* Motion Sensitivity
*/
#ifndef NO_SLEEP_MODE
{SETTINGS_DESC(SettingsItemIndex::SleepTemperature), settings_setSleepTemp, settings_displaySleepTemp, nullptr, SettingsOptions::SettingsOptionsLength}, /*Sleep Temp*/
{SETTINGS_DESC(SettingsItemIndex::SleepTimeout), nullptr, settings_displaySleepTime, nullptr, SettingsOptions::SleepTime}, /*Sleep Time*/
{SETTINGS_DESC(SettingsItemIndex::MotionSensitivity), nullptr, settings_displaySensitivity, nullptr, SettingsOptions::Sensitivity}, /* Motion Sensitivity*/
{SETTINGS_DESC(SettingsItemIndex::SleepTemperature), settings_setSleepTemp, settings_displaySleepTemp, settings_showSleepOptions, SettingsOptions::SettingsOptionsLength}, /*Sleep Temp*/
{SETTINGS_DESC(SettingsItemIndex::SleepTimeout), nullptr, settings_displaySleepTime, settings_showSleepOptions, SettingsOptions::SleepTime}, /*Sleep Time*/
{SETTINGS_DESC(SettingsItemIndex::ShutdownTimeout), nullptr, settings_displayShutdownTime, settings_showSleepOptions, SettingsOptions::ShutdownTime}, /*Shutdown Time*/
#endif
{SETTINGS_DESC(SettingsItemIndex::ShutdownTimeout), nullptr, settings_displayShutdownTime, nullptr, SettingsOptions::ShutdownTime}, /*Shutdown Time*/
{SETTINGS_DESC(SettingsItemIndex::MotionSensitivity), nullptr, settings_displaySensitivity, nullptr, SettingsOptions::Sensitivity}, /* Motion Sensitivity*/
#ifdef HALL_SENSOR
{SETTINGS_DESC(SettingsItemIndex::HallEffSensitivity), nullptr, settings_displayHallEffect, nullptr, SettingsOptions::HallEffectSensitivity}, /* HallEffect Sensitivity*/
#endif
Expand Down Expand Up @@ -309,16 +312,12 @@ static void settings_displayInputVRange(void) {
}
}

static bool settings_showInputVOptions(void) { return getSettingValue(SettingsOptions::MinDCVoltageCells) > 0; }
static void settings_displayInputMinVRange(void) {
if (getSettingValue(SettingsOptions::MinDCVoltageCells)) {
printShortDescription(SettingsItemIndex::MinVolCell, 4);
OLED::printNumber(getSettingValue(SettingsOptions::MinVoltageCells) / 10, 2, FontStyle::LARGE);
OLED::print(SymbolDot, FontStyle::LARGE);
OLED::printNumber(getSettingValue(SettingsOptions::MinVoltageCells) % 10, 1, FontStyle::LARGE);
} else {
printShortDescription(SettingsItemIndex::MinVolCell, 5);
OLED::print(translatedString(Tr->SettingNAChar), FontStyle::LARGE);
}
printShortDescription(SettingsItemIndex::MinVolCell, 4);
OLED::printNumber(getSettingValue(SettingsOptions::MinVoltageCells) / 10, 2, FontStyle::LARGE);
OLED::print(SymbolDot, FontStyle::LARGE);
OLED::printNumber(getSettingValue(SettingsOptions::MinVoltageCells) % 10, 1, FontStyle::LARGE);
}
#endif
#ifdef POW_QC
Expand Down Expand Up @@ -350,6 +349,17 @@ static void settings_displayPDNegTimeout(void) {
#endif

#ifndef NO_SLEEP_MODE

static void settings_displayShutdownTime(void) {
printShortDescription(SettingsItemIndex::ShutdownTimeout, 5);
if (getSettingValue(SettingsOptions::ShutdownTime) == 0) {
OLED::print(translatedString(Tr->OffString), FontStyle::LARGE);
} else {
OLED::printNumber(getSettingValue(SettingsOptions::ShutdownTime), 2, FontStyle::LARGE);
OLED::print(SymbolMinutes, FontStyle::LARGE);
}
}

static bool settings_setSleepTemp(void) {
// If in C, 10 deg, if in F 20 deg
uint16_t temp = getSettingValue(SettingsOptions::SleepTemp);
Expand All @@ -368,6 +378,12 @@ static bool settings_setSleepTemp(void) {
}
}

static void settings_displaySensitivity(void) {
printShortDescription(SettingsItemIndex::MotionSensitivity, 7);
OLED::printNumber(getSettingValue(SettingsOptions::Sensitivity), 1, FontStyle::LARGE, false);
}

static bool settings_showSleepOptions(void) { return getSettingValue(SettingsOptions::Sensitivity) > 0; }
static void settings_displaySleepTemp(void) {
printShortDescription(SettingsItemIndex::SleepTemperature, 5);
OLED::printNumber(getSettingValue(SettingsOptions::SleepTemp), 3, FontStyle::LARGE);
Expand All @@ -387,15 +403,6 @@ static void settings_displaySleepTime(void) {
}
#endif

static void settings_displayShutdownTime(void) {
printShortDescription(SettingsItemIndex::ShutdownTimeout, 5);
if (getSettingValue(SettingsOptions::ShutdownTime) == 0) {
OLED::print(translatedString(Tr->OffString), FontStyle::LARGE);
} else {
OLED::printNumber(getSettingValue(SettingsOptions::ShutdownTime), 2, FontStyle::LARGE);
OLED::print(SymbolMinutes, FontStyle::LARGE);
}
}
static bool settings_setTempF(void) {
bool res = nextSettingValue(SettingsOptions::TemperatureInF);
uint16_t BoostTemp = getSettingValue(SettingsOptions::BoostTemp);
Expand Down Expand Up @@ -435,11 +442,6 @@ static void settings_displayTempF(void) {
OLED::print((getSettingValue(SettingsOptions::TemperatureInF)) ? SymbolDegF : SymbolDegC, FontStyle::LARGE);
}

static void settings_displaySensitivity(void) {
printShortDescription(SettingsItemIndex::MotionSensitivity, 7);
OLED::printNumber(getSettingValue(SettingsOptions::Sensitivity), 1, FontStyle::LARGE, false);
}

static void settings_displayAdvancedSolderingScreens(void) {
printShortDescription(SettingsItemIndex::AdvancedSoldering, 7);
OLED::drawCheckbox(getSettingValue(SettingsOptions::DetailedSoldering));
Expand Down Expand Up @@ -705,6 +707,7 @@ static void settings_displayPowerPulse(void) {
}
}

static bool settings_displayAnimationOptions(void) { return getSettingValue(SettingsOptions::AnimationSpeed) > 0; }
static void settings_displayAnimationLoop(void) {
printShortDescription(SettingsItemIndex::AnimLoop, 7);
OLED::drawCheckbox(getSettingValue(SettingsOptions::AnimationLoop));
Expand Down

0 comments on commit bd19d35

Please sign in to comment.