mirror of
https://github.com/Ralim/IronOS.git
synced 2025-02-26 07:53:55 +00:00
Adding adc2 & new temperature calibration proceedures. [WiP] (#361)
* Add rough calls to ADC2 [untested] * Using dual ADC injected modes * Start both ADCs * Move some IRQ's to ram exec * Stabilize PID a bit more * Add in ideas for tip type selection * Add tiptype formula / settings struct * Add function ids to the settings menu * Rough tip selection * Rough out new cal routine for simple tips * Hardware test is fairly close for first pass * Add Simple calibration case [UNTESTED] This adds the calibration option that uses boiling water to the calibration menu. This is untested, and may need gain adjustments before use. * Simple Cal Roughly working * Rough out advanced cal
This commit is contained in:
@@ -1085,7 +1085,7 @@ __weak void HAL_TIM_PWM_MspDeInit(TIM_HandleTypeDef *htim)
|
||||
* @arg TIM_CHANNEL_4: TIM Channel 4 selected
|
||||
* @retval HAL status
|
||||
*/
|
||||
HAL_StatusTypeDef HAL_TIM_PWM_Start(TIM_HandleTypeDef *htim, uint32_t Channel)
|
||||
HAL_StatusTypeDef __attribute__ ((long_call, section (".data.ramfuncs"))) HAL_TIM_PWM_Start(TIM_HandleTypeDef *htim, uint32_t Channel)
|
||||
{
|
||||
/* Check the parameters */
|
||||
assert_param(IS_TIM_CCX_INSTANCE(htim->Instance, Channel));
|
||||
@@ -1117,7 +1117,7 @@ HAL_StatusTypeDef HAL_TIM_PWM_Start(TIM_HandleTypeDef *htim, uint32_t Channel)
|
||||
* @arg TIM_CHANNEL_4: TIM Channel 4 selected
|
||||
* @retval HAL status
|
||||
*/
|
||||
HAL_StatusTypeDef HAL_TIM_PWM_Stop(TIM_HandleTypeDef *htim, uint32_t Channel)
|
||||
HAL_StatusTypeDef __attribute__ ((long_call, section (".data.ramfuncs"))) HAL_TIM_PWM_Stop(TIM_HandleTypeDef *htim, uint32_t Channel)
|
||||
{
|
||||
/* Check the parameters */
|
||||
assert_param(IS_TIM_CCX_INSTANCE(htim->Instance, Channel));
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#define SETTINGS_H_
|
||||
#include <stdint.h>
|
||||
#include "stm32f1xx_hal.h"
|
||||
#define SETTINGSVERSION 0x14 /*Change this if you change the struct below to prevent people getting out of sync*/
|
||||
#define SETTINGSVERSION 0x15 /*Change this if you change the struct below to prevent people getting out of sync*/
|
||||
|
||||
/*
|
||||
* This struct must be a multiple of 2 bytes as it is saved / restored from flash in uint16_t chunks
|
||||
@@ -38,6 +38,8 @@ typedef struct {
|
||||
uint8_t PID_I; //PID I Term
|
||||
uint8_t PID_D; //PID D Term
|
||||
uint8_t version; //Used to track if a reset is needed on firmware upgrade
|
||||
uint8_t customTipGain; // Tip gain value if custom tuned, or 0 if using a tipType param
|
||||
uint8_t tipType;
|
||||
uint32_t padding; //This is here for in case we are not an even divisor so that nothing gets cut off
|
||||
} systemSettingsType;
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ extern "C" {
|
||||
#include "stm32f1xx_hal.h"
|
||||
|
||||
extern ADC_HandleTypeDef hadc1;
|
||||
extern ADC_HandleTypeDef hadc2;
|
||||
extern DMA_HandleTypeDef hdma_adc1;
|
||||
|
||||
extern DMA_HandleTypeDef hdma_i2c1_rx;
|
||||
|
||||
@@ -17,8 +17,8 @@ enum ShortNameType {
|
||||
* use SettingsShortNames as SettingsShortNames[16][1].. second column undefined
|
||||
*/
|
||||
extern const enum ShortNameType SettingsShortNameType;
|
||||
extern const char* SettingsShortNames[17][2];
|
||||
extern const char* SettingsDescriptions[17];
|
||||
extern const char* SettingsShortNames[20][2];
|
||||
extern const char* SettingsDescriptions[20];
|
||||
extern const char* SettingsMenuEntries[4];
|
||||
extern const char* SettingsMenuEntriesDescriptions[4];
|
||||
|
||||
|
||||
@@ -14,11 +14,21 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
enum Orientation {
|
||||
ORIENTATION_LEFT_HAND = 0,
|
||||
ORIENTATION_RIGHT_HAND = 1,
|
||||
ORIENTATION_FLAT = 3
|
||||
ORIENTATION_LEFT_HAND = 0, ORIENTATION_RIGHT_HAND = 1, ORIENTATION_FLAT = 3
|
||||
};
|
||||
/*
|
||||
* Keep in a uint8_t range for the ID's
|
||||
*/
|
||||
enum TipType {
|
||||
TS_B2 = 0,
|
||||
TS_D24 = 1,
|
||||
TS_BC2 = 2,
|
||||
TS_C1 = 3,
|
||||
Tip_MiniWare=4,
|
||||
HAKKO_BC2=4,
|
||||
Tip_Hakko=5,
|
||||
Tip_Custom=5,
|
||||
};
|
||||
|
||||
#define KEY_B_Pin GPIO_PIN_6
|
||||
#define KEY_B_GPIO_Port GPIOA
|
||||
#define TMP36_INPUT_Pin GPIO_PIN_7
|
||||
@@ -54,6 +64,7 @@ uint16_t ftoTipMeasurement(uint16_t temp);
|
||||
uint16_t tipMeasurementToF(uint16_t raw);
|
||||
|
||||
void setCalibrationOffset(int16_t offSet);
|
||||
void setTipType(enum TipType tipType, uint8_t manualCalGain);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include <MMA8652FC.hpp>
|
||||
#include "Setup.h"
|
||||
#include "OLED.hpp"
|
||||
|
||||
extern uint16_t currentlyActiveTemperatureTarget;
|
||||
extern OLED lcd;
|
||||
extern MMA8652FC accel;
|
||||
extern uint8_t PCBVersion;
|
||||
@@ -25,6 +25,8 @@ enum ButtonState {
|
||||
|
||||
ButtonState getButtonState();
|
||||
void waitForButtonPressOrTimeout(uint32_t timeout);
|
||||
void waitForButtonPress();
|
||||
void GUIDelay();
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
@@ -36,7 +38,8 @@ void HAL_I2C_MasterTxCpltCallback(I2C_HandleTypeDef *hi2c);
|
||||
void HAL_I2C_MasterRxCpltCallback(I2C_HandleTypeDef *hi2c);
|
||||
void HAL_I2C_MemTxCpltCallback(I2C_HandleTypeDef *hi2c);
|
||||
void HAL_I2C_MemRxCpltCallback(I2C_HandleTypeDef *hi2c);
|
||||
void vApplicationStackOverflowHook( xTaskHandle *pxTask, signed portCHAR *pcTaskName );
|
||||
void vApplicationStackOverflowHook( xTaskHandle *pxTask,
|
||||
signed portCHAR *pcTaskName);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#include "FRToSI2C.hpp"
|
||||
|
||||
void FRToSI2C::CpltCallback() {
|
||||
void __attribute__ ((long_call, section (".data.ramfuncs"))) FRToSI2C::CpltCallback() {
|
||||
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
|
||||
i2c->State = HAL_I2C_STATE_READY;//Force state reset
|
||||
if (I2CSemaphore) {
|
||||
|
||||
@@ -42,17 +42,8 @@ uint8_t OLED_Setup_Array[] = { /**/
|
||||
};
|
||||
//Setup based on the SSD1307 and modified for the SSD1306
|
||||
|
||||
const uint8_t REFRESH_COMMANDS[17] = {
|
||||
0x80, 0xAF,
|
||||
0x80, 0x21,
|
||||
0x80, 0x20,
|
||||
0x80, 0x7F,
|
||||
0x80, 0xC0,
|
||||
0x80, 0x22,
|
||||
0x80, 0x00,
|
||||
0x80, 0x01,
|
||||
0x40
|
||||
};
|
||||
const uint8_t REFRESH_COMMANDS[17] = { 0x80, 0xAF, 0x80, 0x21, 0x80, 0x20, 0x80,
|
||||
0x7F, 0x80, 0xC0, 0x80, 0x22, 0x80, 0x00, 0x80, 0x01, 0x40 };
|
||||
|
||||
OLED::OLED(FRToSI2C* i2cHandle) {
|
||||
i2c = i2cHandle;
|
||||
@@ -70,11 +61,12 @@ OLED::OLED(FRToSI2C* i2cHandle) {
|
||||
void OLED::initialize() {
|
||||
memcpy(&screenBuffer[0], &REFRESH_COMMANDS[0], sizeof(REFRESH_COMMANDS));
|
||||
|
||||
HAL_Delay(5);
|
||||
HAL_Delay(50);
|
||||
HAL_GPIO_WritePin(OLED_RESET_GPIO_Port, OLED_RESET_Pin, GPIO_PIN_SET);
|
||||
HAL_Delay(10);
|
||||
HAL_Delay(50);
|
||||
//Send the setup settings
|
||||
i2c->Transmit( DEVICEADDR_OLED, (uint8_t*) OLED_Setup_Array, sizeof(OLED_Setup_Array));
|
||||
i2c->Transmit( DEVICEADDR_OLED, (uint8_t*) OLED_Setup_Array,
|
||||
sizeof(OLED_Setup_Array));
|
||||
displayOnOff(true);
|
||||
}
|
||||
|
||||
@@ -145,19 +137,20 @@ void OLED::setRotation(bool leftHanded) {
|
||||
|
||||
//send command struct again with changes
|
||||
if (leftHanded) {
|
||||
OLED_Setup_Array[11] = 0xC8; //c1?
|
||||
OLED_Setup_Array[19] = 0xA1;
|
||||
OLED_Setup_Array[11] = 0xC8; //c1?
|
||||
OLED_Setup_Array[19] = 0xA1;
|
||||
} else {
|
||||
OLED_Setup_Array[11] = 0xC0;
|
||||
OLED_Setup_Array[19] = 0xA0;
|
||||
}
|
||||
i2c->Transmit( DEVICEADDR_OLED, (uint8_t*) OLED_Setup_Array, sizeof(OLED_Setup_Array));
|
||||
inLeftHandedMode = leftHanded;
|
||||
OLED_Setup_Array[11] = 0xC0;
|
||||
OLED_Setup_Array[19] = 0xA0;
|
||||
}
|
||||
i2c->Transmit( DEVICEADDR_OLED, (uint8_t*) OLED_Setup_Array,
|
||||
sizeof(OLED_Setup_Array));
|
||||
inLeftHandedMode = leftHanded;
|
||||
|
||||
screenBuffer[5] = inLeftHandedMode ? 0 : 32; //display is shifted by 32 in left handed mode as driver ram is 128 wide
|
||||
screenBuffer[7] = inLeftHandedMode ? 95 : 0x7F; //End address of the ram segment we are writing to (96 wide)
|
||||
screenBuffer[9] = inLeftHandedMode ? 0xC8 : 0xC0;
|
||||
}
|
||||
}
|
||||
|
||||
//print a string to the current cursor location
|
||||
void OLED::print(const char* str) {
|
||||
@@ -190,9 +183,13 @@ void OLED::setFont(uint8_t fontNumber) {
|
||||
|
||||
//maximum places is 5
|
||||
void OLED::printNumber(uint16_t number, uint8_t places) {
|
||||
char buffer[6] = { 0 };
|
||||
|
||||
if (places == 5) {
|
||||
char buffer[7] = { 0 };
|
||||
|
||||
if (places >= 5) {
|
||||
buffer[5] = '0' + number % 10;
|
||||
number /= 10;
|
||||
}
|
||||
if (places > 4) {
|
||||
buffer[4] = '0' + number % 10;
|
||||
number /= 10;
|
||||
}
|
||||
@@ -291,7 +288,7 @@ void OLED::fillArea(int16_t x, int8_t y, uint8_t wide, uint8_t height,
|
||||
}
|
||||
|
||||
void OLED::drawFilledRect(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1,
|
||||
bool clear) {
|
||||
bool clear) {
|
||||
//Draw this in 3 sections
|
||||
//This is basically a N wide version of vertical line
|
||||
|
||||
|
||||
@@ -22,7 +22,8 @@ void saveSettings() {
|
||||
pEraseInit.PageAddress = FLASH_ADDR;
|
||||
uint32_t failingAddress = 0;
|
||||
HAL_IWDG_Refresh(&hiwdg);
|
||||
__HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_EOP | FLASH_FLAG_WRPERR | FLASH_FLAG_PGERR | FLASH_FLAG_BSY);
|
||||
__HAL_FLASH_CLEAR_FLAG(
|
||||
FLASH_FLAG_EOP | FLASH_FLAG_WRPERR | FLASH_FLAG_PGERR | FLASH_FLAG_BSY);
|
||||
HAL_FLASH_Unlock();
|
||||
HAL_Delay(10);
|
||||
HAL_IWDG_Refresh(&hiwdg);
|
||||
@@ -35,7 +36,8 @@ void saveSettings() {
|
||||
|
||||
for (uint8_t i = 0; i < (sizeof(systemSettingsType) / 2); i++) {
|
||||
HAL_IWDG_Refresh(&hiwdg);
|
||||
HAL_FLASH_Program(FLASH_TYPEPROGRAM_HALFWORD, FLASH_ADDR + (i * 2), data[i]);
|
||||
HAL_FLASH_Program(FLASH_TYPEPROGRAM_HALFWORD, FLASH_ADDR + (i * 2),
|
||||
data[i]);
|
||||
}
|
||||
HAL_FLASH_Lock();
|
||||
|
||||
@@ -71,29 +73,30 @@ uint8_t lookupVoltageLevel(uint8_t level) {
|
||||
return (level * 33) + (33 * 2);
|
||||
}
|
||||
void resetSettings() {
|
||||
memset((void*)&systemSettings,0,sizeof(systemSettingsType));
|
||||
systemSettings.SleepTemp = 150; //Temperature the iron sleeps at - default 150.0 C
|
||||
systemSettings.SleepTime = 6; //How many seconds/minutes we wait until going to sleep - default 1 min
|
||||
memset((void*) &systemSettings, 0, sizeof(systemSettingsType));
|
||||
systemSettings.SleepTemp = 150; //Temperature the iron sleeps at - default 150.0 C
|
||||
systemSettings.SleepTime = 6; //How many seconds/minutes we wait until going to sleep - default 1 min
|
||||
systemSettings.SolderingTemp = 320; //Default soldering temp is 320.0 C
|
||||
systemSettings.cutoutSetting = 0; //default to no cut-off voltage
|
||||
systemSettings.version = SETTINGSVERSION; //Store the version number to allow for easier upgrades
|
||||
systemSettings.version = SETTINGSVERSION;//Store the version number to allow for easier upgrades
|
||||
systemSettings.detailedSoldering = 0; // Detailed soldering screen
|
||||
systemSettings.detailedIDLE=0; // Detailed idle screen (off for first time users)
|
||||
systemSettings.detailedIDLE = 0;// Detailed idle screen (off for first time users)
|
||||
systemSettings.OrientationMode = 2; //Default to automatic
|
||||
systemSettings.sensitivity = 7; //Default high sensitivity
|
||||
systemSettings.voltageDiv = 117; //Default divider from schematic
|
||||
systemSettings.ShutdownTime = 10; //How many minutes until the unit turns itself off
|
||||
systemSettings.boostModeEnabled = 1; //Default to safe, with no boost mode
|
||||
systemSettings.ShutdownTime = 10;//How many minutes until the unit turns itself off
|
||||
systemSettings.boostModeEnabled = 1;//Default to safe, with no boost mode
|
||||
systemSettings.BoostTemp = 420; //default to 400C
|
||||
systemSettings.autoStartMode = 0; //Auto start off for safety
|
||||
systemSettings.coolingTempBlink = 0; //Blink the temperature on the cooling screen when its > 50C
|
||||
systemSettings.CalibrationOffset = 10; //This appears to be quite close for both of my tips, in both of my handles
|
||||
systemSettings.coolingTempBlink = 0;//Blink the temperature on the cooling screen when its > 50C
|
||||
systemSettings.temperatureInF = 0; //default to 0
|
||||
systemSettings.descriptionScrollSpeed=0;//default to slow
|
||||
systemSettings.PID_P =42;
|
||||
systemSettings.PID_I =50;
|
||||
systemSettings.PID_D =15;
|
||||
|
||||
systemSettings.descriptionScrollSpeed = 0; //default to slow
|
||||
systemSettings.PID_P = 42;
|
||||
systemSettings.PID_I = 50;
|
||||
systemSettings.PID_D = 15;
|
||||
systemSettings.CalibrationOffset = 2780; // the adc offset
|
||||
systemSettings.customTipGain = 0; // The tip type is either default or a custom gain
|
||||
systemSettings.tipType = TS_B2;
|
||||
saveSettings();
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
*/
|
||||
#include "Setup.h"
|
||||
ADC_HandleTypeDef hadc1;
|
||||
ADC_HandleTypeDef hadc2;
|
||||
DMA_HandleTypeDef hdma_adc1;
|
||||
|
||||
I2C_HandleTypeDef hi2c1;
|
||||
@@ -27,6 +28,7 @@ static void MX_TIM3_Init(void);
|
||||
static void MX_TIM2_Init(void);
|
||||
static void MX_DMA_Init(void);
|
||||
static void MX_GPIO_Init(void);
|
||||
static void MX_ADC2_Init(void);
|
||||
|
||||
void Setup_HAL() {
|
||||
SystemClock_Config();
|
||||
@@ -34,12 +36,16 @@ void Setup_HAL() {
|
||||
MX_DMA_Init();
|
||||
MX_I2C1_Init();
|
||||
MX_ADC1_Init();
|
||||
MX_ADC2_Init();
|
||||
MX_TIM3_Init();
|
||||
MX_TIM2_Init();
|
||||
MX_IWDG_Init();
|
||||
|
||||
HAL_ADC_Start_DMA(&hadc1, (uint32_t*) ADCReadings, 64); //start DMA of normal readings
|
||||
HAL_ADC_Start(&hadc2);
|
||||
HAL_ADCEx_MultiModeStart_DMA(&hadc1, (uint32_t*) ADCReadings, 64); //start DMA of normal readings
|
||||
HAL_ADCEx_InjectedStart(&hadc1); //enable injected readings
|
||||
HAL_ADCEx_InjectedStart(&hadc2); //enable injected readings
|
||||
|
||||
|
||||
}
|
||||
|
||||
//channel 0 -> temperature sensor, 1-> VIN
|
||||
@@ -99,6 +105,7 @@ void SystemClock_Config(void) {
|
||||
|
||||
/* ADC1 init function */
|
||||
static void MX_ADC1_Init(void) {
|
||||
ADC_MultiModeTypeDef multimode;
|
||||
|
||||
ADC_ChannelConfTypeDef sConfig;
|
||||
ADC_InjectionConfTypeDef sConfigInjected;
|
||||
@@ -113,6 +120,11 @@ static void MX_ADC1_Init(void) {
|
||||
hadc1.Init.NbrOfConversion = 2;
|
||||
HAL_ADC_Init(&hadc1);
|
||||
|
||||
/**Configure the ADC multi-mode
|
||||
*/
|
||||
multimode.Mode = ADC_DUALMODE_REGSIMULT_INJECSIMULT;
|
||||
HAL_ADCEx_MultiModeConfigChannel(&hadc1, &multimode);
|
||||
|
||||
/**Configure Regular Channel
|
||||
*/
|
||||
sConfig.Channel = ADC_CHANNEL_7;
|
||||
@@ -159,6 +171,59 @@ static void MX_ADC1_Init(void) {
|
||||
;
|
||||
}
|
||||
|
||||
/* ADC2 init function */
|
||||
static void MX_ADC2_Init(void) {
|
||||
|
||||
ADC_ChannelConfTypeDef sConfig;
|
||||
ADC_InjectionConfTypeDef sConfigInjected;
|
||||
|
||||
/**Common config
|
||||
*/
|
||||
hadc2.Instance = ADC2;
|
||||
hadc2.Init.ScanConvMode = ADC_SCAN_ENABLE;
|
||||
hadc2.Init.ContinuousConvMode = ENABLE;
|
||||
hadc2.Init.DiscontinuousConvMode = DISABLE;
|
||||
hadc2.Init.ExternalTrigConv = ADC_SOFTWARE_START;
|
||||
hadc2.Init.DataAlign = ADC_DATAALIGN_RIGHT;
|
||||
hadc2.Init.NbrOfConversion = 2;
|
||||
HAL_ADC_Init(&hadc2);
|
||||
|
||||
/**Configure Regular Channel
|
||||
*/
|
||||
sConfig.Channel = ADC_CHANNEL_8;
|
||||
sConfig.Rank = ADC_REGULAR_RANK_1;
|
||||
sConfig.SamplingTime = ADC_SAMPLETIME_239CYCLES_5;
|
||||
HAL_ADC_ConfigChannel(&hadc2, &sConfig);
|
||||
sConfig.Channel = ADC_CHANNEL_8;
|
||||
sConfig.Rank = ADC_REGULAR_RANK_2;
|
||||
sConfig.SamplingTime = ADC_SAMPLETIME_239CYCLES_5;
|
||||
HAL_ADC_ConfigChannel(&hadc2, &sConfig);
|
||||
|
||||
/**Configure Injected Channel
|
||||
*/
|
||||
sConfigInjected.InjectedChannel = ADC_CHANNEL_8;
|
||||
sConfigInjected.InjectedRank = ADC_INJECTED_RANK_1;
|
||||
sConfigInjected.InjectedNbrOfConversion = 4;
|
||||
sConfigInjected.InjectedSamplingTime = ADC_SAMPLETIME_7CYCLES_5;
|
||||
sConfigInjected.ExternalTrigInjecConv = ADC_EXTERNALTRIGINJECCONV_T2_CC1;
|
||||
sConfigInjected.AutoInjectedConv = DISABLE;
|
||||
sConfigInjected.InjectedDiscontinuousConvMode = DISABLE;
|
||||
sConfigInjected.InjectedOffset = 0;
|
||||
HAL_ADCEx_InjectedConfigChannel(&hadc2, &sConfigInjected);
|
||||
sConfigInjected.InjectedSamplingTime = ADC_SAMPLETIME_1CYCLE_5;
|
||||
|
||||
sConfigInjected.InjectedRank = ADC_INJECTED_RANK_2;
|
||||
HAL_ADCEx_InjectedConfigChannel(&hadc2, &sConfigInjected);
|
||||
sConfigInjected.InjectedRank = ADC_INJECTED_RANK_3;
|
||||
HAL_ADCEx_InjectedConfigChannel(&hadc2, &sConfigInjected);
|
||||
sConfigInjected.InjectedRank = ADC_INJECTED_RANK_4;
|
||||
HAL_ADCEx_InjectedConfigChannel(&hadc2, &sConfigInjected);
|
||||
|
||||
// Run ADC internal calibration
|
||||
while (HAL_ADCEx_Calibration_Start(&hadc2) != HAL_OK)
|
||||
;
|
||||
|
||||
}
|
||||
/* I2C1 init function */
|
||||
static void MX_I2C1_Init(void) {
|
||||
|
||||
@@ -370,6 +435,7 @@ static void MX_GPIO_Init(void) {
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||
HAL_GPIO_Init(OLED_RESET_GPIO_Port, &GPIO_InitStruct);
|
||||
HAL_GPIO_WritePin(OLED_RESET_GPIO_Port, OLED_RESET_Pin, GPIO_PIN_RESET);
|
||||
|
||||
/* Configure GPIO pins : INT_Orientation_Pin INT_Movement_Pin */
|
||||
/* Not used anymore*/
|
||||
|
||||
@@ -8,54 +8,11 @@
|
||||
#ifndef LANG
|
||||
#define LANG_EN
|
||||
#endif
|
||||
// TEMPLATES for short names - choose one and use it as base for your
|
||||
// translation:
|
||||
|
||||
//const enum ShortNameType SettingsShortNameType = SHORT_NAME_SINGLE_LINE;
|
||||
//const char* SettingsShortNames[17][2] = {
|
||||
// /* (<= 5) Power source (DC or batt) */ {"PWRSC"},
|
||||
// /* (<= 4) Sleep temperature */ {"STMP"},
|
||||
// /* (<= 4) Sleep timeout */ {"STME"},
|
||||
// /* (<= 5) Shutdown timeout */ {"SHTME"},
|
||||
// /* (<= 6) Motion sensitivity level */ {"MSENSE"},
|
||||
// /* (<= 6) Temperature in F and C */ {"TMPUNT"},
|
||||
// /* (<= 6) Advanced idle display mode enabled */ {"ADVIDL"},
|
||||
// /* (<= 6) Display rotation mode */ {"DSPROT"},
|
||||
// /* (<= 6) Boost enabled */ {"BOOST"},
|
||||
// /* (<= 4) Boost temperature */ {"BTMP"},
|
||||
// /* (<= 6) Automatic start mode */ {"ASTART"},
|
||||
// /* (<= 6) Cooldown blink */ {"CLBLNK"},
|
||||
// /* (<= 8) Temperature calibration enter menu */ {"TMP CAL?"},
|
||||
// /* (<= 8) Settings reset command */ {"RESET?"},
|
||||
// /* (<= 8) Calibrate input voltage */ {"CAL VIN?"},
|
||||
// /* (<= 6) Advanced soldering screen enabled */ {"ADVSLD"},
|
||||
// /* (<= 6) Message Scroll Speed */ {"DESCSP"},
|
||||
//};
|
||||
|
||||
//const enum ShortNameType SettingsShortNameType = SHORT_NAME_DOUBLE_LINE;
|
||||
//const char* SettingsShortNames[17][2] = {
|
||||
// /* (<= 11) Power source (DC or batt) */ {"Power", "source"},
|
||||
// /* (<= 9) Sleep temperature */ {"Sleep", "temp"},
|
||||
// /* (<= 9) Sleep timeout */ {"Sleep", "timeout"},
|
||||
// /* (<= 11) Shutdown timeout */ {"Shutdown", "timeout"},
|
||||
// /* (<= 13) Motion sensitivity level */ {"Motion", "sensitivity"},
|
||||
// /* (<= 13) Temperature in F and C */ {"Temperature", "units"},
|
||||
// /* (<= 13) Advanced idle display mode enabled */ {"Detailed", "idle screen"},
|
||||
// /* (<= 13) Display rotation mode */ {"Display", "orientation"},
|
||||
// /* (<= 13) Boost enabled */ {"Boost mode", "enabled"},
|
||||
// /* (<= 9) Boost temperature */ {"Boost", "temp"},
|
||||
// /* (<= 13) Automatic start mode */ {"Auto", "start"},
|
||||
// /* (<= 13) Cooldown blink */ {"Cooldown", "blink"},
|
||||
// /* (<= 16) Temperature calibration enter menu */ {"Calibrate", "temperature?"},
|
||||
// /* (<= 16) Settings reset command */ {"Factory", "Reset?"},
|
||||
// /* (<= 16) Calibrate input voltage */ {"Calibrate", "input voltage?"},
|
||||
// /* (<= 13) Advanced soldering screen enabled */ {"Detailed", "solder screen"},
|
||||
// /* (<= 11) Display Help Text Scroll Speed */ {"Description","Scroll Speed"},
|
||||
//};
|
||||
// TEMPLATE: Please use the English translations
|
||||
|
||||
#ifdef LANG_EN
|
||||
|
||||
const char* SettingsDescriptions[17] = {
|
||||
const char* SettingsDescriptions[20] = {
|
||||
// These are all the help text for all the settings.
|
||||
// No requirements on spacing or length.
|
||||
/* Power source (DC or batt) */"Power source. Sets cutoff voltage. <DC 10V> <S 3.3V per cell>",
|
||||
@@ -75,8 +32,12 @@ const char* SettingsDescriptions[17] = {
|
||||
/* Calibrate input voltage */"VIN Calibration. Buttons adjust, long press to exit",
|
||||
/* Advanced soldering screen enabled */"Display detailed information while soldering",
|
||||
/* Description Scroll Speed */"Speed this text scrolls past at",
|
||||
/* Tip Model */"Tip Model selection ",
|
||||
/* Simple Calibration Mode */"Simple Calibration using Hot water",
|
||||
/* Advanced Calibration Mode */"Advanced calibration using thermocouple on the tip"
|
||||
|
||||
#ifdef PIDSETTINGS
|
||||
|
||||
#ifdef PIDSETTINGS
|
||||
|
||||
"PID P term. Inverse values! This acts as a divisor. So Larger numbers == typically smaller in other systems",
|
||||
"PID I term. Inverse values! This acts as a divisor. So Larger numbers == typically smaller in other systems",
|
||||
@@ -112,7 +73,7 @@ const char SettingFastChar = 'F';
|
||||
const char SettingSlowChar = 'S';
|
||||
|
||||
const enum ShortNameType SettingsShortNameType = SHORT_NAME_DOUBLE_LINE;
|
||||
const char* SettingsShortNames[17][2] = {
|
||||
const char* SettingsShortNames[20][2] = {
|
||||
/* (<= 11) Power source (DC or batt) */{"Power", "source"},
|
||||
/* (<= 9) Sleep temperature */{"Sleep", "temp"},
|
||||
/* (<= 9) Sleep timeout */{"Sleep", "timeout"},
|
||||
@@ -130,6 +91,9 @@ const char* SettingsShortNames[17][2] = {
|
||||
/* (<= 16) Calibrate input voltage */{"Calibrate", "input voltage?"},
|
||||
/* (<= 13) Advanced soldering screen enabled */{"Detailed", "solder screen"},
|
||||
/* (<= 11) Display Help Text Scroll Speed */{"Description","Scroll Speed"},
|
||||
/* (<= 08) The Tip model being selected */{"Tip","Model"},
|
||||
/* (<= 16) Simple Calibration */{"Simple","Calibration"},
|
||||
/* (<= 16) Advanced Calibration */{"Advanced","Calibration"},
|
||||
#ifdef PIDSETTINGS
|
||||
|
||||
{ "PID","P"},
|
||||
@@ -139,6 +103,7 @@ const char* SettingsShortNames[17][2] = {
|
||||
|
||||
};
|
||||
|
||||
|
||||
// SettingsMenuEntries lengths <= 13 per line (\n starts second line)
|
||||
const char* SettingsMenuEntries[4] = {
|
||||
/* Soldering Menu */"Soldering\nSettings",
|
||||
@@ -203,7 +168,7 @@ const char SettingFastChar = 'F';
|
||||
const char SettingSlowChar = 'S';
|
||||
|
||||
const enum ShortNameType SettingsShortNameType = SHORT_NAME_DOUBLE_LINE;
|
||||
const char* SettingsShortNames[17][2] = {
|
||||
const char* SettingsShortNames[20][2] = {
|
||||
/* (<= 11) Power source (DC or batt) */{"Източник", "захранване"},
|
||||
/* (<= 9) Sleep temperature */{"Темп.", "сън"},
|
||||
/* (<= 9) Sleep timeout */{"Време", "сън"},
|
||||
@@ -292,7 +257,7 @@ const char SettingFastChar = '+';
|
||||
const char SettingSlowChar = '-';
|
||||
|
||||
const enum ShortNameType SettingsShortNameType = SHORT_NAME_DOUBLE_LINE;
|
||||
const char* SettingsShortNames[17][2] = {
|
||||
const char* SettingsShortNames[20][2] = {
|
||||
/* (<= 11) Power source (DC or batt) */{"Источник","питания"}, //8,7
|
||||
/* (<= 9) Sleep temperature */{"Темпер.","сна"}, //7,3
|
||||
/* (<= 9) Sleep timeout */{"Таймаут","сна"}, //7,3
|
||||
@@ -457,7 +422,7 @@ const char SettingFastChar = 'N';//'F';
|
||||
const char SettingSlowChar = 'H';//'S';
|
||||
|
||||
const enum ShortNameType SettingsShortNameType = SHORT_NAME_DOUBLE_LINE;
|
||||
const char* SettingsShortNames[17][2] = {
|
||||
const char* SettingsShortNames[20][2] = {
|
||||
/* (<= 11) Power source (DC or batt) */{"Virtalähde", "DC"},
|
||||
/* (<= 9) Sleep temperature */{"Lepotilan", "lämpötila"},
|
||||
/* (<= 9) Sleep timeout */{"Lepotilan", "viive"},
|
||||
@@ -544,7 +509,7 @@ const char SettingFastChar = 'V';
|
||||
const char SettingSlowChar = 'L';
|
||||
|
||||
const enum ShortNameType SettingsShortNameType = SHORT_NAME_DOUBLE_LINE;
|
||||
const char* SettingsShortNames[17][2] = {
|
||||
const char* SettingsShortNames[20][2] = {
|
||||
/* (<= 11) Power source (DC or batt) */{"Sorgente", "alimentaz"},
|
||||
/* (<= 9) Sleep temperature */{"Temp", "standby"},
|
||||
/* (<= 9) Sleep timeout */{"Timer", "standby"},
|
||||
@@ -628,7 +593,7 @@ const char SettingFastChar = 'R';
|
||||
const char SettingSlowChar = 'L';
|
||||
|
||||
const enum ShortNameType SettingsShortNameType = SHORT_NAME_DOUBLE_LINE;
|
||||
const char* SettingsShortNames[17][2] = {
|
||||
const char* SettingsShortNames[20][2] = {
|
||||
/* (<= 11) Power source (DC or batt) */{"Source", "d'alim"},
|
||||
/* (<= 9) Sleep temperature */{"Temp.", "veille"},
|
||||
/* (<= 9) Sleep timeout */{"Délai", "veille"},
|
||||
@@ -718,7 +683,7 @@ const char SettingFastChar = 'F';
|
||||
const char SettingSlowChar = 'S';
|
||||
|
||||
const enum ShortNameType SettingsShortNameType = SHORT_NAME_DOUBLE_LINE;
|
||||
const char* SettingsShortNames[17][2] = {
|
||||
const char* SettingsShortNames[20][2] = {
|
||||
/* (<= 11) Power source (DC or batt) */{"Spannungs-", "quelle"},
|
||||
/* (<= 9) Sleep temperature */{"Ruhetemp-", "eratur"},
|
||||
/* (<= 9) Sleep timeout */{"Ruhever-", "zögerung"},
|
||||
@@ -799,7 +764,7 @@ const char SettingFastChar = 'F';
|
||||
const char SettingSlowChar = 'S';
|
||||
|
||||
const enum ShortNameType SettingsShortNameType = SHORT_NAME_SINGLE_LINE;
|
||||
const char* SettingsShortNames[17][2] = {
|
||||
const char* SettingsShortNames[20][2] = {
|
||||
/* (<= 5) Power source (DC or batt) */{"PWRSC"},
|
||||
/* (<= 4) Sleep temperature */{"STMP"},
|
||||
/* (<= 4) Sleep timeout */{"STME"},
|
||||
@@ -880,7 +845,7 @@ const char SettingFastChar = 'F';
|
||||
const char SettingSlowChar = 'S';
|
||||
|
||||
const enum ShortNameType SettingsShortNameType = SHORT_NAME_SINGLE_LINE;
|
||||
const char* SettingsShortNames[17][2] = {
|
||||
const char* SettingsShortNames[20][2] = {
|
||||
/* (<= 5) Power source (DC or batt) */{"PWRSC"},
|
||||
/* (<= 4) Sleep temperature */{"STMP"},
|
||||
/* (<= 4) Sleep timeout */{"STME"},
|
||||
@@ -961,7 +926,7 @@ const char SettingFastChar = 'B';
|
||||
const char SettingSlowChar = 'S';
|
||||
|
||||
const enum ShortNameType SettingsShortNameType = SHORT_NAME_DOUBLE_LINE;
|
||||
const char* SettingsShortNames[17][2] = {
|
||||
const char* SettingsShortNames[20][2] = {
|
||||
/* (<= 11) Power source (DC or batt) */{"Izvor", "napajanja"},
|
||||
/* (<= 9) Sleep temperature */{"Temp", "spavanja"},
|
||||
/* (<= 9) Sleep timeout */{"Vrijeme", "spavanja"},
|
||||
@@ -1040,7 +1005,7 @@ const char SettingFastChar = 'R';
|
||||
const char SettingSlowChar = 'P';
|
||||
|
||||
const enum ShortNameType SettingsShortNameType = SHORT_NAME_DOUBLE_LINE;
|
||||
const char* SettingsShortNames[17][2] = {
|
||||
const char* SettingsShortNames[20][2] = {
|
||||
/* (<= 11) Power source (DC or batt) */{"Zdroj", "napájení"},
|
||||
/* (<= 9) Sleep temperature */{"Teplota v", "r. spánku"},
|
||||
/* (<= 9) Sleep timeout */{"Čas do", "r. spánku"},
|
||||
@@ -1125,7 +1090,7 @@ const char SettingFastChar = 'F';
|
||||
const char SettingSlowChar = 'S';
|
||||
|
||||
const enum ShortNameType SettingsShortNameType = SHORT_NAME_SINGLE_LINE;
|
||||
const char* SettingsShortNames[17][2] = {
|
||||
const char* SettingsShortNames[20][2] = {
|
||||
/* (<= 5) Power source (DC or batt) */{"PWRSC"},
|
||||
/* (<= 4) Sleep temperature */{"STMP"},
|
||||
/* (<= 4) Sleep timeout */{"STME"},
|
||||
@@ -1206,7 +1171,7 @@ const char SettingFastChar = 'F';
|
||||
const char SettingSlowChar = 'S';
|
||||
|
||||
const enum ShortNameType SettingsShortNameType = SHORT_NAME_SINGLE_LINE;
|
||||
const char* SettingsShortNames[17][2] = {
|
||||
const char* SettingsShortNames[20][2] = {
|
||||
/* (<= 5) Power source (DC or batt) */{"PWRSC"},
|
||||
/* (<= 4) Sleep temperature */{"STMP"},
|
||||
/* (<= 4) Sleep timeout */{"STME"},
|
||||
@@ -1287,7 +1252,7 @@ const char SettingFastChar = 'F';
|
||||
const char SettingSlowChar = 'S';
|
||||
|
||||
const enum ShortNameType SettingsShortNameType = SHORT_NAME_SINGLE_LINE;
|
||||
const char* SettingsShortNames[17][2] = {
|
||||
const char* SettingsShortNames[20][2] = {
|
||||
/* (<= 5) Power source (DC or batt) */{"PWRSC"},
|
||||
/* (<= 4) Sleep temperature */{"STMP"},
|
||||
/* (<= 4) Sleep timeout */{"STME"},
|
||||
@@ -1467,7 +1432,7 @@ const char SettingFastChar = 'T';
|
||||
const char SettingSlowChar = 'N';
|
||||
|
||||
const enum ShortNameType SettingsShortNameType = SHORT_NAME_DOUBLE_LINE;
|
||||
const char* SettingsShortNames[17][2] = {
|
||||
const char* SettingsShortNames[20][2] = {
|
||||
/* (<= 11) Power source (DC or batt) */{"Maitinimo", "šaltinis"},
|
||||
/* (<= 9) Sleep temperature */{"Miego", "temperat."},
|
||||
/* (<= 9) Sleep timeout */{"Miego", "laikas"},
|
||||
@@ -1549,7 +1514,7 @@ const char SettingFastChar = '+';
|
||||
const char SettingSlowChar = '-';
|
||||
|
||||
const enum ShortNameType SettingsShortNameType = SHORT_NAME_DOUBLE_LINE;
|
||||
const char* SettingsShortNames[17][2] = {
|
||||
const char* SettingsShortNames[20][2] = {
|
||||
/* (<= 11) Power source (DC or batt) */{"Джерело","живлення"}, //7,8
|
||||
/* (<= 9) Sleep temperature */{"Темпер.","сну"}, //7,3
|
||||
/* (<= 9) Sleep timeout */{"Таймаут","сну"}, //7,3
|
||||
@@ -1633,7 +1598,7 @@ const char SettingFastChar = 'F';
|
||||
const char SettingSlowChar = 'S';
|
||||
|
||||
const enum ShortNameType SettingsShortNameType = SHORT_NAME_DOUBLE_LINE;
|
||||
const char* SettingsShortNames[17][2] = {
|
||||
const char* SettingsShortNames[20][2] = {
|
||||
/* (<= 11) Power source (DC or batt) */{"Spannings-", "bron"},
|
||||
/* (<= 9) Sleep temperature */{"Slaap", "temp"},
|
||||
/* (<= 9) Sleep timeout */{"Slaap", "time-out"},
|
||||
@@ -1719,7 +1684,7 @@ const char SettingFastChar = 'S';
|
||||
const char SettingSlowChar = 'L';
|
||||
|
||||
const enum ShortNameType SettingsShortNameType = SHORT_NAME_DOUBLE_LINE;
|
||||
const char* SettingsShortNames[17][2] = {
|
||||
const char* SettingsShortNames[20][2] = {
|
||||
/* (<= 11) Power source (DC or batt) */{"Ström-", "källa"},
|
||||
/* (<= 9) Sleep temperature */{"Vilo-", "temp"},
|
||||
/* (<= 9) Sleep timeout */{"Vilo-", "timeout"},
|
||||
@@ -1806,7 +1771,7 @@ const char SettingFastChar = 'B';
|
||||
const char SettingSlowChar = 'S';
|
||||
|
||||
const enum ShortNameType SettingsShortNameType = SHORT_NAME_DOUBLE_LINE;
|
||||
const char* SettingsShortNames[17][2] =
|
||||
const char* SettingsShortNames[20][2] =
|
||||
{
|
||||
/* (<= 11) Power source (DC or batt) */{ "Izvor", "napajanja" },
|
||||
/* (<= 9) Sleep temperature */{ "Temp", "spavanja" },
|
||||
@@ -1884,7 +1849,7 @@ const char SettingAutoChar = 'A';
|
||||
const char SettingFastChar = 'H';
|
||||
const char SettingSlowChar = 'L';
|
||||
const enum ShortNameType SettingsShortNameType = SHORT_NAME_SINGLE_LINE;
|
||||
const char* SettingsShortNames[17][2] = {
|
||||
const char* SettingsShortNames[20][2] = {
|
||||
/* (<= 5) Power source (DC or batt) */{"Kilde"},
|
||||
/* (<= 4) Sleep temperature */{"DTmp"},
|
||||
/* (<= 4) Sleep timeout */{"DTid"},
|
||||
|
||||
@@ -52,11 +52,19 @@ static void settings_setCoolingBlinkEnabled(void);
|
||||
static void settings_displayCoolingBlinkEnabled(void);
|
||||
static void settings_setResetSettings(void);
|
||||
static void settings_displayResetSettings(void);
|
||||
static void settings_setTipModel(void);
|
||||
static void settings_displayTipModel(void);
|
||||
static void settings_setCalibrate(void);
|
||||
static void settings_displayCalibrate(void);
|
||||
static void settings_setCalibrateVIN(void);
|
||||
static void settings_displayCalibrateVIN(void);
|
||||
|
||||
//Calibration Menu
|
||||
static void calibration_displaySimpleCal(void); // Hot water cal
|
||||
static void calibration_enterSimpleCal(void);
|
||||
static void calibration_displayAdvancedCal(void); // two point cal
|
||||
static void calibration_enterAdvancedCal(void);
|
||||
|
||||
//Menu functions
|
||||
static void settings_displaySolderingMenu(void);
|
||||
static void settings_enterSolderingMenu(void);
|
||||
@@ -185,6 +193,8 @@ const menuitem advancedMenu[] = {
|
||||
settings_displayAdvancedSolderingScreens } }, /* Advanced soldering screen*/
|
||||
{ (const char*) SettingsDescriptions[13], { settings_setResetSettings }, {
|
||||
settings_displayResetSettings } }, /*Resets settings*/
|
||||
{ (const char*) SettingsDescriptions[17], { settings_setTipModel }, {
|
||||
settings_displayTipModel } }, /*Select tip Model */
|
||||
{ (const char*) SettingsDescriptions[12], { settings_setCalibrate }, {
|
||||
settings_displayCalibrate } }, /*Calibrate tip*/
|
||||
{ (const char*) SettingsDescriptions[14], { settings_setCalibrateVIN }, {
|
||||
@@ -201,6 +211,13 @@ const menuitem advancedMenu[] = {
|
||||
{ NULL, { NULL }, { NULL } } // end of menu marker. DO NOT REMOVE
|
||||
};
|
||||
|
||||
const menuitem calibrationMenu[] { { (const char*) SettingsDescriptions[6], {
|
||||
calibration_enterSimpleCal }, { calibration_displaySimpleCal } },
|
||||
/* Simple Cal*/
|
||||
{ (const char*) SettingsDescriptions[6], { calibration_enterAdvancedCal }, {
|
||||
calibration_displayAdvancedCal } }, /* Advanced Cal */
|
||||
{ NULL, { NULL }, { NULL } } };
|
||||
|
||||
static void printShortDescriptionSingleLine(uint32_t shortDescIndex) {
|
||||
lcd.setFont(0);
|
||||
lcd.setCharCursor(0, 0);
|
||||
@@ -569,30 +586,214 @@ static void settings_displayResetSettings(void) {
|
||||
printShortDescription(13, 7);
|
||||
}
|
||||
|
||||
static void settings_setCalibrate(void) {
|
||||
if (userConfirmation(SettingsCalibrationWarning)) {
|
||||
//User confirmed
|
||||
//So we now perform the actual calculation
|
||||
static void settings_setTipModel(void) {
|
||||
systemSettings.tipType++;
|
||||
systemSettings.tipType %= (Tip_Custom + 1); //Wrap after custom
|
||||
|
||||
}
|
||||
static void settings_displayTipModel(void) {
|
||||
printShortDescription(17, 4);
|
||||
//Print in small text the tip model
|
||||
lcd.setFont(1);
|
||||
//set the cursor
|
||||
//Print the mfg
|
||||
lcd.setCursor(40, 0);
|
||||
if (systemSettings.tipType < Tip_MiniWare) {
|
||||
lcd.print("TS100");
|
||||
} else if (systemSettings.tipType < Tip_Hakko) {
|
||||
lcd.print("HAKKO");
|
||||
} else if (systemSettings.tipType == Tip_Custom) {
|
||||
lcd.print("User");
|
||||
}
|
||||
lcd.setCursor(40, 8);
|
||||
switch ((enum TipType) systemSettings.tipType) {
|
||||
case TS_B2:
|
||||
lcd.print(" B2 ");
|
||||
break;
|
||||
case TS_D24:
|
||||
lcd.print(" D24 ");
|
||||
break;
|
||||
case TS_BC2:
|
||||
lcd.print(" BC2 ");
|
||||
break;
|
||||
case TS_C1:
|
||||
lcd.print(" C1 ");
|
||||
break;
|
||||
case HAKKO_BC2:
|
||||
lcd.print(" BC2 ");
|
||||
break;
|
||||
case Tip_Custom:
|
||||
lcd.print("Tuned");
|
||||
break;
|
||||
default:
|
||||
lcd.print("????");
|
||||
break;
|
||||
}
|
||||
}
|
||||
static void calibration_displaySimpleCal(void) {
|
||||
printShortDescription(18, 5);
|
||||
}
|
||||
static void dotDelay() {
|
||||
for (uint8_t i = 0; i < 20; i++) {
|
||||
getTipRawTemp(1); //cycle through the filter a fair bit to ensure we're stable.
|
||||
lcd.clearScreen();
|
||||
lcd.setCursor(0, 0);
|
||||
lcd.print(".....");
|
||||
for (uint8_t x = 0; x < i / 4; x++)
|
||||
lcd.print(".");
|
||||
lcd.refresh();
|
||||
osDelay(50);
|
||||
}
|
||||
}
|
||||
static void setTipOffset() {
|
||||
setCalibrationOffset(0); //turn off the current offset
|
||||
dotDelay();
|
||||
|
||||
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 we're stable.
|
||||
osDelay(20);
|
||||
//If the thermocouple at the end of the tip, and the handle are at equalibrium, then the output should be zero, as there is no temperature differential.
|
||||
|
||||
int32_t offset = 0;
|
||||
for (uint8_t i = 0; i < 15; i++) {
|
||||
offset += getTipRawTemp(1); //cycle through the filter a fair bit to ensure we're stable.
|
||||
|
||||
lcd.clearScreen();
|
||||
lcd.setCursor(0, 0);
|
||||
|
||||
for (uint8_t x = 0; x < i / 4; x++)
|
||||
lcd.print(".");
|
||||
lcd.refresh();
|
||||
osDelay(200);
|
||||
}
|
||||
systemSettings.CalibrationOffset = offset / 15;
|
||||
setCalibrationOffset(systemSettings.CalibrationOffset); //store the error
|
||||
osDelay(100);
|
||||
}
|
||||
static void calibration_enterSimpleCal(void) {
|
||||
//User has entered into the simple cal routine
|
||||
if (userConfirmation(SettingsCalibrationWarning)) {
|
||||
//User has confirmed their handle is at ambient
|
||||
//So take the offset measurement
|
||||
setTipOffset();
|
||||
//Next we want the user to put the tip into 100C water so we can calculate their tip's gain
|
||||
//Gain is the m term from rise/run plot of raw readings vs (tip-handle)
|
||||
//Thus we want to calculate ([TipRawHot-TipRawCold])/(ActualHot-HandleHot)-(ActualCold-HandleCold)
|
||||
//Thus we first need to store -> TiprawCold,HandleCold,ActualCold==HandleCold -> RawTipCold
|
||||
uint32_t RawTipCold = getTipRawTemp(0) * 10;
|
||||
lcd.clearScreen();
|
||||
lcd.setCursor(0, 0);
|
||||
lcd.setFont(1);
|
||||
lcd.print("Please Insert Tip\nInto Boiling Water");
|
||||
lcd.refresh();
|
||||
osDelay(200);
|
||||
waitForButtonPress();
|
||||
dotDelay(); //cycle the filter a bit
|
||||
//Now take the three hot measurements
|
||||
//Assume water is boiling at 100C
|
||||
uint32_t RawTipHot = getTipRawTemp(0) * 10;
|
||||
uint32_t HandleTempHot = getHandleTemperature() / 10;
|
||||
|
||||
uint32_t gain = (RawTipHot - RawTipCold) / (100 - HandleTempHot);
|
||||
|
||||
//Show this to the user
|
||||
lcd.clearScreen();
|
||||
lcd.setCursor(0, 0);
|
||||
lcd.print("Your G: ");
|
||||
lcd.printNumber(gain, 6);
|
||||
lcd.print("\n~= 120-140");
|
||||
lcd.refresh();
|
||||
osDelay(2000);
|
||||
waitForButtonPress();
|
||||
lcd.clearScreen();
|
||||
lcd.setCursor(0, 0);
|
||||
lcd.print("H: ");
|
||||
lcd.printNumber(RawTipHot, 8);
|
||||
lcd.setCursor(0, 8);
|
||||
lcd.print("C: ");
|
||||
lcd.printNumber(RawTipCold, 8);
|
||||
lcd.refresh();
|
||||
osDelay(2000);
|
||||
waitForButtonPress();
|
||||
}
|
||||
}
|
||||
static void calibration_displayAdvancedCal(void) {
|
||||
printShortDescription(19, 5);
|
||||
}
|
||||
static void calibration_enterAdvancedCal(void) {
|
||||
//Advanced cal
|
||||
if (userConfirmation(SettingsCalibrationWarning)) {
|
||||
//User has confirmed their handle is at ambient
|
||||
//So take the offset measurement
|
||||
setTipOffset();
|
||||
//The tip now has a known ADC offset
|
||||
//Head up until it is at 350C
|
||||
//Then let the user adjust the gain value until it converges
|
||||
systemSettings.customTipGain = 120;
|
||||
bool exit = false;
|
||||
|
||||
while (exit == false) {
|
||||
//Set tip to 350C
|
||||
currentlyActiveTemperatureTarget = ctoTipMeasurement(350);
|
||||
//Check if user has pressed button to change the gain
|
||||
ButtonState buttons = getButtonState();
|
||||
switch (buttons) {
|
||||
case BUTTON_NONE:
|
||||
break;
|
||||
case BUTTON_BOTH:
|
||||
case BUTTON_B_LONG:
|
||||
case BUTTON_F_LONG:
|
||||
exit = true;
|
||||
break;
|
||||
case BUTTON_F_SHORT:
|
||||
systemSettings.customTipGain++;
|
||||
break;
|
||||
case BUTTON_B_SHORT: {
|
||||
systemSettings.customTipGain--;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (systemSettings.customTipGain > 200)
|
||||
systemSettings.customTipGain = 200;
|
||||
else if (systemSettings.customTipGain <= 100)
|
||||
systemSettings.customTipGain = 100;
|
||||
lcd.setCursor(0, 0);
|
||||
lcd.clearScreen();
|
||||
lcd.setFont(0);
|
||||
if (lcd.getRotation())
|
||||
lcd.drawChar('-');
|
||||
else
|
||||
lcd.drawChar('+');
|
||||
|
||||
lcd.drawChar(' ');
|
||||
lcd.printNumber(systemSettings.customTipGain, 4);
|
||||
lcd.drawChar(' ');
|
||||
if (lcd.getRotation())
|
||||
lcd.drawChar('+');
|
||||
else
|
||||
lcd.drawChar('-');
|
||||
lcd.refresh();
|
||||
GUIDelay();
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
//Provide the user the option to tune their own tip if custom is selected
|
||||
//If not only do single point tuning as per usual
|
||||
static void settings_setCalibrate(void) {
|
||||
if (systemSettings.tipType == Tip_Custom) {
|
||||
//Two types of calibration
|
||||
//1. Basic, idle temp + hot water (100C)
|
||||
//2. Advanced, 100C + 350C, we keep PID tracking to a temperature target
|
||||
return gui_Menu(calibrationMenu);
|
||||
}
|
||||
//Else
|
||||
// Ask user if handle is at the tip temperature
|
||||
// Any error between handle and the tip will be a direct offset in the control loop
|
||||
|
||||
else if (userConfirmation(SettingsCalibrationWarning)) {
|
||||
//User confirmed
|
||||
//So we now perform the actual calculation
|
||||
setTipOffset();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,14 @@
|
||||
#include "hardware.h"
|
||||
volatile uint16_t PWMSafetyTimer = 0;
|
||||
volatile int16_t CalibrationTempOffset = 0;
|
||||
uint16_t tipGainCalValue = 0;
|
||||
uint16_t lookupTipDefaultCalValue(enum TipType tipID);
|
||||
void setTipType(enum TipType tipType, uint8_t manualCalGain) {
|
||||
if (manualCalGain)
|
||||
tipGainCalValue = manualCalGain;
|
||||
else
|
||||
tipGainCalValue = lookupTipDefaultCalValue(tipType);
|
||||
}
|
||||
void setCalibrationOffset(int16_t offSet) {
|
||||
CalibrationTempOffset = offSet;
|
||||
}
|
||||
@@ -29,48 +37,95 @@ uint16_t getHandleTemperature() {
|
||||
|
||||
}
|
||||
uint16_t tipMeasurementToC(uint16_t raw) {
|
||||
return ((raw - 532) / 33) + (getHandleTemperature() / 10)
|
||||
- CalibrationTempOffset;
|
||||
//Surprisingly that appears to be a fairly good linear best fit
|
||||
|
||||
//((Raw Tip-RawOffset) * calibrationgain) / 1000 = tip delta in CX10
|
||||
// tip delta in CX10 + handleTemp in CX10 = tip absolute temp in CX10
|
||||
//Div answer by 10 to get final result
|
||||
|
||||
uint32_t tipDelta = ((raw - CalibrationTempOffset) * tipGainCalValue)
|
||||
/ 1000;
|
||||
tipDelta += getHandleTemperature();
|
||||
|
||||
return tipDelta / 10;
|
||||
|
||||
}
|
||||
uint16_t ctoTipMeasurement(uint16_t temp) {
|
||||
//We need to compensate for cold junction temp
|
||||
return ((temp - (getHandleTemperature() / 10) + CalibrationTempOffset) * 33)
|
||||
+ 532;
|
||||
//[ (temp-handle/10) * 10000 ]/calibrationgain = tip raw delta
|
||||
// tip raw delta + tip offset = tip ADC reading
|
||||
int32_t TipRaw = ((temp - (getHandleTemperature() / 10)) * 10000)
|
||||
/ tipGainCalValue;
|
||||
TipRaw += CalibrationTempOffset;
|
||||
return TipRaw;
|
||||
}
|
||||
|
||||
uint16_t tipMeasurementToF(uint16_t raw) {
|
||||
return ((((raw - 532) / 33) + (getHandleTemperature() / 10)
|
||||
- CalibrationTempOffset) * 9) / 5 + 32;
|
||||
//Convert result from C to F
|
||||
return (tipMeasurementToC(raw) * 9) / 5 + 32;
|
||||
|
||||
}
|
||||
uint16_t ftoTipMeasurement(uint16_t temp) {
|
||||
|
||||
return (((((temp - 32) * 5) / 9) - (getHandleTemperature() / 10)
|
||||
+ CalibrationTempOffset) * 33) + 532;
|
||||
//Convert the temp back to C from F
|
||||
return ctoTipMeasurement(((temp - 32) * 5) / 9);
|
||||
}
|
||||
|
||||
uint16_t getTipInstantTemperature() {
|
||||
uint16_t __attribute__ ((long_call, section (".data.ramfuncs"))) getTipInstantTemperature() {
|
||||
uint16_t sum;
|
||||
sum = HAL_ADCEx_InjectedGetValue(&hadc1, ADC_INJECTED_RANK_1);
|
||||
sum += HAL_ADCEx_InjectedGetValue(&hadc1, ADC_INJECTED_RANK_2);
|
||||
sum += HAL_ADCEx_InjectedGetValue(&hadc1, ADC_INJECTED_RANK_3);
|
||||
sum += HAL_ADCEx_InjectedGetValue(&hadc1, ADC_INJECTED_RANK_4);
|
||||
return sum;
|
||||
sum += HAL_ADCEx_InjectedGetValue(&hadc2, ADC_INJECTED_RANK_1);
|
||||
sum += HAL_ADCEx_InjectedGetValue(&hadc2, ADC_INJECTED_RANK_2);
|
||||
sum += HAL_ADCEx_InjectedGetValue(&hadc2, ADC_INJECTED_RANK_3);
|
||||
sum += HAL_ADCEx_InjectedGetValue(&hadc2, ADC_INJECTED_RANK_4);
|
||||
|
||||
return sum; // 8x over sample
|
||||
|
||||
}
|
||||
uint16_t getTipRawTemp(uint8_t instant) {
|
||||
/*
|
||||
* Loopup table for the tip calibration values for
|
||||
* the gain of the tip's
|
||||
* This can be found by line of best fit of TipRaw on X, and TipTemp-handle on Y.
|
||||
* Then take the m term * 10000
|
||||
* */
|
||||
uint16_t lookupTipDefaultCalValue(enum TipType tipID) {
|
||||
|
||||
switch (tipID) {
|
||||
case TS_D24:
|
||||
return 141;
|
||||
break;
|
||||
case TS_BC2:
|
||||
return (133 + 129) / 2;
|
||||
break;
|
||||
case TS_C1:
|
||||
return 133;
|
||||
break;
|
||||
case TS_B2:
|
||||
return 133;
|
||||
default:
|
||||
return 132; // make this the average of all
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
uint16_t __attribute__ ((long_call, section (".data.ramfuncs"))) getTipRawTemp(
|
||||
uint8_t instant) {
|
||||
static int64_t filterFP = 0;
|
||||
const uint8_t filterBeta = 5; //higher values smooth out more, but reduce responsiveness
|
||||
static uint16_t lastSample = 0;
|
||||
const uint8_t filterBeta = 7; //higher values smooth out more, but reduce responsiveness
|
||||
|
||||
if (instant == 1) {
|
||||
uint16_t itemp = getTipInstantTemperature();
|
||||
filterFP = (filterFP << filterBeta) - filterFP;
|
||||
filterFP += (itemp << 9);
|
||||
filterFP = filterFP >> filterBeta;
|
||||
uint16_t temp = itemp;
|
||||
itemp += lastSample;
|
||||
itemp /= 2;
|
||||
lastSample = temp;
|
||||
return itemp;
|
||||
} else if (instant == 2) {
|
||||
filterFP = (getTipInstantTemperature() << 9);
|
||||
filterFP = (getTipInstantTemperature() << 8);
|
||||
return filterFP >> 9;
|
||||
} else {
|
||||
return filterFP >> 9;
|
||||
@@ -101,24 +156,28 @@ uint16_t getInputVoltageX10(uint8_t divisor) {
|
||||
preFillneeded = 1;
|
||||
return sum / divisor;
|
||||
}
|
||||
volatile uint32_t pendingPWM = 0;
|
||||
uint8_t getTipPWM() {
|
||||
return htim2.Instance->CCR4;
|
||||
return pendingPWM;
|
||||
}
|
||||
void setTipPWM(uint8_t pulse) {
|
||||
void __attribute__ ((long_call, section (".data.ramfuncs"))) setTipPWM(uint8_t pulse) {
|
||||
PWMSafetyTimer = 2; //This is decremented in the handler for PWM so that the tip pwm is disabled if the PID task is not scheduled often enough.
|
||||
if (pulse > 100)
|
||||
pulse = 100;
|
||||
htim2.Instance->CCR4 = pulse;
|
||||
|
||||
pendingPWM = pulse;
|
||||
}
|
||||
|
||||
//Thse are called by the HAL after the corresponding events from the system timers.
|
||||
//These are called by the HAL after the corresponding events from the system timers.
|
||||
|
||||
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim) {
|
||||
void __attribute__ ((long_call, section (".data.ramfuncs"))) HAL_TIM_PeriodElapsedCallback(
|
||||
TIM_HandleTypeDef *htim) {
|
||||
//Period has elapsed
|
||||
if (htim->Instance == TIM2) {
|
||||
//we want to turn on the output again
|
||||
PWMSafetyTimer--; //We decrement this safety value so that lockups in the scheduler will not cause the PWM to become locked in an active driving state.
|
||||
//While we could assume this could never happen, its a small price for increased safety
|
||||
htim2.Instance->CCR4 = pendingPWM;
|
||||
if (htim2.Instance->CCR4 && PWMSafetyTimer) {
|
||||
htim3.Instance->CCR1 = 50;
|
||||
HAL_TIM_PWM_Start(&htim3, TIM_CHANNEL_1);
|
||||
@@ -127,21 +186,20 @@ void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim) {
|
||||
htim3.Instance->CCR1 = 0;
|
||||
}
|
||||
} else if (htim->Instance == TIM1) {
|
||||
// STM uses this for internal functions as a counter for timeouts
|
||||
HAL_IncTick();
|
||||
}
|
||||
}
|
||||
|
||||
void HAL_TIM_PWM_PulseFinishedCallback(TIM_HandleTypeDef *htim) {
|
||||
void __attribute__ ((long_call, section (".data.ramfuncs"))) HAL_TIM_PWM_PulseFinishedCallback(
|
||||
TIM_HandleTypeDef *htim) {
|
||||
if (htim->Instance == TIM2) {
|
||||
//This was a pulse event
|
||||
//This was a when the PWM for the output has timed out
|
||||
if (htim->Channel == HAL_TIM_ACTIVE_CHANNEL_4) {
|
||||
HAL_TIM_PWM_Stop(&htim3, TIM_CHANNEL_1);
|
||||
htim3.Instance->CCR1 = 0;
|
||||
|
||||
} /*else if (htim->Channel == HAL_TIM_ACTIVE_CHANNEL_1) {
|
||||
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_13, GPIO_PIN_RESET);
|
||||
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_14, GPIO_PIN_RESET);
|
||||
}*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -68,6 +68,7 @@ int main(void) {
|
||||
HAL_IWDG_Refresh(&hiwdg);
|
||||
restoreSettings(); // load the settings from flash
|
||||
setCalibrationOffset(systemSettings.CalibrationOffset);
|
||||
setTipType((enum TipType)systemSettings.tipType, systemSettings.customTipGain); //apply tip type selection
|
||||
HAL_IWDG_Refresh(&hiwdg);
|
||||
|
||||
/* Create the thread(s) */
|
||||
@@ -97,6 +98,9 @@ void printVoltage() {
|
||||
lcd.printNumber(getInputVoltageX10(systemSettings.voltageDiv) % 10, 1);
|
||||
}
|
||||
void GUIDelay() {
|
||||
//Called in all UI looping tasks,
|
||||
//This limits the re-draw rate to the LCD and also lets the DMA run
|
||||
//As the gui task can very easily fill this bus with transactions, which will prevent the movement detection from running
|
||||
osDelay(50);
|
||||
}
|
||||
void gui_drawTipTemp(bool symbol) {
|
||||
@@ -187,7 +191,7 @@ ButtonState getButtonState() {
|
||||
return BUTTON_NONE;
|
||||
}
|
||||
|
||||
static void waitForButtonPress() {
|
||||
void waitForButtonPress() {
|
||||
// we are just lazy and sleep until user confirms button press
|
||||
// This also eats the button press event!
|
||||
ButtonState buttons = getButtonState();
|
||||
@@ -314,15 +318,11 @@ static void gui_solderingTempAdjust() {
|
||||
if (systemSettings.temperatureInF) {
|
||||
if (systemSettings.SolderingTemp > 850)
|
||||
systemSettings.SolderingTemp = 850;
|
||||
} else {
|
||||
if (systemSettings.SolderingTemp > 450)
|
||||
systemSettings.SolderingTemp = 450;
|
||||
}
|
||||
|
||||
if (systemSettings.temperatureInF) {
|
||||
if (systemSettings.SolderingTemp < 120)
|
||||
systemSettings.SolderingTemp = 120;
|
||||
} else {
|
||||
if (systemSettings.SolderingTemp > 450)
|
||||
systemSettings.SolderingTemp = 450;
|
||||
if (systemSettings.SolderingTemp < 50)
|
||||
systemSettings.SolderingTemp = 50;
|
||||
}
|
||||
@@ -343,9 +343,9 @@ static void gui_solderingTempAdjust() {
|
||||
lcd.drawSymbol(1);
|
||||
lcd.drawChar(' ');
|
||||
if (lcd.getRotation())
|
||||
lcd.drawChar('+');
|
||||
else
|
||||
lcd.drawChar('-');
|
||||
lcd.drawChar('+');
|
||||
else
|
||||
lcd.drawChar('-');
|
||||
lcd.refresh();
|
||||
GUIDelay();
|
||||
}
|
||||
@@ -500,7 +500,7 @@ static void gui_solderingMode() {
|
||||
lcd.setCursor(0, 0);
|
||||
lcd.clearScreen();
|
||||
lcd.setFont(0);
|
||||
if (tipTemp > 16300) {
|
||||
if (tipTemp > 32752) {
|
||||
lcd.print(BadTipString);
|
||||
lcd.refresh();
|
||||
currentlyActiveTemperatureTarget = 0;
|
||||
@@ -508,10 +508,11 @@ static void gui_solderingMode() {
|
||||
return;
|
||||
} else {
|
||||
if (systemSettings.detailedSoldering) {
|
||||
lcd.setFont(1);
|
||||
lcd.print(SolderingAdvancedPowerPrompt); //Power:
|
||||
lcd.printNumber(getTipPWM(), 3);
|
||||
lcd.print("%");
|
||||
lcd.setFont(1);/*
|
||||
lcd.print(SolderingAdvancedPowerPrompt); //Power:
|
||||
lcd.printNumber(getTipPWM(), 3);
|
||||
lcd.print("%");*/
|
||||
lcd.printNumber(getTipRawTemp(0), 6);
|
||||
|
||||
if (systemSettings.sensitivity && systemSettings.SleepTime) {
|
||||
lcd.print(" ");
|
||||
@@ -596,7 +597,7 @@ static void gui_solderingMode() {
|
||||
|
||||
static const char *HEADERS[] = {
|
||||
__DATE__, "Heap: ", "HWMG: ", "HWMP: ", "HWMM: ", "Time: ", "Move: ", "Rtip: ",
|
||||
"Ctip: ", "Vin :" };
|
||||
"Ctip: ", "Vin :", "THan: " };
|
||||
|
||||
void showVersion(void) {
|
||||
uint8_t screen = 0;
|
||||
@@ -629,7 +630,7 @@ void showVersion(void) {
|
||||
lcd.printNumber(lastMovementTime / 100, 5);
|
||||
break;
|
||||
case 7:
|
||||
lcd.printNumber(getTipRawTemp(0), 5);
|
||||
lcd.printNumber(getTipRawTemp(0), 6);
|
||||
break;
|
||||
case 8:
|
||||
lcd.printNumber(tipMeasurementToC(getTipRawTemp(0)), 5);
|
||||
@@ -637,6 +638,8 @@ void showVersion(void) {
|
||||
case 9:
|
||||
printVoltage();
|
||||
break;
|
||||
case 10:
|
||||
lcd.printNumber(getHandleTemperature(), 3);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -647,14 +650,14 @@ void showVersion(void) {
|
||||
return;
|
||||
else if (b == BUTTON_F_SHORT) {
|
||||
screen++;
|
||||
screen = screen % 10;
|
||||
screen = screen % 11;
|
||||
}
|
||||
GUIDelay();
|
||||
}
|
||||
}
|
||||
|
||||
/* StartGUITask function */
|
||||
void startGUITask(void const *argument) {
|
||||
void startGUITask(void const *argument __unused) {
|
||||
i2cDev.FRToSInit();
|
||||
uint8_t tempWarningState = 0;
|
||||
bool buttonLockout = false;
|
||||
@@ -814,7 +817,7 @@ void startGUITask(void const *argument) {
|
||||
}
|
||||
|
||||
/* StartPIDTask function */
|
||||
void startPIDTask(void const *argument) {
|
||||
void __attribute__ ((long_call, section (".data.ramfuncs"))) startPIDTask(void const *argument __unused) {
|
||||
/*
|
||||
* We take the current tip temperature & evaluate the next step for the tip
|
||||
* control PWM
|
||||
@@ -843,8 +846,8 @@ void startPIDTask(void const *argument) {
|
||||
uint16_t rawTemp = getTipRawTemp(1); // get instantaneous reading
|
||||
if (currentlyActiveTemperatureTarget) {
|
||||
// Compute the PID loop in here
|
||||
// Because our values here are quite large for all measurements (0-16k ~=
|
||||
// 33 counts per C)
|
||||
// Because our values here are quite large for all measurements (0-32k ~=
|
||||
// 66 counts per C)
|
||||
// P I & D are divisors, so inverse logic applies (beware)
|
||||
|
||||
// Cap the max set point to 450C
|
||||
@@ -854,9 +857,12 @@ void startPIDTask(void const *argument) {
|
||||
|
||||
int32_t rawTempError = currentlyActiveTemperatureTarget
|
||||
- rawTemp;
|
||||
|
||||
int32_t ierror = (rawTempError
|
||||
/ ((int32_t) systemSettings.PID_I));
|
||||
|
||||
integralCount += ierror;
|
||||
|
||||
if (integralCount > (itermMax / 2))
|
||||
integralCount = itermMax / 2; // prevent too much lead
|
||||
else if (integralCount < -itermMax)
|
||||
@@ -878,9 +884,11 @@ void startPIDTask(void const *argument) {
|
||||
output = 0;
|
||||
}
|
||||
|
||||
/*if (currentlyActiveTemperatureTarget < rawTemp) {
|
||||
output = 0;
|
||||
}*/
|
||||
if (currentlyActiveTemperatureTarget < rawTemp) {
|
||||
output = 0;
|
||||
integralCount = 0;
|
||||
derivativeLastValue = 0;
|
||||
}
|
||||
setTipPWM(output);
|
||||
derivativeLastValue = rawTemp; // store for next loop
|
||||
|
||||
@@ -891,11 +899,17 @@ void startPIDTask(void const *argument) {
|
||||
}
|
||||
|
||||
HAL_IWDG_Refresh(&hiwdg);
|
||||
} else {
|
||||
if (currentlyActiveTemperatureTarget == 0) {
|
||||
setTipPWM(0); // disable the output driver if the output is set to be off
|
||||
integralCount = 0;
|
||||
derivativeLastValue = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#define MOVFilter 8
|
||||
void startMOVTask(void const *argument) {
|
||||
void startMOVTask(void const *argument __unused) {
|
||||
osDelay(250); // wait for accelerometer to stabilize
|
||||
lcd.setRotation(systemSettings.OrientationMode & 1);
|
||||
lastMovementTime = 0;
|
||||
@@ -1011,41 +1025,48 @@ bool showBootLogoIfavailable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
void HAL_ADCEx_InjectedConvCpltCallback(ADC_HandleTypeDef* hadc) {
|
||||
/*
|
||||
* Catch the IRQ that says that the conversion is done on the temperature readings coming in
|
||||
* Once these have come in we can unblock the PID so that it runs again
|
||||
*/
|
||||
void __attribute__ ((long_call, section (".data.ramfuncs"))) HAL_ADCEx_InjectedConvCpltCallback(
|
||||
ADC_HandleTypeDef* hadc) {
|
||||
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
|
||||
|
||||
if (pidTaskNotification) {
|
||||
/* Notify the task that the transmission is complete. */
|
||||
vTaskNotifyGiveFromISR(pidTaskNotification, &xHigherPriorityTaskWoken);
|
||||
|
||||
/* If xHigherPriorityTaskWoken is now set to pdTRUE then a context switch
|
||||
should be performed to ensure the interrupt returns directly to the highest
|
||||
priority task. The macro used for this purpose is dependent on the port in
|
||||
use and may be called portEND_SWITCHING_ISR(). */
|
||||
portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
|
||||
if (hadc == &hadc1) {
|
||||
if (pidTaskNotification) {
|
||||
vTaskNotifyGiveFromISR(pidTaskNotification,
|
||||
&xHigherPriorityTaskWoken);
|
||||
portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void HAL_I2C_MasterRxCpltCallback(I2C_HandleTypeDef *hi2c) {
|
||||
void __attribute__ ((long_call, section (".data.ramfuncs"))) HAL_I2C_MasterRxCpltCallback(
|
||||
I2C_HandleTypeDef *hi2c __unused) {
|
||||
i2cDev.CpltCallback();
|
||||
}
|
||||
void HAL_I2C_MasterTxCpltCallback(I2C_HandleTypeDef *hi2c) {
|
||||
void __attribute__ ((long_call, section (".data.ramfuncs"))) HAL_I2C_MasterTxCpltCallback(
|
||||
I2C_HandleTypeDef *hi2c __unused) {
|
||||
i2cDev.CpltCallback();
|
||||
}
|
||||
void HAL_I2C_MemTxCpltCallback(I2C_HandleTypeDef *hi2c) {
|
||||
void __attribute__ ((long_call, section (".data.ramfuncs"))) HAL_I2C_MemTxCpltCallback(
|
||||
I2C_HandleTypeDef *hi2c __unused) {
|
||||
i2cDev.CpltCallback();
|
||||
}
|
||||
void HAL_I2C_ErrorCallback(I2C_HandleTypeDef *hi2c) {
|
||||
void __attribute__ ((long_call, section (".data.ramfuncs"))) HAL_I2C_ErrorCallback(
|
||||
I2C_HandleTypeDef *hi2c __unused) {
|
||||
i2cDev.CpltCallback();
|
||||
}
|
||||
void HAL_I2C_AbortCpltCallback(I2C_HandleTypeDef *hi2c) {
|
||||
void __attribute__ ((long_call, section (".data.ramfuncs"))) HAL_I2C_AbortCpltCallback(
|
||||
I2C_HandleTypeDef *hi2c __unused) {
|
||||
i2cDev.CpltCallback();
|
||||
}
|
||||
void HAL_I2C_MemRxCpltCallback(I2C_HandleTypeDef *hi2c) {
|
||||
void __attribute__ ((long_call, section (".data.ramfuncs"))) HAL_I2C_MemRxCpltCallback(
|
||||
I2C_HandleTypeDef *hi2c __unused) {
|
||||
i2cDev.CpltCallback();
|
||||
}
|
||||
void vApplicationStackOverflowHook( xTaskHandle *pxTask,
|
||||
signed portCHAR *pcTaskName) {
|
||||
void vApplicationStackOverflowHook( xTaskHandle *pxTask __unused,
|
||||
signed portCHAR *pcTaskName __unused) {
|
||||
//We dont have a good way to handle a stack overflow at this point in time
|
||||
NVIC_SystemReset();
|
||||
|
||||
|
||||
@@ -30,7 +30,8 @@ void HAL_MspInit(void) {
|
||||
*/
|
||||
//__HAL_AFIO_REMAP_SWJ_NOJTAG()
|
||||
//;
|
||||
__HAL_AFIO_REMAP_SWJ_DISABLE(); /*Disable swd for debug io use*/
|
||||
__HAL_AFIO_REMAP_SWJ_DISABLE()
|
||||
; /*Disable swd for debug io use*/
|
||||
|
||||
}
|
||||
|
||||
@@ -70,6 +71,21 @@ void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc) {
|
||||
/* ADC1 interrupt Init */
|
||||
HAL_NVIC_SetPriority(ADC1_2_IRQn, 15, 0);
|
||||
HAL_NVIC_EnableIRQ(ADC1_2_IRQn);
|
||||
} else {
|
||||
__HAL_RCC_ADC2_CLK_ENABLE()
|
||||
;
|
||||
|
||||
/**ADC2 GPIO Configuration
|
||||
PB0 ------> ADC2_IN8
|
||||
PB1 ------> ADC2_IN9
|
||||
*/
|
||||
GPIO_InitStruct.Pin = TIP_TEMP_Pin;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
|
||||
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
||||
|
||||
/* ADC2 interrupt Init */
|
||||
HAL_NVIC_SetPriority(ADC1_2_IRQn, 15, 0);
|
||||
HAL_NVIC_EnableIRQ(ADC1_2_IRQn);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user