This commit is contained in:
Leo
2025-02-22 09:55:45 +02:00
committed by GitHub
52 changed files with 346 additions and 169 deletions

View File

@@ -53,15 +53,18 @@
/**
* OLED Orientation
*
*/
#define ORIENTATION_MODE 0 // 0: Right 1:Left 2:Automatic - Default right
#define MAX_ORIENTATION_MODE 1 // Unlikely to ever change
#define REVERSE_BUTTON_TEMP_CHANGE 0 // 0:Default 1:Reverse - Reverse the plus and minus button assigment for temperature change
/**
* Buttons handling
*/
#define REVERSE_BUTTON_TEMP_CHANGE 0 // 0:Default 1:Reverse - Reverse the plus and minus button assignment for temperature change
#define REVERSE_BUTTON_MENU 0 // 0:Default 1:Reverse - Reverse the A and B button assignment for Settings menu only
/**
* OLED Brightness
*
*/
#define MIN_BRIGHTNESS 0 // Min OLED brightness selectable
#define MAX_BRIGHTNESS 100 // Max OLED brightness selectable

View File

@@ -53,15 +53,18 @@
/**
* OLED Orientation
*
*/
#define ORIENTATION_MODE 2 // 0: Right 1:Left 2:Automatic - Default Automatic
#define MAX_ORIENTATION_MODE 2 // Up to auto
#define REVERSE_BUTTON_TEMP_CHANGE 0 // 0:Default 1:Reverse - Reverse the plus and minus button assigment for temperature change
/**
* Buttons handling
*/
#define REVERSE_BUTTON_TEMP_CHANGE 0 // 0:Default 1:Reverse - Reverse the plus and minus button assignment for temperature change
#define REVERSE_BUTTON_MENU 0 // 0:Default 1:Reverse - Reverse the A and B button assignment for Settings menu only
/**
* OLED Brightness
*
*/
#if defined(MODEL_TS101)
#define MIN_BRIGHTNESS 1 // Min OLED brightness selectable

View File

@@ -53,15 +53,18 @@
/**
* OLED Orientation
*
*/
#define ORIENTATION_MODE 2 // 0: Right 1:Left 2:Automatic - Default Automatic
#define MAX_ORIENTATION_MODE 2 // Up to auto
#define REVERSE_BUTTON_TEMP_CHANGE 0 // 0:Default 1:Reverse - Reverse the plus and minus button assigment for temperature change
/**
* Buttons handling
*/
#define REVERSE_BUTTON_TEMP_CHANGE 0 // 0:Default 1:Reverse - Reverse the plus and minus button assignment for temperature change
#define REVERSE_BUTTON_MENU 0 // 0:Default 1:Reverse - Reverse the A and B button assignment for Settings menu only
/**
* OLED Brightness
*
*/
#define MIN_BRIGHTNESS 0 // Min OLED brightness selectable
#define MAX_BRIGHTNESS 100 // Max OLED brightness selectable

View File

@@ -53,15 +53,18 @@
/**
* OLED Orientation
*
*/
#define ORIENTATION_MODE 2 // 0: Right 1:Left 2:Automatic - Default Automatic
#define MAX_ORIENTATION_MODE 2 // Up to auto
#define REVERSE_BUTTON_TEMP_CHANGE 0 // 0:Default 1:Reverse - Reverse the plus and minus button assigment for temperature change
/**
* Buttons handling
*/
#define REVERSE_BUTTON_TEMP_CHANGE 0 // 0:Default 1:Reverse - Reverse the plus and minus button assignment for temperature change
#define REVERSE_BUTTON_MENU 0 // 0:Default 1:Reverse - Reverse the A and B button assignment for Settings menu only
/**
* OLED Brightness
*
*/
#define MIN_BRIGHTNESS 1 // Min OLED brightness selectable
#define MAX_BRIGHTNESS 101 // Max OLED brightness selectable

View File

