Update GUIThread.cpp
This commit is contained in:
@@ -7,22 +7,22 @@
|
||||
extern "C" {
|
||||
#include "FreeRTOSConfig.h"
|
||||
}
|
||||
#include <MMA8652FC.hpp>
|
||||
#include <gui.hpp>
|
||||
#include <history.hpp>
|
||||
#include "main.hpp"
|
||||
#include <power.hpp>
|
||||
#include "../../configuration.h"
|
||||
#include "Buttons.hpp"
|
||||
#include "I2CBB.hpp"
|
||||
#include "LIS2DH12.hpp"
|
||||
#include "Settings.h"
|
||||
#include "TipThermoModel.h"
|
||||
#include "Translation.h"
|
||||
#include "cmsis_os.h"
|
||||
#include "main.hpp"
|
||||
#include "stdlib.h"
|
||||
#include "string.h"
|
||||
#include "unit.h"
|
||||
#include "I2CBB.hpp"
|
||||
#include <MMA8652FC.hpp>
|
||||
#include <gui.hpp>
|
||||
#include <history.hpp>
|
||||
#include <power.hpp>
|
||||
// File local variables
|
||||
extern uint32_t currentTempTargetDegC;
|
||||
extern TickType_t lastMovementTime;
|
||||
@@ -96,7 +96,8 @@ static bool checkVoltageForExit() {
|
||||
}
|
||||
uint16_t v = getInputVoltageX10(systemSettings.voltageDiv, 0);
|
||||
|
||||
// Dont check for first 2 seconds while the ADC stabilizes and the DMA fills the buffer
|
||||
// Dont check for first 2 seconds while the ADC stabilizes and the DMA fills
|
||||
// the buffer
|
||||
if (xTaskGetTickCount() > (TICKS_SECOND * 2)) {
|
||||
if ((v < lookupVoltageLevel())) {
|
||||
currentTempTargetDegC = 0;
|
||||
@@ -149,8 +150,8 @@ static void gui_drawBatteryIcon() {
|
||||
// User is on a lithium battery
|
||||
// we need to calculate which of the 10 levels they are on
|
||||
uint8_t cellCount = systemSettings.cutoutSetting + 2;
|
||||
uint32_t cellV = getInputVoltageX10(systemSettings.voltageDiv, 0)
|
||||
/ cellCount;
|
||||
uint32_t cellV =
|
||||
getInputVoltageX10(systemSettings.voltageDiv, 0) / cellCount;
|
||||
// Should give us approx cell voltage X10
|
||||
// Range is 42 -> 33 = 9 steps therefore we will use battery 1-10
|
||||
if (cellV < 33)
|
||||
@@ -162,7 +163,6 @@ static void gui_drawBatteryIcon() {
|
||||
} else
|
||||
OLED::drawSymbol(15); // Draw the DC Logo
|
||||
#endif
|
||||
|
||||
}
|
||||
static void gui_solderingTempAdjust() {
|
||||
uint32_t lastChange = xTaskGetTickCount();
|
||||
@@ -185,7 +185,8 @@ static void gui_solderingTempAdjust() {
|
||||
return;
|
||||
break;
|
||||
case BUTTON_B_LONG:
|
||||
if (xTaskGetTickCount() - autoRepeatTimer + autoRepeatAcceleration > PRESS_ACCEL_INTERVAL_MAX) {
|
||||
if (xTaskGetTickCount() - autoRepeatTimer + autoRepeatAcceleration >
|
||||
PRESS_ACCEL_INTERVAL_MAX) {
|
||||
if (systemSettings.ReverseButtonTempChangeEnabled) {
|
||||
systemSettings.SolderingTemp += systemSettings.TempChangeLongStep;
|
||||
} else
|
||||
@@ -202,7 +203,8 @@ static void gui_solderingTempAdjust() {
|
||||
systemSettings.SolderingTemp -= systemSettings.TempChangeShortStep;
|
||||
break;
|
||||
case BUTTON_F_LONG:
|
||||
if (xTaskGetTickCount() - autoRepeatTimer + autoRepeatAcceleration > PRESS_ACCEL_INTERVAL_MAX) {
|
||||
if (xTaskGetTickCount() - autoRepeatTimer + autoRepeatAcceleration >
|
||||
PRESS_ACCEL_INTERVAL_MAX) {
|
||||
if (systemSettings.ReverseButtonTempChangeEnabled) {
|
||||
systemSettings.SolderingTemp -= systemSettings.TempChangeLongStep;
|
||||
} else
|
||||
@@ -220,14 +222,18 @@ static void gui_solderingTempAdjust() {
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if ((PRESS_ACCEL_INTERVAL_MAX - autoRepeatAcceleration) < PRESS_ACCEL_INTERVAL_MIN) {
|
||||
autoRepeatAcceleration = PRESS_ACCEL_INTERVAL_MAX - PRESS_ACCEL_INTERVAL_MIN;
|
||||
if ((PRESS_ACCEL_INTERVAL_MAX - autoRepeatAcceleration) <
|
||||
PRESS_ACCEL_INTERVAL_MIN) {
|
||||
autoRepeatAcceleration =
|
||||
PRESS_ACCEL_INTERVAL_MAX - PRESS_ACCEL_INTERVAL_MIN;
|
||||
}
|
||||
// constrain between 10-450 C
|
||||
#ifdef ENABLED_FAHRENHEIT_SUPPORT
|
||||
if (systemSettings.temperatureInF) {
|
||||
if (systemSettings.SolderingTemp > 850) systemSettings.SolderingTemp = 850;
|
||||
if (systemSettings.SolderingTemp < 60) systemSettings.SolderingTemp = 60;
|
||||
if (systemSettings.SolderingTemp > 850)
|
||||
systemSettings.SolderingTemp = 850;
|
||||
if (systemSettings.SolderingTemp < 60)
|
||||
systemSettings.SolderingTemp = 60;
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
@@ -298,13 +304,17 @@ static int gui_SolderingSleepingMode(bool stayOff) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef MODEL_TS100
|
||||
#ifdef POW_PD
|
||||
if (checkVoltageForExit())
|
||||
return 1; // return non-zero on error
|
||||
#endif
|
||||
#ifdef ENABLED_FAHRENHEIT_SUPPORT
|
||||
if (systemSettings.temperatureInF) {
|
||||
currentTempTargetDegC = stayOff ? 0 : TipThermoModel::convertFtoC(min(systemSettings.SleepTemp, systemSettings.SolderingTemp));
|
||||
currentTempTargetDegC =
|
||||
stayOff
|
||||
? 0
|
||||
: TipThermoModel::convertFtoC(min(systemSettings.SleepTemp,
|
||||
systemSettings.SolderingTemp));
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
@@ -394,19 +404,20 @@ static uint32_t getSleepTimeout() {
|
||||
return 0;
|
||||
}
|
||||
static bool shouldBeSleeping() {
|
||||
//Return true if the iron should be in sleep mode
|
||||
// Return true if the iron should be in sleep mode
|
||||
if (systemSettings.sensitivity && systemSettings.SleepTime) {
|
||||
if ((xTaskGetTickCount() - lastMovementTime) > getSleepTimeout() && (xTaskGetTickCount() - lastButtonTime) > getSleepTimeout()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
#ifdef HALL_SENSOR
|
||||
//If the hall effect sensor is enabled in the build, check if its over threshold, and if so then we force sleep
|
||||
// If the hall effect sensor is enabled in the build, check if its over
|
||||
// threshold, and if so then we force sleep
|
||||
if (lookupHallEffectThreshold()) {
|
||||
int16_t hallEffectStrength = getRawHallEffect();
|
||||
if (hallEffectStrength < 0)
|
||||
hallEffectStrength = -hallEffectStrength;
|
||||
//Have absolute value of measure of magnetic field strength
|
||||
// Have absolute value of measure of magnetic field strength
|
||||
if (hallEffectStrength > lookupHallEffectThreshold()) {
|
||||
if (lastHallEffectSleepStart == 0) {
|
||||
lastHallEffectSleepStart = xTaskGetTickCount();
|
||||
@@ -459,7 +470,7 @@ static void gui_solderingMode(uint8_t jumpToSleep) {
|
||||
OLED::setCursor(0, 0);
|
||||
OLED::clearScreen();
|
||||
OLED::setFont(0);
|
||||
OLED::print(UnlockingKeysString);
|
||||
OLED::print (UnlockingKeysString);
|
||||
OLED::refresh();
|
||||
waitForButtonPressOrTimeout(1000);
|
||||
break;
|
||||
@@ -479,7 +490,7 @@ static void gui_solderingMode(uint8_t jumpToSleep) {
|
||||
OLED::setCursor(0, 0);
|
||||
OLED::clearScreen();
|
||||
OLED::setFont(0);
|
||||
OLED::print(WarningKeysLockedString);
|
||||
OLED::print (WarningKeysLockedString);
|
||||
OLED::refresh();
|
||||
waitForButtonPressOrTimeout(500);
|
||||
break;
|
||||
@@ -520,7 +531,7 @@ static void gui_solderingMode(uint8_t jumpToSleep) {
|
||||
OLED::setCursor(0, 0);
|
||||
OLED::clearScreen();
|
||||
OLED::setFont(0);
|
||||
OLED::print(LockingKeysString);
|
||||
OLED::print (LockingKeysString);
|
||||
OLED::refresh();
|
||||
waitForButtonPressOrTimeout(1000);
|
||||
}
|
||||
@@ -593,7 +604,8 @@ static void gui_solderingMode(uint8_t jumpToSleep) {
|
||||
if (boostModeOn) {
|
||||
#ifdef ENABLED_FAHRENHEIT_SUPPORT
|
||||
if (systemSettings.temperatureInF)
|
||||
currentTempTargetDegC = TipThermoModel::convertFtoC(systemSettings.BoostTemp);
|
||||
currentTempTargetDegC =
|
||||
TipThermoModel::convertFtoC(systemSettings.BoostTemp);
|
||||
else
|
||||
#endif
|
||||
{
|
||||
@@ -602,7 +614,8 @@ static void gui_solderingMode(uint8_t jumpToSleep) {
|
||||
} else {
|
||||
#ifdef ENABLED_FAHRENHEIT_SUPPORT
|
||||
if (systemSettings.temperatureInF)
|
||||
currentTempTargetDegC = TipThermoModel::convertFtoC(systemSettings.SolderingTemp);
|
||||
currentTempTargetDegC =
|
||||
TipThermoModel::convertFtoC(systemSettings.SolderingTemp);
|
||||
else
|
||||
#endif
|
||||
{
|
||||
@@ -710,8 +723,8 @@ void startGUITask(void const *argument __unused) {
|
||||
bool buttonLockout = false;
|
||||
bool tempOnDisplay = false;
|
||||
{
|
||||
//Generate the flipped screen into ram for later use
|
||||
//flipped is generated by flipping each row
|
||||
// Generate the flipped screen into ram for later use
|
||||
// flipped is generated by flipping each row
|
||||
for (int row = 0; row < 2; row++) {
|
||||
for (int x = 0; x < 84; x++) {
|
||||
idleScreenBGF[(row * 84) + x] = idleScreenBG[(row * 84) + (83 - x)];
|
||||
@@ -807,7 +820,8 @@ void startGUITask(void const *argument __unused) {
|
||||
// button presses) in a while.
|
||||
OLED::setDisplayState(OLED::DisplayState::ON);
|
||||
|
||||
if ((tipTemp < 50) && systemSettings.sensitivity && (((xTaskGetTickCount() - lastMovementTime) > MOVEMENT_INACTIVITY_TIME) && ((xTaskGetTickCount() - lastButtonTime) > BUTTON_INACTIVITY_TIME))) {
|
||||
if ((tipTemp < 50) && systemSettings.sensitivity && (((xTaskGetTickCount() - lastMovementTime) >
|
||||
MOVEMENT_INACTIVITY_TIME) && ((xTaskGetTickCount() - lastButtonTime) > BUTTON_INACTIVITY_TIME))) {
|
||||
OLED::setDisplayState(OLED::DisplayState::OFF);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user