Draft tip selection menu

This commit is contained in:
=
2024-08-30 07:30:49 +10:00
parent 2fc3b24f72
commit 4e42cdda44
39 changed files with 365 additions and 43 deletions

View File

@@ -7,8 +7,8 @@
* Houses the system settings and allows saving / restoring from flash
*/
#ifndef SETTINGS_H_
#define SETTINGS_H_
#ifndef CORE_SETTINGS_H_
#define CORE_SETTINGS_H_
#include <stdbool.h>
#include <stdint.h>
@@ -74,8 +74,9 @@ enum SettingsOptions {
ProfilePhase5Duration = 51, // Target duration for phase 5
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
//
SettingsOptionsLength = 54, //
SettingsOptionsLength = 55, // End marker
};
typedef enum {
@@ -117,6 +118,31 @@ typedef enum {
FULL = 2, // Locking buttons for Boost mode AND for Soldering mode
} lockingMode_t;
/* Selection of the soldering tip
* Some devices allow multiple types of tips to be fitted, this allows selecting them or overriding the logic
* The first type will be the default (gets value of 0)
*/
typedef enum {
#ifdef AUTO_TIP_SELECTION
AUTO, // If the hardware supports automatic detection
#endif
#ifdef TIPTYPE_T12
T12_8_OHM, // TS100 style tips or Hakko T12 tips with adaptors
T12_6_2_OHM, // Short Tips manufactured by Pine64
T12_4_OHM, // Longer tip but low resistance for PTS200
#endif
#ifdef TIPTYE_TS80
TS80_4_5_OHM, // TS80(P) default tips
// We do not know of other tuning tips (?yet?)
#endif
#ifdef TIPTYPE_JBC
JBC_2_5_OHM, // Small JBC tips as used in the S60
#endif
TIP_TYPE_MAX, // Max value marker
} tipType_t;
// Settings wide operations
void saveSettings();
bool loadSettings();
@@ -129,11 +155,11 @@ uint16_t getSettingValue(const enum SettingsOptions option);
void nextSettingValue(const enum SettingsOptions option);
void prevSettingValue(const enum SettingsOptions option);
bool isLastSettingValue(const enum SettingsOptions option);
// For setting values to settings
void setSettingValue(const enum SettingsOptions option, const uint16_t newValue);
// Special access
// Special access helpers, to reduce logic duplication
uint8_t lookupVoltageLevel();
uint16_t lookupHallEffectThreshold();
const char* lookupTipName(); // Get the name string for the current soldering tip
#endif /* SETTINGS_H_ */

View File

@@ -106,6 +106,7 @@ enum class SettingsItemIndex : uint8_t {
PowerPulseDuration,
SettingsReset,
LanguageSwitch,
SolderingTipType,
NUM_ITEMS,
};
@@ -149,6 +150,12 @@ struct TranslationIndexTable {
uint16_t USBPDModeDefault;
uint16_t USBPDModeNoDynamic;
uint16_t USBPDModeSafe;
uint16_t TipTypeAuto;
uint16_t TipTypeT12Long;
uint16_t TipTypeT12Short;
uint16_t TipTypeT12PTS;
uint16_t TipTypeTS80;
uint16_t TipTypeJBC;
uint16_t SettingsDescriptions[static_cast<uint32_t>(SettingsItemIndex::NUM_ITEMS)];
uint16_t SettingsShortNames[static_cast<uint32_t>(SettingsItemIndex::NUM_ITEMS)];

View File

@@ -16,6 +16,10 @@
#include <string.h> // for memset
bool sanitiseSettings();
/*
* Used to constrain the QC 3.0 Voltage selection to suit hardware.
* We allow a little overvoltage for users who want to push it
*/
#ifdef POW_QC_20V
#define QC_VOLTAGE_MAX 220
#else
@@ -105,6 +109,7 @@ static const SettingConstants settingsConstants[(int)SettingsOptions::SettingsOp
{ 10, 180, 5, 30}, // ProfilePhase5Duration
{ 1, 10, 1, 2}, // ProfileCooldownSpeed
{ 0, 12, 1, 0}, // HallEffectSleepTime
{ 0, tipType_t::TIP_TYPE_MAX, 1, 0}, // SolderingTipType
};
static_assert((sizeof(settingsConstants) / sizeof(SettingConstants)) == ((int)SettingsOptions::SettingsOptionsLength));
@@ -292,3 +297,19 @@ uint8_t lookupVoltageLevel() {
return (minVoltageOnCell * minVoltageCellCount) + (minVoltageCellCount * 2);
}
}
const char *lookupTipName() {
// Get the name string for the current soldering tip
tipType_t value = (tipType_t)getSettingValue(SettingsOptions::SolderingTipType);
switch (value) {
#ifdef AUTO_TIP_SELECTION
case tipType_t::AUTO:
return translatedString(Tr->USBPDModeDefault);
break;
#endif
default:
return nullptr;
break;
}
}

View File

@@ -115,6 +115,10 @@ static void displayHallEffectSleepTime(void);
static bool showHallEffect(void);
#endif /* HALL_SENSOR */
// Tip type selection
static void displaySolderingTipType(void);
static bool showSolderingTipType(void);
// Menu functions
#if defined(POW_DC) || defined(POW_QC) || defined(POW_PD)
@@ -137,6 +141,7 @@ static void displayAdvancedMenu(void);
* USBPDMode
*
* Soldering
* Tip Type selection
* Boost Mode Temp
* Auto Start
* Temp Change Short Step
@@ -262,6 +267,7 @@ const menuitem powerMenu[] = {
const menuitem solderingMenu[] = {
/*
* Tip Type
* Boost Mode Temp
* Auto Start
* Temp Change Short Step
@@ -282,6 +288,8 @@ const menuitem solderingMenu[] = {
* Profile Phase 5 Duration (s)
* Profile Cooldown Max Temperature Change Per Second
*/
/* Tip Type */
{SETTINGS_DESC(SettingsItemIndex::SolderingTipType), nullptr, displaySolderingTipType, showSolderingTipType, SettingsOptions::SolderingTipType, SettingsItemIndex::SolderingTipType, 5},
/* Boost Temp */
{SETTINGS_DESC(SettingsItemIndex::BoostTemperature), setBoostTemp, displayBoostTemp, nullptr, SettingsOptions::BoostTemp, SettingsItemIndex::BoostTemperature, 5},
/* Auto start */
@@ -755,7 +763,12 @@ static void displayHallEffectSleepTime(void) {
}
}
#endif /* HALL_SENSOR */
static void displaySolderingTipType(void) {
// TODO wrapping X value
OLED::print(lookupTipName(), FontStyle::SMALL);
}
// If there is no detection, and no options, max is 0
static bool showSolderingTipType(void) { return tipType_t::TIP_TYPE_MAX != 0; }
static void setTempF(const enum SettingsOptions option) {
uint16_t Temp = getSettingValue(option);
if (getSettingValue(SettingsOptions::TemperatureInF)) {