Pull out more QC hooks

This commit is contained in:
Ben V. Brown
2020-05-30 12:05:11 +10:00
parent 2bcebd473e
commit 5bb85a4a32
6 changed files with 739 additions and 782 deletions

View File

@@ -1,8 +1,8 @@
#include "Defines.h"
#include "stdint.h"
#include "UnitSettings.h"
#include "BSP_QC.h"
#include "BSP_Flash.h" #include "BSP_Flash.h"
#include "BSP_QC.h"
#include "Defines.h"
#include "UnitSettings.h"
#include "stdint.h"
/* /*
* BSP.h -- Board Support * BSP.h -- Board Support
* *
@@ -15,20 +15,20 @@
extern "C" { extern "C" {
#endif #endif
//Called first thing in main() to init the hardware // Called first thing in main() to init the hardware
void preRToSInit(); void preRToSInit();
//Called once the RToS has started for any extra work // Called once the RToS has started for any extra work
void postRToSInit(); void postRToSInit();
// Called to reset the hardware watchdog unit // Called to reset the hardware watchdog unit
void resetWatchdog(); void resetWatchdog();
//Accepts a output level of 0.. to use to control the tip output PWM // Accepts a output level of 0.. to use to control the tip output PWM
void setTipPWM(uint8_t pulse); void setTipPWM(uint8_t pulse);
//Returns the Handle temp in C, X10 // Returns the Handle temp in C, X10
uint16_t getHandleTemperature(); uint16_t getHandleTemperature();
//Returns the Tip temperature ADC reading in raw units // Returns the Tip temperature ADC reading in raw units
uint16_t getTipRawTemp(uint8_t refresh); uint16_t getTipRawTemp(uint8_t refresh);
//Returns the main DC input voltage, using the adjustable divisor + sample flag // Returns the main DC input voltage, using the adjustable divisor + sample flag
uint16_t getInputVoltageX10(uint16_t divisor, uint8_t sample); uint16_t getInputVoltageX10(uint16_t divisor, uint8_t sample);
// Readers for the two buttons // Readers for the two buttons
@@ -40,11 +40,11 @@ uint8_t getButtonB();
// This should toggle the SCL line until SDA goes high to end the current transaction // This should toggle the SCL line until SDA goes high to end the current transaction
void unstick_I2C(); void unstick_I2C();
//Reboot the IC when things go seriously wrong // Reboot the IC when things go seriously wrong
void reboot(); void reboot();
//If the user has programmed in a bootup logo, draw it to the screen from flash // If the user has programmed in a bootup logo, draw it to the screen from flash
//Returns 1 if the logo was printed so that the unit waits for the timeout or button // Returns 1 if the logo was printed so that the unit waits for the timeout or button
uint8_t showBootLogoIfavailable(); uint8_t showBootLogoIfavailable();
void delay_ms(uint16_t count); void delay_ms(uint16_t count);

View File

@@ -32,6 +32,9 @@ void QC_Post_Probe_En();
// Check if DM was pulled down // Check if DM was pulled down
// 1=Pulled down, 0 == pulled high // 1=Pulled down, 0 == pulled high
uint8_t QC_DM_PulledDown(); uint8_t QC_DM_PulledDown();
// Re-sync if required
void QC_resync();
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@@ -6,6 +6,8 @@
*/ */
#include "BSP.h" #include "BSP.h"
#include "Pins.h" #include "Pins.h"
#include "QC3.h"
#include "Settings.h"
#include "stm32f1xx_hal.h" #include "stm32f1xx_hal.h"
void QC_DPlusZero_Six() { void QC_DPlusZero_Six() {
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_3, GPIO_PIN_RESET); // pull down D+ HAL_GPIO_WritePin(GPIOB, GPIO_PIN_3, GPIO_PIN_RESET); // pull down D+
@@ -63,3 +65,10 @@ void QC_Post_Probe_En() {
} }
uint8_t QC_DM_PulledDown() { return HAL_GPIO_ReadPin(GPIOA, GPIO_PIN_11) == GPIO_PIN_RESET ? 1 : 0; } uint8_t QC_DM_PulledDown() { return HAL_GPIO_ReadPin(GPIOA, GPIO_PIN_11) == GPIO_PIN_RESET ? 1 : 0; }
void QC_resync() {
#ifdef MODEL_TS80
seekQC((systemSettings.cutoutSetting) ? 120 : 90,
systemSettings.voltageDiv); // Run the QC seek again if we have drifted too much
#endif
}

View File

