Backport some master changes

This commit is contained in:
Ben V. Brown
2020-09-17 19:05:55 +10:00
parent b4c8fc2aab
commit 8074255b9e
23 changed files with 754 additions and 581 deletions

View File

@@ -7,9 +7,7 @@
#include "FreeRTOSHooks.h"
#include "BSP.h"
#include "cmsis_os.h"
void vApplicationIdleHook(void)
{
void vApplicationIdleHook(void) {
resetWatchdog();
}
@@ -18,19 +16,19 @@ static StaticTask_t xIdleTaskTCBBuffer;
static StackType_t xIdleStack[configMINIMAL_STACK_SIZE];
void vApplicationGetIdleTaskMemory(StaticTask_t **ppxIdleTaskTCBBuffer,
StackType_t **ppxIdleTaskStackBuffer, uint32_t *pulIdleTaskStackSize)
{
StackType_t **ppxIdleTaskStackBuffer, uint32_t *pulIdleTaskStackSize) {
*ppxIdleTaskTCBBuffer = &xIdleTaskTCBBuffer;
*ppxIdleTaskStackBuffer = &xIdleStack[0];
*pulIdleTaskStackSize = configMINIMAL_STACK_SIZE;
/* place for user code */
}
void vApplicationStackOverflowHook(TaskHandle_t *pxTask,
signed portCHAR *pcTaskName)
{
(void)pxTask;
(void)pcTaskName;
// We dont have a good way to handle a stack overflow at this point in time
signed portCHAR *pcTaskName) {
(void) pxTask;
(void) pcTaskName;
// We dont have a good way to handle a stack overflow at this point in time
reboot();
}

View File

@@ -12,9 +12,7 @@
#include "Setup.h"
#include "../../configuration.h"
#include "BSP.h"
#define FLASH_ADDR \
(0x8000000 | \
0xFC00) /*Flash start OR'ed with the maximum amount of flash - 1024 bytes*/
#include "string.h"
volatile systemSettingsType systemSettings;
@@ -65,7 +63,6 @@ void resetSettings() {
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.boostModeEnabled = BOOST_MODE_ENABLED; // Default to having boost mode on as most people prefer it
systemSettings.BoostTemp = BOOST_TEMP; // default to 400C
systemSettings.autoStartMode = AUTO_START_MODE; // Auto start off for safety
systemSettings.coolingTempBlink = COOLING_TEMP_BLINK; // Blink the temperature on the cooling screen when its > 50C
@@ -73,7 +70,6 @@ void resetSettings() {
systemSettings.temperatureInF = TEMPERATURE_INF; // default to 0
#endif
systemSettings.descriptionScrollSpeed = DESCRIPTION_SCROLL_SPEED; // default to slow
systemSettings.powerLimitEnable = POWER_LIMIT_ENABLE; // Default to no power limit
systemSettings.CalibrationOffset = CALIBRATION_OFFSET; // the adc offset in uV
systemSettings.powerLimit = POWER_LIMIT; // 30 watts default limit
systemSettings.ReverseButtonTempChangeEnabled = REVERSE_BUTTON_TEMP_CHANGE; //

View File

@@ -1,52 +1,52 @@
/**
******************************************************************************
* File Name : freertos.c
* Description : Code for freertos applications
******************************************************************************
* This notice applies to any and all portions of this file
* that are not between comment pairs USER CODE BEGIN and
* USER CODE END. Other portions of this file, whether
* inserted by the user or by software development tools
* are owned by their respective copyright owners.
*
* Copyright (c) 2017 STMicroelectronics International N.V.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted, provided that the following conditions are met:
*
* 1. Redistribution of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of STMicroelectronics nor the names of other
* contributors to this software may be used to endorse or promote products
* derived from this software without specific written permission.
* 4. This software, including modifications and/or derivative works of this
* software, must execute solely and exclusively on microcontroller or
* microprocessor devices manufactured by or for STMicroelectronics.
* 5. Redistribution and use of this software other than as permitted under
* this license is void and will automatically terminate your rights under
* this license.
*
* THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
* PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY
* RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT
* SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "FreeRTOS.h"
#include "task.h"
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
/**
******************************************************************************
* File Name : freertos.c
* Description : Code for freertos applications
******************************************************************************
* This notice applies to any and all portions of this file
* that are not between comment pairs USER CODE BEGIN and
* USER CODE END. Other portions of this file, whether
* inserted by the user or by software development tools
* are owned by their respective copyright owners.
*
* Copyright (c) 2017 STMicroelectronics International N.V.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted, provided that the following conditions are met:
*
* 1. Redistribution of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of STMicroelectronics nor the names of other
* contributors to this software may be used to endorse or promote products
* derived from this software without specific written permission.
* 4. This software, including modifications and/or derivative works of this
* software, must execute solely and exclusively on microcontroller or
* microprocessor devices manufactured by or for STMicroelectronics.
* 5. Redistribution and use of this software other than as permitted under
* this license is void and will automatically terminate your rights under
* this license.
*
* THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
* PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY
* RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT
* SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "FreeRTOS.h"
#include "task.h"
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -18,70 +18,66 @@
void gui_Menu(const menuitem *menu);
#ifdef MODEL_TS100
static void settings_setInputVRange(void);
static bool settings_setInputVRange(void);
static void settings_displayInputVRange(void);
#else
static void settings_setInputPRange(void);
static bool settings_setInputPRange(void);
static void settings_displayInputPRange(void);
#endif
static void settings_setSleepTemp(void);
static bool settings_setSleepTemp(void);
static void settings_displaySleepTemp(void);
static void settings_setSleepTime(void);
static bool settings_setSleepTime(void);
static void settings_displaySleepTime(void);
static void settings_setShutdownTime(void);
static bool settings_setShutdownTime(void);
static void settings_displayShutdownTime(void);
static void settings_setSensitivity(void);
static bool settings_setSensitivity(void);
static void settings_displaySensitivity(void);
#ifdef ENABLED_FAHRENHEIT_SUPPORT
static void settings_setTempF(void);
static bool settings_setTempF(void);
static void settings_displayTempF(void);
#endif
static void settings_setAdvancedSolderingScreens(void);
static bool settings_setAdvancedSolderingScreens(void);
static void settings_displayAdvancedSolderingScreens(void);
static void settings_setAdvancedIDLEScreens(void);
static bool settings_setAdvancedIDLEScreens(void);
static void settings_displayAdvancedIDLEScreens(void);
static void settings_setScrollSpeed(void);
static bool settings_setScrollSpeed(void);
static void settings_displayScrollSpeed(void);
static void settings_setPowerLimitEnable(void);
static void settings_displayPowerLimitEnable(void);
static void settings_setPowerLimit(void);
static bool settings_setPowerLimit(void);
static void settings_displayPowerLimit(void);
static void settings_setDisplayRotation(void);
static bool settings_setDisplayRotation(void);
static void settings_displayDisplayRotation(void);
static void settings_setBoostModeEnabled(void);
static void settings_displayBoostModeEnabled(void);
static void settings_setBoostTemp(void);
static bool settings_setBoostTemp(void);
static void settings_displayBoostTemp(void);
static void settings_setAutomaticStartMode(void);
static bool settings_setAutomaticStartMode(void);
static void settings_displayAutomaticStartMode(void);
static void settings_setCoolingBlinkEnabled(void);
static bool settings_setCoolingBlinkEnabled(void);
static void settings_displayCoolingBlinkEnabled(void);
static void settings_setResetSettings(void);
static bool settings_setResetSettings(void);
static void settings_displayResetSettings(void);
static void settings_setCalibrate(void);
static bool settings_setCalibrate(void);
static void settings_displayCalibrate(void);
static void settings_setTipGain(void);
static bool settings_setTipGain(void);
static void settings_displayTipGain(void);
static void settings_setCalibrateVIN(void);
static bool settings_setCalibrateVIN(void);
static void settings_displayCalibrateVIN(void);
static void settings_displayReverseButtonTempChangeEnabled(void);
static void settings_setReverseButtonTempChangeEnabled(void);
static bool settings_setReverseButtonTempChangeEnabled(void);
static void settings_displayTempChangeShortStep(void);
static void settings_setTempChangeShortStep(void);
static bool settings_setTempChangeShortStep(void);
static void settings_displayTempChangeLongStep(void);
static void settings_setTempChangeLongStep(void);
static bool settings_setTempChangeLongStep(void);
static void settings_displayPowerPulse(void);
static void settings_setPowerPulse(void);
static bool settings_setPowerPulse(void);
// Menu functions
static void settings_displaySolderingMenu(void);
static void settings_enterSolderingMenu(void);
static bool settings_enterSolderingMenu(void);
static void settings_displayPowerMenu(void);
static void settings_enterPowerMenu(void);
static bool settings_enterPowerMenu(void);
static void settings_displayUIMenu(void);
static void settings_enterUIMenu(void);
static bool settings_enterUIMenu(void);
static void settings_displayAdvancedMenu(void);
static void settings_enterAdvancedMenu(void);
static bool settings_enterAdvancedMenu(void);
/*
* Root Settings Menu
*
@@ -129,21 +125,19 @@ const menuitem rootSettingsMenu[] {
* Exit
*/
#ifdef MODEL_TS100
{ (const char*) SettingsDescriptions[0], { settings_setInputVRange }, {
settings_displayInputVRange } }, /*Voltage input*/
{ (const char*) SettingsDescriptions[0], settings_setInputVRange,
settings_displayInputVRange }, /*Voltage input*/
#else
{ (const char*) SettingsDescriptions[20], { settings_setInputPRange }, {
settings_displayInputPRange } }, /*Voltage input*/
{ (const char*) SettingsDescriptions[19], settings_setInputPRange,
settings_displayInputPRange }, /*Voltage input*/
#endif
{ (const char*) NULL, { settings_enterSolderingMenu }, {
settings_displaySolderingMenu } }, /*Soldering*/
{ (const char*) NULL, { settings_enterPowerMenu }, {
settings_displayPowerMenu } }, /*Sleep Options Menu*/
{ (const char*) NULL, { settings_enterUIMenu },
{ settings_displayUIMenu } }, /*UI Menu*/
{ (const char*) NULL, { settings_enterAdvancedMenu }, {
settings_displayAdvancedMenu } }, /*Advanced Menu*/
{ NULL, { NULL }, { NULL } } // end of menu marker. DO NOT REMOVE
{ (const char*) NULL, settings_enterSolderingMenu,
settings_displaySolderingMenu }, /*Soldering*/
{ (const char*) NULL, settings_enterPowerMenu, settings_displayPowerMenu }, /*Sleep Options Menu*/
{ (const char*) NULL, settings_enterUIMenu, settings_displayUIMenu }, /*UI Menu*/
{ (const char*) NULL, settings_enterAdvancedMenu,
settings_displayAdvancedMenu }, /*Advanced Menu*/
{ NULL, NULL, NULL } // end of menu marker. DO NOT REMOVE
};
const menuitem solderingMenu[] = {
@@ -154,17 +148,15 @@ const menuitem solderingMenu[] = {
* Temp change short step
* Temp change long step
*/
{ (const char*) SettingsDescriptions[8], { settings_setBoostModeEnabled }, {
settings_displayBoostModeEnabled } }, /*Enable Boost*/
{ (const char*) SettingsDescriptions[9], { settings_setBoostTemp }, {
settings_displayBoostTemp } }, /*Boost Temp*/
{ (const char*) SettingsDescriptions[10], { settings_setAutomaticStartMode }, {
settings_displayAutomaticStartMode } }, /*Auto start*/
{ (const char*) SettingsDescriptions[24], { settings_setTempChangeShortStep }, {
settings_displayTempChangeShortStep } }, /*Temp change short step*/
{ (const char*) SettingsDescriptions[25], { settings_setTempChangeLongStep }, {
settings_displayTempChangeLongStep } }, /*Temp change long step*/
{ NULL, { NULL }, { NULL } } // end of menu marker. DO NOT REMOVE
{ (const char*) SettingsDescriptions[8], settings_setBoostTemp,
settings_displayBoostTemp }, /*Boost Temp*/
{ (const char*) SettingsDescriptions[9], settings_setAutomaticStartMode,
settings_displayAutomaticStartMode }, /*Auto start*/
{ (const char*) SettingsDescriptions[22], settings_setTempChangeShortStep,
settings_displayTempChangeShortStep }, /*Temp change short step*/
{ (const char*) SettingsDescriptions[23], settings_setTempChangeLongStep,
settings_displayTempChangeLongStep }, /*Temp change long step*/
{ NULL, NULL, NULL } // end of menu marker. DO NOT REMOVE
};
const menuitem UIMenu[] = {
/*
@@ -176,21 +168,20 @@ const menuitem UIMenu[] = {
* Reverse Temp change buttons + -
*/
#ifdef ENABLED_FAHRENHEIT_SUPPORT
{ (const char*) SettingsDescriptions[5], { settings_setTempF }, {
settings_displayTempF } }, /* Temperature units*/
{ (const char*) SettingsDescriptions[5], settings_setTempF,
settings_displayTempF }, /* Temperature units*/
#endif
{ (const char*) SettingsDescriptions[7],
{ settings_setDisplayRotation }, {
settings_displayDisplayRotation } }, /*Display Rotation*/
{ (const char*) SettingsDescriptions[11], {
settings_setCoolingBlinkEnabled }, {
settings_displayCoolingBlinkEnabled } }, /*Cooling blink warning*/
{ (const char*) SettingsDescriptions[16], { settings_setScrollSpeed }, {
settings_displayScrollSpeed } }, /*Scroll Speed for descriptions*/
{ (const char*) SettingsDescriptions[23], {
settings_setReverseButtonTempChangeEnabled }, {
settings_displayReverseButtonTempChangeEnabled } }, /* Reverse Temp change buttons + - */
{ NULL, { NULL }, { NULL } } // end of menu marker. DO NOT REMOVE
{ (const char*) SettingsDescriptions[7], settings_setDisplayRotation,
settings_displayDisplayRotation }, /*Display Rotation*/
{ (const char*) SettingsDescriptions[10],
settings_setCoolingBlinkEnabled,
settings_displayCoolingBlinkEnabled }, /*Cooling blink warning*/
{ (const char*) SettingsDescriptions[15], settings_setScrollSpeed,
settings_displayScrollSpeed }, /*Scroll Speed for descriptions*/
{ (const char*) SettingsDescriptions[21],
settings_setReverseButtonTempChangeEnabled,
settings_displayReverseButtonTempChangeEnabled }, /* Reverse Temp change buttons + - */
{ NULL, NULL, NULL } // end of menu marker. DO NOT REMOVE
};
const menuitem PowerMenu[] = {
/*
@@ -199,20 +190,19 @@ const menuitem PowerMenu[] = {
* Shutdown Time
* Motion Sensitivity
*/
{ (const char*) SettingsDescriptions[1], { settings_setSleepTemp }, {
settings_displaySleepTemp } }, /*Sleep Temp*/
{ (const char*) SettingsDescriptions[2], { settings_setSleepTime }, {
settings_displaySleepTime } }, /*Sleep Time*/
{ (const char*) SettingsDescriptions[3], { settings_setShutdownTime }, {
settings_displayShutdownTime } }, /*Shutdown Time*/
{ (const char*) SettingsDescriptions[4], { settings_setSensitivity }, {
settings_displaySensitivity } }, /* Motion Sensitivity*/
{ NULL, { NULL }, { NULL } } // end of menu marker. DO NOT REMOVE
{ (const char*) SettingsDescriptions[1], settings_setSleepTemp,
settings_displaySleepTemp }, /*Sleep Temp*/
{ (const char*) SettingsDescriptions[2], settings_setSleepTime,
settings_displaySleepTime }, /*Sleep Time*/
{ (const char*) SettingsDescriptions[3], settings_setShutdownTime,
settings_displayShutdownTime }, /*Shutdown Time*/
{ (const char*) SettingsDescriptions[4], settings_setSensitivity,
settings_displaySensitivity }, /* Motion Sensitivity*/
{ NULL, NULL, NULL } // end of menu marker. DO NOT REMOVE
};
const menuitem advancedMenu[] = {
/*
* Power limit enable
* Power limit
* Detailed IDLE
* Detailed Soldering
@@ -221,34 +211,25 @@ const menuitem advancedMenu[] = {
* Reset Settings
* Power Pulse
*/
{ (const char*) SettingsDescriptions[21], { settings_setPowerLimitEnable }, {
settings_displayPowerLimitEnable } }, /*Power limit enable*/
{ (const char*) SettingsDescriptions[22], { settings_setPowerLimit }, {
settings_displayPowerLimit } }, /*Power limit*/
{ (const char*) SettingsDescriptions[6], { settings_setAdvancedIDLEScreens }, {
settings_displayAdvancedIDLEScreens } }, /* Advanced idle screen*/
{ (const char*) SettingsDescriptions[15],
{ settings_setAdvancedSolderingScreens }, {
settings_displayAdvancedSolderingScreens } }, /* Advanced soldering screen*/
{ (const char*) SettingsDescriptions[13], { settings_setResetSettings }, {
settings_displayResetSettings } }, /*Resets settings*/
{ (const char*) SettingsDescriptions[12], { settings_setCalibrate }, {
settings_displayCalibrate } }, /*Calibrate tip*/
{ (const char*) SettingsDescriptions[14], { settings_setCalibrateVIN }, {
settings_displayCalibrateVIN } }, /*Voltage input cal*/
{ (const char*) SettingsDescriptions[26], { settings_setPowerPulse }, {
settings_displayPowerPulse } }, /*Power Pulse adjustment */
{ (const char*) SettingsDescriptions[27], { settings_setTipGain }, {
settings_displayTipGain } }, /*TipGain*/
{ NULL, { NULL }, { NULL } } // end of menu marker. DO NOT REMOVE
{ (const char*) SettingsDescriptions[20], settings_setPowerLimit,
settings_displayPowerLimit }, /*Power limit*/
{ (const char*) SettingsDescriptions[6], settings_setAdvancedIDLEScreens,
settings_displayAdvancedIDLEScreens }, /* Advanced idle screen*/
{ (const char*) SettingsDescriptions[14], settings_setAdvancedSolderingScreens,
settings_displayAdvancedSolderingScreens }, /* Advanced soldering screen*/
{ (const char*) SettingsDescriptions[12], settings_setResetSettings,
settings_displayResetSettings }, /*Resets settings*/
{ (const char*) SettingsDescriptions[11], settings_setCalibrate,
settings_displayCalibrate }, /*Calibrate tip*/
{ (const char*) SettingsDescriptions[13], settings_setCalibrateVIN,
settings_displayCalibrateVIN }, /*Voltage input cal*/
{ (const char*) SettingsDescriptions[24], settings_setPowerPulse,
settings_displayPowerPulse }, /*Power Pulse adjustment */
{ (const char*) SettingsDescriptions[25], settings_setTipGain,
settings_displayTipGain }, /*TipGain*/
{ NULL, NULL, NULL } // end of menu marker. DO NOT REMOVE
};
static void printShortDescriptionSingleLine(uint32_t shortDescIndex) {
OLED::setFont(0);
OLED::setCharCursor(0, 0);
OLED::print(SettingsShortNames[shortDescIndex][0]);
}
static void printShortDescriptionDoubleLine(uint32_t shortDescIndex) {
OLED::setFont(1);
OLED::setCharCursor(0, 0);
@@ -267,11 +248,7 @@ static void printShortDescriptionDoubleLine(uint32_t shortDescIndex) {
static void printShortDescription(uint32_t shortDescIndex,
uint16_t cursorCharPosition) {
// print short description (default single line, explicit double line)
if (SettingsShortNameType == SHORT_NAME_DOUBLE_LINE) {
printShortDescriptionDoubleLine(shortDescIndex);
} else {
printShortDescriptionSingleLine(shortDescIndex);
}
printShortDescriptionDoubleLine(shortDescIndex);
// prepare cursor for value
OLED::setFont(0);
@@ -329,10 +306,11 @@ static int userConfirmation(const char *message) {
return 0;
}
#ifdef MODEL_TS100
static void settings_setInputVRange(void) {
static bool settings_setInputVRange(void) {
systemSettings.cutoutSetting = (systemSettings.cutoutSetting + 1) % 5;
if (systemSettings.cutoutSetting)
systemSettings.powerLimitEnable = 0; // disable power limit if switching to a lipo power source
systemSettings.powerLimit = 0; // disable power limit if switching to a lipo power source
return systemSettings.cutoutSetting == 4;
}
static void settings_displayInputVRange(void) {
@@ -346,14 +324,15 @@ static void settings_displayInputVRange(void) {
}
}
#else
static void settings_setInputPRange(void) {
static bool settings_setInputPRange(void) {
systemSettings.cutoutSetting = (systemSettings.cutoutSetting + 1) % 2;
return false;
}
static void settings_displayInputPRange(void) {
printShortDescription(0, 5);
//0 = 9V, 1=12V (Fixed Voltages, these imply 1.5A limits)
/// TODO TS80P
// These are only used in QC3.0 modes
switch (systemSettings.cutoutSetting) {
case 0:
OLED::printNumber(9, 2);
@@ -370,19 +349,21 @@ static void settings_displayInputPRange(void) {
}
#endif
static void settings_setSleepTemp(void) {
static bool settings_setSleepTemp(void) {
// If in C, 10 deg, if in F 20 deg
#ifdef ENABLED_FAHRENHEIT_SUPPORT
if (systemSettings.temperatureInF) {
systemSettings.SleepTemp += 20;
if (systemSettings.SleepTemp > 580)
systemSettings.SleepTemp = 60;
return systemSettings.SleepTemp == 580;
} else
#endif
{
systemSettings.SleepTemp += 10;
if (systemSettings.SleepTemp > 300)
systemSettings.SleepTemp = 10;
return systemSettings.SleepTemp == 300;
}
}
@@ -391,7 +372,7 @@ static void settings_displaySleepTemp(void) {
OLED::printNumber(systemSettings.SleepTemp, 3);
}
static void settings_setSleepTime(void) {
static bool settings_setSleepTime(void) {
systemSettings.SleepTime++; // Go up 1 minute at a time
if (systemSettings.SleepTime >= 16) {
systemSettings.SleepTime = 0; // can't set time over 10 mins
@@ -399,6 +380,7 @@ static void settings_setSleepTime(void) {
// Remember that ^ is the time of no movement
if (PCBVersion == 3)
systemSettings.SleepTime = 0; // Disable sleep on no accel
return systemSettings.SleepTime == 15;
}
static void settings_displaySleepTime(void) {
@@ -414,13 +396,14 @@ static void settings_displaySleepTime(void) {
}
}
static void settings_setShutdownTime(void) {
static bool settings_setShutdownTime(void) {
systemSettings.ShutdownTime++;
if (systemSettings.ShutdownTime > 60) {
systemSettings.ShutdownTime = 0; // wrap to off
}
if (PCBVersion == 3)
systemSettings.ShutdownTime = 0; // Disable shutdown on no accel
return systemSettings.ShutdownTime == 60;
}
static void settings_displayShutdownTime(void) {
@@ -433,7 +416,7 @@ static void settings_displayShutdownTime(void) {
}
}
#ifdef ENABLED_FAHRENHEIT_SUPPORT
static void settings_setTempF(void) {
static bool settings_setTempF(void) {
systemSettings.temperatureInF = !systemSettings.temperatureInF;
if (systemSettings.temperatureInF) {
// Change sleep, boost and soldering temps to the F equiv
@@ -457,6 +440,7 @@ static void settings_setTempF(void) {
systemSettings.SolderingTemp *= 10;
systemSettings.SleepTemp = systemSettings.SleepTemp / 10;
systemSettings.SleepTemp *= 10;
return false;
}
static void settings_displayTempF(void) {
@@ -466,9 +450,10 @@ static void settings_displayTempF(void) {
}
#endif
static void settings_setSensitivity(void) {
static bool settings_setSensitivity(void) {
systemSettings.sensitivity++;
systemSettings.sensitivity = systemSettings.sensitivity % 10;
return systemSettings.sensitivity == 9;
}
static void settings_displaySensitivity(void) {
@@ -476,18 +461,20 @@ static void settings_displaySensitivity(void) {
OLED::printNumber(systemSettings.sensitivity, 1, false);
}
static void settings_setAdvancedSolderingScreens(void) {
static bool settings_setAdvancedSolderingScreens(void) {
systemSettings.detailedSoldering = !systemSettings.detailedSoldering;
return false;
}
static void settings_displayAdvancedSolderingScreens(void) {
printShortDescription(15, 7);
printShortDescription(14, 7);
OLED::drawCheckbox(systemSettings.detailedSoldering);
}
static void settings_setAdvancedIDLEScreens(void) {
static bool settings_setAdvancedIDLEScreens(void) {
systemSettings.detailedIDLE = !systemSettings.detailedIDLE;
return false;
}
static void settings_displayAdvancedIDLEScreens(void) {
@@ -496,42 +483,39 @@ static void settings_displayAdvancedIDLEScreens(void) {
OLED::drawCheckbox(systemSettings.detailedIDLE);
}
static void settings_setPowerLimitEnable(void) {
systemSettings.powerLimitEnable = !systemSettings.powerLimitEnable;
}
static void settings_displayPowerLimitEnable(void) {
printShortDescription(21, 7);
OLED::drawCheckbox(systemSettings.powerLimitEnable);
}
static void settings_setPowerLimit(void) {
if (systemSettings.powerLimit >= MAX_POWER_LIMIT)
systemSettings.powerLimit = POWER_LIMIT_STEPS;
else
systemSettings.powerLimit += POWER_LIMIT_STEPS;
static bool settings_setPowerLimit(void) {
systemSettings.powerLimit += POWER_LIMIT_STEPS;
if (systemSettings.powerLimit > MAX_POWER_LIMIT)
systemSettings.powerLimit = 0;
return systemSettings.powerLimit + POWER_LIMIT_STEPS > MAX_POWER_LIMIT;
}
static void settings_displayPowerLimit(void) {
printShortDescription(22, 5);
OLED::printNumber(systemSettings.powerLimit, 2);
OLED::print(SymbolWatts);
printShortDescription(20, 5);
if (systemSettings.powerLimit == 0) {
OLED::print(OffString);
} else {
OLED::printNumber(systemSettings.powerLimit, 2);
OLED::print(SymbolWatts);
}
}
static void settings_setScrollSpeed(void) {
static bool settings_setScrollSpeed(void) {
if (systemSettings.descriptionScrollSpeed == 0)
systemSettings.descriptionScrollSpeed = 1;
else
systemSettings.descriptionScrollSpeed = 0;
return false;
}
static void settings_displayScrollSpeed(void) {
printShortDescription(16, 7);
printShortDescription(15, 7);
OLED::print(
(systemSettings.descriptionScrollSpeed) ?
SettingFastChar : SettingSlowChar);
}
static void settings_setDisplayRotation(void) {
static bool settings_setDisplayRotation(void) {
systemSettings.OrientationMode++;
systemSettings.OrientationMode = systemSettings.OrientationMode % 3;
switch (systemSettings.OrientationMode) {
@@ -547,6 +531,7 @@ static void settings_setDisplayRotation(void) {
default:
break;
}
return systemSettings.OrientationMode == 2;
}
static void settings_displayDisplayRotation(void) {
@@ -568,45 +553,53 @@ static void settings_displayDisplayRotation(void) {
}
}
static void settings_setBoostModeEnabled(void) {
systemSettings.boostModeEnabled = !systemSettings.boostModeEnabled;
}
static void settings_displayBoostModeEnabled(void) {
printShortDescription(8, 7);
OLED::drawCheckbox(systemSettings.boostModeEnabled);
}
static void settings_setBoostTemp(void) {
static bool settings_setBoostTemp(void) {
#ifdef ENABLED_FAHRENHEIT_SUPPORT
if (systemSettings.temperatureInF) {
systemSettings.BoostTemp += 20; // Go up 20F at a time
if (systemSettings.BoostTemp > 850) {
systemSettings.BoostTemp = 480; // loop back at 250
if (systemSettings.BoostTemp == 0) {
systemSettings.BoostTemp = 480; // loop back at 480
} else {
systemSettings.BoostTemp += 20; // Go up 20F at a time
}
if (systemSettings.BoostTemp > 850) {
systemSettings.BoostTemp = 0; // jump to off
}
return systemSettings.BoostTemp == 840;
} else
#endif
{
systemSettings.BoostTemp += 10; // Go up 10C at a time
if (systemSettings.BoostTemp > 450) {
if (systemSettings.BoostTemp == 0) {
systemSettings.BoostTemp = 250; // loop back at 250
} else {
systemSettings.BoostTemp += 10; // Go up 10C at a time
}
if (systemSettings.BoostTemp > 450) {
systemSettings.BoostTemp = 0; //Go to off state
}
return systemSettings.BoostTemp == 450;
}
}
static void settings_displayBoostTemp(void) {
printShortDescription(9, 5);
OLED::printNumber(systemSettings.BoostTemp, 3);
printShortDescription(8, 5);
if (systemSettings.BoostTemp) {
OLED::printNumber(systemSettings.BoostTemp, 3);
} else {
OLED::print(OffString);
}
}
static void settings_setAutomaticStartMode(void) {
static bool settings_setAutomaticStartMode(void) {
systemSettings.autoStartMode++;
systemSettings.autoStartMode %= 4;
return systemSettings.autoStartMode == 3;
}
static void settings_displayAutomaticStartMode(void) {
printShortDescription(10, 7);
printShortDescription(9, 7);
switch (systemSettings.autoStartMode) {
case 0:
@@ -627,17 +620,18 @@ static void settings_displayAutomaticStartMode(void) {
}
}
static void settings_setCoolingBlinkEnabled(void) {
static bool settings_setCoolingBlinkEnabled(void) {
systemSettings.coolingTempBlink = !systemSettings.coolingTempBlink;
return false;
}
static void settings_displayCoolingBlinkEnabled(void) {
printShortDescription(11, 7);
printShortDescription(10, 7);
OLED::drawCheckbox(systemSettings.coolingTempBlink);
}
static void settings_setResetSettings(void) {
static bool settings_setResetSettings(void) {
if (userConfirmation(SettingsResetWarning)) {
resetSettings();
@@ -648,10 +642,11 @@ static void settings_setResetSettings(void) {
waitForButtonPressOrTimeout(2000); // 2 second timeout
}
return false;
}
static void settings_displayResetSettings(void) {
printShortDescription(13, 7);
printShortDescription(12, 7);
}
static void setTipOffset() {
@@ -686,20 +681,21 @@ static void setTipOffset() {
//Provide the user the option to tune their own tip if custom is selected
//If not only do single point tuning as per usual
static void settings_setCalibrate(void) {
static bool settings_setCalibrate(void) {
if (userConfirmation(SettingsCalibrationWarning)) {
// User confirmed
// So we now perform the actual calculation
setTipOffset();
}
return false;
}
static void settings_displayCalibrate(void) {
printShortDescription(12, 5);
printShortDescription(11, 5);
}
static void settings_setCalibrateVIN(void) {
static bool settings_setCalibrateVIN(void) {
// Jump to the voltage calibration subscreen
OLED::setFont(0);
OLED::clearScreen();
@@ -732,8 +728,7 @@ static void settings_setCalibrateVIN(void) {
OLED::printNumber(systemSettings.voltageDiv, 3);
OLED::refresh();
waitForButtonPressOrTimeout(1000);
return;
break;
return false;
case BUTTON_NONE:
default:
break;
@@ -757,9 +752,10 @@ static void settings_setCalibrateVIN(void) {
}
#endif
}
return false;
}
static void settings_setTipGain(void) {
static bool settings_setTipGain(void) {
OLED::setFont(0);
OLED::clearScreen();
@@ -783,8 +779,7 @@ static void settings_setTipGain(void) {
case BUTTON_F_LONG:
case BUTTON_B_LONG:
saveSettings();
return;
break;
return false;
case BUTTON_NONE:
default:
break;
@@ -800,57 +795,64 @@ static void settings_setTipGain(void) {
systemSettings.TipGain = 300;
}
}
return false;
}
static void settings_displayTipGain(void) {
printShortDescription(27, 5);
printShortDescription(25, 5);
}
static void settings_setReverseButtonTempChangeEnabled(void) {
static bool settings_setReverseButtonTempChangeEnabled(void) {
systemSettings.ReverseButtonTempChangeEnabled =
!systemSettings.ReverseButtonTempChangeEnabled;
return false;
}
static void settings_displayReverseButtonTempChangeEnabled(void) {
printShortDescription(23, 7);
printShortDescription(21, 7);
OLED::drawCheckbox(systemSettings.ReverseButtonTempChangeEnabled);
}
static void settings_setTempChangeShortStep(void) {
static bool settings_setTempChangeShortStep(void) {
systemSettings.TempChangeShortStep += TEMP_CHANGE_SHORT_STEP;
if (systemSettings.TempChangeShortStep > TEMP_CHANGE_SHORT_STEP_MAX) {
systemSettings.TempChangeShortStep = TEMP_CHANGE_SHORT_STEP; // loop back at TEMP_CHANGE_SHORT_STEP_MAX
}
return systemSettings.TempChangeShortStep == TEMP_CHANGE_SHORT_STEP_MAX;
}
static void settings_displayTempChangeShortStep(void) {
printShortDescription(24, 6);
printShortDescription(22, 6);
OLED::printNumber(systemSettings.TempChangeShortStep, 2);
}
static void settings_setTempChangeLongStep(void) {
static bool settings_setTempChangeLongStep(void) {
systemSettings.TempChangeLongStep += TEMP_CHANGE_LONG_STEP;
if (systemSettings.TempChangeLongStep > TEMP_CHANGE_LONG_STEP_MAX) {
systemSettings.TempChangeLongStep = TEMP_CHANGE_LONG_STEP; // loop back at TEMP_CHANGE_LONG_STEP_MAX
}
return systemSettings.TempChangeLongStep == TEMP_CHANGE_LONG_STEP_MAX;
}
static void settings_displayTempChangeLongStep(void) {
printShortDescription(25, 6);
printShortDescription(23, 6);
OLED::printNumber(systemSettings.TempChangeLongStep, 2);
}
static void settings_setPowerPulse(void) {
static bool settings_setPowerPulse(void) {
systemSettings.KeepAwakePulse += POWER_PULSE_INCREMENT;
systemSettings.KeepAwakePulse %= POWER_PULSE_MAX;
return systemSettings.KeepAwakePulse == POWER_PULSE_MAX - 1;
}
static void settings_displayPowerPulse(void) {
printShortDescription(26, 5);
printShortDescription(24, 5);
if (systemSettings.KeepAwakePulse) {
OLED::printNumber(systemSettings.KeepAwakePulse / 10, 1);
OLED::print(SymbolDot);
OLED::printNumber(systemSettings.KeepAwakePulse % 10, 1);
} else {
OLED::drawCheckbox(false);
OLED::print(OffString);
}
}
@@ -868,31 +870,35 @@ static void displayMenu(size_t index) {
}
static void settings_displayCalibrateVIN(void) {
printShortDescription(14, 5);
printShortDescription(13, 5);
}
static void settings_displaySolderingMenu(void) {
displayMenu(0);
}
static void settings_enterSolderingMenu(void) {
static bool settings_enterSolderingMenu(void) {
gui_Menu(solderingMenu);
return false;
}
static void settings_displayPowerMenu(void) {
displayMenu(1);
}
static void settings_enterPowerMenu(void) {
static bool settings_enterPowerMenu(void) {
gui_Menu(PowerMenu);
return false;
}
static void settings_displayUIMenu(void) {
displayMenu(2);
}
static void settings_enterUIMenu(void) {
static bool settings_enterUIMenu(void) {
gui_Menu(UIMenu);
return false;
}
static void settings_displayAdvancedMenu(void) {
displayMenu(3);
}
static void settings_enterAdvancedMenu(void) {
static bool settings_enterAdvancedMenu(void) {
gui_Menu(advancedMenu);
return false;
}
void gui_Menu(const menuitem *menu) {
@@ -908,13 +914,15 @@ void gui_Menu(const menuitem *menu) {
static bool enterGUIMenu = true;
enterGUIMenu = true;
uint8_t scrollContentSize = 0;
bool scrollBlink = false;
bool lastValue = false;
for (uint8_t i = 0; menu[i].draw.func != NULL; i++) {
for (uint8_t i = 0; menu[i].draw != NULL; i++) {
scrollContentSize += 1;
}
// Animated menu opening.
if (menu[currentScreen].draw.func != NULL) {
if (menu[currentScreen].draw != NULL) {
// This menu is drawn in a secondary framebuffer.
// Then we play a transition from the current primary
// framebuffer to the new buffer.
@@ -923,12 +931,12 @@ void gui_Menu(const menuitem *menu) {
OLED::setFont(0);
OLED::setCursor(0, 0);
OLED::clearScreen();
menu[currentScreen].draw.func();
menu[currentScreen].draw();
OLED::useSecondaryFramebuffer(false);
OLED::transitionSecondaryFramebuffer(true);
}
while ((menu[currentScreen].draw.func != NULL) && earlyExit == false) {
while ((menu[currentScreen].draw != NULL) && earlyExit == false) {
OLED::setFont(0);
OLED::setCursor(0, 0);
// If the user has hesitated for >=3 seconds, show the long text
@@ -936,10 +944,13 @@ void gui_Menu(const menuitem *menu) {
if ((xTaskGetTickCount() - lastButtonTime < 3000)
|| menu[currentScreen].description == NULL) {
OLED::clearScreen();
menu[currentScreen].draw.func();
menu[currentScreen].draw();
uint8_t indicatorHeight = OLED_HEIGHT / scrollContentSize;
uint8_t position = OLED_HEIGHT * currentScreen / scrollContentSize;
OLED::drawScrollIndicator(position, indicatorHeight);
if (lastValue)
scrollBlink = !scrollBlink;
if (!lastValue || !scrollBlink)
OLED::drawScrollIndicator(position, indicatorHeight);
lastOffset = -1;
lcdRefresh = true;
} else {
@@ -978,16 +989,16 @@ void gui_Menu(const menuitem *menu) {
case BUTTON_F_SHORT:
// increment
if (descriptionStart == 0) {
if (menu[currentScreen].incrementHandler.func != NULL) {
if (menu[currentScreen].incrementHandler != NULL) {
enterGUIMenu = false;
menu[currentScreen].incrementHandler.func();
lastValue = menu[currentScreen].incrementHandler();
if (enterGUIMenu) {
OLED::useSecondaryFramebuffer(true);
OLED::setFont(0);
OLED::setCursor(0, 0);
OLED::clearScreen();
menu[currentScreen].draw.func();
menu[currentScreen].draw();
OLED::useSecondaryFramebuffer(false);
OLED::transitionSecondaryFramebuffer(false);
}
@@ -999,16 +1010,23 @@ void gui_Menu(const menuitem *menu) {
descriptionStart = 0;
break;
case BUTTON_B_SHORT:
if (descriptionStart == 0)
if (descriptionStart == 0) {
currentScreen++;
else
lastValue = false;
} else
descriptionStart = 0;
break;
case BUTTON_F_LONG:
if (xTaskGetTickCount() - autoRepeatTimer + autoRepeatAcceleration >
if ((int) (xTaskGetTickCount() - autoRepeatTimer
+ autoRepeatAcceleration) >
PRESS_ACCEL_INTERVAL_MAX) {
menu[currentScreen].incrementHandler.func();
autoRepeatTimer = xTaskGetTickCount();
if ((lastValue = menu[currentScreen].incrementHandler()))
autoRepeatTimer = 1000;
else
autoRepeatTimer = 0;
autoRepeatTimer += xTaskGetTickCount();
descriptionStart = 0;
autoRepeatAcceleration += PRESS_ACCEL_STEP;

View File

@@ -12,8 +12,6 @@
#include "Settings.h"
#include "cmsis_os.h"
uint8_t PCBVersion = 0;
// File local variables
bool usb_pd_available = false;
bool settingsWereReset = false;
// FreeRTOS variables
@@ -32,44 +30,17 @@ uint32_t MOVTaskBuffer[MOVTaskStackSize];
osStaticThreadDef_t MOVTaskControlBlock;
// End FreeRTOS
// Main sets up the hardware then hands over to the FreeRTOS kernel
int main(void) {
preRToSInit();
setTipX10Watts(0); // force tip off
resetWatchdog();
OLED::initialize(); // start up the LCD
OLED::setFont(0); // default to bigger font
// Testing for which accelerometer is mounted
resetWatchdog();
usb_pd_available = usb_pd_detect();
resetWatchdog();
settingsWereReset = restoreSettings(); // load the settings from flash
#ifdef ACCEL_MMA
if (MMA8652FC::detect()) {
PCBVersion = 1;
MMA8652FC::initalize(); // this sets up the I2C registers
} else
#endif
#ifdef ACCEL_LIS
if (LIS2DH12::detect()) {
PCBVersion = 2;
// Setup the ST Accelerometer
LIS2DH12::initalize(); // startup the accelerometer
} else
#endif
{
PCBVersion = 3;
systemSettings.SleepTime = 0;
systemSettings.ShutdownTime = 0; // No accel -> disable sleep
systemSettings.sensitivity = 0;
}
resetWatchdog();
/* Create the thread(s) */
/* definition and creation of GUITask */
osThreadStaticDef(GUITask, startGUITask, osPriorityBelowNormal, 0,
GUITaskStackSize, GUITaskBuffer, &GUITaskControlBlock);
GUITaskHandle = osThreadCreate(osThread(GUITask), NULL);