2.04 bugfixes
Should help with UI lockups
This commit is contained in:
@@ -11,31 +11,34 @@
|
|||||||
#define SETTINGS_H_
|
#define SETTINGS_H_
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include "stm32f1xx_hal.h"
|
#include "stm32f1xx_hal.h"
|
||||||
#define SETTINGSVERSION 0x13 /*Change this if you change the struct below to prevent people getting out of sync*/
|
#define SETTINGSVERSION 0x14 /*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
|
* This struct must be a multiple of 2 bytes as it is saved / restored from flash in uint16_t chunks
|
||||||
*/
|
*/
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint16_t SolderingTemp; //current set point for the iron
|
uint16_t SolderingTemp; //current set point for the iron
|
||||||
uint16_t SleepTemp; //temp to drop to in sleep
|
uint16_t SleepTemp; //temp to drop to in sleep
|
||||||
uint8_t SleepTime; //minutes timeout to sleep
|
uint8_t SleepTime; //minutes timeout to sleep
|
||||||
uint8_t cutoutSetting; // The voltage we cut out at for under voltage
|
uint8_t cutoutSetting; // The voltage we cut out at for under voltage
|
||||||
uint8_t OrientationMode:2; //If true we want to invert the display for lefties
|
uint8_t OrientationMode:2; //If true we want to invert the display for lefties
|
||||||
uint8_t sensitivity :4; //Sensitivity of accelerometer (5 bits)
|
uint8_t sensitivity :4; //Sensitivity of accelerometer (5 bits)
|
||||||
uint8_t autoStartMode :2; //Should the unit automatically jump straight into soldering mode when power is applied
|
uint8_t autoStartMode :2; //Should the unit automatically jump straight into soldering mode when power is applied
|
||||||
uint8_t ShutdownTime; //Time until unit shuts down if left alone
|
uint8_t ShutdownTime; //Time until unit shuts down if left alone
|
||||||
uint8_t boostModeEnabled :1; //Boost mode swaps BUT_A in soldering mode to temporary soldering temp over-ride
|
uint8_t boostModeEnabled :1; //Boost mode swaps BUT_A in soldering mode to temporary soldering temp over-ride
|
||||||
uint8_t coolingTempBlink :1; //Should the temperature blink on the cool down screen until its <50C
|
uint8_t coolingTempBlink :1; //Should the temperature blink on the cool down screen until its <50C
|
||||||
uint8_t detailedIDLE :1; //Detailed idle screen
|
uint8_t detailedIDLE :1; //Detailed idle screen
|
||||||
uint8_t detailedSoldering :1; //Detailed soldering screens
|
uint8_t detailedSoldering :1; //Detailed soldering screens
|
||||||
uint8_t temperatureInF; //Should the temp be in F or C (true is F)
|
uint8_t temperatureInF; //Should the temp be in F or C (true is F)
|
||||||
uint8_t descriptionScrollSpeed:1; // Description scroll speed
|
uint8_t descriptionScrollSpeed:1; // Description scroll speed
|
||||||
uint16_t voltageDiv; //Voltage divisor factor
|
uint16_t voltageDiv; //Voltage divisor factor
|
||||||
uint16_t BoostTemp; //Boost mode set point for the iron
|
uint16_t BoostTemp; //Boost mode set point for the iron
|
||||||
int16_t CalibrationOffset; //This stores the temperature offset for this tip in the iron.
|
int16_t CalibrationOffset; //This stores the temperature offset for this tip in the iron.
|
||||||
uint8_t version; //Used to track if a reset is needed on firmware upgrade
|
uint8_t PID_P; //PID P Term
|
||||||
uint32_t padding; //This is here for in case we are not an even divisor so that nothing gets cut off
|
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
|
||||||
|
uint32_t padding; //This is here for in case we are not an even divisor so that nothing gets cut off
|
||||||
} systemSettingsType;
|
} systemSettingsType;
|
||||||
|
|
||||||
extern volatile systemSettingsType systemSettings;
|
extern volatile systemSettingsType systemSettings;
|
||||||
|
|||||||
@@ -14,11 +14,13 @@ FRToSI2C::FRToSI2C(I2C_HandleTypeDef* i2chandle) {
|
|||||||
|
|
||||||
void FRToSI2C::CpltCallback() {
|
void FRToSI2C::CpltCallback() {
|
||||||
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
|
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
|
||||||
|
i2c->State = HAL_I2C_STATE_READY;//Force state reset
|
||||||
if (I2CSemaphore) {
|
if (I2CSemaphore) {
|
||||||
xSemaphoreGiveFromISR(I2CSemaphore, &xHigherPriorityTaskWoken);
|
xSemaphoreGiveFromISR(I2CSemaphore, &xHigherPriorityTaskWoken);
|
||||||
portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
|
portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FRToSI2C::Mem_Read(uint16_t DevAddress, uint16_t MemAddress,
|
void FRToSI2C::Mem_Read(uint16_t DevAddress, uint16_t MemAddress,
|
||||||
@@ -32,7 +34,7 @@ void FRToSI2C::Mem_Read(uint16_t DevAddress, uint16_t MemAddress,
|
|||||||
//RToS is active, run threading
|
//RToS is active, run threading
|
||||||
//Get the mutex so we can use the I2C port
|
//Get the mutex so we can use the I2C port
|
||||||
//Wait up to 1 second for the mutex
|
//Wait up to 1 second for the mutex
|
||||||
if ( xSemaphoreTake( I2CSemaphore, ( TickType_t ) portMAX_DELAY ) == pdTRUE) {
|
if ( xSemaphoreTake( I2CSemaphore, ( TickType_t ) 5000 ) == pdTRUE) {
|
||||||
if (HAL_I2C_Mem_Read(i2c, DevAddress, MemAddress, MemAddSize, pData,
|
if (HAL_I2C_Mem_Read(i2c, DevAddress, MemAddress, MemAddSize, pData,
|
||||||
Size, 5000) != HAL_OK) {
|
Size, 5000) != HAL_OK) {
|
||||||
NVIC_SystemReset();
|
NVIC_SystemReset();
|
||||||
@@ -57,7 +59,7 @@ void FRToSI2C::Mem_Write(uint16_t DevAddress, uint16_t MemAddress,
|
|||||||
//RToS is active, run threading
|
//RToS is active, run threading
|
||||||
//Get the mutex so we can use the I2C port
|
//Get the mutex so we can use the I2C port
|
||||||
//Wait up to 1 second for the mutex
|
//Wait up to 1 second for the mutex
|
||||||
if ( xSemaphoreTake( I2CSemaphore, ( TickType_t ) portMAX_DELAY ) == pdTRUE) {
|
if ( xSemaphoreTake( I2CSemaphore, ( TickType_t ) 5000 ) == pdTRUE) {
|
||||||
if (HAL_I2C_Mem_Write(i2c, DevAddress, MemAddress, MemAddSize,
|
if (HAL_I2C_Mem_Write(i2c, DevAddress, MemAddress, MemAddSize,
|
||||||
pData, Size, 5000) != HAL_OK) {
|
pData, Size, 5000) != HAL_OK) {
|
||||||
NVIC_SystemReset();
|
NVIC_SystemReset();
|
||||||
@@ -86,7 +88,7 @@ void FRToSI2C::Transmit(uint16_t DevAddress, uint8_t* pData, uint16_t Size) {
|
|||||||
//RToS is active, run threading
|
//RToS is active, run threading
|
||||||
//Get the mutex so we can use the I2C port
|
//Get the mutex so we can use the I2C port
|
||||||
//Wait up to 1 second for the mutex
|
//Wait up to 1 second for the mutex
|
||||||
if ( xSemaphoreTake( I2CSemaphore, ( TickType_t ) portMAX_DELAY ) == pdTRUE) {
|
if ( xSemaphoreTake( I2CSemaphore, ( TickType_t ) 5000 ) == pdTRUE) {
|
||||||
if (HAL_I2C_Master_Transmit_DMA(i2c, DevAddress, pData, Size)
|
if (HAL_I2C_Master_Transmit_DMA(i2c, DevAddress, pData, Size)
|
||||||
!= HAL_OK) {
|
!= HAL_OK) {
|
||||||
NVIC_SystemReset();
|
NVIC_SystemReset();
|
||||||
|
|||||||
@@ -90,6 +90,10 @@ void resetSettings() {
|
|||||||
systemSettings.CalibrationOffset = 10; //This appears to be quite close for both of my tips, in both of my handles
|
systemSettings.CalibrationOffset = 10; //This appears to be quite close for both of my tips, in both of my handles
|
||||||
systemSettings.temperatureInF = 0; //default to 0
|
systemSettings.temperatureInF = 0; //default to 0
|
||||||
systemSettings.descriptionScrollSpeed=0;//default to slow
|
systemSettings.descriptionScrollSpeed=0;//default to slow
|
||||||
|
systemSettings.PID_P =42;
|
||||||
|
systemSettings.PID_I =50;
|
||||||
|
systemSettings.PID_D =15;
|
||||||
|
|
||||||
saveSettings();
|
saveSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -154,14 +154,16 @@ static void MX_ADC1_Init(void) {
|
|||||||
sConfigInjected.InjectedRank = 4;
|
sConfigInjected.InjectedRank = 4;
|
||||||
HAL_ADCEx_InjectedConfigChannel(&hadc1, &sConfigInjected);
|
HAL_ADCEx_InjectedConfigChannel(&hadc1, &sConfigInjected);
|
||||||
SET_BIT(hadc1.Instance->CR1, ( ADC_CR1_JEOCIE )); //Enable end of injected conv irq
|
SET_BIT(hadc1.Instance->CR1, ( ADC_CR1_JEOCIE )); //Enable end of injected conv irq
|
||||||
while(HAL_ADCEx_Calibration_Start(&hadc1) != HAL_OK);
|
// Run ADC internal calibration
|
||||||
|
while (HAL_ADCEx_Calibration_Start(&hadc1) != HAL_OK)
|
||||||
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* I2C1 init function */
|
/* I2C1 init function */
|
||||||
static void MX_I2C1_Init(void) {
|
static void MX_I2C1_Init(void) {
|
||||||
|
|
||||||
hi2c1.Instance = I2C1;
|
hi2c1.Instance = I2C1;
|
||||||
hi2c1.Init.ClockSpeed = 300000; //300Khz
|
hi2c1.Init.ClockSpeed = 100000; // OLED doesnt handle >100k when its asleep (off).
|
||||||
hi2c1.Init.DutyCycle = I2C_DUTYCYCLE_2;
|
hi2c1.Init.DutyCycle = I2C_DUTYCYCLE_2;
|
||||||
hi2c1.Init.OwnAddress1 = 0;
|
hi2c1.Init.OwnAddress1 = 0;
|
||||||
hi2c1.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;
|
hi2c1.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;
|
||||||
|
|||||||
@@ -75,6 +75,15 @@ const char* SettingsDescriptions[17] = {
|
|||||||
/* Calibrate input voltage */ "VIN Calibration. Buttons adjust, long press to exit",
|
/* Calibrate input voltage */ "VIN Calibration. Buttons adjust, long press to exit",
|
||||||
/* Advanced soldering screen enabled */ "Display detailed information while soldering",
|
/* Advanced soldering screen enabled */ "Display detailed information while soldering",
|
||||||
/* Description Scroll Speed */ "Speed this text scrolls past at",
|
/* Description Scroll Speed */ "Speed this text scrolls past at",
|
||||||
|
|
||||||
|
#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",
|
||||||
|
"PID D term. Inverse values! This acts as a divisor. So Larger numbers == typically smaller in other systems",
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const char* SettingsCalibrationWarning = "Please ensure the tip is at room temperature before continuing!";
|
const char* SettingsCalibrationWarning = "Please ensure the tip is at room temperature before continuing!";
|
||||||
@@ -121,6 +130,13 @@ const char* SettingsShortNames[17][2] = {
|
|||||||
/* (<= 16) Calibrate input voltage */ {"Calibrate", "input voltage?"},
|
/* (<= 16) Calibrate input voltage */ {"Calibrate", "input voltage?"},
|
||||||
/* (<= 13) Advanced soldering screen enabled */ {"Detailed", "solder screen"},
|
/* (<= 13) Advanced soldering screen enabled */ {"Detailed", "solder screen"},
|
||||||
/* (<= 11) Display Help Text Scroll Speed */ {"Description","Scroll Speed"},
|
/* (<= 11) Display Help Text Scroll Speed */ {"Description","Scroll Speed"},
|
||||||
|
#ifdef PIDSETTINGS
|
||||||
|
|
||||||
|
{"PID","P"},
|
||||||
|
{"PID","I"},
|
||||||
|
{"PID","D"},
|
||||||
|
#endif
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// SettingsMenuEntries lengths <= 13 per line (\n starts second line)
|
// SettingsMenuEntries lengths <= 13 per line (\n starts second line)
|
||||||
|
|||||||
@@ -31,7 +31,15 @@ static void settings_setAdvancedIDLEScreens(void);
|
|||||||
static void settings_displayAdvancedIDLEScreens(void);
|
static void settings_displayAdvancedIDLEScreens(void);
|
||||||
static void settings_setScrollSpeed(void);
|
static void settings_setScrollSpeed(void);
|
||||||
static void settings_displayScrollSpeed(void);
|
static void settings_displayScrollSpeed(void);
|
||||||
|
#ifdef PIDSETTINGS
|
||||||
|
|
||||||
|
static void settings_setPIDP(void);
|
||||||
|
static void settings_displayPIDP(void);
|
||||||
|
static void settings_setPIDI(void);
|
||||||
|
static void settings_displayPIDI(void);
|
||||||
|
static void settings_setPIDD(void);
|
||||||
|
static void settings_displayPIDD(void);
|
||||||
|
#endif
|
||||||
static void settings_setDisplayRotation(void);
|
static void settings_setDisplayRotation(void);
|
||||||
static void settings_displayDisplayRotation(void);
|
static void settings_displayDisplayRotation(void);
|
||||||
static void settings_setBoostModeEnabled(void);
|
static void settings_setBoostModeEnabled(void);
|
||||||
@@ -181,6 +189,15 @@ const menuitem advancedMenu[] = {
|
|||||||
settings_displayCalibrate } }, /*Calibrate tip*/
|
settings_displayCalibrate } }, /*Calibrate tip*/
|
||||||
{ (const char*) SettingsDescriptions[14], { settings_setCalibrateVIN }, {
|
{ (const char*) SettingsDescriptions[14], { settings_setCalibrateVIN }, {
|
||||||
settings_displayCalibrateVIN } }, /*Voltage input cal*/
|
settings_displayCalibrateVIN } }, /*Voltage input cal*/
|
||||||
|
#ifdef PIDSETTINGS
|
||||||
|
|
||||||
|
{ (const char*) SettingsDescriptions[17], { settings_setPIDP }, {
|
||||||
|
settings_displayPIDP } }, /*Voltage input cal*/
|
||||||
|
{ (const char*) SettingsDescriptions[18], { settings_setPIDI }, {
|
||||||
|
settings_displayPIDI } }, /*Voltage input cal*/
|
||||||
|
{ (const char*) SettingsDescriptions[19], { settings_setPIDD }, {
|
||||||
|
settings_displayPIDD } }, /*Voltage input cal*/
|
||||||
|
#endif
|
||||||
{ NULL, { NULL }, { NULL } } // end of menu marker. DO NOT REMOVE
|
{ NULL, { NULL }, { NULL } } // end of menu marker. DO NOT REMOVE
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -363,13 +380,13 @@ static void settings_setTempF(void) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
// Rescale both to be multiples of 10
|
// Rescale both to be multiples of 10
|
||||||
systemSettings.BoostTemp = systemSettings.BoostTemp/10;
|
systemSettings.BoostTemp = systemSettings.BoostTemp / 10;
|
||||||
systemSettings.BoostTemp *=10;
|
systemSettings.BoostTemp *= 10;
|
||||||
systemSettings.SolderingTemp = systemSettings.SolderingTemp/10;
|
systemSettings.SolderingTemp = systemSettings.SolderingTemp / 10;
|
||||||
systemSettings.SolderingTemp *=10;
|
systemSettings.SolderingTemp *= 10;
|
||||||
systemSettings.SleepTemp = systemSettings.SleepTemp/10;
|
systemSettings.SleepTemp = systemSettings.SleepTemp / 10;
|
||||||
systemSettings.SleepTemp *=10;
|
systemSettings.SleepTemp *= 10;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void settings_displayTempF(void) {
|
static void settings_displayTempF(void) {
|
||||||
@@ -488,6 +505,33 @@ static void settings_displayBoostTemp(void) {
|
|||||||
lcd.printNumber(systemSettings.BoostTemp, 3);
|
lcd.printNumber(systemSettings.BoostTemp, 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef PIDSETTINGS
|
||||||
|
static void settings_setPIDP(void) {
|
||||||
|
systemSettings.PID_P++;
|
||||||
|
systemSettings.PID_P %= 100;
|
||||||
|
}
|
||||||
|
static void settings_displayPIDP(void) {
|
||||||
|
printShortDescription(17, 6);
|
||||||
|
lcd.printNumber(systemSettings.PID_P, 2);
|
||||||
|
}
|
||||||
|
static void settings_setPIDI(void) {
|
||||||
|
systemSettings.PID_I++;
|
||||||
|
systemSettings.PID_I %= 100;
|
||||||
|
}
|
||||||
|
static void settings_displayPIDI(void) {
|
||||||
|
printShortDescription(18, 6);
|
||||||
|
lcd.printNumber(systemSettings.PID_I, 2);
|
||||||
|
}
|
||||||
|
static void settings_setPIDD(void) {
|
||||||
|
systemSettings.PID_D++;
|
||||||
|
systemSettings.PID_D %= 100;
|
||||||
|
}
|
||||||
|
static void settings_displayPIDD(void) {
|
||||||
|
printShortDescription(19, 6);
|
||||||
|
lcd.printNumber(systemSettings.PID_D, 2);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static void settings_setAutomaticStartMode(void) {
|
static void settings_setAutomaticStartMode(void) {
|
||||||
systemSettings.autoStartMode++;
|
systemSettings.autoStartMode++;
|
||||||
systemSettings.autoStartMode %= 2;
|
systemSettings.autoStartMode %= 2;
|
||||||
@@ -495,7 +539,6 @@ static void settings_setAutomaticStartMode(void) {
|
|||||||
|
|
||||||
static void settings_displayAutomaticStartMode(void) {
|
static void settings_displayAutomaticStartMode(void) {
|
||||||
printShortDescription(10, 7);
|
printShortDescription(10, 7);
|
||||||
|
|
||||||
lcd.drawCheckbox(systemSettings.autoStartMode);
|
lcd.drawCheckbox(systemSettings.autoStartMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -787,17 +787,11 @@ void startPIDTask(void const *argument) {
|
|||||||
osDelay(500);
|
osDelay(500);
|
||||||
int32_t integralCount = 0;
|
int32_t integralCount = 0;
|
||||||
int32_t derivativeLastValue = 0;
|
int32_t derivativeLastValue = 0;
|
||||||
int32_t kp, ki, kd;
|
|
||||||
ki = 50;
|
|
||||||
kd = 15;
|
|
||||||
// REMEBER ^^^^ These constants are backwards
|
// REMEBER ^^^^ These constants are backwards
|
||||||
// They act as dividers, so to 'increase' a P term, you make the number
|
// They act as dividers, so to 'increase' a P term, you make the number
|
||||||
// smaller.
|
// smaller.
|
||||||
if (getInputVoltageX10(systemSettings.voltageDiv) < 150) {
|
|
||||||
//Boot P term if < 15 Volts
|
|
||||||
kp = 30;
|
|
||||||
} else
|
|
||||||
kp = 42;
|
|
||||||
const int32_t itermMax = 100;
|
const int32_t itermMax = 100;
|
||||||
pidTaskNotification = xTaskGetCurrentTaskHandle();
|
pidTaskNotification = xTaskGetCurrentTaskHandle();
|
||||||
for (;;) {
|
for (;;) {
|
||||||
@@ -818,7 +812,7 @@ void startPIDTask(void const *argument) {
|
|||||||
|
|
||||||
int32_t rawTempError = currentlyActiveTemperatureTarget
|
int32_t rawTempError = currentlyActiveTemperatureTarget
|
||||||
- rawTemp;
|
- rawTemp;
|
||||||
int32_t ierror = (rawTempError / ki);
|
int32_t ierror = (rawTempError / ((int32_t)systemSettings.PID_I));
|
||||||
integralCount += ierror;
|
integralCount += ierror;
|
||||||
if (integralCount > (itermMax / 2))
|
if (integralCount > (itermMax / 2))
|
||||||
integralCount = itermMax / 2; // prevent too much lead
|
integralCount = itermMax / 2; // prevent too much lead
|
||||||
@@ -828,11 +822,11 @@ void startPIDTask(void const *argument) {
|
|||||||
int32_t dInput = (rawTemp - derivativeLastValue);
|
int32_t dInput = (rawTemp - derivativeLastValue);
|
||||||
|
|
||||||
/*Compute PID Output*/
|
/*Compute PID Output*/
|
||||||
int32_t output = (rawTempError / kp);
|
int32_t output = (rawTempError / ((int32_t)systemSettings.PID_P));
|
||||||
if (ki)
|
if (((int32_t)systemSettings.PID_I))
|
||||||
output += integralCount;
|
output += integralCount;
|
||||||
if (kd)
|
if (((int32_t)systemSettings.PID_D))
|
||||||
output -= (dInput / kd);
|
output -= (dInput / ((int32_t)systemSettings.PID_D));
|
||||||
|
|
||||||
if (output > 100) {
|
if (output > 100) {
|
||||||
output = 100; // saturate
|
output = 100; // saturate
|
||||||
@@ -968,6 +962,7 @@ void startMOVTask(void const *argument) {
|
|||||||
bool showBootLogoIfavailable() {
|
bool showBootLogoIfavailable() {
|
||||||
// check if the header is there (0xAA,0x55,0xF0,0x0D)
|
// check if the header is there (0xAA,0x55,0xF0,0x0D)
|
||||||
// If so display logo
|
// If so display logo
|
||||||
|
//TODO REDUCE STACK ON THIS ONE, USE DRAWING IN THE READ LOOP
|
||||||
uint16_t temp[98];
|
uint16_t temp[98];
|
||||||
|
|
||||||
for (uint8_t i = 0; i < (98); i++) {
|
for (uint8_t i = 0; i < (98); i++) {
|
||||||
|
|||||||
Reference in New Issue
Block a user