|
|
|
|
@@ -9,19 +9,20 @@ extern "C" {
|
|
|
|
|
}
|
|
|
|
|
#include <MMA8652FC.hpp>
|
|
|
|
|
#include <gui.hpp>
|
|
|
|
|
#include <main.hpp>
|
|
|
|
|
#include "LIS2DH12.hpp"
|
|
|
|
|
#include <history.hpp>
|
|
|
|
|
#include <main.hpp>
|
|
|
|
|
#include <power.hpp>
|
|
|
|
|
|
|
|
|
|
#include "../../configuration.h"
|
|
|
|
|
#include "Buttons.hpp"
|
|
|
|
|
#include "LIS2DH12.hpp"
|
|
|
|
|
#include "Settings.h"
|
|
|
|
|
#include "TipThermoModel.h"
|
|
|
|
|
#include "Translation.h"
|
|
|
|
|
#include "cmsis_os.h"
|
|
|
|
|
#include "stdlib.h"
|
|
|
|
|
#include "string.h"
|
|
|
|
|
#include "TipThermoModel.h"
|
|
|
|
|
#include "unit.h"
|
|
|
|
|
#include "../../configuration.h"
|
|
|
|
|
#include "Buttons.hpp"
|
|
|
|
|
extern uint8_t PCBVersion;
|
|
|
|
|
// File local variables
|
|
|
|
|
extern uint32_t currentTempTargetDegC;
|
|
|
|
|
@@ -126,15 +127,12 @@ 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)
|
|
|
|
|
cellV = 33;
|
|
|
|
|
if (cellV < 33) cellV = 33;
|
|
|
|
|
cellV -= 33; // Should leave us a number of 0-9
|
|
|
|
|
if (cellV > 9)
|
|
|
|
|
cellV = 9;
|
|
|
|
|
if (cellV > 9) cellV = 9;
|
|
|
|
|
OLED::drawBattery(cellV + 1);
|
|
|
|
|
} else
|
|
|
|
|
OLED::drawSymbol(15); // Draw the DC Logo
|
|
|
|
|
@@ -169,8 +167,7 @@ static void gui_solderingTempAdjust() {
|
|
|
|
|
OLED::clearScreen();
|
|
|
|
|
OLED::setFont(0);
|
|
|
|
|
ButtonState buttons = getButtonState();
|
|
|
|
|
if (buttons)
|
|
|
|
|
lastChange = xTaskGetTickCount();
|
|
|
|
|
if (buttons) lastChange = xTaskGetTickCount();
|
|
|
|
|
switch (buttons) {
|
|
|
|
|
case BUTTON_NONE:
|
|
|
|
|
// stay
|
|
|
|
|
@@ -180,14 +177,11 @@ 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;
|
|
|
|
|
systemSettings.SolderingTemp += systemSettings.TempChangeLongStep;
|
|
|
|
|
} else
|
|
|
|
|
systemSettings.SolderingTemp -=
|
|
|
|
|
systemSettings.TempChangeLongStep;
|
|
|
|
|
systemSettings.SolderingTemp -= systemSettings.TempChangeLongStep;
|
|
|
|
|
|
|
|
|
|
autoRepeatTimer = xTaskGetTickCount();
|
|
|
|
|
autoRepeatAcceleration += PRESS_ACCEL_STEP;
|
|
|
|
|
@@ -195,73 +189,54 @@ static void gui_solderingTempAdjust() {
|
|
|
|
|
break;
|
|
|
|
|
case BUTTON_B_SHORT:
|
|
|
|
|
if (systemSettings.ReverseButtonTempChangeEnabled) {
|
|
|
|
|
systemSettings.SolderingTemp +=
|
|
|
|
|
systemSettings.TempChangeShortStep;
|
|
|
|
|
systemSettings.SolderingTemp += systemSettings.TempChangeShortStep;
|
|
|
|
|
} else
|
|
|
|
|
systemSettings.SolderingTemp -=
|
|
|
|
|
systemSettings.TempChangeShortStep;
|
|
|
|
|
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;
|
|
|
|
|
systemSettings.SolderingTemp -= systemSettings.TempChangeLongStep;
|
|
|
|
|
} else
|
|
|
|
|
systemSettings.SolderingTemp +=
|
|
|
|
|
systemSettings.TempChangeLongStep;
|
|
|
|
|
systemSettings.SolderingTemp += systemSettings.TempChangeLongStep;
|
|
|
|
|
autoRepeatTimer = xTaskGetTickCount();
|
|
|
|
|
autoRepeatAcceleration += PRESS_ACCEL_STEP;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case BUTTON_F_SHORT:
|
|
|
|
|
if (systemSettings.ReverseButtonTempChangeEnabled) {
|
|
|
|
|
systemSettings.SolderingTemp -=
|
|
|
|
|
systemSettings.TempChangeShortStep; // add 10
|
|
|
|
|
systemSettings.SolderingTemp -= systemSettings.TempChangeShortStep; // add 10
|
|
|
|
|
} else
|
|
|
|
|
systemSettings.SolderingTemp +=
|
|
|
|
|
systemSettings.TempChangeShortStep; // add 10
|
|
|
|
|
systemSettings.SolderingTemp += systemSettings.TempChangeShortStep; // add 10
|
|
|
|
|
break;
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
if (systemSettings.SolderingTemp > 850) systemSettings.SolderingTemp = 850;
|
|
|
|
|
if (systemSettings.SolderingTemp < 60) systemSettings.SolderingTemp = 60;
|
|
|
|
|
} else
|
|
|
|
|
#endif
|
|
|
|
|
{
|
|
|
|
|
if (systemSettings.SolderingTemp > 450)
|
|
|
|
|
systemSettings.SolderingTemp = 450;
|
|
|
|
|
if (systemSettings.SolderingTemp < 10)
|
|
|
|
|
systemSettings.SolderingTemp = 10;
|
|
|
|
|
if (systemSettings.SolderingTemp > 450) systemSettings.SolderingTemp = 450;
|
|
|
|
|
if (systemSettings.SolderingTemp < 10) systemSettings.SolderingTemp = 10;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (xTaskGetTickCount() - lastChange > 200)
|
|
|
|
|
return; // exit if user just doesn't press anything for a bit
|
|
|
|
|
if (xTaskGetTickCount() - lastChange > 200) return; // exit if user just doesn't press anything for a bit
|
|
|
|
|
|
|
|
|
|
#ifdef MODEL_TS80
|
|
|
|
|
if (!OLED::getRotation()) {
|
|
|
|
|
#else
|
|
|
|
|
if (OLED::getRotation()) {
|
|
|
|
|
#endif
|
|
|
|
|
OLED::print(
|
|
|
|
|
systemSettings.ReverseButtonTempChangeEnabled ?
|
|
|
|
|
SymbolPlus : SymbolMinus);
|
|
|
|
|
OLED::print(systemSettings.ReverseButtonTempChangeEnabled ? SymbolPlus : SymbolMinus);
|
|
|
|
|
} else {
|
|
|
|
|
OLED::print(
|
|
|
|
|
systemSettings.ReverseButtonTempChangeEnabled ?
|
|
|
|
|
SymbolMinus : SymbolPlus);
|
|
|
|
|
OLED::print(systemSettings.ReverseButtonTempChangeEnabled ? SymbolMinus : SymbolPlus);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
OLED::print(SymbolSpace);
|
|
|
|
|
@@ -280,13 +255,9 @@ static void gui_solderingTempAdjust() {
|
|
|
|
|
#else
|
|
|
|
|
if (OLED::getRotation()) {
|
|
|
|
|
#endif
|
|
|
|
|
OLED::print(
|
|
|
|
|
systemSettings.ReverseButtonTempChangeEnabled ?
|
|
|
|
|
SymbolMinus : SymbolPlus);
|
|
|
|
|
OLED::print(systemSettings.ReverseButtonTempChangeEnabled ? SymbolMinus : SymbolPlus);
|
|
|
|
|
} else {
|
|
|
|
|
OLED::print(
|
|
|
|
|
systemSettings.ReverseButtonTempChangeEnabled ?
|
|
|
|
|
SymbolPlus : SymbolMinus);
|
|
|
|
|
OLED::print(systemSettings.ReverseButtonTempChangeEnabled ? SymbolPlus : SymbolMinus);
|
|
|
|
|
}
|
|
|
|
|
OLED::refresh();
|
|
|
|
|
GUIDelay();
|
|
|
|
|
@@ -298,29 +269,18 @@ static int gui_SolderingSleepingMode(bool stayOff) {
|
|
|
|
|
|
|
|
|
|
for (;;) {
|
|
|
|
|
ButtonState buttons = getButtonState();
|
|
|
|
|
if (buttons)
|
|
|
|
|
return 0;
|
|
|
|
|
if ((xTaskGetTickCount() > 100)
|
|
|
|
|
&& ((accelInit && (xTaskGetTickCount() - lastMovementTime < 100))
|
|
|
|
|
|| (xTaskGetTickCount() - lastButtonTime < 100)))
|
|
|
|
|
return 0; // user moved or pressed a button, go back to soldering
|
|
|
|
|
if (buttons) return 0;
|
|
|
|
|
if ((xTaskGetTickCount() > 100) && ((accelInit && (xTaskGetTickCount() - lastMovementTime < 100)) || (xTaskGetTickCount() - lastButtonTime < 100))) return 0; // user moved or pressed a button, go back to soldering
|
|
|
|
|
#ifdef MODEL_TS100
|
|
|
|
|
if (checkVoltageForExit())
|
|
|
|
|
return 1; // return non-zero on error
|
|
|
|
|
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
|
|
|
|
|
{
|
|
|
|
|
currentTempTargetDegC =
|
|
|
|
|
stayOff ?
|
|
|
|
|
0 :
|
|
|
|
|
min(systemSettings.SleepTemp,
|
|
|
|
|
systemSettings.SolderingTemp);
|
|
|
|
|
currentTempTargetDegC = stayOff ? 0 : min(systemSettings.SleepTemp, systemSettings.SolderingTemp);
|
|
|
|
|
}
|
|
|
|
|
// draw the lcd
|
|
|
|
|
uint16_t tipTemp;
|
|
|
|
|
@@ -368,8 +328,7 @@ static int gui_SolderingSleepingMode(bool stayOff) {
|
|
|
|
|
}
|
|
|
|
|
if (systemSettings.ShutdownTime) // only allow shutdown exit if time > 0
|
|
|
|
|
if (lastMovementTime)
|
|
|
|
|
if (((uint32_t) (xTaskGetTickCount() - lastMovementTime))
|
|
|
|
|
> (uint32_t) (systemSettings.ShutdownTime * 60 * 100)) {
|
|
|
|
|
if (((uint32_t)(xTaskGetTickCount() - lastMovementTime)) > (uint32_t)(systemSettings.ShutdownTime * 60 * 100)) {
|
|
|
|
|
// shutdown
|
|
|
|
|
currentTempTargetDegC = 0;
|
|
|
|
|
return 1; // we want to exit soldering mode
|
|
|
|
|
@@ -385,9 +344,7 @@ static void display_countdown(int sleepThres) {
|
|
|
|
|
* Print seconds or minutes (if > 99 seconds) until sleep
|
|
|
|
|
* mode is triggered.
|
|
|
|
|
*/
|
|
|
|
|
int lastEventTime =
|
|
|
|
|
lastButtonTime < lastMovementTime ?
|
|
|
|
|
lastMovementTime : lastButtonTime;
|
|
|
|
|
int lastEventTime = lastButtonTime < lastMovementTime ? lastMovementTime : lastButtonTime;
|
|
|
|
|
int downCount = sleepThres - xTaskGetTickCount() + lastEventTime;
|
|
|
|
|
if (downCount > 9900) {
|
|
|
|
|
OLED::printNumber(downCount / 6000 + 1, 2);
|
|
|
|
|
@@ -426,7 +383,6 @@ static void gui_solderingMode(uint8_t jumpToSleep) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
for (;;) {
|
|
|
|
|
|
|
|
|
|
ButtonState buttons = getButtonState();
|
|
|
|
|
switch (buttons) {
|
|
|
|
|
case BUTTON_NONE:
|
|
|
|
|
@@ -442,8 +398,7 @@ static void gui_solderingMode(uint8_t jumpToSleep) {
|
|
|
|
|
break;
|
|
|
|
|
case BUTTON_F_LONG:
|
|
|
|
|
// if boost mode is enabled turn it on
|
|
|
|
|
if (systemSettings.boostModeEnabled)
|
|
|
|
|
boostModeOn = true;
|
|
|
|
|
if (systemSettings.boostModeEnabled) boostModeOn = true;
|
|
|
|
|
break;
|
|
|
|
|
case BUTTON_F_SHORT:
|
|
|
|
|
case BUTTON_B_SHORT: {
|
|
|
|
|
@@ -452,8 +407,7 @@ static void gui_solderingMode(uint8_t jumpToSleep) {
|
|
|
|
|
if (oldTemp != systemSettings.SolderingTemp) {
|
|
|
|
|
saveSettings(); // only save on change
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
} break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
@@ -524,8 +478,7 @@ 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
|
|
|
|
|
{
|
|
|
|
|
@@ -534,8 +487,7 @@ 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
|
|
|
|
|
{
|
|
|
|
|
@@ -559,8 +511,7 @@ static void gui_solderingMode(uint8_t jumpToSleep) {
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
if (systemSettings.sensitivity && systemSettings.SleepTime)
|
|
|
|
|
if (xTaskGetTickCount() - lastMovementTime > sleepThres
|
|
|
|
|
&& xTaskGetTickCount() - lastButtonTime > sleepThres) {
|
|
|
|
|
if (xTaskGetTickCount() - lastMovementTime > sleepThres && xTaskGetTickCount() - lastButtonTime > sleepThres) {
|
|
|
|
|
if (gui_SolderingSleepingMode(false)) {
|
|
|
|
|
return; // If the function returns non-0 then exit
|
|
|
|
|
}
|
|
|
|
|
@@ -608,8 +559,7 @@ void showDebugMenu(void) {
|
|
|
|
|
{
|
|
|
|
|
uint32_t temp = systemSettings.CalibrationOffset;
|
|
|
|
|
systemSettings.CalibrationOffset = 0;
|
|
|
|
|
OLED::printNumber(
|
|
|
|
|
TipThermoModel::convertTipRawADCTouV(getTipRawTemp(1)), 6);
|
|
|
|
|
OLED::printNumber(TipThermoModel::convertTipRawADCTouV(getTipRawTemp(1)), 6);
|
|
|
|
|
systemSettings.CalibrationOffset = temp;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
@@ -656,11 +606,9 @@ void startGUITask(void const *argument __unused) {
|
|
|
|
|
uint32_t ticks = xTaskGetTickCount();
|
|
|
|
|
ticks += 400; // 4 seconds from now
|
|
|
|
|
while (xTaskGetTickCount() < ticks) {
|
|
|
|
|
if (showBootLogoIfavailable() == false)
|
|
|
|
|
ticks = xTaskGetTickCount();
|
|
|
|
|
if (showBootLogoIfavailable() == false) ticks = xTaskGetTickCount();
|
|
|
|
|
ButtonState buttons = getButtonState();
|
|
|
|
|
if (buttons)
|
|
|
|
|
ticks = xTaskGetTickCount(); // make timeout now so we will exit
|
|
|
|
|
if (buttons) ticks = xTaskGetTickCount(); // make timeout now so we will exit
|
|
|
|
|
GUIDelay();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -672,7 +620,6 @@ void startGUITask(void const *argument __unused) {
|
|
|
|
|
OLED::print(SettingsResetMessage);
|
|
|
|
|
OLED::refresh();
|
|
|
|
|
waitForButtonPressOrTimeout(1000);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (systemSettings.autoStartMode) {
|
|
|
|
|
@@ -695,8 +642,7 @@ void startGUITask(void const *argument __unused) {
|
|
|
|
|
OLED::setDisplayState(OLED::DisplayState::ON);
|
|
|
|
|
OLED::setFont(0);
|
|
|
|
|
}
|
|
|
|
|
if (tempWarningState == 2)
|
|
|
|
|
buttons = BUTTON_F_SHORT;
|
|
|
|
|
if (tempWarningState == 2) buttons = BUTTON_F_SHORT;
|
|
|
|
|
if (buttons != BUTTON_NONE && buttonLockout)
|
|
|
|
|
buttons = BUTTON_NONE;
|
|
|
|
|
else
|
|
|
|
|
@@ -742,11 +688,7 @@ 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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -805,9 +747,7 @@ void startGUITask(void const *argument __unused) {
|
|
|
|
|
OLED::setCursor(0, 0);
|
|
|
|
|
}
|
|
|
|
|
// draw in the temp
|
|
|
|
|
if (!(systemSettings.coolingTempBlink
|
|
|
|
|
&& (xTaskGetTickCount() % 25 < 16)))
|
|
|
|
|
gui_drawTipTemp(false); // draw in the temp
|
|
|
|
|
if (!(systemSettings.coolingTempBlink && (xTaskGetTickCount() % 25 < 16))) gui_drawTipTemp(false); // draw in the temp
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
OLED::refresh();
|
|
|
|
|
|