Refactor to 1khz RToS
This commit is contained in:
@@ -24,7 +24,7 @@ ButtonState getButtonState() {
|
|||||||
*/
|
*/
|
||||||
static uint8_t previousState = 0;
|
static uint8_t previousState = 0;
|
||||||
static uint32_t previousStateChange = 0;
|
static uint32_t previousStateChange = 0;
|
||||||
const uint16_t timeout = 40;
|
const uint16_t timeout = 400;
|
||||||
uint8_t currentState;
|
uint8_t currentState;
|
||||||
currentState = (getButtonA()) << 0;
|
currentState = (getButtonA()) << 0;
|
||||||
currentState |= (getButtonB()) << 1;
|
currentState |= (getButtonB()) << 1;
|
||||||
|
|||||||
@@ -171,7 +171,7 @@ void OLED::transitionSecondaryFramebuffer(bool forwardNavigation) {
|
|||||||
|
|
||||||
while (duration <= totalDuration) {
|
while (duration <= totalDuration) {
|
||||||
duration = xTaskGetTickCount() - start;
|
duration = xTaskGetTickCount() - start;
|
||||||
uint8_t progress = duration * 100 / totalDuration;
|
uint8_t progress = duration * 1000 / totalDuration;
|
||||||
progress = easeInOutTiming(progress);
|
progress = easeInOutTiming(progress);
|
||||||
progress = lerp(0, OLED_WIDTH, progress);
|
progress = lerp(0, OLED_WIDTH, progress);
|
||||||
if (progress > OLED_WIDTH) {
|
if (progress > OLED_WIDTH) {
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ extern uint32_t SystemCoreClock;
|
|||||||
#define configUSE_IDLE_HOOK 1
|
#define configUSE_IDLE_HOOK 1
|
||||||
#define configUSE_TICK_HOOK 0
|
#define configUSE_TICK_HOOK 0
|
||||||
#define configCPU_CLOCK_HZ ( SystemCoreClock )
|
#define configCPU_CLOCK_HZ ( SystemCoreClock )
|
||||||
#define configTICK_RATE_HZ ((TickType_t)100)
|
#define configTICK_RATE_HZ ((TickType_t)1000)
|
||||||
#define configMAX_PRIORITIES ( 6 )
|
#define configMAX_PRIORITIES ( 6 )
|
||||||
#define configMINIMAL_STACK_SIZE ((uint16_t)256)
|
#define configMINIMAL_STACK_SIZE ((uint16_t)256)
|
||||||
#define configTOTAL_HEAP_SIZE ((size_t)1024*14) /*Currently use about 9000*/
|
#define configTOTAL_HEAP_SIZE ((size_t)1024*14) /*Currently use about 9000*/
|
||||||
|
|||||||
@@ -12,8 +12,8 @@
|
|||||||
#include "BSP.h"
|
#include "BSP.h"
|
||||||
|
|
||||||
#define PRESS_ACCEL_STEP 3
|
#define PRESS_ACCEL_STEP 3
|
||||||
#define PRESS_ACCEL_INTERVAL_MIN 10
|
#define PRESS_ACCEL_INTERVAL_MIN 100
|
||||||
#define PRESS_ACCEL_INTERVAL_MAX 30
|
#define PRESS_ACCEL_INTERVAL_MAX 300
|
||||||
|
|
||||||
//GUI holds the menu structure and all its methods for the menu itself
|
//GUI holds the menu structure and all its methods for the menu itself
|
||||||
|
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ void seekQC(int16_t Vx10, uint16_t divisor) {
|
|||||||
|
|
||||||
if (Vx10 < 45)
|
if (Vx10 < 45)
|
||||||
return;
|
return;
|
||||||
if (xTaskGetTickCount() < 100)
|
if (xTaskGetTickCount() < 1000)
|
||||||
return;
|
return;
|
||||||
if (Vx10 > 130)
|
if (Vx10 > 130)
|
||||||
Vx10 = 130; // Cap max value at 13V
|
Vx10 = 130; // Cap max value at 13V
|
||||||
|
|||||||
@@ -291,7 +291,7 @@ static int userConfirmation(const char *message) {
|
|||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
int16_t messageOffset = ((xTaskGetTickCount() - messageStart)
|
int16_t messageOffset = ((xTaskGetTickCount() - messageStart)
|
||||||
/ (systemSettings.descriptionScrollSpeed == 1 ? 1 : 2));
|
/ (systemSettings.descriptionScrollSpeed == 1 ? 10 : 20));
|
||||||
messageOffset %= messageWidth; // Roll around at the end
|
messageOffset %= messageWidth; // Roll around at the end
|
||||||
|
|
||||||
if (lastOffset != messageOffset) {
|
if (lastOffset != messageOffset) {
|
||||||
@@ -646,7 +646,7 @@ static void settings_setResetSettings(void) {
|
|||||||
OLED::print(ResetOKMessage);
|
OLED::print(ResetOKMessage);
|
||||||
OLED::refresh();
|
OLED::refresh();
|
||||||
|
|
||||||
waitForButtonPressOrTimeout(200); // 2 second timeout
|
waitForButtonPressOrTimeout(2000); // 2 second timeout
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -731,7 +731,7 @@ static void settings_setCalibrateVIN(void) {
|
|||||||
OLED::setCursor(0, 0);
|
OLED::setCursor(0, 0);
|
||||||
OLED::printNumber(systemSettings.voltageDiv, 3);
|
OLED::printNumber(systemSettings.voltageDiv, 3);
|
||||||
OLED::refresh();
|
OLED::refresh();
|
||||||
waitForButtonPressOrTimeout(100);
|
waitForButtonPressOrTimeout(1000);
|
||||||
return;
|
return;
|
||||||
break;
|
break;
|
||||||
case BUTTON_NONE:
|
case BUTTON_NONE:
|
||||||
@@ -933,7 +933,7 @@ void gui_Menu(const menuitem *menu) {
|
|||||||
OLED::setCursor(0, 0);
|
OLED::setCursor(0, 0);
|
||||||
// If the user has hesitated for >=3 seconds, show the long text
|
// If the user has hesitated for >=3 seconds, show the long text
|
||||||
// Otherwise "draw" the option
|
// Otherwise "draw" the option
|
||||||
if ((xTaskGetTickCount() - lastButtonTime < 300)
|
if ((xTaskGetTickCount() - lastButtonTime < 3000)
|
||||||
|| menu[currentScreen].description == NULL) {
|
|| menu[currentScreen].description == NULL) {
|
||||||
OLED::clearScreen();
|
OLED::clearScreen();
|
||||||
menu[currentScreen].draw.func();
|
menu[currentScreen].draw.func();
|
||||||
@@ -952,7 +952,7 @@ void gui_Menu(const menuitem *menu) {
|
|||||||
int16_t descriptionOffset =
|
int16_t descriptionOffset =
|
||||||
((xTaskGetTickCount() - descriptionStart)
|
((xTaskGetTickCount() - descriptionStart)
|
||||||
/ (systemSettings.descriptionScrollSpeed == 1 ?
|
/ (systemSettings.descriptionScrollSpeed == 1 ?
|
||||||
1 : 2));
|
10 : 20));
|
||||||
descriptionOffset %= descriptionWidth; // Roll around at the end
|
descriptionOffset %= descriptionWidth; // Roll around at the end
|
||||||
if (lastOffset != descriptionOffset) {
|
if (lastOffset != descriptionOffset) {
|
||||||
OLED::clearScreen();
|
OLED::clearScreen();
|
||||||
@@ -1040,7 +1040,7 @@ void gui_Menu(const menuitem *menu) {
|
|||||||
osDelay(40);
|
osDelay(40);
|
||||||
lcdRefresh = false;
|
lcdRefresh = false;
|
||||||
}
|
}
|
||||||
if ((xTaskGetTickCount() - lastButtonTime) > (100 * 30)) {
|
if ((xTaskGetTickCount() - lastButtonTime) > (1000 * 30)) {
|
||||||
// If user has not pressed any buttons in 30 seconds, exit back a menu layer
|
// If user has not pressed any buttons in 30 seconds, exit back a menu layer
|
||||||
// This will trickle the user back to the main screen eventually
|
// This will trickle the user back to the main screen eventually
|
||||||
earlyExit = true;
|
earlyExit = true;
|
||||||
|
|||||||
@@ -246,7 +246,7 @@ static void gui_solderingTempAdjust() {
|
|||||||
systemSettings.SolderingTemp = 10;
|
systemSettings.SolderingTemp = 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (xTaskGetTickCount() - lastChange > 200)
|
if (xTaskGetTickCount() - lastChange > 2000)
|
||||||
return; // exit if user just doesn't press anything for a bit
|
return; // exit if user just doesn't press anything for a bit
|
||||||
|
|
||||||
#ifdef OLED_FLIP
|
#ifdef OLED_FLIP
|
||||||
@@ -299,9 +299,10 @@ static int gui_SolderingSleepingMode(bool stayOff) {
|
|||||||
ButtonState buttons = getButtonState();
|
ButtonState buttons = getButtonState();
|
||||||
if (buttons)
|
if (buttons)
|
||||||
return 0;
|
return 0;
|
||||||
if ((xTaskGetTickCount() > 100)
|
if ((xTaskGetTickCount() > 1000)
|
||||||
&& ((accelInit && (xTaskGetTickCount() - lastMovementTime < 100))
|
&& ((accelInit
|
||||||
|| (xTaskGetTickCount() - lastButtonTime < 100)))
|
&& (xTaskGetTickCount() - lastMovementTime < 1000))
|
||||||
|
|| (xTaskGetTickCount() - lastButtonTime < 1000)))
|
||||||
return 0; // user moved or pressed a button, go back to soldering
|
return 0; // user moved or pressed a button, go back to soldering
|
||||||
#ifdef MODEL_TS100
|
#ifdef MODEL_TS100
|
||||||
if (checkVoltageForExit())
|
if (checkVoltageForExit())
|
||||||
@@ -366,7 +367,7 @@ static int gui_SolderingSleepingMode(bool stayOff) {
|
|||||||
if (systemSettings.ShutdownTime) // only allow shutdown exit if time > 0
|
if (systemSettings.ShutdownTime) // only allow shutdown exit if time > 0
|
||||||
if (lastMovementTime)
|
if (lastMovementTime)
|
||||||
if (((uint32_t) (xTaskGetTickCount() - lastMovementTime))
|
if (((uint32_t) (xTaskGetTickCount() - lastMovementTime))
|
||||||
> (uint32_t) (systemSettings.ShutdownTime * 60 * 100)) {
|
> (uint32_t) (systemSettings.ShutdownTime * 60 * 1000)) {
|
||||||
// shutdown
|
// shutdown
|
||||||
currentTempTargetDegC = 0;
|
currentTempTargetDegC = 0;
|
||||||
return 1; // we want to exit soldering mode
|
return 1; // we want to exit soldering mode
|
||||||
@@ -386,11 +387,11 @@ static void display_countdown(int sleepThres) {
|
|||||||
lastButtonTime < lastMovementTime ?
|
lastButtonTime < lastMovementTime ?
|
||||||
lastMovementTime : lastButtonTime;
|
lastMovementTime : lastButtonTime;
|
||||||
int downCount = sleepThres - xTaskGetTickCount() + lastEventTime;
|
int downCount = sleepThres - xTaskGetTickCount() + lastEventTime;
|
||||||
if (downCount > 9900) {
|
if (downCount > 99000) {
|
||||||
OLED::printNumber(downCount / 6000 + 1, 2);
|
OLED::printNumber(downCount / 60000 + 1, 2);
|
||||||
OLED::print(SymbolMinutes);
|
OLED::print(SymbolMinutes);
|
||||||
} else {
|
} else {
|
||||||
OLED::printNumber(downCount / 100 + 1, 2);
|
OLED::printNumber(downCount / 1000 + 1, 2);
|
||||||
OLED::print(SymbolSeconds);
|
OLED::print(SymbolSeconds);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -413,9 +414,9 @@ static void gui_solderingMode(uint8_t jumpToSleep) {
|
|||||||
|
|
||||||
uint32_t sleepThres = 0;
|
uint32_t sleepThres = 0;
|
||||||
if (systemSettings.SleepTime < 6)
|
if (systemSettings.SleepTime < 6)
|
||||||
sleepThres = systemSettings.SleepTime * 10 * 100;
|
sleepThres = systemSettings.SleepTime * 10 * 1000;
|
||||||
else
|
else
|
||||||
sleepThres = (systemSettings.SleepTime - 5) * 60 * 100;
|
sleepThres = (systemSettings.SleepTime - 5) * 60 * 1000;
|
||||||
if (jumpToSleep) {
|
if (jumpToSleep) {
|
||||||
if (gui_SolderingSleepingMode(jumpToSleep == 2)) {
|
if (gui_SolderingSleepingMode(jumpToSleep == 2)) {
|
||||||
lastButtonTime = xTaskGetTickCount();
|
lastButtonTime = xTaskGetTickCount();
|
||||||
@@ -473,9 +474,6 @@ static void gui_solderingMode(uint8_t jumpToSleep) {
|
|||||||
|
|
||||||
OLED::setCursor(0, 8);
|
OLED::setCursor(0, 8);
|
||||||
OLED::print(SleepingTipAdvancedString);
|
OLED::print(SleepingTipAdvancedString);
|
||||||
// OLED::printNumber(
|
|
||||||
// TipThermoModel::convertTipRawADCTouV(getTipRawTemp(0)), 5); // Draw the tip temp out finally
|
|
||||||
|
|
||||||
gui_drawTipTemp(true);
|
gui_drawTipTemp(true);
|
||||||
OLED::print(SymbolSpace);
|
OLED::print(SymbolSpace);
|
||||||
printVoltage();
|
printVoltage();
|
||||||
@@ -543,13 +541,6 @@ static void gui_solderingMode(uint8_t jumpToSleep) {
|
|||||||
lastButtonTime = xTaskGetTickCount();
|
lastButtonTime = xTaskGetTickCount();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
// on the TS80 we only want to check for over voltage to prevent tip damage
|
|
||||||
/*if (getInputVoltageX10(systemSettings.voltageDiv, 1) > 150) {
|
|
||||||
lastButtonTime = xTaskGetTickCount();
|
|
||||||
currentlyActiveTemperatureTarget = 0;
|
|
||||||
return; // Over voltage
|
|
||||||
}*/
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (systemSettings.sensitivity && systemSettings.SleepTime)
|
if (systemSettings.sensitivity && systemSettings.SleepTime)
|
||||||
@@ -658,7 +649,7 @@ void startGUITask(void const *argument __unused) {
|
|||||||
getTipRawTemp(1); // reset filter
|
getTipRawTemp(1); // reset filter
|
||||||
OLED::setRotation(systemSettings.OrientationMode & 1);
|
OLED::setRotation(systemSettings.OrientationMode & 1);
|
||||||
uint32_t ticks = xTaskGetTickCount();
|
uint32_t ticks = xTaskGetTickCount();
|
||||||
ticks += 400; // 4 seconds from now
|
ticks += 4000; // 4 seconds from now
|
||||||
while (xTaskGetTickCount() < ticks) {
|
while (xTaskGetTickCount() < ticks) {
|
||||||
if (showBootLogoIfavailable() == false)
|
if (showBootLogoIfavailable() == false)
|
||||||
ticks = xTaskGetTickCount();
|
ticks = xTaskGetTickCount();
|
||||||
@@ -675,7 +666,7 @@ void startGUITask(void const *argument __unused) {
|
|||||||
OLED::setCursor(0, 0);
|
OLED::setCursor(0, 0);
|
||||||
OLED::print(SettingsResetMessage);
|
OLED::print(SettingsResetMessage);
|
||||||
OLED::refresh();
|
OLED::refresh();
|
||||||
waitForButtonPressOrTimeout(1000);
|
waitForButtonPressOrTimeout(10000);
|
||||||
}
|
}
|
||||||
if (systemSettings.autoStartMode) {
|
if (systemSettings.autoStartMode) {
|
||||||
// jump directly to the autostart mode
|
// jump directly to the autostart mode
|
||||||
|
|||||||
@@ -14,8 +14,8 @@
|
|||||||
#include "FreeRTOS.h"
|
#include "FreeRTOS.h"
|
||||||
#include "task.h"
|
#include "task.h"
|
||||||
#include "Settings.h"
|
#include "Settings.h"
|
||||||
static TickType_t powerPulseRate = 1000;
|
static TickType_t powerPulseRate = 10000;
|
||||||
static TickType_t powerPulseDuration = 50;
|
static TickType_t powerPulseDuration = 250;
|
||||||
TaskHandle_t pidTaskNotification = NULL;
|
TaskHandle_t pidTaskNotification = NULL;
|
||||||
uint32_t currentTempTargetDegC = 0; // Current temperature target in C
|
uint32_t currentTempTargetDegC = 0; // Current temperature target in C
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user