Locking Mode

This commit is contained in:
Mel-kior
2020-10-11 00:07:34 +02:00
parent 2112173214
commit f9813ec494
34 changed files with 1197 additions and 705 deletions

View File

@@ -42,7 +42,7 @@ ButtonState getButtonState() {
else if (currentState == 0x02)
return BUTTON_B_LONG;
else
return BUTTON_NONE; // Both being held case, we dont long hold this
return BUTTON_BOTH_LONG; // Both being held case
} else
return BUTTON_NONE;
} else {

View File

@@ -17,6 +17,7 @@ enum ButtonState {
BUTTON_F_LONG = 4, /* User is holding the front button*/
BUTTON_B_LONG = 8, /* User is holding the back button*/
BUTTON_BOTH = 16, /* User has pressed both buttons*/
BUTTON_BOTH_LONG = 32, /* User is holding both buttons*/
/*
* Note:

View File

@@ -12,7 +12,7 @@
#include <stdint.h>
#include "stm32f1xx_hal.h"
#include "unit.h"
#define SETTINGSVERSION ( 0x21 )
#define SETTINGSVERSION ( 0x22 )
/*Change this if you change the struct below to prevent people getting \
out of sync*/
@@ -41,6 +41,7 @@ typedef struct {
uint8_t temperatureInF :1; // Should the temp be in F or C (true is F)
#endif
uint8_t descriptionScrollSpeed :1; // Description scroll speed
uint8_t lockingMode :2; // Store the locking mode
uint8_t KeepAwakePulse; // Keep Awake pulse power in 0.1 watts (10 = 1Watt)
uint16_t voltageDiv; // Voltage divisor factor
@@ -56,6 +57,7 @@ typedef struct {
uint16_t TempChangeLongStep; // Change the plus and minus button assigment
uint16_t TempChangeShortStep; // Change the plus and minus button assigment
uint32_t padding; // This is here for in case we are not an even divisor so
// that nothing gets cut off
//MUST BE LAST

View File

@@ -15,8 +15,8 @@ extern const uint8_t USER_FONT_6x8[];
* When SettingsShortNameType is SHORT_NAME_SINGLE_LINE
* use SettingsShortNames as SettingsShortNames[16][1].. second column undefined
*/
extern const char *SettingsShortNames[28][2];
extern const char *SettingsDescriptions[28];
extern const char *SettingsShortNames[29][2];
extern const char *SettingsDescriptions[29];
extern const char *SettingsMenuEntries[4];
extern const char *SettingsCalibrationDone;
@@ -41,6 +41,9 @@ extern const char *OffString;
extern const char *ResetOKMessage;
extern const char *YourGainMessage;
extern const char *SettingsResetMessage;
extern const char *LockingKeysString;
extern const char *UnlockingKeysString;
extern const char *WarningKeysLockedString;
extern const char *SettingTrueChar;
extern const char *SettingFalseChar;
@@ -51,6 +54,9 @@ extern const char *SettingStartSolderingChar;
extern const char *SettingStartSleepChar;
extern const char *SettingStartSleepOffChar;
extern const char *SettingStartNoneChar;
extern const char *SettingLockDisableChar;
extern const char *SettingLockBoostChar;
extern const char *SettingLockFullChar;
extern const char *SettingFastChar;
extern const char *SettingSlowChar;

View File

@@ -65,6 +65,7 @@ void resetSettings() {
systemSettings.ShutdownTime = SHUTDOWN_TIME; // How many minutes until the unit turns itself off
systemSettings.BoostTemp = BOOST_TEMP; // default to 400C
systemSettings.autoStartMode = AUTO_START_MODE; // Auto start off for safety
systemSettings.lockingMode = LOCKING_MODE; // Disable locking for safety
systemSettings.coolingTempBlink = COOLING_TEMP_BLINK; // Blink the temperature on the cooling screen when its > 50C
#ifdef ENABLED_FAHRENHEIT_SUPPORT
systemSettings.temperatureInF = TEMPERATURE_INF; // default to 0

View File

@@ -50,6 +50,8 @@ static bool settings_setBoostTemp(void);
static void settings_displayBoostTemp(void);
static bool settings_setAutomaticStartMode(void);
static void settings_displayAutomaticStartMode(void);
static bool settings_setLockingMode(void);
static void settings_displayLockingMode(void);
static bool settings_setCoolingBlinkEnabled(void);
static void settings_displayCoolingBlinkEnabled(void);
static bool settings_setResetSettings(void);
@@ -88,6 +90,7 @@ static bool settings_enterAdvancedMenu(void);
* Auto Start
* Temp change short step
* Temp change long step
* Locking Mode
*
* Power Saving
@@ -156,6 +159,8 @@ const menuitem solderingMenu[] = {
settings_displayTempChangeShortStep }, /*Temp change short step*/
{ (const char*) SettingsDescriptions[23], settings_setTempChangeLongStep,
settings_displayTempChangeLongStep }, /*Temp change long step*/
{ (const char*) SettingsDescriptions[26], settings_setLockingMode,
settings_displayLockingMode }, /*Locking Mode*/
{ NULL, NULL, NULL } // end of menu marker. DO NOT REMOVE
};
const menuitem UIMenu[] = {
@@ -620,6 +625,31 @@ static void settings_displayAutomaticStartMode(void) {
}
}
static bool settings_setLockingMode(void) {
systemSettings.lockingMode++;
systemSettings.lockingMode %= 3;
return systemSettings.lockingMode == 2;
}
static void settings_displayLockingMode(void) {
printShortDescription(26, 7);
switch (systemSettings.lockingMode) {
case 0:
OLED::print(SettingLockDisableChar);
break;
case 1:
OLED::print(SettingLockBoostChar);
break;
case 2:
OLED::print(SettingLockFullChar);
break;
default:
OLED::print(SettingLockDisableChar);
break;
}
}
static bool settings_setCoolingBlinkEnabled(void) {
systemSettings.coolingTempBlink = !systemSettings.coolingTempBlink;
return false;

View File

@@ -409,8 +409,10 @@ static void gui_solderingMode(uint8_t jumpToSleep) {
* PID control
* --> Long hold back button to exit
* --> Double button to exit
* --> Long hold double button to toggle key lock
*/
bool boostModeOn = false;
bool buttonsLocked = false;
uint32_t sleepThres = 0;
if (systemSettings.SleepTime < 6)
@@ -425,34 +427,86 @@ static void gui_solderingMode(uint8_t jumpToSleep) {
}
for (;;) {
ButtonState buttons = getButtonState();
switch (buttons) {
case BUTTON_NONE:
// stay
boostModeOn = false;
break;
case BUTTON_BOTH:
// exit
return;
break;
case BUTTON_B_LONG:
return; // exit on back long hold
break;
case BUTTON_F_LONG:
// if boost mode is enabled turn it on
if (systemSettings.BoostTemp)
boostModeOn = true;
break;
case BUTTON_F_SHORT:
case BUTTON_B_SHORT: {
uint16_t oldTemp = systemSettings.SolderingTemp;
gui_solderingTempAdjust(); // goto adjust temp mode
if (oldTemp != systemSettings.SolderingTemp) {
saveSettings(); // only save on change
if (buttonsLocked && (systemSettings.lockingMode != 0)) { // If buttons locked
switch (buttons) {
case BUTTON_NONE:
// stay
boostModeOn = false;
break;
case BUTTON_BOTH_LONG:
// Unlock buttons
buttonsLocked = false;
OLED::setCursor(0, 0);
OLED::clearScreen();
OLED::setFont(0);
OLED::print(UnlockingKeysString);
OLED::refresh();
waitForButtonPressOrTimeout(1000);
break;
case BUTTON_F_LONG:
// if boost mode is enabled turn it on
if (systemSettings.BoostTemp && (systemSettings.lockingMode == 1)) {
boostModeOn = true;
break;
};
// fall through
case BUTTON_BOTH:
case BUTTON_B_LONG:
case BUTTON_F_SHORT:
case BUTTON_B_SHORT:
// Do nothing and display a lock warming
OLED::setCursor(0, 0);
OLED::clearScreen();
OLED::setFont(0);
OLED::print(WarningKeysLockedString);
OLED::refresh();
waitForButtonPressOrTimeout(500);
break;
default:
break;
}
} else { // Button not locked
switch (buttons) {
case BUTTON_NONE:
// stay
boostModeOn = false;
break;
case BUTTON_BOTH:
// exit
return;
break;
case BUTTON_B_LONG:
return; // exit on back long hold
break;
case BUTTON_F_LONG:
// if boost mode is enabled turn it on
if (systemSettings.BoostTemp)
boostModeOn = true;
break;
case BUTTON_F_SHORT:
case BUTTON_B_SHORT: {
uint16_t oldTemp = systemSettings.SolderingTemp;
gui_solderingTempAdjust(); // goto adjust temp mode
if (oldTemp != systemSettings.SolderingTemp) {
saveSettings(); // only save on change
}
}
break;
case BUTTON_BOTH_LONG:
if (systemSettings.lockingMode != 0) {
// Lock buttons
buttonsLocked = true;
OLED::setCursor(0, 0);
OLED::clearScreen();
OLED::setFont(0);
OLED::print(LockingKeysString);
OLED::refresh();
waitForButtonPressOrTimeout(1000);
}
break;
default:
break;
}
}
break;
default:
break;
}
// else we update the screen information
OLED::setCursor(0, 0);

View File

@@ -40,6 +40,16 @@
*/
#define AUTO_START_MODE 0 // Default to none
/**
* Locking Mode
* When in soldering mode a long press on both keys toggle the lock of the buttons
* Possible values are:
* 0 - Desactivated
* 1 - Lock except boost
* 2 - Full lock
*/
#define LOCKING_MODE 0 // Default to desactivated for safety
/**
* OLED Orientation
*