Update temperature types

This commit is contained in:
Scott Lahteine
2021-04-23 19:14:49 -05:00
parent 51a61c5431
commit 72e3d2492f
16 changed files with 88 additions and 76 deletions

View File

@ -373,10 +373,9 @@ int8_t ChironTFT::FindToken(char c) {
void ChironTFT::CheckHeaters() {
uint8_t faultDuration = 0;
float temp = 0;
// if the hotend temp is abnormal, confirm state before signalling panel
temp = getActualTemp_celsius(E0);
celsius_float_t temp = getActualTemp_celsius(E0);
while (!WITHIN(temp, HEATER_0_MINTEMP, HEATER_0_MAXTEMP)) {
faultDuration++;
if (faultDuration >= AC_HEATER_FAULT_VALIDATION_TIME) {

View File

@ -534,6 +534,8 @@ void AnycubicTFTClass::OnPrintTimerStopped() {
#endif
}
#define ROUND(val) int((val)+0.5f)
void AnycubicTFTClass::GetCommandFromTFT() {
char *starpos = nullptr;
while (LCD_SERIAL.available() > 0 && TFTbuflen < TFTBUFSIZE) {
@ -560,26 +562,26 @@ void AnycubicTFTClass::GetCommandFromTFT() {
switch (a_command) {
case 0: { // A0 GET HOTEND TEMP
const float hotendActualTemp = getActualTemp_celsius(E0);
SEND_PGM_VAL("A0V ", int(hotendActualTemp + 0.5));
const celsius_float_t hotendActualTemp = getActualTemp_celsius(E0);
SEND_PGM_VAL("A0V ", ROUND(hotendActualTemp));
}
break;
case 1: { // A1 GET HOTEND TARGET TEMP
const float hotendTargetTemp = getTargetTemp_celsius(E0);
SEND_PGM_VAL("A1V ", int(hotendTargetTemp + 0.5));
const celsius_float_t hotendTargetTemp = getTargetTemp_celsius(E0);
SEND_PGM_VAL("A1V ", ROUND(hotendTargetTemp));
}
break;
case 2: { // A2 GET HOTBED TEMP
const float heatedBedActualTemp = getActualTemp_celsius(BED);
SEND_PGM_VAL("A2V ", int(heatedBedActualTemp + 0.5));
const celsius_float_t heatedBedActualTemp = getActualTemp_celsius(BED);
SEND_PGM_VAL("A2V ", ROUND(heatedBedActualTemp));
}
break;
case 3: { // A3 GET HOTBED TARGET TEMP
const float heatedBedTargetTemp = getTargetTemp_celsius(BED);
SEND_PGM_VAL("A3V ", int(heatedBedTargetTemp + 0.5));
const celsius_float_t heatedBedTargetTemp = getTargetTemp_celsius(BED);
SEND_PGM_VAL("A3V ", ROUND(heatedBedTargetTemp));
} break;
case 4: { // A4 GET FAN SPEED

View File

@ -33,28 +33,28 @@
/**
* Formats a temperature string (e.g. "100°C")
*/
void format_temp(char *str, float t1) {
void format_temp(char *str, const_celsius_float_t t1) {
sprintf_P(str, PSTR("%3d" S_FMT), ROUND(t1), GET_TEXT(MSG_UNITS_C));
}
/**
* Formats a temperature string for an idle heater (e.g. "100 °C / idle")
*/
void format_temp_and_idle(char *str, float t1) {
void format_temp_and_idle(char *str, const_celsius_float_t t1) {
sprintf_P(str, PSTR("%3d" S_FMT " / " S_FMT), ROUND(t1), GET_TEXT(MSG_UNITS_C), GET_TEXT(MSG_IDLE));
}
/**
* Formats a temperature string for an active heater (e.g. "100 / 200°C")
*/
void format_temp_and_temp(char *str, float t1, float t2) {
void format_temp_and_temp(char *str, const_celsius_float_t t1, const_celsius_float_t t2) {
sprintf_P(str, PSTR("%3d / %3d" S_FMT), ROUND(t1), ROUND(t2), GET_TEXT(MSG_UNITS_C));
}
/**
* Formats a temperature string for a material (e.g. "100°C (PLA)")
*/
void format_temp_and_material(char *str, float t1, const char *material) {
void format_temp_and_material(char *str, const_celsius_float_t t1, const char *material) {
sprintf_P(str, PSTR("%3d" S_FMT " (" S_FMT ")"), ROUND(t1), GET_TEXT(MSG_UNITS_C), material);
}

View File

@ -21,9 +21,9 @@
#pragma once
void format_temp(char *str, float t1);
void format_temp_and_idle(char *str, float t1);
void format_temp_and_temp(char *str, float t1, float t2);
void format_temp_and_material(char *str, float t1, const char *material);
void format_temp(char *str, const_celsius_float_t t1);
void format_temp_and_idle(char *str, const_celsius_float_t t1);
void format_temp_and_temp(char *str, const_celsius_float_t t1, const_celsius_float_t t2);
void format_temp_and_material(char *str, const_celsius_float_t t1, const char *material);
void format_position(char *str, float p, uint8_t decimals = 1);
void format_position(char *str, float x, float y, float z);

View File

@ -595,8 +595,8 @@ void NextionTFT::PanelAction(uint8_t req) {
void NextionTFT::UpdateOnChange() {
const millis_t ms = millis();
static millis_t next_event_ms = 0;
static float last_degBed = 999, last_degHotend0 = 999, last_degHotend1 = 999,
last_degTargetBed = 999, last_degTargetHotend0 = 999, last_degTargetHotend1 = 999;
static celsius_float_t last_degBed = 999, last_degHotend0 = 999, last_degHotend1 = 999,
last_degTargetBed = 999, last_degTargetHotend0 = 999, last_degTargetHotend1 = 999;
// tmppage Temperature
if (!WITHIN(last_degHotend0 - getActualTemp_celsius(E0), -0.2, 0.2) || !WITHIN(last_degTargetHotend0 - getTargetTemp_celsius(E0), -0.5, 0.5)) {

View File

@ -263,7 +263,7 @@ namespace ExtUI {
#define GET_TEMP_ADJUSTMENT(A) A
#endif
float getActualTemp_celsius(const heater_t heater) {
celsius_float_t getActualTemp_celsius(const heater_t heater) {
switch (heater) {
#if ENABLED(HAS_HEATED_BED)
case BED: return GET_TEMP_ADJUSTMENT(thermalManager.degBed());
@ -275,11 +275,11 @@ namespace ExtUI {
}
}
float getActualTemp_celsius(const extruder_t extruder) {
celsius_float_t getActualTemp_celsius(const extruder_t extruder) {
return GET_TEMP_ADJUSTMENT(thermalManager.degHotend(extruder - E0));
}
float getTargetTemp_celsius(const heater_t heater) {
celsius_float_t getTargetTemp_celsius(const heater_t heater) {
switch (heater) {
#if ENABLED(HAS_HEATED_BED)
case BED: return GET_TEMP_ADJUSTMENT(thermalManager.degTargetBed());
@ -291,7 +291,7 @@ namespace ExtUI {
}
}
float getTargetTemp_celsius(const extruder_t extruder) {
celsius_float_t getTargetTemp_celsius(const extruder_t extruder) {
return GET_TEMP_ADJUSTMENT(thermalManager.degTargetHotend(extruder - E0));
}

View File

@ -109,10 +109,10 @@ namespace ExtUI {
void setTMCBumpSensitivity(const_float_t , const axis_t);
#endif
float getActualTemp_celsius(const heater_t);
float getActualTemp_celsius(const extruder_t);
float getTargetTemp_celsius(const heater_t);
float getTargetTemp_celsius(const extruder_t);
celsius_float_t getActualTemp_celsius(const heater_t);
celsius_float_t getActualTemp_celsius(const extruder_t);
celsius_float_t getTargetTemp_celsius(const heater_t);
celsius_float_t getTargetTemp_celsius(const extruder_t);
float getTargetFan_percent(const fan_t);
float getActualFan_percent(const fan_t);
float getAxisPosition_mm(const axis_t);