@@ -0,0 +1,23 @@
#include "BSP.h"
#include "FreeRTOS.h"
#include "QC3.h"
#include "Settings.h"
#include "cmsis_os.h"
#include "main.hpp"
#include "power.hpp"
#include "stdlib.h"
#include "task.h"
void postRToSInit() {
#ifdef MODEL_TS80
startQC(systemSettings.voltageDiv);
while (pidTaskNotification == 0) osDelay(30); // Wait for PID to start
seekQC((systemSettings.cutoutSetting) ? 120 : 90,
systemSettings.voltageDiv); // this will move the QC output to the preferred voltage to start with
#else
while (pidTaskNotification == 0) osDelay(30); // Wait for PID to start
osDelay(200); // wait for accelerometer to stabilize
#endif
}

View File

@@ -9,19 +9,20 @@ extern "C" {
} }
#include <MMA8652FC.hpp> #include <MMA8652FC.hpp>
#include <gui.hpp> #include <gui.hpp>
#include <main.hpp>
#include "LIS2DH12.hpp"
#include <history.hpp> #include <history.hpp>
#include <main.hpp>
#include <power.hpp> #include <power.hpp>
#include "../../configuration.h"
#include "Buttons.hpp"
#include "LIS2DH12.hpp"
#include "Settings.h" #include "Settings.h"
#include "TipThermoModel.h"
#include "Translation.h" #include "Translation.h"
#include "cmsis_os.h" #include "cmsis_os.h"
#include "stdlib.h" #include "stdlib.h"
#include "string.h" #include "string.h"
#include "TipThermoModel.h"
#include "unit.h" #include "unit.h"
#include "../../configuration.h"
#include "Buttons.hpp"
extern uint8_t PCBVersion; extern uint8_t PCBVersion;
// File local variables // File local variables
extern uint32_t currentTempTargetDegC; extern uint32_t currentTempTargetDegC;
@@ -32,8 +33,8 @@ extern osThreadId GUITaskHandle;
extern osThreadId MOVTaskHandle; extern osThreadId MOVTaskHandle;
extern osThreadId PIDTaskHandle; extern osThreadId PIDTaskHandle;
#define MOVEMENT_INACTIVITY_TIME (60*configTICK_RATE_HZ) #define MOVEMENT_INACTIVITY_TIME (60 * configTICK_RATE_HZ)
#define BUTTON_INACTIVITY_TIME (60*configTICK_RATE_HZ) #define BUTTON_INACTIVITY_TIME (60 * configTICK_RATE_HZ)
static uint16_t min(uint16_t a, uint16_t b) { static uint16_t min(uint16_t a, uint16_t b) {
if (a > b) if (a > b)
@@ -62,26 +63,26 @@ void gui_drawTipTemp(bool symbol) {
if (systemSettings.temperatureInF) if (systemSettings.temperatureInF)
Temp = TipThermoModel::getTipInF(); Temp = TipThermoModel::getTipInF();
else else
#endif #endif
Temp = TipThermoModel::getTipInC(); Temp = TipThermoModel::getTipInC();
OLED::printNumber(Temp, 3); // Draw the tip temp out finally OLED::printNumber(Temp, 3); // Draw the tip temp out finally
if (symbol) { if (symbol) {
if (OLED::getFont() == 0) { if (OLED::getFont() == 0) {
//Big font, can draw nice symbols // Big font, can draw nice symbols
#ifdef ENABLED_FAHRENHEIT_SUPPORT #ifdef ENABLED_FAHRENHEIT_SUPPORT
if (systemSettings.temperatureInF) if (systemSettings.temperatureInF)
OLED::drawSymbol(0); OLED::drawSymbol(0);
else else
#endif #endif
OLED::drawSymbol(1); OLED::drawSymbol(1);
} else { } else {
//Otherwise fall back to chars // Otherwise fall back to chars
#ifdef ENABLED_FAHRENHEIT_SUPPORT #ifdef ENABLED_FAHRENHEIT_SUPPORT
if (systemSettings.temperatureInF) if (systemSettings.temperatureInF)
OLED::print(SymbolDegF); OLED::print(SymbolDegF);
else else
#endif #endif
OLED::print(SymbolDegC); OLED::print(SymbolDegC);
} }
} }
@@ -92,7 +93,7 @@ void gui_drawTipTemp(bool symbol) {
static bool checkVoltageForExit() { static bool checkVoltageForExit() {
uint16_t v = getInputVoltageX10(systemSettings.voltageDiv, 0); uint16_t v = getInputVoltageX10(systemSettings.voltageDiv, 0);
//Dont check for first 1.5 seconds while the ADC stabilizes and the DMA fills the buffer // Dont check for first 1.5 seconds while the ADC stabilizes and the DMA fills the buffer
if (xTaskGetTickCount() > 150) { if (xTaskGetTickCount() > 150) {
if ((v < lookupVoltageLevel(systemSettings.cutoutSetting))) { if ((v < lookupVoltageLevel(systemSettings.cutoutSetting))) {
GUIDelay(); GUIDelay();
@@ -126,15 +127,12 @@ static void gui_drawBatteryIcon() {
// User is on a lithium battery // User is on a lithium battery
// we need to calculate which of the 10 levels they are on // we need to calculate which of the 10 levels they are on
uint8_t cellCount = systemSettings.cutoutSetting + 2; uint8_t cellCount = systemSettings.cutoutSetting + 2;
uint32_t cellV = getInputVoltageX10(systemSettings.voltageDiv, 0) uint32_t cellV = getInputVoltageX10(systemSettings.voltageDiv, 0) / cellCount;
/ cellCount;
// Should give us approx cell voltage X10 // Should give us approx cell voltage X10
// Range is 42 -> 33 = 9 steps therefore we will use battery 1-10 // Range is 42 -> 33 = 9 steps therefore we will use battery 1-10
if (cellV < 33) if (cellV < 33) cellV = 33;
cellV = 33;
cellV -= 33; // Should leave us a number of 0-9 cellV -= 33; // Should leave us a number of 0-9
if (cellV > 9) if (cellV > 9) cellV = 9;
cellV = 9;
OLED::drawBattery(cellV + 1); OLED::drawBattery(cellV + 1);
} else } else
OLED::drawSymbol(15); // Draw the DC Logo OLED::drawSymbol(15); // Draw the DC Logo
@@ -169,8 +167,7 @@ static void gui_solderingTempAdjust() {
OLED::clearScreen(); OLED::clearScreen();
OLED::setFont(0); OLED::setFont(0);
ButtonState buttons = getButtonState(); ButtonState buttons = getButtonState();
if (buttons) if (buttons) lastChange = xTaskGetTickCount();
lastChange = xTaskGetTickCount();
switch (buttons) { switch (buttons) {
case BUTTON_NONE: case BUTTON_NONE:
// stay // stay
@@ -180,14 +177,11 @@ static void gui_solderingTempAdjust() {
return; return;
break; break;
case BUTTON_B_LONG: case BUTTON_B_LONG:
if (xTaskGetTickCount() - autoRepeatTimer if (xTaskGetTickCount() - autoRepeatTimer + autoRepeatAcceleration > PRESS_ACCEL_INTERVAL_MAX) {
+ autoRepeatAcceleration> PRESS_ACCEL_INTERVAL_MAX) {
if (systemSettings.ReverseButtonTempChangeEnabled) { if (systemSettings.ReverseButtonTempChangeEnabled) {
systemSettings.SolderingTemp += systemSettings.SolderingTemp += systemSettings.TempChangeLongStep;
systemSettings.TempChangeLongStep;
} else } else
systemSettings.SolderingTemp -= systemSettings.SolderingTemp -= systemSettings.TempChangeLongStep;
systemSettings.TempChangeLongStep;
autoRepeatTimer = xTaskGetTickCount(); autoRepeatTimer = xTaskGetTickCount();
autoRepeatAcceleration += PRESS_ACCEL_STEP; autoRepeatAcceleration += PRESS_ACCEL_STEP;
@@ -195,73 +189,54 @@ static void gui_solderingTempAdjust() {
break; break;
case BUTTON_B_SHORT: case BUTTON_B_SHORT:
if (systemSettings.ReverseButtonTempChangeEnabled) { if (systemSettings.ReverseButtonTempChangeEnabled) {
systemSettings.SolderingTemp += systemSettings.SolderingTemp += systemSettings.TempChangeShortStep;
systemSettings.TempChangeShortStep;
} else } else
systemSettings.SolderingTemp -= systemSettings.SolderingTemp -= systemSettings.TempChangeShortStep;
systemSettings.TempChangeShortStep;
break; break;
case BUTTON_F_LONG: case BUTTON_F_LONG:
if (xTaskGetTickCount() - autoRepeatTimer if (xTaskGetTickCount() - autoRepeatTimer + autoRepeatAcceleration > PRESS_ACCEL_INTERVAL_MAX) {
+ autoRepeatAcceleration> PRESS_ACCEL_INTERVAL_MAX) {
if (systemSettings.ReverseButtonTempChangeEnabled) { if (systemSettings.ReverseButtonTempChangeEnabled) {
systemSettings.SolderingTemp -= systemSettings.SolderingTemp -= systemSettings.TempChangeLongStep;
systemSettings.TempChangeLongStep;
} else } else
systemSettings.SolderingTemp += systemSettings.SolderingTemp += systemSettings.TempChangeLongStep;
systemSettings.TempChangeLongStep;
autoRepeatTimer = xTaskGetTickCount(); autoRepeatTimer = xTaskGetTickCount();
autoRepeatAcceleration += PRESS_ACCEL_STEP; autoRepeatAcceleration += PRESS_ACCEL_STEP;
} }
break; break;
case BUTTON_F_SHORT: case BUTTON_F_SHORT:
if (systemSettings.ReverseButtonTempChangeEnabled) { if (systemSettings.ReverseButtonTempChangeEnabled) {
systemSettings.SolderingTemp -= systemSettings.SolderingTemp -= systemSettings.TempChangeShortStep; // add 10
systemSettings.TempChangeShortStep; // add 10
} else } else
systemSettings.SolderingTemp += systemSettings.SolderingTemp += systemSettings.TempChangeShortStep; // add 10
systemSettings.TempChangeShortStep; // add 10
break; break;
default: default:
break; break;
} }
if ((PRESS_ACCEL_INTERVAL_MAX - autoRepeatAcceleration) if ((PRESS_ACCEL_INTERVAL_MAX - autoRepeatAcceleration) < PRESS_ACCEL_INTERVAL_MIN) {
< PRESS_ACCEL_INTERVAL_MIN) { autoRepeatAcceleration = PRESS_ACCEL_INTERVAL_MAX - PRESS_ACCEL_INTERVAL_MIN;
autoRepeatAcceleration = PRESS_ACCEL_INTERVAL_MAX
- PRESS_ACCEL_INTERVAL_MIN;
} }
// constrain between 10-450 C // constrain between 10-450 C
#ifdef ENABLED_FAHRENHEIT_SUPPORT #ifdef ENABLED_FAHRENHEIT_SUPPORT
if (systemSettings.temperatureInF) { if (systemSettings.temperatureInF) {
if (systemSettings.SolderingTemp > 850) if (systemSettings.SolderingTemp > 850) systemSettings.SolderingTemp = 850;
systemSettings.SolderingTemp = 850; if (systemSettings.SolderingTemp < 60) systemSettings.SolderingTemp = 60;
if (systemSettings.SolderingTemp < 60) } else
systemSettings.SolderingTemp = 60; #endif
}
else
#endif
{ {
if (systemSettings.SolderingTemp > 450) if (systemSettings.SolderingTemp > 450) systemSettings.SolderingTemp = 450;
systemSettings.SolderingTemp = 450; if (systemSettings.SolderingTemp < 10) systemSettings.SolderingTemp = 10;
if (systemSettings.SolderingTemp < 10)
systemSettings.SolderingTemp = 10;
} }
if (xTaskGetTickCount() - lastChange > 200) if (xTaskGetTickCount() - lastChange > 200) 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 MODEL_TS80 #ifdef MODEL_TS80
if (!OLED::getRotation()) { if (!OLED::getRotation()) {
#else #else
if (OLED::getRotation()) { if (OLED::getRotation()) {
#endif #endif
OLED::print( OLED::print(systemSettings.ReverseButtonTempChangeEnabled ? SymbolPlus : SymbolMinus);
systemSettings.ReverseButtonTempChangeEnabled ?
SymbolPlus : SymbolMinus);
} else { } else {
OLED::print( OLED::print(systemSettings.ReverseButtonTempChangeEnabled ? SymbolMinus : SymbolPlus);
systemSettings.ReverseButtonTempChangeEnabled ?
SymbolMinus : SymbolPlus);
} }
OLED::print(SymbolSpace); OLED::print(SymbolSpace);
@@ -270,7 +245,7 @@ static void gui_solderingTempAdjust() {
if (systemSettings.temperatureInF) if (systemSettings.temperatureInF)
OLED::drawSymbol(0); OLED::drawSymbol(0);
else else
#endif #endif
{ {
OLED::drawSymbol(1); OLED::drawSymbol(1);
} }
@@ -280,13 +255,9 @@ static void gui_solderingTempAdjust() {
#else #else
if (OLED::getRotation()) { if (OLED::getRotation()) {
#endif #endif
OLED::print( OLED::print(systemSettings.ReverseButtonTempChangeEnabled ? SymbolMinus : SymbolPlus);
systemSettings.ReverseButtonTempChangeEnabled ?
SymbolMinus : SymbolPlus);
} else { } else {
OLED::print( OLED::print(systemSettings.ReverseButtonTempChangeEnabled ? SymbolPlus : SymbolMinus);
systemSettings.ReverseButtonTempChangeEnabled ?
SymbolPlus : SymbolMinus);
} }
OLED::refresh(); OLED::refresh();
GUIDelay(); GUIDelay();
@@ -298,29 +269,18 @@ static int gui_SolderingSleepingMode(bool stayOff) {
for (;;) { for (;;) {
ButtonState buttons = getButtonState(); ButtonState buttons = getButtonState();
if (buttons) if (buttons) return 0;
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 ((xTaskGetTickCount() > 100)
&& ((accelInit && (xTaskGetTickCount() - lastMovementTime < 100))
|| (xTaskGetTickCount() - lastButtonTime < 100)))
return 0; // user moved or pressed a button, go back to soldering
#ifdef MODEL_TS100 #ifdef MODEL_TS100
if (checkVoltageForExit()) if (checkVoltageForExit()) return 1; // return non-zero on error
return 1; // return non-zero on error
#endif #endif
#ifdef ENABLED_FAHRENHEIT_SUPPORT #ifdef ENABLED_FAHRENHEIT_SUPPORT
if (systemSettings.temperatureInF) { if (systemSettings.temperatureInF) {
currentTempTargetDegC = stayOff ? 0 : TipThermoModel::convertFtoC( currentTempTargetDegC = stayOff ? 0 : TipThermoModel::convertFtoC(min(systemSettings.SleepTemp, systemSettings.SolderingTemp));
min(systemSettings.SleepTemp,
systemSettings.SolderingTemp));
} else } else
#endif #endif
{ {
currentTempTargetDegC = currentTempTargetDegC = stayOff ? 0 : min(systemSettings.SleepTemp, systemSettings.SolderingTemp);
stayOff ?
0 :
min(systemSettings.SleepTemp,
systemSettings.SolderingTemp);
} }
// draw the lcd // draw the lcd
uint16_t tipTemp; uint16_t tipTemp;
@@ -368,8 +328,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 * 100)) {
// shutdown // shutdown
currentTempTargetDegC = 0; currentTempTargetDegC = 0;
return 1; // we want to exit soldering mode 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 * Print seconds or minutes (if > 99 seconds) until sleep
* mode is triggered. * mode is triggered.
*/ */
int lastEventTime = int lastEventTime = lastButtonTime < lastMovementTime ? lastMovementTime : lastButtonTime;
lastButtonTime < lastMovementTime ?
lastMovementTime : lastButtonTime;
int downCount = sleepThres - xTaskGetTickCount() + lastEventTime; int downCount = sleepThres - xTaskGetTickCount() + lastEventTime;
if (downCount > 9900) { if (downCount > 9900) {
OLED::printNumber(downCount / 6000 + 1, 2); OLED::printNumber(downCount / 6000 + 1, 2);
@@ -426,7 +383,6 @@ static void gui_solderingMode(uint8_t jumpToSleep) {
} }
} }
for (;;) { for (;;) {
ButtonState buttons = getButtonState(); ButtonState buttons = getButtonState();
switch (buttons) { switch (buttons) {
case BUTTON_NONE: case BUTTON_NONE:
@@ -442,8 +398,7 @@ static void gui_solderingMode(uint8_t jumpToSleep) {
break; break;
case BUTTON_F_LONG: case BUTTON_F_LONG:
// if boost mode is enabled turn it on // if boost mode is enabled turn it on
if (systemSettings.boostModeEnabled) if (systemSettings.boostModeEnabled) boostModeOn = true;
boostModeOn = true;
break; break;
case BUTTON_F_SHORT: case BUTTON_F_SHORT:
case BUTTON_B_SHORT: { case BUTTON_B_SHORT: {
@@ -452,8 +407,7 @@ static void gui_solderingMode(uint8_t jumpToSleep) {
if (oldTemp != systemSettings.SolderingTemp) { if (oldTemp != systemSettings.SolderingTemp) {
saveSettings(); // only save on change saveSettings(); // only save on change
} }
} } break;
break;
default: default:
break; break;
} }
@@ -461,7 +415,7 @@ static void gui_solderingMode(uint8_t jumpToSleep) {
OLED::setCursor(0, 0); OLED::setCursor(0, 0);
OLED::clearScreen(); OLED::clearScreen();
OLED::setFont(0); OLED::setFont(0);
//Draw in the screen details // Draw in the screen details
if (systemSettings.detailedSoldering) { if (systemSettings.detailedSoldering) {
OLED::setFont(1); OLED::setFont(1);
OLED::print(SolderingAdvancedPowerPrompt); // Power: OLED::print(SolderingAdvancedPowerPrompt); // Power:
@@ -477,7 +431,7 @@ static void gui_solderingMode(uint8_t jumpToSleep) {
OLED::setCursor(0, 8); OLED::setCursor(0, 8);
OLED::print(SleepingTipAdvancedString); OLED::print(SleepingTipAdvancedString);
//OLED::printNumber( // OLED::printNumber(
// TipThermoModel::convertTipRawADCTouV(getTipRawTemp(0)), 5); // Draw the tip temp out finally // TipThermoModel::convertTipRawADCTouV(getTipRawTemp(0)), 5); // Draw the tip temp out finally
gui_drawTipTemp(true); gui_drawTipTemp(true);
@@ -524,8 +478,7 @@ static void gui_solderingMode(uint8_t jumpToSleep) {
if (boostModeOn) { if (boostModeOn) {
#ifdef ENABLED_FAHRENHEIT_SUPPORT #ifdef ENABLED_FAHRENHEIT_SUPPORT
if (systemSettings.temperatureInF) if (systemSettings.temperatureInF)
currentTempTargetDegC = TipThermoModel::convertFtoC( currentTempTargetDegC = TipThermoModel::convertFtoC(systemSettings.BoostTemp);
systemSettings.BoostTemp);
else else
#endif #endif
{ {
@@ -534,8 +487,7 @@ static void gui_solderingMode(uint8_t jumpToSleep) {
} else { } else {
#ifdef ENABLED_FAHRENHEIT_SUPPORT #ifdef ENABLED_FAHRENHEIT_SUPPORT
if (systemSettings.temperatureInF) if (systemSettings.temperatureInF)
currentTempTargetDegC = TipThermoModel::convertFtoC( currentTempTargetDegC = TipThermoModel::convertFtoC(systemSettings.SolderingTemp);
systemSettings.SolderingTemp);
else else
#endif #endif
{ {
@@ -559,13 +511,12 @@ static void gui_solderingMode(uint8_t jumpToSleep) {
#endif #endif
if (systemSettings.sensitivity && systemSettings.SleepTime) if (systemSettings.sensitivity && systemSettings.SleepTime)
if (xTaskGetTickCount() - lastMovementTime > sleepThres if (xTaskGetTickCount() - lastMovementTime > sleepThres && xTaskGetTickCount() - lastButtonTime > sleepThres) {
&& xTaskGetTickCount() - lastButtonTime > sleepThres) {
if (gui_SolderingSleepingMode(false)) { if (gui_SolderingSleepingMode(false)) {
return; // If the function returns non-0 then exit return; // If the function returns non-0 then exit
} }
} }
//slow down ui update rate // slow down ui update rate
GUIDelay(); GUIDelay();
} }
} }
@@ -581,48 +532,47 @@ void showDebugMenu(void) {
OLED::setCursor(0, 8); // second line OLED::setCursor(0, 8); // second line
OLED::print(DebugMenu[screen]); OLED::print(DebugMenu[screen]);
switch (screen) { switch (screen) {
case 0: //Just prints date case 0: // Just prints date
break; break;
case 1: case 1:
//High water mark for GUI // High water mark for GUI
OLED::printNumber(uxTaskGetStackHighWaterMark(GUITaskHandle), 5); OLED::printNumber(uxTaskGetStackHighWaterMark(GUITaskHandle), 5);
break; break;
case 2: case 2:
//High water mark for the Movement task // High water mark for the Movement task
OLED::printNumber(uxTaskGetStackHighWaterMark(MOVTaskHandle), 5); OLED::printNumber(uxTaskGetStackHighWaterMark(MOVTaskHandle), 5);
break; break;
case 3: case 3:
//High water mark for the PID task // High water mark for the PID task
OLED::printNumber(uxTaskGetStackHighWaterMark(PIDTaskHandle), 5); OLED::printNumber(uxTaskGetStackHighWaterMark(PIDTaskHandle), 5);
break; break;
case 4: case 4:
//system up time stamp // system up time stamp
OLED::printNumber(xTaskGetTickCount() / 100, 5); OLED::printNumber(xTaskGetTickCount() / 100, 5);
break; break;
case 5: case 5:
//Movement time stamp // Movement time stamp
OLED::printNumber(lastMovementTime / 100, 5); OLED::printNumber(lastMovementTime / 100, 5);
break; break;
case 6: case 6:
//Raw Tip // Raw Tip
{ {
uint32_t temp = systemSettings.CalibrationOffset; uint32_t temp = systemSettings.CalibrationOffset;
systemSettings.CalibrationOffset = 0; systemSettings.CalibrationOffset = 0;
OLED::printNumber( OLED::printNumber(TipThermoModel::convertTipRawADCTouV(getTipRawTemp(1)), 6);
TipThermoModel::convertTipRawADCTouV(getTipRawTemp(1)), 6);
systemSettings.CalibrationOffset = temp; systemSettings.CalibrationOffset = temp;
} }
break; break;
case 7: case 7:
//Temp in C // Temp in C
OLED::printNumber(TipThermoModel::getTipInC(1), 5); OLED::printNumber(TipThermoModel::getTipInC(1), 5);
break; break;
case 8: case 8:
//Handle Temp // Handle Temp
OLED::printNumber(getHandleTemperature(), 3); OLED::printNumber(getHandleTemperature(), 3);
break; break;
case 9: case 9:
//Voltage input // Voltage input
printVoltage(); printVoltage();
break; break;
case 10: case 10:
@@ -656,23 +606,20 @@ void startGUITask(void const *argument __unused) {
uint32_t ticks = xTaskGetTickCount(); uint32_t ticks = xTaskGetTickCount();
ticks += 400; // 4 seconds from now ticks += 400; // 4 seconds from now
while (xTaskGetTickCount() < ticks) { while (xTaskGetTickCount() < ticks) {
if (showBootLogoIfavailable() == false) if (showBootLogoIfavailable() == false) ticks = xTaskGetTickCount();
ticks = xTaskGetTickCount();
ButtonState buttons = getButtonState(); ButtonState buttons = getButtonState();
if (buttons) if (buttons) ticks = xTaskGetTickCount(); // make timeout now so we will exit
ticks = xTaskGetTickCount(); // make timeout now so we will exit
GUIDelay(); GUIDelay();
} }
if (settingsWereReset) { if (settingsWereReset) {
//Display alert settings were reset // Display alert settings were reset
OLED::clearScreen(); OLED::clearScreen();
OLED::setFont(1); OLED::setFont(1);
OLED::setCursor(0, 0); OLED::setCursor(0, 0);
OLED::print(SettingsResetMessage); OLED::print(SettingsResetMessage);
OLED::refresh(); OLED::refresh();
waitForButtonPressOrTimeout(1000); waitForButtonPressOrTimeout(1000);
} }
if (systemSettings.autoStartMode) { if (systemSettings.autoStartMode) {
@@ -695,8 +642,7 @@ void startGUITask(void const *argument __unused) {
OLED::setDisplayState(OLED::DisplayState::ON); OLED::setDisplayState(OLED::DisplayState::ON);
OLED::setFont(0); OLED::setFont(0);
} }
if (tempWarningState == 2) if (tempWarningState == 2) buttons = BUTTON_F_SHORT;
buttons = BUTTON_F_SHORT;
if (buttons != BUTTON_NONE && buttonLockout) if (buttons != BUTTON_NONE && buttonLockout)
buttons = BUTTON_NONE; buttons = BUTTON_NONE;
else else
@@ -742,11 +688,7 @@ void startGUITask(void const *argument __unused) {
// button presses) in a while. // button presses) in a while.
OLED::setDisplayState(OLED::DisplayState::ON); OLED::setDisplayState(OLED::DisplayState::ON);
if ((tipTemp < 50) && systemSettings.sensitivity if ((tipTemp < 50) && systemSettings.sensitivity && (((xTaskGetTickCount() - lastMovementTime) > MOVEMENT_INACTIVITY_TIME) && ((xTaskGetTickCount() - lastButtonTime) > BUTTON_INACTIVITY_TIME))) {
&& (((xTaskGetTickCount() - lastMovementTime)
> MOVEMENT_INACTIVITY_TIME)
&& ((xTaskGetTickCount() - lastButtonTime)
> BUTTON_INACTIVITY_TIME))) {
OLED::setDisplayState(OLED::DisplayState::OFF); OLED::setDisplayState(OLED::DisplayState::OFF);
} }
@@ -805,9 +747,7 @@ void startGUITask(void const *argument __unused) {
OLED::setCursor(0, 0); OLED::setCursor(0, 0);
} }
// draw in the temp // draw in the temp
if (!(systemSettings.coolingTempBlink if (!(systemSettings.coolingTempBlink && (xTaskGetTickCount() % 25 < 16))) gui_drawTipTemp(false); // draw in the temp
&& (xTaskGetTickCount() % 25 < 16)))
gui_drawTipTemp(false); // draw in the temp
} }
} }
OLED::refresh(); OLED::refresh();

View File

@@ -5,51 +5,36 @@
* Author: Ralim * Author: Ralim
*/ */
#include "main.hpp"
#include "BSP.h" #include "BSP.h"
#include "power.hpp" #include "FreeRTOS.h"
#include "history.hpp" #include "I2C_Wrapper.hpp"
#include "LIS2DH12.hpp"
#include "MMA8652FC.hpp"
#include "QC3.h"
#include "Settings.h"
#include "TipThermoModel.h" #include "TipThermoModel.h"
#include "cmsis_os.h" #include "cmsis_os.h"
#include "FreeRTOS.h" #include "history.hpp"
#include "task.h" #include "main.hpp"
#include "Settings.h" #include "power.hpp"
#include "I2C_Wrapper.hpp"
#include "stdlib.h" #include "stdlib.h"
#include "LIS2DH12.hpp" #include "task.h"
#include <MMA8652FC.hpp>
#include "QC3.h"
#define MOVFilter 8 #define MOVFilter 8
uint8_t accelInit = 0; uint8_t accelInit = 0;
uint32_t lastMovementTime = 0; uint32_t lastMovementTime = 0;
void startMOVTask(void const *argument __unused) { void startMOVTask(void const *argument __unused) {
OLED::setRotation(true); OLED::setRotation(true);
postRToSInit();
#ifdef MODEL_TS80
startQC(systemSettings.voltageDiv);
while (pidTaskNotification == 0)
osDelay(30); // To ensure we return after idealQCVoltage/tip resistance
seekQC((systemSettings.cutoutSetting) ? 120 : 90,
systemSettings.voltageDiv); // this will move the QC output to the preferred voltage to start with
#else
osDelay(250); // wait for accelerometer to stabilize
#endif
OLED::setRotation(systemSettings.OrientationMode & 1); OLED::setRotation(systemSettings.OrientationMode & 1);
lastMovementTime = 0; lastMovementTime = 0;
int16_t datax[MOVFilter] = { 0 }; int16_t datax[MOVFilter] = {0};
int16_t datay[MOVFilter] = { 0 }; int16_t datay[MOVFilter] = {0};
int16_t dataz[MOVFilter] = { 0 }; int16_t dataz[MOVFilter] = {0};
uint8_t currentPointer = 0; uint8_t currentPointer = 0;
int16_t tx = 0, ty = 0, tz = 0; int16_t tx = 0, ty = 0, tz = 0;
int32_t avgx = 0, avgy = 0, avgz = 0; int32_t avgx, avgy, avgz;
if (systemSettings.sensitivity > 9) if (systemSettings.sensitivity > 9) systemSettings.sensitivity = 9;
systemSettings.sensitivity = 9;
#ifdef ACCELDEBUG
uint32_t max = 0;
#endif
Orientation rotation = ORIENTATION_FLAT; Orientation rotation = ORIENTATION_FLAT;
for (;;) { for (;;) {
int32_t threshold = 1500 + (9 * 200); int32_t threshold = 1500 + (9 * 200);
@@ -67,14 +52,14 @@ void startMOVTask(void const *argument __unused) {
OLED::setRotation(rotation == ORIENTATION_LEFT_HAND); // link the data through OLED::setRotation(rotation == ORIENTATION_LEFT_HAND); // link the data through
} }
} }
datax[currentPointer] = (int32_t) tx; datax[currentPointer] = (int32_t)tx;
datay[currentPointer] = (int32_t) ty; datay[currentPointer] = (int32_t)ty;
dataz[currentPointer] = (int32_t) tz; dataz[currentPointer] = (int32_t)tz;
if (!accelInit) { if (!accelInit) {
for (uint8_t i = currentPointer + 1; i < MOVFilter; i++) { for (uint8_t i = currentPointer + 1; i < MOVFilter; i++) {
datax[i] = (int32_t) tx; datax[i] = (int32_t)tx;
datay[i] = (int32_t) ty; datay[i] = (int32_t)ty;
dataz[i] = (int32_t) tz; dataz[i] = (int32_t)tz;
} }
accelInit = 1; accelInit = 1;
} }
@@ -101,9 +86,6 @@ void startMOVTask(void const *argument __unused) {
} }
osDelay(100); // Slow down update rate osDelay(100); // Slow down update rate
#ifdef MODEL_TS80 QC_resync();
seekQC((systemSettings.cutoutSetting) ? 120 : 90,
systemSettings.voltageDiv); // Run the QC seek again if we have drifted too much
#endif
} }
} }