@@ -4,7 +4,6 @@
/**
* Configuration.h
* Define here your default pre settings for S60
*
*/
//===========================================================================
@@ -21,7 +20,6 @@
/**
* OLED Brightness
*
*/
#define MIN_BRIGHTNESS 1 // Min OLED brightness selectable
#define MAX_BRIGHTNESS 101 // Max OLED brightness selectable
@@ -62,11 +60,15 @@
/**
* OLED Orientation
*
*/
#define ORIENTATION_MODE 0 // 0: Right 1:Left (2:Automatic N/A)
#define MAX_ORIENTATION_MODE 1 // Disable auto mode
#define REVERSE_BUTTON_TEMP_CHANGE 0 // 0:Default 1:Reverse - Reverse the plus and minus button assigment for temperature change
/**
* Buttons handling
*/
#define REVERSE_BUTTON_TEMP_CHANGE 0 // 0:Default 1:Reverse - Reverse the plus and minus button assignment for temperature change
#define REVERSE_BUTTON_MENU 0 // 0:Default 1:Reverse - Reverse the A and B button assignment for Settings menu only
/**
* Temp change settings

View File

@@ -11,7 +11,7 @@
#include <Buttons.hpp>
TickType_t lastButtonTime = 0;
ButtonState getButtonState() {
ButtonState getButtonState(bool swapButtonMenu) {
/*
* Read in the buttons and then determine if a state change needs to occur
*/
@@ -28,8 +28,8 @@ ButtonState getButtonState() {
static TickType_t previousStateChange = 0;
const TickType_t timeout = TICKS_100MS * 4;
uint8_t currentState;
currentState = (getButtonA()) << 0;
currentState |= (getButtonB()) << 1;
currentState = (getButtonA()) << (0 xor swapButtonMenu);
currentState |= (getButtonB()) << (1 xor swapButtonMenu);
if (currentState) {
lastButtonTime = xTaskGetTickCount();

View File

@@ -27,7 +27,8 @@ enum ButtonState {
};
// Returns what buttons are pressed (if any)
ButtonState getButtonState();
ButtonState getButtonState(bool swapButtonMenu = 0);
// Helpers
void waitForButtonPressOrTimeout(TickType_t timeout);
void waitForButtonPress();

View File

@@ -76,8 +76,9 @@ enum SettingsOptions {
ProfileCooldownSpeed = 52, // Maximum allowed cooldown speed in degrees per second
HallEffectSleepTime = 53, // Seconds (/5) timeout to sleep when hall effect over threshold
SolderingTipType = 54, // Selecting the type of soldering tip fitted
ReverseButtonMenu = 55, // Change the A and B button assigment in menus
//
SettingsOptionsLength = 55, // End marker
SettingsOptionsLength = 56, // End marker
};
typedef enum {

View File

@@ -54,6 +54,11 @@ extern const char *DebugMenu[];
extern const char *AccelTypeNames[];
extern const char *PowerSourceNames[];
/* !
* The order of the items inside this enum class SettingsItemIndex
* must be the same as the order of the related items
* in the "menuOptions" section of translations_definitions.json file.
*/
enum class SettingsItemIndex : uint8_t {
DCInCutoff,
MinVolCell,
@@ -90,6 +95,7 @@ enum class SettingsItemIndex : uint8_t {
CooldownBlink,
ScrollingSpeed,
ReverseButtonTempChange,
ReverseButtonMenu,
AnimSpeed,
AnimLoop,
Brightness,

View File

@@ -54,7 +54,7 @@ typedef struct {
} SettingConstants;
static const SettingConstants settingsConstants[(int)SettingsOptions::SettingsOptionsLength] = {
//{ min, max, increment, default}
// MIN, MAX, INCREMENT, DEFAULT
{ MIN_TEMP_C, MAX_TEMP_F, 5, SOLDERING_TEMP}, // SolderingTemp
{ MIN_TEMP_C, MAX_TEMP_F, 5, 150}, // SleepTemp
{ 0, 15, 1, SLEEP_TIME}, // SleepTime
@@ -110,6 +110,8 @@ static const SettingConstants settingsConstants[(int)SettingsOptions::SettingsOp
{ 1, 10, 1, 2}, // ProfileCooldownSpeed
{ 0, 12, 1, 0}, // HallEffectSleepTime
{ 0, (tipType_t::TIP_TYPE_MAX - 1) > 0 ? (tipType_t::TIP_TYPE_MAX - 1) : 0, 1, 0}, // SolderingTipType
{ 0, 1, 1, REVERSE_BUTTON_MENU}, // ReverseButtonMenu
// MIN, MAX, INCREMENT, DEFAULT
};
static_assert((sizeof(settingsConstants) / sizeof(SettingConstants)) == ((int)SettingsOptions::SettingsOptionsLength));

View File

@@ -47,6 +47,7 @@ static void displayAdvancedSolderingScreens(void);
static void displayAdvancedIDLEScreens(void);
static void displayScrollSpeed(void);
static void displayReverseButtonTempChangeEnabled(void);
static void displayReverseButtonMenu(void);
static void displayPowerLimit(void);
#ifdef BLE_ENABLED
@@ -395,6 +396,8 @@ const menuitem UIMenu[] = {
{SETTINGS_DESC(SettingsItemIndex::ScrollingSpeed), nullptr, displayScrollSpeed, nullptr, SettingsOptions::DescriptionScrollSpeed, SettingsItemIndex::ScrollingSpeed, 7},
/* Reverse Temp change buttons +/- */
{SETTINGS_DESC(SettingsItemIndex::ReverseButtonTempChange), nullptr, displayReverseButtonTempChangeEnabled, nullptr, SettingsOptions::ReverseButtonTempChangeEnabled, SettingsItemIndex::ReverseButtonTempChange, 7},
/* Reverse menu nav buttons A/B */
{SETTINGS_DESC(SettingsItemIndex::ReverseButtonMenu), nullptr, displayReverseButtonMenu, nullptr, SettingsOptions::ReverseButtonMenu, SettingsItemIndex::ReverseButtonMenu, 7},
/* Animation Speed adjustment */
{SETTINGS_DESC(SettingsItemIndex::AnimSpeed), nullptr, displayAnimationSpeed, nullptr, SettingsOptions::AnimationSpeed, SettingsItemIndex::AnimSpeed, 7},
/* Animation Loop switch */
@@ -480,7 +483,7 @@ static int userConfirmation(const char *message) {
for (;;) {
drawScrollingText(message, xTaskGetTickCount() - tickStart);
ButtonState buttons = getButtonState();
ButtonState buttons = getButtonState(getSettingValue(SettingsOptions::ReverseButtonTempChangeEnabled));
switch (buttons) {
case BUTTON_F_SHORT:
// User confirmed
@@ -853,6 +856,8 @@ static void displayScrollSpeed(void) { OLED::print(translatedString((getSettingV
static void displayReverseButtonTempChangeEnabled(void) { OLED::drawCheckbox(getSettingValue(SettingsOptions::ReverseButtonTempChangeEnabled)); }
static void displayReverseButtonMenu(void) { OLED::drawCheckbox(getSettingValue(SettingsOptions::ReverseButtonMenu)); }
static void displayAnimationSpeed(void) {
switch (getSettingValue(SettingsOptions::AnimationSpeed)) {
case settingOffSpeed_t::SLOW:
@@ -948,7 +953,7 @@ static void setCalibrateVIN(void) {
OLED::setCursor(0, 8);
OLED::printNumber(getSettingValue(SettingsOptions::VoltageDiv), 3, FontStyle::SMALL);
switch (getButtonState()) {
switch (getButtonState(getSettingValue(SettingsOptions::ReverseButtonMenu))) {
case BUTTON_F_SHORT:
prevSettingValue(SettingsOptions::VoltageDiv);
break;

View File

@@ -41,10 +41,18 @@ OperatingMode currentOperatingMode = OperatingMode::InitialisationDone; // Curre
guiContext context; // Context passed to functions to aid in state during render passes
OperatingMode handle_post_init_state();
OperatingMode guiHandleDraw(void) {
OLED::clearScreen(); // Clear ready for render pass
bool swapButtonMenu = getSettingValue(SettingsOptions::ReverseButtonMenu);
bool swapButtonTemp = getSettingValue(SettingsOptions::ReverseButtonTempChangeEnabled);
#ifdef OPT_FULL_BUTTON_REVERSE
bool isTempAdjust = currentOperatingMode == OperatingMode::TemperatureAdjust;
// Read button state
ButtonState buttons = getButtonState((swapButtonTemp && isTempAdjust) || (swapButtonMenu && !swapButtonTemp && !isTempAdjust) || (swapButtonMenu && swapButtonTemp && !isTempAdjust));
#else
ButtonState buttons = getButtonState();
#endif
// Enforce screen on if buttons pressed, movement, hot tip etc
if (buttons != BUTTON_NONE) {
OLED::setDisplayState(OLED::DisplayState::ON);
@@ -110,7 +118,11 @@ OperatingMode guiHandleDraw(void) {
newMode = gui_SolderingSleepingMode(buttons, &context);
break;
case OperatingMode::TemperatureAdjust:
newMode = gui_solderingTempAdjust(buttons, &context);
#ifdef OPT_FULL_BUTTON_REVERSE
newMode = gui_solderingTempAdjust(getButtonState(), &context);
#else
newMode = gui_solderingTempAdjust(getButtonState(swapButtonTemp), &context);
#endif
break;
case OperatingMode::DebugMenuReadout:
newMode = showDebugMenu(buttons, &context);
@@ -119,7 +131,11 @@ OperatingMode guiHandleDraw(void) {
newMode = performCJCC(buttons, &context);
break;
case OperatingMode::SettingsMenu:
newMode = gui_SettingsMenu(buttons, &context);
#ifdef OPT_FULL_BUTTON_REVERSE
newMode = gui_SettingsMenu(getButtonState(), &context);
#else
newMode = gui_SettingsMenu(getButtonState(swapButtonMenu), &context);
#endif
break;
case OperatingMode::InitialisationDone:
newMode = handle_post_init_state();
@@ -138,6 +154,7 @@ OperatingMode guiHandleDraw(void) {
};
return newMode;
}
void guiRenderLoop(void) {
OperatingMode newMode = guiHandleDraw(); // This does the screen drawing

View File

@@ -7,56 +7,49 @@ extern uint8_t buttonBF[sizeof(buttonB)];
extern uint8_t disconnectedTipF[sizeof(disconnectedTip)];
void ui_draw_homescreen_simplified(TemperatureType_t tipTemp) {
bool tempOnDisplay = false;
bool tipDisconnectedDisplay = false;
if (OLED::getRotation()) {
OLED::drawArea(68, 0, 56, 32, buttonAF);
OLED::drawArea(12, 0, 56, 32, buttonBF);
OLED::setCursor(0, 0);
ui_draw_power_source_icon();
} else {
OLED::drawArea(0, 0, 56, 32, buttonA); // Needs to be flipped so button ends up
OLED::drawArea(58, 0, 56, 32, buttonB); // on right side of screen
OLED::setCursor(116, 0);
ui_draw_power_source_icon();
}
tipDisconnectedDisplay = false;
if (tipTemp > 55) {
tempOnDisplay = true;
} else if (tipTemp < 45) {
tempOnDisplay = false;
}
if (isTipDisconnected()) {
tempOnDisplay = false;
tipDisconnectedDisplay = true;
}
if (tempOnDisplay || tipDisconnectedDisplay) {
// draw temp over the start soldering button
// Location changes on screen rotation
if (OLED::getRotation()) {
// in right handed mode we want to draw over the first part
OLED::fillArea(68, 0, 56, 32, 0); // clear the area for the temp
OLED::setCursor(56, 0);
} else {
OLED::fillArea(0, 0, 56, 32, 0); // clear the area
OLED::setCursor(0, 0);
}
// If we have a tip connected draw the temp, if not we leave it blank
if (!tipDisconnectedDisplay) {
// draw in the temp
if (!(getSettingValue(SettingsOptions::CoolingTempBlink) && (xTaskGetTickCount() % 1000 < 300))) {
ui_draw_tip_temperature(false, FontStyle::LARGE); // draw in the temp
}
} else {
// Draw in missing tip symbol
if (OLED::getRotation()) {
// in right handed mode we want to draw over the first part
OLED::drawArea(54, 0, 56, 32, disconnectedTipF);
} else {
OLED::drawArea(0, 0, 56, 32, disconnectedTip);
}
}
}
}
bool isFlipped = OLED::getRotation();
bool tipDisconnected = isTipDisconnected();
#ifdef OPT_FULL_BUTTON_REVERSE
bool swapButtonMenu = getSettingValue(SettingsOptions::ReverseButtonMenu);
#endif
#endif
// Flip and switch buttons accordingly
#ifdef OPT_FULL_BUTTON_REVERSE
OLED::drawArea(isFlipped ? 68 : 0, 0, 56, 32, isFlipped ? (swapButtonMenu ? buttonBF : buttonAF) : (swapButtonMenu ? buttonB : buttonA));
OLED::drawArea(isFlipped ? 12 : 58, 0, 56, 32, isFlipped ? (swapButtonMenu ? buttonAF : buttonBF) : (swapButtonMenu ? buttonA : buttonB));
#else
OLED::drawArea(isFlipped ? 68 : 0, 0, 56, 32, isFlipped ? buttonAF : buttonA);
OLED::drawArea(isFlipped ? 12 : 58, 0, 56, 32, isFlipped ? buttonBF : buttonB);
#endif
if ((tipTemp > 55) || tipDisconnected) {
// draw temp over the start soldering button
// Location changes on screen rotation and due to button swapping
// in right handed mode we want to draw over the first part
#ifdef OPT_FULL_BUTTON_REVERSE
OLED::fillArea(swapButtonMenu ? (isFlipped ? 26 : 58) : (isFlipped ? 68 : 0), 0, 56, 32, 0); // clear the area
OLED::setCursor(swapButtonMenu ? (isFlipped ? 27 : 59) : (isFlipped ? 56 : 0), 0);
#else
OLED::fillArea(isFlipped ? 68 : 0, 0, 56, 32, 0); // clear the area
OLED::setCursor(isFlipped ? 56 : 0, 0);
#endif
// If tip is disconnected draw the notification, otherwise - the temp
if (tipDisconnected) {
// Draw-in the missing tip symbol
#ifdef OPT_FULL_BUTTON_REVERSE
if (swapButtonMenu) {
OLED::drawArea(isFlipped ? 20 : 54, 0, 56, 32, isFlipped ? disconnectedTipF : disconnectedTip);
} else {
#endif
OLED::drawArea(isFlipped ? 54 : 0, 0, 56, 32, isFlipped ? disconnectedTipF : disconnectedTip);
#ifdef OPT_FULL_BUTTON_REVERSE
}
#endif
} else if (!(getSettingValue(SettingsOptions::CoolingTempBlink) && (xTaskGetTickCount() % 1000 < 300))) {
ui_draw_tip_temperature(false, FontStyle::LARGE); // Draw-in the temp
}
}
OLED::setCursor(isFlipped ? 0 : 116, 0);
ui_draw_power_source_icon();
}
#endif

View File

@@ -6,57 +6,49 @@ extern uint8_t buttonBF[sizeof(buttonB)];
extern uint8_t disconnectedTipF[sizeof(disconnectedTip)];
void ui_draw_homescreen_simplified(TemperatureType_t tipTemp) {
bool tempOnDisplay = false;
bool tipDisconnectedDisplay = false;
if (OLED::getRotation()) {
OLED::drawArea(54, 0, 42, 16, buttonAF);
OLED::drawArea(12, 0, 42, 16, buttonBF);
OLED::setCursor(0, 0);
ui_draw_power_source_icon();
} else {
OLED::drawArea(0, 0, 42, 16, buttonA); // Needs to be flipped so button ends up
OLED::drawArea(42, 0, 42, 16, buttonB); // on right side of screen
OLED::setCursor(84, 0);
ui_draw_power_source_icon();
}
tipDisconnectedDisplay = false;
if (tipTemp > 55) {
tempOnDisplay = true;
} else if (tipTemp < 45) {
tempOnDisplay = false;
}
if (isTipDisconnected()) {
tempOnDisplay = false;
tipDisconnectedDisplay = true;
}
if (tempOnDisplay || tipDisconnectedDisplay) {
bool isFlipped = OLED::getRotation();
bool tipDisconnected = isTipDisconnected();
#ifdef OPT_FULL_BUTTON_REVERSE
bool swapButtonMenu = getSettingValue(SettingsOptions::ReverseButtonMenu);
#endif
// Flip and switch buttons accordingly
#ifdef OPT_FULL_BUTTON_REVERSE
OLED::drawArea(isFlipped ? 54 : 0, 0, 42, 16, isFlipped ? (swapButtonMenu ? buttonBF : buttonAF) : (swapButtonMenu ? buttonB : buttonA));
OLED::drawArea(isFlipped ? 12 : 42, 0, 42, 16, isFlipped ? (swapButtonMenu ? buttonAF : buttonBF) : (swapButtonMenu ? buttonA : buttonB));
#else
OLED::drawArea(isFlipped ? 54 : 0, 0, 42, 16, isFlipped ? buttonAF : buttonA);
OLED::drawArea(isFlipped ? 12 : 42, 0, 42, 16, isFlipped ? buttonBF : buttonB);
#endif
if ((tipTemp > 55) || tipDisconnected) {
// draw temp over the start soldering button
// Location changes on screen rotation
if (OLED::getRotation()) {
// in right handed mode we want to draw over the first part
OLED::fillArea(55, 0, 41, 16, 0); // clear the area for the temp
OLED::setCursor(56, 0);
} else {
OLED::fillArea(0, 0, 41, 16, 0); // clear the area
OLED::setCursor(0, 0);
}
// If we have a tip connected draw the temp, if not we leave it blank
if (!tipDisconnectedDisplay) {
// draw in the temp
if (!(getSettingValue(SettingsOptions::CoolingTempBlink) && (xTaskGetTickCount() % 1000 < 300))) {
ui_draw_tip_temperature(false, FontStyle::LARGE); // draw in the temp
}
} else {
// Draw in missing tip symbol
if (OLED::getRotation()) {
// in right handed mode we want to draw over the first part
OLED::drawArea(54, 0, 42, 16, disconnectedTipF);
// Location changes on screen rotation and due to button swapping
// in right handed mode we want to draw over the first part
#ifdef OPT_FULL_BUTTON_REVERSE
OLED::fillArea(swapButtonMenu ? (isFlipped ? 14 : 42) : (isFlipped ? 55 : 0), 0, 41, 16, 0); // clear the area
OLED::setCursor(swapButtonMenu ? (isFlipped ? 15 : 43) : (isFlipped ? 56 : 0), 0);
#else
OLED::fillArea(isFlipped ? 55 : 0, 0, 41, 16, 0); // clear the area
OLED::setCursor(isFlipped ? 56 : 0, 0);
#endif
// If tip is disconnected draw the notification, otherwise - the temp
if (tipDisconnected) {
// Draw-in the missing tip symbol
#ifdef OPT_FULL_BUTTON_REVERSE
if (swapButtonMenu) {
OLED::drawArea(isFlipped ? 12 : 42, 0, 42, 16, isFlipped ? disconnectedTipF : disconnectedTip);
} else {
OLED::drawArea(0, 0, 42, 16, disconnectedTip);
#endif
OLED::drawArea(isFlipped ? 54 : 0, 0, 42, 16, isFlipped ? disconnectedTipF : disconnectedTip);
#ifdef OPT_FULL_BUTTON_REVERSE
}
#endif
} else if (!(getSettingValue(SettingsOptions::CoolingTempBlink) && (xTaskGetTickCount() % 1000 < 300))) {
ui_draw_tip_temperature(false, FontStyle::LARGE); // Draw-in the temp
}
}
OLED::setCursor(isFlipped ? 0 : 84, 0);
ui_draw_power_source_icon();
}
#endif
#endif

View File

@@ -54,10 +54,6 @@ OperatingMode gui_solderingTempAdjust(const ButtonState buttonIn, guiContext *cx
if ((PRESS_ACCEL_INTERVAL_MAX - (*autoRepeatAcceleration)) < PRESS_ACCEL_INTERVAL_MIN) {
(*autoRepeatAcceleration) = PRESS_ACCEL_INTERVAL_MAX - PRESS_ACCEL_INTERVAL_MIN;
}
// If buttons are flipped; flip the delta
if (getSettingValue(SettingsOptions::ReverseButtonTempChangeEnabled)) {
delta = -delta;
}
if (delta != 0) {
// constrain between the set temp limits, i.e. 10-450 C
int16_t newTemp = getSettingValue(SettingsOptions::SolderingTemp);

View File

@@ -17,7 +17,11 @@ bool shouldShutdown(void) {
}
}
}
#ifdef OPT_FULL_BUTTON_REVERSE
if (getButtonState(getSettingValue(SettingsOptions::ReverseButtonMenu) == BUTTON_B_LONG) { // allow also if back button is pressed long
#else
if (getButtonState() == BUTTON_B_LONG) { // allow also if back button is pressed long
#endif
return true;
}
return false;