1
0
forked from me/IronOS

Slow temp, add #124

Closes #124
This commit is contained in:
Ben V. Brown
2017-12-12 11:26:00 +11:00
parent 0f4ceb131c
commit b0e20b9e2f
3 changed files with 227 additions and 165 deletions

View File

@@ -392,7 +392,41 @@ const char SettingRightChar = 'P';
const char SettingLeftChar = 'L'; const char SettingLeftChar = 'L';
const char SettingAutoChar = 'A'; const char SettingAutoChar = 'A';
#endif #endif
#ifdef LANG_HUN
const char* SettingsLongNames[16] = {
/*These are all the help text for all the settings.*/
/*No requirements on spacing or length*/
"Áramforrás. Beállítja a lekapcsolási feszültséget. <DC 10V> <S 3.3V cellánként>", //Power Source
"Alvási hőmérséklet <C>", //Sleep Temp
"Elalvási időzítő <Perc/Másodperc>", //Sleep Timeout
"Kikapcsolási időzítő <Minutes>", //Shutdown Time
"Mozgás érzékenység beállítása. <0.Ki 1.kevésbé érzékeny 9.legérzékenyebb>", //Motion Sensitivity
"Hőmérsékleti egység <C=Celsius F=Fahrenheit>", //Temp Unit
"Részletes információ megjelenítése kisebb betűméretben a készenléti képernyőn.", //Detailed Information
"Megjelenítési tájolás <A. Automatikus L. Balkezes R. Jobbkezes>", //Orientation
"Elülső gombbal lépjen boost módba, 450C forrasztás közben", //Boost enable
"Hőmérséklet \"boost\" módban", //Boost Temp
"Bekapcsolás után automatikusan lépjen forrasztás módba. T=Forrasztás, S=Alvó mód,F=Ki", //Auto start
"Villogjon a hőmérséklet hűlés közben, amíg a hegy forró.", //Cooling Blink
"Hegy hőmérsékletének kalibrálása", //Calibrate Tip
"Beállítások alaphelyzetbe állítása", //Reset Settings
"A bemeneti feszültség kalibrálása. Röviden megnyomva állítsa be, hosszan nyomja meg a kilépéshez.", //VIN Cal
"Részletes információk megjelenítése forrasztás közben", //ADV SLD
};
const char* SettingsCalibrationWarning = "Folytatás előtt győződj meg róla, hogy a hegy szobahőmérsékletű!";
const char* UVLOWarningString = "LOW VOLT"; //Fixed width 8 chars
const char* SleepingSimpleString = "Zzzz"; // Must be <= 4 chars
const char* SleepingAdvancedString = "Alvás..."; // <=17 chars
const char* WarningSimpleString = "HOT!"; //Must be <= 4 chars
const char* WarningAdvancedString = "FIGYELEM! FORRÓ HEGY!";
const char SettingTrueChar = 'T';
const char SettingFalseChar = 'F';
const char SettingRightChar = 'R';
const char SettingLeftChar = 'L';
const char SettingAutoChar = 'A';
#endif
//Currently the settings names are not translated //Currently the settings names are not translated
const char* SettingsShortNames[16] = { /**/ const char* SettingsShortNames[16] = { /**/
"PWRSC ", // Power Source (DC or batt) "PWRSC ", // Power Source (DC or batt)

View File

@@ -58,7 +58,7 @@ uint16_t getTipInstantTemperature() {
uint16_t getTipRawTemp(uint8_t instant) { uint16_t getTipRawTemp(uint8_t instant) {
#define filterDepth1 1 #define filterDepth1 1
/*Pre filter used before PID*/ /*Pre filter used before PID*/
#define filterDepth2 32 #define filterDepth2 64
/*Post filter used for UI display*/ /*Post filter used for UI display*/
static uint16_t filterLayer1[filterDepth1]; static uint16_t filterLayer1[filterDepth1];
static uint16_t filterLayer2[filterDepth2]; static uint16_t filterLayer2[filterDepth2];

View File

@@ -103,8 +103,12 @@ ButtonState getButtonState() {
static uint32_t previousStateChange = 0; static uint32_t previousStateChange = 0;
const uint16_t timeout = 400; const uint16_t timeout = 400;
uint8_t currentState; uint8_t currentState;
currentState = (HAL_GPIO_ReadPin(KEY_A_GPIO_Port, KEY_A_Pin) == GPIO_PIN_RESET ? 1 : 0) << 0; currentState = (
currentState |= (HAL_GPIO_ReadPin(KEY_B_GPIO_Port, KEY_B_Pin) == GPIO_PIN_RESET ? 1 : 0) << 1; HAL_GPIO_ReadPin(KEY_A_GPIO_Port, KEY_A_Pin) == GPIO_PIN_RESET ?
1 : 0) << 0;
currentState |= (
HAL_GPIO_ReadPin(KEY_B_GPIO_Port, KEY_B_Pin) == GPIO_PIN_RESET ?
1 : 0) << 1;
if (currentState) if (currentState)
lastButtonTime = HAL_GetTick(); lastButtonTime = HAL_GetTick();
@@ -194,9 +198,11 @@ static bool checkVoltageForExit() {
lcd.print("Undervoltage"); lcd.print("Undervoltage");
lcd.setCursor(0, 8); lcd.setCursor(0, 8);
lcd.print("Input V: "); lcd.print("Input V: ");
lcd.printNumber(getInputVoltageX10(systemSettings.voltageDiv) / 10, 2); lcd.printNumber(getInputVoltageX10(systemSettings.voltageDiv) / 10,
2);
lcd.drawChar('.'); lcd.drawChar('.');
lcd.printNumber(getInputVoltageX10(systemSettings.voltageDiv) % 10, 1); lcd.printNumber(getInputVoltageX10(systemSettings.voltageDiv) % 10,
1);
lcd.print("V"); lcd.print("V");
} else { } else {
@@ -216,7 +222,8 @@ 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;
uint16_t cellV = getInputVoltageX10(systemSettings.voltageDiv) / cellCount; uint16_t cellV = getInputVoltageX10(systemSettings.voltageDiv)
/ 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)
@@ -307,7 +314,8 @@ static void gui_settingsMenu() {
settingsResetRequest = false; settingsResetRequest = false;
bool earlyExit = false; bool earlyExit = false;
uint32_t descriptionStart = 0; uint32_t descriptionStart = 0;
while ((settingsMenu[currentScreen].description != NULL) && earlyExit == false) { while ((settingsMenu[currentScreen].description != NULL)
&& earlyExit == false) {
lcd.setFont(0); lcd.setFont(0);
lcd.clearScreen(); lcd.clearScreen();
lcd.setCursor(0, 0); lcd.setCursor(0, 0);
@@ -318,11 +326,13 @@ static void gui_settingsMenu() {
} else { } else {
//Draw description //Draw description
//draw string starting from descriptionOffset //draw string starting from descriptionOffset
int16_t maxOffset = strlen(settingsMenu[currentScreen].description) + 5; int16_t maxOffset = strlen(settingsMenu[currentScreen].description)
+ 5;
if (descriptionStart == 0) if (descriptionStart == 0)
descriptionStart = HAL_GetTick(); descriptionStart = HAL_GetTick();
int16_t descriptionOffset = (((HAL_GetTick() - descriptionStart) / 150) % maxOffset); int16_t descriptionOffset = (((HAL_GetTick() - descriptionStart)
/ 150) % maxOffset);
//^ Rolling offset based on time //^ Rolling offset based on time
lcd.setCursor(12 * (7 - descriptionOffset), 0); lcd.setCursor(12 * (7 - descriptionOffset), 0);
lcd.print(settingsMenu[currentScreen].description); lcd.print(settingsMenu[currentScreen].description);
@@ -439,17 +449,20 @@ static int gui_SolderingSleepingMode() {
ButtonState buttons = getButtonState(); ButtonState buttons = getButtonState();
if (buttons) if (buttons)
return 0; return 0;
if ((HAL_GetTick() - lastMovementTime < 1000) || (HAL_GetTick() - lastButtonTime < 1000)) if ((HAL_GetTick() - lastMovementTime < 1000)
|| (HAL_GetTick() - 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
if (checkVoltageForExit()) if (checkVoltageForExit())
return 1; //return non-zero on error return 1; //return non-zero on error
if (systemSettings.temperatureInF) if (systemSettings.temperatureInF)
currentlyActiveTemperatureTarget = ftoTipMeasurement( currentlyActiveTemperatureTarget = ftoTipMeasurement(
min(systemSettings.SleepTemp, systemSettings.SolderingTemp)); min(systemSettings.SleepTemp,
systemSettings.SolderingTemp));
else else
currentlyActiveTemperatureTarget = ctoTipMeasurement( currentlyActiveTemperatureTarget = ctoTipMeasurement(
min(systemSettings.SleepTemp, systemSettings.SolderingTemp)); min(systemSettings.SleepTemp,
systemSettings.SolderingTemp));
//draw the lcd //draw the lcd
uint16_t tipTemp; uint16_t tipTemp;
if (systemSettings.temperatureInF) if (systemSettings.temperatureInF)
@@ -471,9 +484,11 @@ static int gui_SolderingSleepingMode() {
lcd.print("C"); lcd.print("C");
lcd.print(" "); lcd.print(" ");
lcd.printNumber(getInputVoltageX10(systemSettings.voltageDiv) / 10, 2); lcd.printNumber(getInputVoltageX10(systemSettings.voltageDiv) / 10,
2);
lcd.drawChar('.'); lcd.drawChar('.');
lcd.printNumber(getInputVoltageX10(systemSettings.voltageDiv) % 10, 1); lcd.printNumber(getInputVoltageX10(systemSettings.voltageDiv) % 10,
1);
lcd.drawChar('V'); lcd.drawChar('V');
} else { } else {
lcd.setFont(0); lcd.setFont(0);
@@ -616,15 +631,19 @@ static void gui_solderingMode() {
//Update the setpoints for the temperature //Update the setpoints for the temperature
if (boostModeOn) { if (boostModeOn) {
if (systemSettings.temperatureInF) if (systemSettings.temperatureInF)
currentlyActiveTemperatureTarget = ftoTipMeasurement(systemSettings.BoostTemp); currentlyActiveTemperatureTarget = ftoTipMeasurement(
systemSettings.BoostTemp);
else else
currentlyActiveTemperatureTarget = ctoTipMeasurement(systemSettings.BoostTemp); currentlyActiveTemperatureTarget = ctoTipMeasurement(
systemSettings.BoostTemp);
} else { } else {
if (systemSettings.temperatureInF) if (systemSettings.temperatureInF)
currentlyActiveTemperatureTarget = ftoTipMeasurement(systemSettings.SolderingTemp); currentlyActiveTemperatureTarget = ftoTipMeasurement(
systemSettings.SolderingTemp);
else else
currentlyActiveTemperatureTarget = ctoTipMeasurement(systemSettings.SolderingTemp); currentlyActiveTemperatureTarget = ctoTipMeasurement(
systemSettings.SolderingTemp);
} }
//Undervoltage test //Undervoltage test
@@ -634,7 +653,8 @@ static void gui_solderingMode() {
lcd.refresh(); lcd.refresh();
if (systemSettings.sensitivity) if (systemSettings.sensitivity)
if (HAL_GetTick() - lastMovementTime > sleepThres && HAL_GetTick() - lastButtonTime > sleepThres) { if (HAL_GetTick() - lastMovementTime > sleepThres
&& HAL_GetTick() - lastButtonTime > sleepThres) {
if (gui_SolderingSleepingMode()) { if (gui_SolderingSleepingMode()) {
return; //If the function returns non-0 then exit return; //If the function returns non-0 then exit
} }
@@ -669,23 +689,25 @@ void startGUITask(void const * argument) {
uint8_t animationStep = 0; uint8_t animationStep = 0;
uint8_t tempWarningState = 0; uint8_t tempWarningState = 0;
HAL_IWDG_Refresh(&hiwdg);
if (showBootLogoIfavailable())
waitForButtonPressOrTimeout(2000);
HAL_IWDG_Refresh(&hiwdg);
if (systemSettings.autoStartMode) { if (systemSettings.autoStartMode) {
//jump directly to the autostart mode //jump directly to the autostart mode
if (systemSettings.autoStartMode == 1) if (systemSettings.autoStartMode == 1)
gui_solderingMode(); gui_solderingMode();
} }
HAL_IWDG_Refresh(&hiwdg);
if (showBootLogoIfavailable())
waitForButtonPressOrTimeout(1000);
HAL_IWDG_Refresh(&hiwdg);
#if ACCELDEBUG #if ACCELDEBUG
for (;;) { for (;;) {
HAL_IWDG_Refresh(&hiwdg); HAL_IWDG_Refresh(&hiwdg);
osDelay(100); osDelay(100);
} }
#endif
//^ Kept here for a way to block this thread //^ Kept here for a way to block this thread
#endif
for (;;) { for (;;) {
ButtonState buttons = getButtonState(); ButtonState buttons = getButtonState();
if (tempWarningState == 2) if (tempWarningState == 2)
@@ -734,9 +756,11 @@ void startGUITask(void const * argument) {
currentlyActiveTemperatureTarget = 0; //ensure tip is off currentlyActiveTemperatureTarget = 0; //ensure tip is off
if (systemSettings.sensitivity) { if (systemSettings.sensitivity) {
if ((HAL_GetTick() - lastMovementTime) > 60000 && (HAL_GetTick() - lastButtonTime) > 60000) if ((HAL_GetTick() - lastMovementTime) > 60000
&& (HAL_GetTick() - lastButtonTime) > 60000)
lcd.displayOnOff(false); // turn lcd off when no movement lcd.displayOnOff(false); // turn lcd off when no movement
else if (HAL_GetTick() - lastMovementTime < 1000 || HAL_GetTick() - lastButtonTime < 1000) /*Use short time for test, and prevent lots of I2C writes for no need*/ else if (HAL_GetTick() - lastMovementTime < 1000
|| HAL_GetTick() - lastButtonTime < 1000) /*Use short time for test, and prevent lots of I2C writes for no need*/
lcd.displayOnOff(true); //turn lcd back on lcd.displayOnOff(true); //turn lcd back on
} }
@@ -773,9 +797,11 @@ void startGUITask(void const * argument) {
} }
lcd.setCursor(0, 8); lcd.setCursor(0, 8);
lcd.print("Input V: "); lcd.print("Input V: ");
lcd.printNumber(getInputVoltageX10(systemSettings.voltageDiv) / 10, 2); lcd.printNumber(getInputVoltageX10(systemSettings.voltageDiv) / 10,
2);
lcd.drawChar('.'); lcd.drawChar('.');
lcd.printNumber(getInputVoltageX10(systemSettings.voltageDiv) % 10, 1); lcd.printNumber(getInputVoltageX10(systemSettings.voltageDiv) % 10,
1);
lcd.print("V"); lcd.print("V");
} else { } else {
@@ -971,7 +997,8 @@ void startRotationTask(void const * argument) {
} }
for (;;) { for (;;) {
if ( xSemaphoreTake( rotationChangedSemaphore, portMAX_DELAY ) == pdTRUE if ( xSemaphoreTake( rotationChangedSemaphore, portMAX_DELAY ) == pdTRUE
|| (HAL_GPIO_ReadPin(INT_Orientation_GPIO_Port, INT_Orientation_Pin) == GPIO_PIN_RESET)) { || (HAL_GPIO_ReadPin(INT_Orientation_GPIO_Port,
INT_Orientation_Pin) == GPIO_PIN_RESET)) {
// a rotation event has occured // a rotation event has occured
bool rotation = accel.getOrientation(); bool rotation = accel.getOrientation();
if (systemSettings.OrientationMode == 2) if (systemSettings.OrientationMode == 2)
@@ -986,7 +1013,8 @@ void startRotationTask(void const * argument) {
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin) { void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin) {
static signed long xHigherPriorityTaskWoken; static signed long xHigherPriorityTaskWoken;
if (GPIO_Pin == INT_Orientation_Pin) { if (GPIO_Pin == INT_Orientation_Pin) {
xSemaphoreGiveFromISR(rotationChangedSemaphore, &xHigherPriorityTaskWoken); xSemaphoreGiveFromISR(rotationChangedSemaphore,
&xHigherPriorityTaskWoken);
} else if (GPIO_Pin == INT_Movement_Pin) { } else if (GPIO_Pin == INT_Movement_Pin) {
//New data is available for reading from the unit //New data is available for reading from the unit
//xSemaphoreGiveFromISR(accelDataAvailableSemaphore, &xHigherPriorityTaskWoken); //xSemaphoreGiveFromISR(accelDataAvailableSemaphore, &xHigherPriorityTaskWoken);