暂时修复校准后内存溢出的问题

通过校准后自动重启缓解这个问题
This commit is contained in:
createskyblue
2020-11-14 17:20:24 +08:00
parent b8a05cb631
commit d4edca579c
3 changed files with 25 additions and 11 deletions

View File

@@ -162,7 +162,7 @@ bool BeepEnable = BEEP_ENABLE;
#define TempP3 -0.0033245713
#define TempP4 0.0000045338
float PTemp[4] = {TempP1, TempP2, TempP3, TempP4}; //温度拟合系数
const uint16_t CalTemp[9] = {50,100,150,200,250,300,350,400,450};
const uint16_t CalTemp[9] = {50,100,150,200,250,300,350,400,450};
char TipName[TIPNAMELENGTH] = {TIPNAME};
uint8_t CurrentTip = 0;
uint8_t NumberOfTips = 1;
@@ -295,7 +295,7 @@ void setup() {
SetTemp = DefaultTemp;
RawTemp = denoiseAnalog(SENSOR_PIN);
ChipTemp = getChipTemp();
calculateTemp();
CurrentTemp = calculateTemp(RawTemp);
// turn on heater if iron temperature is well below setpoint
#if UsePMOS
if ((CurrentTemp + 20) < DefaultTemp) analogWrite(CONTROL_PIN, 255);

View File

@@ -1,4 +1,4 @@
void(* resetFunc) (void) = 0;
// reads current rotary encoder value
int getRotary() {
return (Count >> ROTARY_TYPE);
@@ -110,8 +110,8 @@ ISR (PCINT0_vect) {
//计算实际温度
// calculates real temperature value according to ADC reading and calibration values
void calculateTemp() {
CurrentTemp = PTemp[0] + RawTemp * PTemp[1] + RawTemp * RawTemp * PTemp[2] + RawTemp * RawTemp * RawTemp * PTemp[3];
float calculateTemp(float t) {
return PTemp[0] + RawTemp * PTemp[1] + RawTemp * RawTemp * PTemp[2] + RawTemp * RawTemp * RawTemp * PTemp[3];
}
/*
@@ -200,7 +200,7 @@ void SENSORCheck() {
RawTemp += (temp - RawTemp) * SMOOTHIE; // stabilize ADC temperature reading
calculateTemp();
CurrentTemp = calculateTemp(RawTemp);
// stabilize displayed temperature when around setpoint
if ((ShowTemp != Setpoint) || (abs(ShowTemp - CurrentTemp) > 5)) ShowTemp = CurrentTemp;

View File

@@ -259,7 +259,7 @@ void TipScreen() {
default: repeat = false; break;
}
}
//ViewEEPRom();
ViewEEPRom();
}
//温控设置菜单
@@ -502,7 +502,7 @@ void ChangeTipScreen() {
for (uint8_t i = 0; i < 3; i++) {
uint8_t drawnumber = selected + i - arrow;
if (drawnumber < NumberOfTips) {
arduboy.setCursor(12, 16 * (i + 1));
arduboy.setCursor(12, 16 * (i + 1));
GetEEPRomTip(selected + i - arrow);
arduboy.print(TipName);
}
@@ -569,7 +569,6 @@ void CalibrationScreen() {
for (int i = 0; i < 8; i++) if (xx[i] + 5 >= xx[i + 1]) pass = false;
if (pass) {
MenuLevel = 7;
free(&pass);
polyfit(9, xx, CalTemp, 3, P); //拟合程序
free(xx);
ShowPTemp(&P[0]);
@@ -584,6 +583,11 @@ void CalibrationScreen() {
arduboy.display();
delay(5000);
}
arduboy.clear();
arduboy.print(F("Reboot..."));
arduboy.display();
delay(500);
resetFunc();
}
//显示默认烙铁头温度曲线系数
void ShowPTemp(float *p) {
@@ -598,9 +602,18 @@ void ShowPTemp(float *p) {
p++;
}
arduboy.display();
lastbutton = (!digitalRead(BUTTON_PIN));
while (digitalRead(BUTTON_PIN) || lastbutton) CheckLastButton();
/*
lastbutton = (!digitalRead(BUTTON_PIN));
setRotary(50, 450, 1, 0);
do {
arduboy.clear();
for (int y = 0; y < 64; y++) arduboy.drawPixel(map(calculateTemp(map(y, 0, 63, 0, 400)), CalTemp[0], CalTemp[8], 0, 127), y,1);
arduboy.display();
CheckLastButton();
} while (digitalRead(BUTTON_PIN) || lastbutton);*/
}
//命名界面 文本输入界面
// input tip name screen
@@ -630,13 +643,14 @@ void InputNameScreen() {
arduboy.display();
} while (digitalRead(BUTTON_PIN) || lastbutton);
TipName[digit] = value;
UpdateEEPROM();
beep(); delay (10);
}
TipName[TIPNAMELENGTH - 1] = 0;
return value;
}
//删除烙铁头
// delete tip screen
void DeleteTipScreen() {
MenuLevel = 7;