Change to using setting to control power pulse
This commit is contained in:
@@ -36,15 +36,13 @@ uint32_t MOVTaskBuffer[MOVTaskStackSize];
|
||||
osStaticThreadDef_t MOVTaskControlBlock;
|
||||
|
||||
static TaskHandle_t pidTaskNotification = NULL;
|
||||
|
||||
static TickType_t powerPulseRate = 1000;
|
||||
static TickType_t powerPulseDuration = 50;
|
||||
void startGUITask(void const *argument);
|
||||
void startPIDTask(void const *argument);
|
||||
void startMOVTask(void const *argument);
|
||||
// End FreeRTOS
|
||||
|
||||
static const int maxPowerIdleTicks = 1000;
|
||||
static const int powerPulseTicks = 50;
|
||||
static const int x10PowerPulseWatts = 3;
|
||||
|
||||
// Main sets up the hardware then hands over to the FreeRTOS kernel
|
||||
int main(void) {
|
||||
@@ -117,7 +115,8 @@ void startPIDTask(void const *argument __unused) {
|
||||
#ifdef MODEL_TS80
|
||||
//Set power management code to the tip resistance in ohms * 10
|
||||
|
||||
TickType_t lastPowerPulse = 0;
|
||||
TickType_t lastPowerPulseStart = 0;
|
||||
TickType_t lastPowerPulseEnd = 0;
|
||||
#else
|
||||
|
||||
#endif
|
||||
@@ -183,18 +182,23 @@ void startPIDTask(void const *argument __unused) {
|
||||
// Unfortunately, our temp signal is too noisy to really help.
|
||||
|
||||
}
|
||||
#ifdef MODEL_TS80
|
||||
//If its a TS80, we want to have the option of using an occasional pulse to keep the power bank on
|
||||
if (((xTaskGetTickCount() - lastPowerPulse) > maxPowerIdleTicks)
|
||||
&& (x10WattsOut < x10PowerPulseWatts)) {
|
||||
x10WattsOut = x10PowerPulseWatts;
|
||||
//If the user turns on the option of using an occasional pulse to keep the power bank on
|
||||
if (systemSettings.KeepAwakePulse) {
|
||||
|
||||
if (xTaskGetTickCount() - lastPowerPulseStart
|
||||
> powerPulseRate) {
|
||||
lastPowerPulseStart = xTaskGetTickCount();
|
||||
lastPowerPulseEnd = lastPowerPulseStart
|
||||
+ powerPulseDuration;
|
||||
}
|
||||
|
||||
//If current PID is less than the pulse level, check if we want to constrain to the pulse as the floor
|
||||
if (x10WattsOut < systemSettings.KeepAwakePulse
|
||||
&& xTaskGetTickCount() < lastPowerPulseEnd) {
|
||||
x10WattsOut = systemSettings.KeepAwakePulse;
|
||||
}
|
||||
}
|
||||
if (((xTaskGetTickCount() - lastPowerPulse)
|
||||
> (maxPowerIdleTicks + powerPulseTicks))
|
||||
&& (x10WattsOut >= x10PowerPulseWatts)) {
|
||||
lastPowerPulse = xTaskGetTickCount();
|
||||
}
|
||||
#endif
|
||||
|
||||
//Secondary safety check to forcefully disable header when within ADC noise of top of ADC
|
||||
if (getTipRawTemp(0) > (0x7FFF - 150)) {
|
||||
x10WattsOut = 0;
|
||||
@@ -263,8 +267,7 @@ void startMOVTask(void const *argument __unused) {
|
||||
datax[currentPointer] = (int32_t) tx;
|
||||
datay[currentPointer] = (int32_t) ty;
|
||||
dataz[currentPointer] = (int32_t) tz;
|
||||
if (!accelInit)
|
||||
{
|
||||
if (!accelInit) {
|
||||
for (uint8_t i = currentPointer + 1; i < MOVFilter; i++) {
|
||||
datax[i] = (int32_t) tx;
|
||||
datay[i] = (int32_t) ty;
|
||||
@@ -304,19 +307,20 @@ void startMOVTask(void const *argument __unused) {
|
||||
|
||||
// Second last page of flash set aside for logo image.
|
||||
#define FLASH_LOGOADDR (0x8000000 | 0xF800)
|
||||
|
||||
|
||||
// Logo header signature.
|
||||
#define LOGO_HEADER_VALUE 0xF00DAA55
|
||||
|
||||
bool showBootLogoIfavailable() {
|
||||
// Do not show logo data if signature is not found.
|
||||
if (LOGO_HEADER_VALUE != *(reinterpret_cast<const uint32_t *>(FLASH_LOGOADDR))) {
|
||||
return false;
|
||||
}
|
||||
// Do not show logo data if signature is not found.
|
||||
if (LOGO_HEADER_VALUE
|
||||
!= *(reinterpret_cast<const uint32_t*>(FLASH_LOGOADDR))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
OLED::drawAreaSwapped(0, 0, 96, 16, (uint8_t*) (FLASH_LOGOADDR + 4));
|
||||
OLED::refresh();
|
||||
return true;
|
||||
OLED::drawAreaSwapped(0, 0, 96, 16, (uint8_t*) (FLASH_LOGOADDR + 4));
|
||||
OLED::refresh();
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -344,12 +348,10 @@ void HAL_I2C_MemTxCpltCallback(I2C_HandleTypeDef *hi2c __unused) {
|
||||
FRToSI2C::CpltCallback();
|
||||
}
|
||||
void HAL_I2C_ErrorCallback(I2C_HandleTypeDef *hi2c __unused) {
|
||||
asm("bkpt");
|
||||
|
||||
FRToSI2C::CpltCallback();
|
||||
}
|
||||
void HAL_I2C_AbortCpltCallback(I2C_HandleTypeDef *hi2c __unused) {
|
||||
//asm("bkpt");
|
||||
|
||||
FRToSI2C::CpltCallback();
|
||||
}
|
||||
@@ -358,7 +360,7 @@ void HAL_I2C_MemRxCpltCallback(I2C_HandleTypeDef *hi2c __unused) {
|
||||
}
|
||||
void vApplicationStackOverflowHook(xTaskHandle *pxTask __unused,
|
||||
signed portCHAR *pcTaskName __unused) {
|
||||
asm("bkpt");
|
||||
// We dont have a good way to handle a stack overflow at this point in time
|
||||
|
||||
// We dont have a good way to handle a stack overflow at this point in time
|
||||
NVIC_SystemReset();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user