1
0
forked from me/IronOS

Refactor to 1khz RToS

This commit is contained in:
Ben V. Brown
2020-08-01 21:16:23 +10:00
parent 9391158399
commit e2c5e51fe1
8 changed files with 27 additions and 36 deletions

View File

@@ -24,7 +24,7 @@ ButtonState getButtonState() {
*/
static uint8_t previousState = 0;
static uint32_t previousStateChange = 0;
const uint16_t timeout = 40;
const uint16_t timeout = 400;
uint8_t currentState;
currentState = (getButtonA()) << 0;
currentState |= (getButtonB()) << 1;

View File

@@ -171,7 +171,7 @@ void OLED::transitionSecondaryFramebuffer(bool forwardNavigation) {
while (duration <= totalDuration) {
duration = xTaskGetTickCount() - start;
uint8_t progress = duration * 100 / totalDuration;
uint8_t progress = duration * 1000 / totalDuration;
progress = easeInOutTiming(progress);
progress = lerp(0, OLED_WIDTH, progress);
if (progress > OLED_WIDTH) {

View File

@@ -98,7 +98,7 @@ extern uint32_t SystemCoreClock;
#define configUSE_IDLE_HOOK 1
#define configUSE_TICK_HOOK 0
#define configCPU_CLOCK_HZ ( SystemCoreClock )
#define configTICK_RATE_HZ ((TickType_t)100)
#define configTICK_RATE_HZ ((TickType_t)1000)
#define configMAX_PRIORITIES ( 6 )
#define configMINIMAL_STACK_SIZE ((uint16_t)256)
#define configTOTAL_HEAP_SIZE ((size_t)1024*14) /*Currently use about 9000*/

View File

@@ -12,8 +12,8 @@
#include "BSP.h"
#define PRESS_ACCEL_STEP 3
#define PRESS_ACCEL_INTERVAL_MIN 10
#define PRESS_ACCEL_INTERVAL_MAX 30
#define PRESS_ACCEL_INTERVAL_MIN 100
#define PRESS_ACCEL_INTERVAL_MAX 300
//GUI holds the menu structure and all its methods for the menu itself

View File

@@ -50,7 +50,7 @@ void seekQC(int16_t Vx10, uint16_t divisor) {
if (Vx10 < 45)
return;
if (xTaskGetTickCount() < 100)
if (xTaskGetTickCount() < 1000)
return;
if (Vx10 > 130)
Vx10 = 130; // Cap max value at 13V

View File

@@ -291,7 +291,7 @@ static int userConfirmation(const char *message) {
for (;;) {
int16_t messageOffset = ((xTaskGetTickCount() - messageStart)
/ (systemSettings.descriptionScrollSpeed == 1 ? 1 : 2));
/ (systemSettings.descriptionScrollSpeed == 1 ? 10 : 20));
messageOffset %= messageWidth; // Roll around at the end
if (lastOffset != messageOffset) {
@@ -646,7 +646,7 @@ static void settings_setResetSettings(void) {
OLED::print(ResetOKMessage);
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::printNumber(systemSettings.voltageDiv, 3);
OLED::refresh();
waitForButtonPressOrTimeout(100);
waitForButtonPressOrTimeout(1000);
return;
break;
case BUTTON_NONE:
@@ -933,7 +933,7 @@ void gui_Menu(const menuitem *menu) {
OLED::setCursor(0, 0);
// If the user has hesitated for >=3 seconds, show the long text
// Otherwise "draw" the option
if ((xTaskGetTickCount() - lastButtonTime < 300)
if ((xTaskGetTickCount() - lastButtonTime < 3000)
|| menu[currentScreen].description == NULL) {
OLED::clearScreen();
menu[currentScreen].draw.func();
@@ -952,7 +952,7 @@ void gui_Menu(const menuitem *menu) {
int16_t descriptionOffset =
((xTaskGetTickCount() - descriptionStart)
/ (systemSettings.descriptionScrollSpeed == 1 ?
1 : 2));
10 : 20));
descriptionOffset %= descriptionWidth; // Roll around at the end
if (lastOffset != descriptionOffset) {
OLED::clearScreen();
@@ -1040,7 +1040,7 @@ void gui_Menu(const menuitem *menu) {
osDelay(40);
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
// This will trickle the user back to the main screen eventually
earlyExit = true;

View File

@@ -246,7 +246,7 @@ static void gui_solderingTempAdjust() {
systemSettings.SolderingTemp = 10;
}
if (xTaskGetTickCount() - lastChange > 200)
if (xTaskGetTickCount() - lastChange > 2000)
return; // exit if user just doesn't press anything for a bit
#ifdef OLED_FLIP
@@ -299,9 +299,10 @@ static int gui_SolderingSleepingMode(bool stayOff) {
ButtonState buttons = getButtonState();
if (buttons)
return 0;
if ((xTaskGetTickCount() > 100)
&& ((accelInit && (xTaskGetTickCount() - lastMovementTime < 100))
|| (xTaskGetTickCount() - lastButtonTime < 100)))
if ((xTaskGetTickCount() > 1000)
&& ((accelInit
&& (xTaskGetTickCount() - lastMovementTime < 1000))
|| (xTaskGetTickCount() - lastButtonTime < 1000)))
return 0; // user moved or pressed a button, go back to soldering
#ifdef MODEL_TS100
if (checkVoltageForExit())
@@ -366,7 +367,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)) {
> (uint32_t) (systemSettings.ShutdownTime * 60 * 1000)) {
// shutdown
currentTempTargetDegC = 0;
return 1; // we want to exit soldering mode
@@ -386,11 +387,11 @@ static void display_countdown(int sleepThres) {
lastButtonTime < lastMovementTime ?
lastMovementTime : lastButtonTime;
int downCount = sleepThres - xTaskGetTickCount() + lastEventTime;
if (downCount > 9900) {
OLED::printNumber(downCount / 6000 + 1, 2);
if (downCount > 99000) {
OLED::printNumber(downCount / 60000 + 1, 2);
OLED::print(SymbolMinutes);
} else {
OLED::printNumber(downCount / 100 + 1, 2);
OLED::printNumber(downCount / 1000 + 1, 2);
OLED::print(SymbolSeconds);
}
}
@@ -413,9 +414,9 @@ static void gui_solderingMode(uint8_t jumpToSleep) {
uint32_t sleepThres = 0;
if (systemSettings.SleepTime < 6)
sleepThres = systemSettings.SleepTime * 10 * 100;
sleepThres = systemSettings.SleepTime * 10 * 1000;
else
sleepThres = (systemSettings.SleepTime - 5) * 60 * 100;
sleepThres = (systemSettings.SleepTime - 5) * 60 * 1000;
if (jumpToSleep) {
if (gui_SolderingSleepingMode(jumpToSleep == 2)) {
lastButtonTime = xTaskGetTickCount();
@@ -473,9 +474,6 @@ static void gui_solderingMode(uint8_t jumpToSleep) {
OLED::setCursor(0, 8);
OLED::print(SleepingTipAdvancedString);
// OLED::printNumber(
// TipThermoModel::convertTipRawADCTouV(getTipRawTemp(0)), 5); // Draw the tip temp out finally
gui_drawTipTemp(true);
OLED::print(SymbolSpace);
printVoltage();
@@ -543,13 +541,6 @@ static void gui_solderingMode(uint8_t jumpToSleep) {
lastButtonTime = xTaskGetTickCount();
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
if (systemSettings.sensitivity && systemSettings.SleepTime)
@@ -658,7 +649,7 @@ void startGUITask(void const *argument __unused) {
getTipRawTemp(1); // reset filter
OLED::setRotation(systemSettings.OrientationMode & 1);
uint32_t ticks = xTaskGetTickCount();
ticks += 400; // 4 seconds from now
ticks += 4000; // 4 seconds from now
while (xTaskGetTickCount() < ticks) {
if (showBootLogoIfavailable() == false)
ticks = xTaskGetTickCount();
@@ -675,7 +666,7 @@ void startGUITask(void const *argument __unused) {
OLED::setCursor(0, 0);
OLED::print(SettingsResetMessage);
OLED::refresh();
waitForButtonPressOrTimeout(1000);
waitForButtonPressOrTimeout(10000);
}
if (systemSettings.autoStartMode) {
// jump directly to the autostart mode

View File

@@ -14,8 +14,8 @@
#include "FreeRTOS.h"
#include "task.h"
#include "Settings.h"
static TickType_t powerPulseRate = 1000;
static TickType_t powerPulseDuration = 50;
static TickType_t powerPulseRate = 10000;
static TickType_t powerPulseDuration = 250;
TaskHandle_t pidTaskNotification = NULL;
uint32_t currentTempTargetDegC = 0; // Current temperature target in C