1
0
forked from me/IronOS

Merge branch 'master' into pr/1010

This commit is contained in:
Ben V. Brown
2021-09-12 18:36:33 +10:00
21 changed files with 580 additions and 648 deletions

View File

@@ -16,7 +16,7 @@ void power_check() {
if (FUSB302_present) {
PolicyEngine::PPSTimerCallback();
// Cant start QC until either PD works or fails
if (PolicyEngine::setupCompleteOrTimedOut(systemSettings.PDNegTimeout) == false) {
if (PolicyEngine::setupCompleteOrTimedOut(getSettingValue(SettingsOptions::PDNegTimeout)) == false) {
return;
}
if (PolicyEngine::pdHasNegotiated()) {

View File

@@ -16,7 +16,7 @@ void power_check() {
if (FUSB302_present) {
PolicyEngine::PPSTimerCallback();
// Cant start QC until either PD works or fails
if (PolicyEngine::setupCompleteOrTimedOut(systemSettings.PDNegTimeout) == false) {
if (PolicyEngine::setupCompleteOrTimedOut(getSettingValue(SettingsOptions::PDNegTimeout)) == false) {
return;
}
if (PolicyEngine::pdHasNegotiated()) {

View File

@@ -70,7 +70,7 @@ uint8_t QC_DM_PulledDown() { return HAL_GPIO_ReadPin(GPIOA, GPIO_PIN_11) == GPIO
#endif
void QC_resync() {
#ifdef POW_QC
seekQC((systemSettings.QCIdealVoltage) ? 120 : 90,
systemSettings.voltageDiv); // Run the QC seek again if we have drifted too much
seekQC((getSettingValue(SettingsOptions::QCIdealVoltage)) ? 120 : 90,
getSettingValue(SettingsOptions::VoltageDiv)); // Run the QC seek again if we have drifted too much
#endif
}

View File

@@ -16,7 +16,7 @@ void power_check() {
if (FUSB302_present) {
PolicyEngine::PPSTimerCallback();
// Cant start QC until either PD works or fails
if (PolicyEngine::setupCompleteOrTimedOut(systemSettings.PDNegTimeout) == false) {
if (PolicyEngine::setupCompleteOrTimedOut(getSettingValue(SettingsOptions::PDNegTimeout)) == false) {
return;
}
if (PolicyEngine::pdHasNegotiated()) {
@@ -43,7 +43,7 @@ uint8_t usb_pd_detect() {
bool getIsPoweredByDCIN() {
// We return false until we are sure we are not using PD
if (PolicyEngine::setupCompleteOrTimedOut(systemSettings.PDNegTimeout) == false) {
if (PolicyEngine::setupCompleteOrTimedOut(getSettingValue(SettingsOptions::PDNegTimeout)) == false) {
return false;
}
if (PolicyEngine::pdHasNegotiated()) {

View File

@@ -47,12 +47,12 @@ uint8_t QC_DM_PulledDown() { return gpio_input_bit_get(USB_DM_LOW_GPIO_Port, USB
void QC_resync() {
#ifdef POW_QC
uint8_t targetvoltage = 90;
if (systemSettings.QCIdealVoltage == 1) {
if (getSettingValue(SettingsOptions::QCIdealVoltage) == 1) {
targetvoltage = 120;
} else if (systemSettings.QCIdealVoltage == 2) {
} else if (getSettingValue(SettingsOptions::QCIdealVoltage) == 2) {
targetvoltage = 200;
}
seekQC(targetvoltage, systemSettings.voltageDiv); // Run the QC seek again if we have drifted too much
seekQC(targetvoltage, getSettingValue(SettingsOptions::VoltageDiv)); // Run the QC seek again if we have drifted too much
#endif
}

View File

@@ -41,10 +41,10 @@ uint32_t TipThermoModel::convertTipRawADCTouV(uint16_t rawADC, bool ski
// Now to divide this down by the gain
valueuV /= OP_AMP_GAIN_STAGE;
if (systemSettings.CalibrationOffset && skipCalOffset == false) {
if (getSettingValue(SettingsOptions::CalibrationOffset) && skipCalOffset == false) {
// Remove uV tipOffset
if (valueuV > systemSettings.CalibrationOffset)
valueuV -= systemSettings.CalibrationOffset;
if (valueuV > getSettingValue(SettingsOptions::CalibrationOffset))
valueuV -= getSettingValue(SettingsOptions::CalibrationOffset);
else
valueuV = 0;
}

View File

@@ -9,65 +9,49 @@
#ifndef SETTINGS_H_
#define SETTINGS_H_
#include <stdbool.h>
#include <stdint.h>
#define SETTINGSVERSION (0x2A)
/*Change this if you change the struct below to prevent people getting \
out of sync*/
#define SETTINGSVERSION (0x2A) // This number is frozen, do not edit
/*
* This struct must be a multiple of 2 bytes as it is saved / restored from
* flash in uint16_t chunks
*/
typedef struct {
uint8_t version; // Used to track if a reset is needed on firmware upgrade
enum SettingsOptions {
SolderingTemp = 0, // current set point for the iron
SleepTemp = 1, // temp to drop to in sleep
SleepTime = 2, // minutes timeout to sleep
MinDCVoltageCells = 3, // The voltage we cut out at for under voltage when powered by DC jack
MinVoltageCells = 4, // Minimum allowed voltage per cell <3S - 3.0V (30)> <4S - 2.4V (24)> <...> (Minimum recommended 2.7V)
QCIdealVoltage = 5, // Desired QC3.0 voltage (9,12,20V)
OrientationMode = 6, // Selects between Auto,Right and left handed layouts
Sensitivity = 7, // Sensitivity of accelerometer (5 bits)
AnimationLoop = 8, // Animation loop switch
AnimationSpeed = 9, // Animation speed (in miliseconds)
AutoStartMode = 10, // Should the unit automatically jump straight into soldering mode when power is applied
ShutdownTime = 11, // Time until unit shuts down if left alone
CoolingTempBlink = 12, // Should the temperature blink on the cool down screen until its <50C
DetailedIDLE = 13, // Detailed idle screen
DetailedSoldering = 14, // Detailed soldering screens
TemperatureInF = 15, // Should the temp be in F or C (true is F)
DescriptionScrollSpeed = 16, // Description scroll speed
LockingMode = 17, // Store the locking mode
KeepAwakePulse = 18, // Keep Awake pulse power in 0.1 watts (10 = 1Watt)
KeepAwakePulseWait = 19, // Time between Keep Awake pulses in 2500 ms = 2.5 s increments
KeepAwakePulseDuration = 20, // Duration of the Keep Awake pusle in 250 ms increments
VoltageDiv = 21, // Voltage divisor factor
BoostTemp = 22, // Boost mode set point for the iron
CalibrationOffset = 23, // This stores the temperature offset for this tip in the iron.
PowerLimit = 24, // Maximum power iron allowed to output
ReverseButtonTempChangeEnabled = 25, // Change the plus and minus button assigment
TempChangeLongStep = 26, // Change the plus and minus button assigment
TempChangeShortStep = 27, // Change the plus and minus button assigment
HallEffectSensitivity = 28, // Operating mode of the hall effect sensor
AccelMissingWarningCounter = 29, // Counter of how many times we have warned we cannot detect the accelerometer
PDMissingWarningCounter = 30, // Counter of how many times we have warned we cannot detect the pd interface
UILanguage = 31, // Selected UI Language code, null-terminated *only if* the length is less than 8 chars
PDNegTimeout = 32, // PD timeout in 100ms steps
uint16_t SolderingTemp; // current set point for the iron
uint16_t SleepTemp; // temp to drop to in sleep
uint8_t SleepTime; // minutes timeout to sleep
uint8_t minDCVoltageCells; // The voltage we cut out at for under voltage when powered by DC jack
uint8_t minVoltageCells; // Minimum allowed voltage per cell <3S - 3.0V (30)> <4S - 2.4V (24)> <...> (Minimum recommended 2.7V)
uint8_t QCIdealVoltage; // Desired QC3.0 voltage (9,12,20V)
uint8_t OrientationMode : 2; // Selects between Auto,Right and left handed layouts
uint8_t sensitivity : 4; // Sensitivity of accelerometer (5 bits)
uint8_t animationLoop : 1; // Animation loop switch
uint8_t animationSpeed : 2; // Animation speed (in miliseconds)
uint8_t autoStartMode : 2; // Should the unit automatically jump straight
// into soldering mode when power is applied
uint8_t ShutdownTime; // Time until unit shuts down if left alone
//
SettingsOptionsLength = 33, //
};
uint8_t coolingTempBlink : 1; // Should the temperature blink on the cool
// down screen until its <50C
uint8_t detailedIDLE : 1; // Detailed idle screen
uint8_t detailedSoldering : 1; // Detailed soldering screens
uint8_t temperatureInF : 1; // Should the temp be in F or C (true is F)
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)
uint8_t KeepAwakePulseWait; // Time between Keep Awake pulses in 2500 ms = 2.5 s increments
uint8_t KeepAwakePulseDuration; // Duration of the Keep Awake pusle in 250 ms increments
uint16_t voltageDiv; // Voltage divisor factor
uint16_t BoostTemp; // Boost mode set point for the iron
uint16_t CalibrationOffset; // This stores the temperature offset for this tip
// in the iron.
uint8_t powerLimit; // Maximum power iron allowed to output
uint8_t ReverseButtonTempChangeEnabled; // Change the plus and minus button assigment
uint16_t TempChangeLongStep; // Change the plus and minus button assigment
uint16_t TempChangeShortStep; // Change the plus and minus button assigment
uint8_t hallEffectSensitivity; // Operating mode of the hall effect sensor
uint8_t accelMissingWarningCounter; // Counter of how many times we have warned we cannot detect the accelerometer
uint8_t pdMissingWarningCounter; // Counter of how many times we have warned we cannot detect the pd interface
char uiLanguage[8]; // Selected UI Language code, null-terminated *only if* the length is less than 8 chars
uint8_t PDNegTimeout; // PD timeout in 100ms steps
uint32_t padding; // This is here for in case we are not an even divisor so
// that nothing gets cut off
// MUST BE LAST
} systemSettingsType;
typedef enum {
OFF = 0, // Off (disabled)
SLOW = 1, //
@@ -75,12 +59,22 @@ typedef enum {
FAST = 3, //
MAX_VALUE = 4 //
} settingOffSpeed_t;
extern volatile systemSettingsType systemSettings;
// Settings wide operations
void saveSettings();
bool loadSettings();
void resetSettings();
void saveSettings();
bool restoreSettings();
// Settings access
uint16_t getSettingValue(const enum SettingsOptions option);
// Returns true if setting is now on the last value (next iteration will wrap)
bool nextSettingValue(const enum SettingsOptions option);
bool prevSettingValue(const enum SettingsOptions option);
void setSettingValue(const enum SettingsOptions option, const uint16_t newValue);
// Special access
uint8_t lookupVoltageLevel();
uint16_t lookupHallEffectThreshold();
void resetSettings();
#endif /* SETTINGS_H_ */

View File

@@ -30,7 +30,7 @@ extern const uint8_t FontSectionDataCount;
extern FontSection DynamicFontSections[];
struct LanguageMeta {
char code[8];
uint16_t uniqueID;
const uint8_t *translation_data;
uint16_t translation_size : 15;
bool translation_is_compressed : 1;

View File

@@ -78,8 +78,8 @@
#else
#define POWER_PULSE_DEFAULT 5
#endif
#define POWER_PULSE_WAIT_DEFAULT 4; // Default rate of the power pulse: 4*2500 = 10000 ms = 10 s
#define POWER_PULSE_DURATION_DEFAULT 1; // Default duration of the power pulse: 1*250 = 250 ms
#define POWER_PULSE_WAIT_DEFAULT 4 // Default rate of the power pulse: 4*2500 = 10000 ms = 10 s
#define POWER_PULSE_DURATION_DEFAULT 1 // Default duration of the power pulse: 1*250 = 250 ms
/**
* OLED Orientation Sensitivity on Automatic mode!
@@ -250,3 +250,9 @@ const uint8_t tipResistance = 45; // x10 ohms, 4.5 typical for ts80 tips
const uint32_t tipMass = 45; // TODO
const uint8_t tipResistance = 60; // x10 ohms, ~6 typical
#endif
#ifdef POW_QC_20V
#define QC_SETTINGS_MAX 3
#else
#define QC_SETTINGS_MAX 2
#endif

View File

@@ -27,6 +27,8 @@ typedef struct {
// return true if increment reached the maximum value
bool (*const incrementHandler)(void);
bool (*const draw)(void);
// If this is set, we will automatically use the settings increment handler instead, set >= num settings to disable
SettingsOptions autoSettingOption;
} menuitem;
void enterSettingsMenu();

View File

@@ -12,9 +12,11 @@ static uint8_t selectedLangIndex = 255;
static void initSelectedLanguageIndex() {
if (selectedLangIndex == 255) {
const char *lang = const_cast<char *>(systemSettings.uiLanguage);
const uint16_t wantedLanguageID = getSettingValue(SettingsOptions::UILanguage);
for (size_t i = 0; i < LanguageCount; i++) {
if (strncmp(lang, LanguageMetas[i].code, sizeof(systemSettings.uiLanguage)) == 0) {
if (LanguageMetas[i].uniqueID == wantedLanguageID) {
selectedLangIndex = i;
return;
}
@@ -24,10 +26,7 @@ static void initSelectedLanguageIndex() {
}
}
static void writeSelectedLanguageToSettings() {
char *lang = const_cast<char *>(systemSettings.uiLanguage);
strncpy(lang, LanguageMetas[selectedLangIndex].code, sizeof(systemSettings.uiLanguage));
}
static void writeSelectedLanguageToSettings() { setSettingValue(SettingsOptions::UILanguage, LanguageMetas[selectedLangIndex].uniqueID); }
void prepareTranslations() {
initSelectedLanguageIndex();

View File

@@ -40,7 +40,7 @@ bool ScrollMessage::drawUpdate(const char *message, uint32_t currentTick) {
int16_t messageOffset;
uint16_t msgWidth = messageWidth(message);
if (msgWidth > OLED_WIDTH) {
messageOffset = ((currentTick - messageStart) / (systemSettings.descriptionScrollSpeed == 1 ? TICKS_100MS / 10 : (TICKS_100MS / 5)));
messageOffset = ((currentTick - messageStart) / (getSettingValue(SettingsOptions::DescriptionScrollSpeed) == 1 ? TICKS_100MS / 10 : (TICKS_100MS / 5)));
messageOffset %= msgWidth + OLED_WIDTH; // Roll around at the end
if (messageOffset < OLED_WIDTH) {
// Snap the message to the left edge.

View File

@@ -12,85 +12,152 @@
#include "BSP.h"
#include "Setup.h"
#include "configuration.h"
#include <string.h> // for memset
bool sanitiseSettings();
#include "string.h"
/*
* This struct must be a multiple of 2 bytes as it is saved / restored from
* flash in uint16_t chunks
*/
typedef struct {
uint16_t length; // Length of valid bytes following
uint16_t settingsValues[SettingsOptionsLength];
// used to make this nicely "good enough" aligned to 32 butes to make driver code trivial
uint32_t padding;
} systemSettingsType;
//~1024 is common programming size, setting threshold to be lower so we have warning
static_assert(sizeof(systemSettingsType) < 512);
// char (*__kaboom)[sizeof(systemSettingsType)] = 1; // Uncomment to print size at compile time
volatile systemSettingsType systemSettings;
void saveSettings() {
// First we erase the flash
flash_save_buffer((uint8_t *)&systemSettings, sizeof(systemSettingsType));
}
// For every setting we need to store the min/max/increment values
typedef struct {
const uint16_t min; // Inclusive minimum value
const uint16_t max; // Exclusive maximum value
const uint16_t increment; // Standard increment
const uint16_t defaultValue; // Default vaue after reset
} SettingConstants;
bool restoreSettings() {
static const SettingConstants settingsConstants[(int)SettingsOptions::SettingsOptionsLength] = {
//{min,max,increment,default}
{10, 580, 5, 320}, // SolderingTemp
{10, 580, 5, 150}, // SleepTemp
{0, 16, 1, SLEEP_TIME}, // SleepTime
{0, 5, 1, CUT_OUT_SETTING}, // MinDCVoltageCells
{24, 38, 1, RECOM_VOL_CELL}, // MinVoltageCells
{0, QC_SETTINGS_MAX, 1, 0}, // QCIdealVoltage
{0, 3, 1, ORIENTATION_MODE}, // OrientationMode
{0, 10, 1, SENSITIVITY}, // Sensitivity
{0, 2, 1, ANIMATION_LOOP}, // AnimationLoop
{0, settingOffSpeed_t::MAX_VALUE, 1, ANIMATION_SPEED}, // AnimationSpeed
{0, 4, 1, AUTO_START_MODE}, // AutoStartMode
{0, 61, 1, SHUTDOWN_TIME}, // ShutdownTime
{0, 2, 1, COOLING_TEMP_BLINK}, // CoolingTempBlink
{0, 2, 1, DETAILED_IDLE}, // DetailedIDLE
{0, 2, 1, DETAILED_SOLDERING}, // DetailedSoldering
{0, 2, 1, TEMPERATURE_INF}, // TemperatureInF
{0, 2, 1, DESCRIPTION_SCROLL_SPEED}, // DescriptionScrollSpeed
{0, 3, 1, LOCKING_MODE}, // LockingMode
{0, 100, 1, POWER_PULSE_DEFAULT}, // KeepAwakePulse
{1, POWER_PULSE_WAIT_MAX, 1, POWER_PULSE_WAIT_DEFAULT}, // KeepAwakePulseWait
{1, POWER_PULSE_DURATION_MAX, 1, POWER_PULSE_DURATION_DEFAULT}, // KeepAwakePulseDuration
{360, 900, 1, VOLTAGE_DIV}, // VoltageDiv
{100, 580, 10, BOOST_TEMP}, // BoostTemp
{100, 2500, 1, CALIBRATION_OFFSET}, // CalibrationOffset
{0, MAX_POWER_LIMIT, POWER_LIMIT_STEPS, POWER_LIMIT}, // PowerLimit
{0, 2, 1, REVERSE_BUTTON_TEMP_CHANGE}, // ReverseButtonTempChangeEnabled
{5, TEMP_CHANGE_LONG_STEP_MAX, 5, TEMP_CHANGE_LONG_STEP}, // TempChangeLongStep
{1, TEMP_CHANGE_SHORT_STEP_MAX, 1, TEMP_CHANGE_SHORT_STEP}, // TempChangeShortStep
{0, 4, 1, 1}, // HallEffectSensitivity
{0, 10, 1, 0}, // AccelMissingWarningCounter
{0, 10, 1, 0}, // PDMissingWarningCounter
{0, 0xFFFF, 0, 41431 /*EN*/}, // UILanguage
{0, 51, 1, 0}, // PDNegTimeout
};
void saveSettings() { flash_save_buffer((uint8_t *)&systemSettings, sizeof(systemSettingsType)); }
bool loadSettings() {
// We read the flash
flash_read_buffer((uint8_t *)&systemSettings, sizeof(systemSettingsType));
// if the version is correct were done
// if not we reset and save
if (systemSettings.version != SETTINGSVERSION) {
// probably not setup
resetSettings();
return true;
}
return false;
// Then ensure all values are valid
return sanitiseSettings();
}
// Lookup function for cutoff setting -> X10 voltage
/*
* 0=DC
* 1=3S
* 2=4S
* 3=5S
* 4=6S
*/
uint8_t lookupVoltageLevel() {
if (systemSettings.minDCVoltageCells == 0)
return 90; // 9V since iron does not function effectively below this
else
return (systemSettings.minDCVoltageCells * systemSettings.minVoltageCells) + (systemSettings.minVoltageCells * 2);
bool sanitiseSettings() {
// For all settings, need to ensure settings are in a valid range
// First for any not know about due to array growth, reset them and update the length value
bool dirty = false;
if (systemSettings.padding != 0xFFFFFFFF) {
systemSettings.padding = 0xFFFFFFFF; // Force padding to 0xFFFFFFFF so that rolling forwards / back should be easier
dirty = true;
}
if (systemSettings.length < (int)SettingsOptions::SettingsOptionsLength) {
dirty = true;
for (int i = systemSettings.length; i < (int)SettingsOptions::SettingsOptionsLength; i++) {
systemSettings.settingsValues[i] = 0xFFFF; // Ensure its as if it was erased
}
systemSettings.length = (int)SettingsOptions::SettingsOptionsLength;
}
for (int i = 0; i < (int)SettingsOptions::SettingsOptionsLength; i++) {
// Check min max for all settings, if outside the range, move to default
if (systemSettings.settingsValues[i] < settingsConstants[i].min || systemSettings.settingsValues[i] > settingsConstants[i].max) {
systemSettings.settingsValues[i] = settingsConstants[i].defaultValue;
dirty = true;
}
}
if (dirty) {
saveSettings();
}
return dirty;
}
void resetSettings() {
memset((void *)&systemSettings, 0, sizeof(systemSettingsType));
systemSettings.SleepTemp = SLEEP_TEMP; // Temperature the iron sleeps at - default 150.0 C
systemSettings.SleepTime = SLEEP_TIME; // How many seconds/minutes we wait until going
// to sleep - default 1 min
systemSettings.SolderingTemp = SOLDERING_TEMP; // Default soldering temp is 320.0 C
systemSettings.minDCVoltageCells = CUT_OUT_SETTING; // default to no cut-off voltage
systemSettings.minVoltageCells = RECOM_VOL_CELL; // Minimum voltage per cell (Recommended 3.3V (33))
systemSettings.QCIdealVoltage = 0; // Default to 9V for QC3.0 Voltage
systemSettings.PDNegTimeout = 0; // Default for PD timout to 0
systemSettings.version = SETTINGSVERSION; // Store the version number to allow for easier upgrades
systemSettings.detailedSoldering = DETAILED_SOLDERING; // Detailed soldering screen
systemSettings.detailedIDLE = DETAILED_IDLE; // Detailed idle screen (off for first time users)
systemSettings.OrientationMode = ORIENTATION_MODE; // Default to automatic
systemSettings.sensitivity = SENSITIVITY; // Default high sensitivity
systemSettings.voltageDiv = VOLTAGE_DIV; // Default divider from schematic
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
systemSettings.temperatureInF = TEMPERATURE_INF; // default to 0
systemSettings.descriptionScrollSpeed = DESCRIPTION_SCROLL_SPEED; // default to slow
systemSettings.animationLoop = ANIMATION_LOOP; // Default false
systemSettings.animationSpeed = ANIMATION_SPEED; // Default 400 ms (Medium)
systemSettings.CalibrationOffset = CALIBRATION_OFFSET; // the adc offset in uV
systemSettings.powerLimit = POWER_LIMIT; // 30 watts default limit
systemSettings.ReverseButtonTempChangeEnabled = REVERSE_BUTTON_TEMP_CHANGE; //
systemSettings.TempChangeShortStep = TEMP_CHANGE_SHORT_STEP; //
systemSettings.TempChangeLongStep = TEMP_CHANGE_LONG_STEP; //
systemSettings.KeepAwakePulse = POWER_PULSE_DEFAULT; // Power of the power pulse
systemSettings.KeepAwakePulseWait = POWER_PULSE_WAIT_DEFAULT; // Time between Keep Awake pulses in 2.5 second increments
systemSettings.KeepAwakePulseDuration = POWER_PULSE_DURATION_DEFAULT; // Duration of the Keep Awake pusle in 250ms increments
systemSettings.hallEffectSensitivity = 1;
systemSettings.accelMissingWarningCounter = 0;
systemSettings.pdMissingWarningCounter = 0;
memset((void *)&systemSettings, 0xFF, sizeof(systemSettingsType));
sanitiseSettings();
saveSettings(); // Save defaults
}
void setSettingValue(const enum SettingsOptions option, const uint16_t newValue) {
const auto constants = settingsConstants[(int)option];
systemSettings.settingsValues[(int)option] = newValue;
if (systemSettings.settingsValues[(int)option] < constants.min) {
systemSettings.settingsValues[(int)option] = constants.min;
}
// If hit max, constrain
if (systemSettings.settingsValues[(int)option] >= constants.max) {
systemSettings.settingsValues[(int)option] = constants.max - 1;
}
}
uint16_t getSettingValue(const enum SettingsOptions option) { return systemSettings.settingsValues[(int)option]; }
bool nextSettingValue(const enum SettingsOptions option) {
const auto constants = settingsConstants[(int)option];
if (systemSettings.settingsValues[(int)option] == (constants.max - constants.increment)) {
systemSettings.settingsValues[(int)option] = constants.min;
} else {
systemSettings.settingsValues[(int)option] += constants.increment;
}
return systemSettings.settingsValues[(int)option] == constants.max - constants.increment;
}
bool prevSettingValue(const enum SettingsOptions option) {
const auto constants = settingsConstants[(int)option];
int value = systemSettings.settingsValues[(int)option];
if (value == constants.min) {
value = constants.max;
} else {
value -= constants.increment;
}
systemSettings.settingsValues[(int)option] = value;
return systemSettings.settingsValues[(int)option] == constants.min;
}
uint16_t lookupHallEffectThreshold() {
// Return the threshold above which the hall effect sensor is "activated"
switch (systemSettings.hallEffectSensitivity) {
switch (getSettingValue(SettingsOptions::HallEffectSensitivity)) {
case 0:
return 0;
case 1: // Low
@@ -103,3 +170,19 @@ uint16_t lookupHallEffectThreshold() {
return 0; // Off
}
}
// Lookup function for cutoff setting -> X10 voltage
/*
* 0=DC
* 1=3S
* 2=4S
* 3=5S
* 4=6S
*/
uint8_t lookupVoltageLevel() {
auto minVoltageOnCell = getSettingValue(SettingsOptions::MinDCVoltageCells);
auto minVoltageCellCount = getSettingValue(SettingsOptions::MinVoltageCells);
if (minVoltageOnCell == 0)
return 90; // 9V since iron does not function effectively below this
else
return (minVoltageOnCell * minVoltageCellCount) + (minVoltageCellCount * 2);
}

File diff suppressed because it is too large Load Diff

View File

@@ -40,7 +40,7 @@ int main(void) {
setTipX10Watts(0); // force tip off
resetWatchdog();
// Testing for which accelerometer is mounted
settingsWereReset = restoreSettings(); // load the settings from flash
settingsWereReset = loadSettings(); // load the settings from flash
resetWatchdog();
/* Create the thread(s) */

View File

@@ -33,7 +33,7 @@ static uint32_t availableW10(uint8_t sample) {
// P = V^2 / R, v*v = v^2 * 100
// R = R*10
// P therefore is in V^2*100/R*10 = W*10.
uint32_t v = getInputVoltageX10(systemSettings.voltageDiv, sample); // 100 = 10v
uint32_t v = getInputVoltageX10(getSettingValue(SettingsOptions::VoltageDiv), sample); // 100 = 10v
uint32_t availableWattsX10 = (v * v) / tipResistance;
// However, 100% duty cycle is not possible as there is a dead time while the ADC takes a reading
// Therefore need to scale available milliwats by this
@@ -50,7 +50,7 @@ uint8_t X10WattsToPWM(int32_t milliWatts, uint8_t sample) {
// Scale input milliWatts to the pwm range available
if (milliWatts < 1) {
// keep the battery voltage updating the filter
getInputVoltageX10(systemSettings.voltageDiv, sample);
getInputVoltageX10(getSettingValue(SettingsOptions::VoltageDiv), sample);
return 0;
}

View File

@@ -53,7 +53,7 @@ void warnUser(const char *warning, const int timeout) {
}
void printVoltage() {
uint32_t volt = getInputVoltageX10(systemSettings.voltageDiv, 0);
uint32_t volt = getInputVoltageX10(getSettingValue(SettingsOptions::VoltageDiv), 0);
OLED::printNumber(volt / 10, 2, FontStyle::SMALL);
OLED::print(SymbolDot, FontStyle::SMALL);
OLED::printNumber(volt % 10, 1, FontStyle::SMALL);
@@ -68,7 +68,7 @@ void GUIDelay() {
void gui_drawTipTemp(bool symbol, const FontStyle font) {
// Draw tip temp handling unit conversion & tolerance near setpoint
uint32_t Temp = 0;
if (systemSettings.temperatureInF) {
if (getSettingValue(SettingsOptions::TemperatureInF)) {
Temp = TipThermoModel::getTipInF();
} else {
Temp = TipThermoModel::getTipInC();
@@ -78,13 +78,13 @@ void gui_drawTipTemp(bool symbol, const FontStyle font) {
if (symbol) {
if (font == FontStyle::LARGE) {
// Big font, can draw nice symbols
if (systemSettings.temperatureInF)
if (getSettingValue(SettingsOptions::TemperatureInF))
OLED::drawSymbol(0);
else
OLED::drawSymbol(1);
} else {
// Otherwise fall back to chars
if (systemSettings.temperatureInF)
if (getSettingValue(SettingsOptions::TemperatureInF))
OLED::print(SymbolDegF, FontStyle::SMALL);
else
OLED::print(SymbolDegC, FontStyle::SMALL);
@@ -98,7 +98,7 @@ static bool checkVoltageForExit() {
if (!getIsPoweredByDCIN()) {
return false;
}
uint16_t v = getInputVoltageX10(systemSettings.voltageDiv, 0);
uint16_t v = getInputVoltageX10(getSettingValue(SettingsOptions::VoltageDiv), 0);
// Dont check for first 2 seconds while the ADC stabilizes and the DMA fills
// the buffer
@@ -107,7 +107,7 @@ static bool checkVoltageForExit() {
currentTempTargetDegC = 0;
OLED::clearScreen();
OLED::setCursor(0, 0);
if (systemSettings.detailedSoldering) {
if (getSettingValue(SettingsOptions::DetailedSoldering)) {
OLED::print(translatedString(Tr->UndervoltageString), FontStyle::SMALL);
OLED::setCursor(0, 8);
OLED::print(translatedString(Tr->InputVoltageString), FontStyle::SMALL);
@@ -131,7 +131,7 @@ static void gui_drawBatteryIcon() {
if (!getIsPoweredByDCIN()) {
// On TS80 we replace this symbol with the voltage we are operating on
// If <9V then show single digit, if not show dual small ones vertically stacked
uint8_t V = getInputVoltageX10(systemSettings.voltageDiv, 0);
uint8_t V = getInputVoltageX10(getSettingValue(SettingsOptions::VoltageDiv), 0);
if (V % 10 >= 5)
V = V / 10 + 1; // round up
else
@@ -149,16 +149,16 @@ static void gui_drawBatteryIcon() {
}
#endif
#ifdef POW_DC
if (systemSettings.minDCVoltageCells) {
if (getSettingValue(SettingsOptions::MinDCVoltageCells)) {
// User is on a lithium battery
// we need to calculate which of the 10 levels they are on
uint8_t cellCount = systemSettings.minDCVoltageCells + 2;
uint32_t cellV = getInputVoltageX10(systemSettings.voltageDiv, 0) / cellCount;
uint8_t cellCount = getSettingValue(SettingsOptions::MinDCVoltageCells) + 2;
uint32_t cellV = getInputVoltageX10(getSettingValue(SettingsOptions::VoltageDiv), 0) / cellCount;
// Should give us approx cell voltage X10
// Range is 42 -> Minimum voltage setting (systemSettings.minVoltageCells) = 9 steps therefore we will use battery 0-9
if (cellV < systemSettings.minVoltageCells)
cellV = systemSettings.minVoltageCells;
cellV -= systemSettings.minVoltageCells; // Should leave us a number of 0-9
if (cellV < getSettingValue(SettingsOptions::MinVoltageCells))
cellV = getSettingValue(SettingsOptions::MinVoltageCells);
cellV -= getSettingValue(SettingsOptions::MinVoltageCells); // Should leave us a number of 0-9
if (cellV > 9)
cellV = 9;
OLED::drawBattery(cellV + 1);
@@ -190,6 +190,7 @@ static void gui_solderingTempAdjust() {
} else {
waitForRelease = false;
}
int16_t delta = 0;
switch (buttons) {
case BUTTON_NONE:
// stay
@@ -201,36 +202,36 @@ static void gui_solderingTempAdjust() {
break;
case BUTTON_B_LONG:
if (xTaskGetTickCount() - autoRepeatTimer + autoRepeatAcceleration > PRESS_ACCEL_INTERVAL_MAX) {
if (systemSettings.ReverseButtonTempChangeEnabled) {
systemSettings.SolderingTemp += systemSettings.TempChangeLongStep;
if (getSettingValue(SettingsOptions::ReverseButtonTempChangeEnabled)) {
delta = getSettingValue(SettingsOptions::TempChangeLongStep);
} else
systemSettings.SolderingTemp -= systemSettings.TempChangeLongStep;
delta = -getSettingValue(SettingsOptions::TempChangeLongStep);
autoRepeatTimer = xTaskGetTickCount();
autoRepeatAcceleration += PRESS_ACCEL_STEP;
}
break;
case BUTTON_B_SHORT:
if (systemSettings.ReverseButtonTempChangeEnabled) {
systemSettings.SolderingTemp += systemSettings.TempChangeShortStep;
if (getSettingValue(SettingsOptions::ReverseButtonTempChangeEnabled)) {
delta = getSettingValue(SettingsOptions::TempChangeShortStep);
} else
systemSettings.SolderingTemp -= systemSettings.TempChangeShortStep;
delta = -getSettingValue(SettingsOptions::TempChangeShortStep);
break;
case BUTTON_F_LONG:
if (xTaskGetTickCount() - autoRepeatTimer + autoRepeatAcceleration > PRESS_ACCEL_INTERVAL_MAX) {
if (systemSettings.ReverseButtonTempChangeEnabled) {
systemSettings.SolderingTemp -= systemSettings.TempChangeLongStep;
if (getSettingValue(SettingsOptions::ReverseButtonTempChangeEnabled)) {
delta = -getSettingValue(SettingsOptions::TempChangeLongStep);
} else
systemSettings.SolderingTemp += systemSettings.TempChangeLongStep;
delta = getSettingValue(SettingsOptions::TempChangeLongStep);
autoRepeatTimer = xTaskGetTickCount();
autoRepeatAcceleration += PRESS_ACCEL_STEP;
}
break;
case BUTTON_F_SHORT:
if (systemSettings.ReverseButtonTempChangeEnabled) {
systemSettings.SolderingTemp -= systemSettings.TempChangeShortStep; // add 10
if (getSettingValue(SettingsOptions::ReverseButtonTempChangeEnabled)) {
delta = -getSettingValue(SettingsOptions::TempChangeShortStep);
} else
systemSettings.SolderingTemp += systemSettings.TempChangeShortStep; // add 10
delta = getSettingValue(SettingsOptions::TempChangeShortStep);
break;
default:
break;
@@ -239,17 +240,20 @@ static void gui_solderingTempAdjust() {
autoRepeatAcceleration = PRESS_ACCEL_INTERVAL_MAX - PRESS_ACCEL_INTERVAL_MIN;
}
// constrain between 10-450 C
if (systemSettings.temperatureInF) {
if (systemSettings.SolderingTemp > MAX_TEMP_F)
systemSettings.SolderingTemp = MAX_TEMP_F;
if (systemSettings.SolderingTemp < MIN_TEMP_F)
systemSettings.SolderingTemp = MIN_TEMP_F;
uint16_t newTemp = getSettingValue(SettingsOptions::SolderingTemp);
newTemp += delta;
if (getSettingValue(SettingsOptions::TemperatureInF)) {
if (newTemp > MAX_TEMP_F)
newTemp = MAX_TEMP_F;
if (newTemp < MIN_TEMP_F)
newTemp = MIN_TEMP_F;
} else {
if (systemSettings.SolderingTemp > MAX_TEMP_C)
systemSettings.SolderingTemp = MAX_TEMP_C;
if (systemSettings.SolderingTemp < MIN_TEMP_C)
systemSettings.SolderingTemp = MIN_TEMP_C;
if (newTemp > MAX_TEMP_C)
newTemp = MAX_TEMP_C;
if (newTemp < MIN_TEMP_C)
newTemp = MIN_TEMP_C;
}
setSettingValue(SettingsOptions::SolderingTemp, newTemp);
if (xTaskGetTickCount() - lastChange > (TICKS_SECOND * 2))
return; // exit if user just doesn't press anything for a bit
@@ -259,14 +263,15 @@ static void gui_solderingTempAdjust() {
#else
if (OLED::getRotation()) {
#endif
OLED::print(systemSettings.ReverseButtonTempChangeEnabled ? SymbolPlus : SymbolMinus, FontStyle::LARGE);
OLED::print(getSettingValue(SettingsOptions::ReverseButtonTempChangeEnabled) ? SymbolPlus : SymbolMinus, FontStyle::LARGE);
} else {
OLED::print(systemSettings.ReverseButtonTempChangeEnabled ? SymbolMinus : SymbolPlus, FontStyle::LARGE);
OLED::print(getSettingValue(SettingsOptions::ReverseButtonTempChangeEnabled) ? SymbolMinus : SymbolPlus, FontStyle::LARGE);
}
OLED::print(SymbolSpace, FontStyle::LARGE);
OLED::printNumber(systemSettings.SolderingTemp, 3, FontStyle::LARGE);
if (systemSettings.temperatureInF)
OLED::printNumber(getSettingValue(SettingsOptions::SolderingTemp), 3, FontStyle::LARGE);
if (getSettingValue(SettingsOptions::TemperatureInF))
OLED::drawSymbol(0);
else {
OLED::drawSymbol(1);
@@ -277,23 +282,23 @@ static void gui_solderingTempAdjust() {
#else
if (OLED::getRotation()) {
#endif
OLED::print(systemSettings.ReverseButtonTempChangeEnabled ? SymbolMinus : SymbolPlus, FontStyle::LARGE);
OLED::print(getSettingValue(SettingsOptions::ReverseButtonTempChangeEnabled) ? SymbolMinus : SymbolPlus, FontStyle::LARGE);
} else {
OLED::print(systemSettings.ReverseButtonTempChangeEnabled ? SymbolPlus : SymbolMinus, FontStyle::LARGE);
OLED::print(getSettingValue(SettingsOptions::ReverseButtonTempChangeEnabled) ? SymbolPlus : SymbolMinus, FontStyle::LARGE);
}
OLED::refresh();
GUIDelay();
}
}
static bool shouldShutdown() {
if (systemSettings.ShutdownTime) { // only allow shutdown exit if time > 0
if (getSettingValue(SettingsOptions::ShutdownTime)) { // only allow shutdown exit if time > 0
if (lastMovementTime) {
if (((TickType_t)(xTaskGetTickCount() - lastMovementTime)) > (TickType_t)(systemSettings.ShutdownTime * TICKS_MIN)) {
if (((TickType_t)(xTaskGetTickCount() - lastMovementTime)) > (TickType_t)(getSettingValue(SettingsOptions::ShutdownTime) * TICKS_MIN)) {
return true;
}
}
if (lastHallEffectSleepStart) {
if (((TickType_t)(xTaskGetTickCount() - lastHallEffectSleepStart)) > (TickType_t)(systemSettings.ShutdownTime * TICKS_MIN)) {
if (((TickType_t)(xTaskGetTickCount() - lastHallEffectSleepStart)) > (TickType_t)(getSettingValue(SettingsOptions::ShutdownTime) * TICKS_MIN)) {
return true;
}
}
@@ -314,14 +319,14 @@ static int gui_SolderingSleepingMode(bool stayOff, bool autoStarted) {
if (checkVoltageForExit())
return 1; // return non-zero on error
#endif
if (systemSettings.temperatureInF) {
currentTempTargetDegC = stayOff ? 0 : TipThermoModel::convertFtoC(min(systemSettings.SleepTemp, systemSettings.SolderingTemp));
if (getSettingValue(SettingsOptions::TemperatureInF)) {
currentTempTargetDegC = stayOff ? 0 : TipThermoModel::convertFtoC(min(getSettingValue(SettingsOptions::SleepTemp), getSettingValue(SettingsOptions::SolderingTemp)));
} else {
currentTempTargetDegC = stayOff ? 0 : min(systemSettings.SleepTemp, systemSettings.SolderingTemp);
currentTempTargetDegC = stayOff ? 0 : min(getSettingValue(SettingsOptions::SleepTemp), getSettingValue(SettingsOptions::SolderingTemp));
}
// draw the lcd
uint16_t tipTemp;
if (systemSettings.temperatureInF)
if (getSettingValue(SettingsOptions::TemperatureInF))
tipTemp = TipThermoModel::getTipInF();
else {
tipTemp = TipThermoModel::getTipInC();
@@ -329,12 +334,12 @@ static int gui_SolderingSleepingMode(bool stayOff, bool autoStarted) {
OLED::clearScreen();
OLED::setCursor(0, 0);
if (systemSettings.detailedSoldering) {
if (getSettingValue(SettingsOptions::DetailedSoldering)) {
OLED::print(translatedString(Tr->SleepingAdvancedString), FontStyle::SMALL);
OLED::setCursor(0, 8);
OLED::print(translatedString(Tr->SleepingTipAdvancedString), FontStyle::SMALL);
OLED::printNumber(tipTemp, 3, FontStyle::SMALL);
if (systemSettings.temperatureInF)
if (getSettingValue(SettingsOptions::TemperatureInF))
OLED::print(SymbolDegF, FontStyle::SMALL);
else {
OLED::print(SymbolDegC, FontStyle::SMALL);
@@ -346,7 +351,7 @@ static int gui_SolderingSleepingMode(bool stayOff, bool autoStarted) {
} else {
OLED::print(translatedString(Tr->SleepingSimpleString), FontStyle::LARGE);
OLED::printNumber(tipTemp, 3, FontStyle::LARGE);
if (systemSettings.temperatureInF)
if (getSettingValue(SettingsOptions::TemperatureInF))
OLED::drawSymbol(0);
else {
OLED::drawSymbol(1);
@@ -357,7 +362,7 @@ static int gui_SolderingSleepingMode(bool stayOff, bool autoStarted) {
GUIDelay();
#ifdef ACCEL_EXITS_ON_MOVEMENT
// If the accel works in reverse where movement will cause exiting the soldering mode
if (systemSettings.sensitivity) {
if (getSettingValue(SettingsOptions::Sensitivity)) {
if (lastMovementTime) {
if (lastMovementTime > TICKS_SECOND * 10) {
// If we have moved recently; in the last second
@@ -404,13 +409,13 @@ static void display_countdown(int sleepThres) {
}
static uint32_t getSleepTimeout() {
if (systemSettings.sensitivity && systemSettings.SleepTime) {
if (getSettingValue(SettingsOptions::Sensitivity) && getSettingValue(SettingsOptions::SleepTime)) {
uint32_t sleepThres = 0;
if (systemSettings.SleepTime < 6)
sleepThres = systemSettings.SleepTime * 10 * 1000;
if (getSettingValue(SettingsOptions::SleepTime) < 6)
sleepThres = getSettingValue(SettingsOptions::SleepTime) * 10 * 1000;
else
sleepThres = (systemSettings.SleepTime - 5) * 60 * 1000;
sleepThres = (getSettingValue(SettingsOptions::SleepTime) - 5) * 60 * 1000;
return sleepThres;
}
return 0;
@@ -419,7 +424,7 @@ static uint32_t getSleepTimeout() {
static bool shouldBeSleeping(bool inAutoStart) {
#ifndef NO_SLEEP_MODE
// Return true if the iron should be in sleep mode
if (systemSettings.sensitivity && systemSettings.SleepTime) {
if (getSettingValue(SettingsOptions::Sensitivity) && getSettingValue(SettingsOptions::SleepTime)) {
if (inAutoStart) {
// In auto start we are asleep until movement
if (lastMovementTime == 0 && lastButtonTime == 0) {
@@ -482,7 +487,7 @@ static void gui_solderingMode(uint8_t jumpToSleep) {
}
for (;;) {
ButtonState buttons = getButtonState();
if (buttonsLocked && (systemSettings.lockingMode != 0)) { // If buttons locked
if (buttonsLocked && (getSettingValue(SettingsOptions::LockingMode) != 0)) { // If buttons locked
switch (buttons) {
case BUTTON_NONE:
boostModeOn = false;
@@ -494,7 +499,7 @@ static void gui_solderingMode(uint8_t jumpToSleep) {
break;
case BUTTON_F_LONG:
// if boost mode is enabled turn it on
if (systemSettings.BoostTemp && (systemSettings.lockingMode == 1)) {
if (getSettingValue(SettingsOptions::BoostTemp) && (getSettingValue(SettingsOptions::LockingMode) == 1)) {
boostModeOn = true;
}
break;
@@ -524,19 +529,19 @@ static void gui_solderingMode(uint8_t jumpToSleep) {
break;
case BUTTON_F_LONG:
// if boost mode is enabled turn it on
if (systemSettings.BoostTemp)
if (getSettingValue(SettingsOptions::BoostTemp))
boostModeOn = true;
break;
case BUTTON_F_SHORT:
case BUTTON_B_SHORT: {
uint16_t oldTemp = systemSettings.SolderingTemp;
uint16_t oldTemp = getSettingValue(SettingsOptions::SolderingTemp);
gui_solderingTempAdjust(); // goto adjust temp mode
if (oldTemp != systemSettings.SolderingTemp) {
if (oldTemp != getSettingValue(SettingsOptions::SolderingTemp)) {
saveSettings(); // only save on change
}
} break;
case BUTTON_BOTH_LONG:
if (systemSettings.lockingMode != 0) {
if (getSettingValue(SettingsOptions::LockingMode) != 0) {
// Lock buttons
buttonsLocked = true;
warnUser(translatedString(Tr->LockingKeysString), TICKS_SECOND);
@@ -550,11 +555,11 @@ static void gui_solderingMode(uint8_t jumpToSleep) {
OLED::setCursor(0, 0);
OLED::clearScreen();
// Draw in the screen details
if (systemSettings.detailedSoldering) {
if (getSettingValue(SettingsOptions::DetailedSoldering)) {
gui_drawTipTemp(true, FontStyle::LARGE);
#ifndef NO_SLEEP_MODE
if (systemSettings.sensitivity && systemSettings.SleepTime) {
if (getSettingValue(SettingsOptions::Sensitivity) && getSettingValue(SettingsOptions::SleepTime)) {
OLED::setCursor(47, 0);
display_countdown(getSleepTimeout());
}
@@ -610,16 +615,16 @@ static void gui_solderingMode(uint8_t jumpToSleep) {
OLED::refresh();
// Update the setpoints for the temperature
if (boostModeOn) {
if (systemSettings.temperatureInF)
currentTempTargetDegC = TipThermoModel::convertFtoC(systemSettings.BoostTemp);
if (getSettingValue(SettingsOptions::TemperatureInF))
currentTempTargetDegC = TipThermoModel::convertFtoC(getSettingValue(SettingsOptions::BoostTemp));
else {
currentTempTargetDegC = (systemSettings.BoostTemp);
currentTempTargetDegC = (getSettingValue(SettingsOptions::BoostTemp));
}
} else {
if (systemSettings.temperatureInF)
currentTempTargetDegC = TipThermoModel::convertFtoC(systemSettings.SolderingTemp);
if (getSettingValue(SettingsOptions::TemperatureInF))
currentTempTargetDegC = TipThermoModel::convertFtoC(getSettingValue(SettingsOptions::SolderingTemp));
else {
currentTempTargetDegC = (systemSettings.SolderingTemp);
currentTempTargetDegC = (getSettingValue(SettingsOptions::SolderingTemp));
}
}
@@ -768,8 +773,8 @@ void showWarnings() {
}
// Display alert if accelerometer is not detected
if (DetectedAccelerometerVersion == NO_DETECTED_ACCELEROMETER) {
if (systemSettings.accelMissingWarningCounter < 2) {
systemSettings.accelMissingWarningCounter++;
if (getSettingValue(SettingsOptions::AccelMissingWarningCounter) < 2) {
nextSettingValue(SettingsOptions::AccelMissingWarningCounter);
saveSettings();
warnUser(translatedString(Tr->NoAccelerometerMessage), 10 * TICKS_SECOND);
}
@@ -777,8 +782,8 @@ void showWarnings() {
#ifdef POW_PD
// We expect pd to be present
if (!usb_pd_detect()) {
if (systemSettings.pdMissingWarningCounter < 2) {
systemSettings.pdMissingWarningCounter++;
if (getSettingValue(SettingsOptions::PDMissingWarningCounter) < 2) {
nextSettingValue(SettingsOptions::PDMissingWarningCounter);
saveSettings();
warnUser(translatedString(Tr->NoPowerDeliveryMessage), 10 * TICKS_SECOND);
}
@@ -789,7 +794,8 @@ void showWarnings() {
uint8_t idleScreenBGF[sizeof(idleScreenBG)];
/* StartGUITask function */
void startGUITask(void const *argument __unused) {
void startGUITask(void const *argument) {
(void)argument;
prepareTranslations();
OLED::initialize(); // start up the LCD
@@ -809,7 +815,7 @@ void startGUITask(void const *argument __unused) {
}
}
getTipRawTemp(1); // reset filter
OLED::setRotation(systemSettings.OrientationMode & 1);
OLED::setRotation(getSettingValue(SettingsOptions::OrientationMode) & 1);
uint32_t ticks = xTaskGetTickCount();
ticks += (TICKS_SECOND * 4); // 4 seconds from now
while (xTaskGetTickCount() < ticks) {
@@ -823,9 +829,9 @@ void startGUITask(void const *argument __unused) {
showWarnings();
if (systemSettings.autoStartMode) {
if (getSettingValue(SettingsOptions::AutoStartMode)) {
// jump directly to the autostart mode
gui_solderingMode(systemSettings.autoStartMode - 1);
gui_solderingMode(getSettingValue(SettingsOptions::AutoStartMode) - 1);
buttonLockout = true;
}
@@ -878,7 +884,7 @@ void startGUITask(void const *argument __unused) {
}
currentTempTargetDegC = 0; // ensure tip is off
getInputVoltageX10(systemSettings.voltageDiv, 0);
getInputVoltageX10(getSettingValue(SettingsOptions::VoltageDiv), 0);
uint32_t tipTemp = TipThermoModel::getTipInC();
if (tipTemp > 55) {
setStatusLED(LED_COOLING_STILL_HOT);
@@ -892,25 +898,26 @@ void startGUITask(void const *argument __unused) {
// This is zero cost really as state is only changed on display updates
OLED::setDisplayState(OLED::DisplayState::ON);
if ((tipTemp < 50) && systemSettings.sensitivity && (((xTaskGetTickCount() - lastMovementTime) > MOVEMENT_INACTIVITY_TIME) && ((xTaskGetTickCount() - lastButtonTime) > BUTTON_INACTIVITY_TIME))) {
if ((tipTemp < 50) && getSettingValue(SettingsOptions::Sensitivity)
&& (((xTaskGetTickCount() - lastMovementTime) > MOVEMENT_INACTIVITY_TIME) && ((xTaskGetTickCount() - lastButtonTime) > BUTTON_INACTIVITY_TIME))) {
OLED::setDisplayState(OLED::DisplayState::OFF);
setStatusLED(LED_OFF);
}
// Clear the lcd buffer
OLED::clearScreen();
OLED::setCursor(0, 0);
if (systemSettings.detailedIDLE) {
if (getSettingValue(SettingsOptions::DetailedIDLE)) {
if (isTipDisconnected()) {
OLED::print(translatedString(Tr->TipDisconnectedString), FontStyle::SMALL);
} else {
if (!(systemSettings.coolingTempBlink && (tipTemp > 55) && (xTaskGetTickCount() % 1000 < 300)))
if (!(getSettingValue(SettingsOptions::CoolingTempBlink) && (tipTemp > 55) && (xTaskGetTickCount() % 1000 < 300)))
// Blink temp if setting enable and temp < 55°
// 1000 tick/sec
// OFF 300ms ON 700ms
gui_drawTipTemp(true, FontStyle::LARGE); // draw in the temp
OLED::setCursor(73, 0); // top right
OLED::printNumber(systemSettings.SolderingTemp, 3, FontStyle::SMALL); // draw set temp
if (systemSettings.temperatureInF)
gui_drawTipTemp(true, FontStyle::LARGE); // draw in the temp
OLED::setCursor(73, 0); // top right
OLED::printNumber(getSettingValue(SettingsOptions::SolderingTemp), 3, FontStyle::SMALL); // draw set temp
if (getSettingValue(SettingsOptions::TemperatureInF))
OLED::print(SymbolDegF, FontStyle::SMALL);
else
OLED::print(SymbolDegC, FontStyle::SMALL);
@@ -963,7 +970,7 @@ void startGUITask(void const *argument __unused) {
// If we have a tip connected draw the temp, if not we leave it blank
if (!tipDisconnectedDisplay) {
// draw in the temp
if (!(systemSettings.coolingTempBlink && (xTaskGetTickCount() % 260 < 160)))
if (!(getSettingValue(SettingsOptions::CoolingTempBlink) && (xTaskGetTickCount() % 260 < 160)))
gui_drawTipTemp(false, FontStyle::LARGE); // draw in the temp
} else {
// Draw in missing tip symbol

View File

@@ -70,7 +70,7 @@ void detectAccelerometerVersion() {
#endif
{
// disable imu sensitivity
systemSettings.sensitivity = 0;
setSettingValue(SettingsOptions::Sensitivity, 0);
DetectedAccelerometerVersion = NO_DETECTED_ACCELEROMETER;
}
}
@@ -116,23 +116,21 @@ void startMOVTask(void const *argument __unused) {
lastMovementTime = 0;
// Mask 2 seconds if we are in autostart so that if user is plugging in and
// then putting in stand it doesnt wake instantly
if (systemSettings.autoStartMode)
if (getSettingValue(SettingsOptions::AutoStartMode))
osDelay(2 * TICKS_SECOND);
int16_t datax[MOVFilter] = {0};
int16_t datay[MOVFilter] = {0};
int16_t dataz[MOVFilter] = {0};
uint8_t currentPointer = 0;
int16_t tx = 0, ty = 0, tz = 0;
int32_t avgx, avgy, avgz;
if (systemSettings.sensitivity > 9)
systemSettings.sensitivity = 9;
int16_t datax[MOVFilter] = {0};
int16_t datay[MOVFilter] = {0};
int16_t dataz[MOVFilter] = {0};
uint8_t currentPointer = 0;
int16_t tx = 0, ty = 0, tz = 0;
int32_t avgx, avgy, avgz;
Orientation rotation = ORIENTATION_FLAT;
for (;;) {
int32_t threshold = 1500 + (9 * 200);
threshold -= systemSettings.sensitivity * 200; // 200 is the step size
threshold -= getSettingValue(SettingsOptions::Sensitivity) * 200; // 200 is the step size
readAccelerometer(tx, ty, tz, rotation);
if (systemSettings.OrientationMode == 2) {
if (getSettingValue(SettingsOptions::OrientationMode) == 2) {
if (rotation != ORIENTATION_FLAT) {
OLED::setRotation(rotation == ORIENTATION_LEFT_HAND); // link the data through
}

View File

@@ -122,18 +122,19 @@ void startPIDTask(void const *argument __unused) {
tipTempCRunawayTemp = currentTipTempInC;
runawaylastChangeTime = xTaskGetTickCount();
}
// If the user turns on the option of using an occasional pulse to keep the power bank on
if (systemSettings.KeepAwakePulse) {
const TickType_t powerPulseWait = powerPulseWaitUnit * systemSettings.KeepAwakePulseWait;
if (getSettingValue(SettingsOptions::KeepAwakePulse)) {
const TickType_t powerPulseWait = powerPulseWaitUnit * getSettingValue(SettingsOptions::KeepAwakePulseWait);
if (xTaskGetTickCount() - lastPowerPulseStart > powerPulseWait) {
const TickType_t powerPulseDuration = powerPulseDurationUnit * systemSettings.KeepAwakePulseDuration;
const TickType_t powerPulseDuration = powerPulseDurationUnit * getSettingValue(SettingsOptions::KeepAwakePulseDuration);
lastPowerPulseStart = xTaskGetTickCount();
lastPowerPulseEnd = lastPowerPulseStart + powerPulseDuration;
}
// If current PID is less than the pulse level, check if we want to constrain to the pulse as the floor
if (x10WattsOut < systemSettings.KeepAwakePulse && xTaskGetTickCount() < lastPowerPulseEnd) {
x10WattsOut = systemSettings.KeepAwakePulse;
if (x10WattsOut < getSettingValue(SettingsOptions::KeepAwakePulse) && xTaskGetTickCount() < lastPowerPulseEnd) {
x10WattsOut = getSettingValue(SettingsOptions::KeepAwakePulse);
}
}
@@ -144,8 +145,8 @@ void startPIDTask(void const *argument __unused) {
if (heaterThermalRunaway) {
x10WattsOut = 0;
}
if (systemSettings.powerLimit && x10WattsOut > (systemSettings.powerLimit * 10)) {
x10WattsOut = systemSettings.powerLimit * 10;
if (getSettingValue(SettingsOptions::PowerLimit) && x10WattsOut > (getSettingValue(SettingsOptions::PowerLimit) * 10)) {
x10WattsOut = getSettingValue(SettingsOptions::PowerLimit) * 10;
}
if (powerSupplyWattageLimit && x10WattsOut > powerSupplyWattageLimit * 10) {
x10WattsOut = powerSupplyWattageLimit * 10;