Add tip compensation support
This commit is contained in:
@@ -6,7 +6,9 @@
|
||||
*/
|
||||
|
||||
#include "gui.h"
|
||||
|
||||
#include "string.h"
|
||||
#include "hardware.h"
|
||||
#include "cmsis_os.h"
|
||||
static void settings_setInputVRange(void);
|
||||
static void settings_displayInputVRange(void);
|
||||
static void settings_setSleepTemp(void);
|
||||
@@ -31,10 +33,10 @@ static void settings_setCoolingBlinkEnabled(void);
|
||||
static void settings_displayCoolingBlinkEnabled(void);
|
||||
static void settings_setResetSettings(void);
|
||||
static void settings_displayResetSettings(void);
|
||||
static void settings_setCalibrate(void);
|
||||
static void settings_displayCalibrate(void);
|
||||
|
||||
|
||||
|
||||
bool settingsResetRequest=false;
|
||||
bool settingsResetRequest = false;
|
||||
const menuitem settingsMenu[] = { /*Struct used for all settings options in the settings menu*/
|
||||
{ (const char*) SettingsLongNames[0], { settings_setInputVRange }, { settings_displayInputVRange } },/*Voltage input*/
|
||||
{ (const char*) SettingsLongNames[1], { settings_setSleepTemp }, { settings_displaySleepTemp } }, /*Sleep Temp*/
|
||||
@@ -47,12 +49,11 @@ const menuitem settingsMenu[] = { /*Struct used for all settings options in the
|
||||
{ (const char*) SettingsLongNames[8], { settings_setBoostTemp }, { settings_displayBoostTemp } }, /**/
|
||||
{ (const char*) SettingsLongNames[9], { settings_setAutomaticStartMode }, { settings_displayAutomaticStartMode } },/**/
|
||||
{ (const char*) SettingsLongNames[10], { settings_setCoolingBlinkEnabled }, { settings_displayCoolingBlinkEnabled } }, /**/
|
||||
{ (const char*) SettingsLongNames[11], { settings_setResetSettings }, { settings_displayResetSettings } }, /**/
|
||||
{ (const char*) SettingsLongNames[11], { settings_setCalibrate }, { settings_displayCalibrate } }, /**/
|
||||
{ (const char*) SettingsLongNames[12], { settings_setResetSettings }, { settings_displayResetSettings } }, /**/
|
||||
{ NULL, { NULL }, { NULL } } //end of menu marker. DO NOT REMOVE
|
||||
};
|
||||
|
||||
|
||||
|
||||
static void settings_setInputVRange(void) {
|
||||
systemSettings.cutoutSetting = (systemSettings.cutoutSetting + 1) % 5;
|
||||
}
|
||||
@@ -188,9 +189,64 @@ static void settings_setResetSettings(void) {
|
||||
settingsResetRequest = !settingsResetRequest;
|
||||
}
|
||||
static void settings_displayResetSettings(void) {
|
||||
lcd.print(SettingsShortNames[11]);
|
||||
lcd.print(SettingsShortNames[12]);
|
||||
if (settingsResetRequest)
|
||||
lcd.drawChar('T');
|
||||
else
|
||||
lcd.drawChar('F');
|
||||
}
|
||||
|
||||
static void settings_setCalibrate(void) {
|
||||
//Calibrate the offset
|
||||
//We split off here to confirm with the user
|
||||
uint8_t maxOffset = strlen(SettingsCalibrationWarning);
|
||||
uint32_t descriptionStart = HAL_GetTick();
|
||||
lcd.setFont(0);
|
||||
for (;;) {
|
||||
|
||||
int16_t descriptionOffset = ((HAL_GetTick() - descriptionStart) / 150) % maxOffset;
|
||||
lcd.setCursor(12 * (7 - descriptionOffset), 0);
|
||||
lcd.print(SettingsCalibrationWarning);
|
||||
ButtonState buttons = getButtonState();
|
||||
|
||||
switch (buttons) {
|
||||
case BUTTON_F_SHORT: {
|
||||
//User confirmed
|
||||
//So we now perform the actual calculation
|
||||
lcd.clearScreen();
|
||||
lcd.print(".....");
|
||||
lcd.refresh();
|
||||
setCalibrationOffset(0); //turn off the current offset
|
||||
for (uint8_t i = 0; i < 20; i++) {
|
||||
getTipRawTemp(1); //cycle through the filter a fair bit to ensure were stable.
|
||||
osDelay(20);
|
||||
}
|
||||
osDelay(100);
|
||||
uint16_t rawTempC = tipMeasurementToC(getTipRawTemp(0));
|
||||
//We now measure the current reported tip temperature
|
||||
uint16_t handleTempC = getHandleTemperature() / 10;
|
||||
//We now have an error between these that we want to store as the offset
|
||||
rawTempC = rawTempC - handleTempC;
|
||||
systemSettings.CalibrationOffset = rawTempC;
|
||||
setCalibrationOffset(rawTempC); //store the error
|
||||
osDelay(100);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case BUTTON_BOTH:
|
||||
case BUTTON_B_SHORT:
|
||||
case BUTTON_F_LONG:
|
||||
case BUTTON_B_LONG:
|
||||
return;
|
||||
break;
|
||||
case BUTTON_NONE:
|
||||
break;
|
||||
}
|
||||
lcd.refresh();
|
||||
osDelay(50);
|
||||
}
|
||||
|
||||
}
|
||||
static void settings_displayCalibrate(void) {
|
||||
lcd.print(SettingsShortNames[11]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user