Add whole-degree accessors, simplify some temperature-related features (#21685)

This commit is contained in:
Scott Lahteine
2021-04-23 20:19:23 -05:00
committed by GitHub
parent 384e09aa7c
commit c4620bb528
28 changed files with 144 additions and 139 deletions

View File

@ -40,9 +40,9 @@ PrinterEventLEDs printerEventLEDs;
uint8_t PrinterEventLEDs::old_intensity = 0;
inline uint8_t pel_intensity(const_float_t start, const_float_t current, const_float_t target) {
if (uint16_t(start) == uint16_t(target)) return 255;
return (uint8_t)map(constrain(current, start, target), start, target, 0.f, 255.f);
inline uint8_t pel_intensity(const celsius_t start, const celsius_t current, const celsius_t target) {
if (start == target) return 255;
return (uint8_t)map(constrain(current, start, target), start, target, 0, 255);
}
inline void pel_set_rgb(const uint8_t r, const uint8_t g, const uint8_t b) {
@ -58,7 +58,7 @@ PrinterEventLEDs printerEventLEDs;
#if HAS_TEMP_HOTEND
void PrinterEventLEDs::onHotendHeating(const_float_t start, const_float_t current, const_float_t target) {
void PrinterEventLEDs::onHotendHeating(const celsius_t start, const celsius_t current, const celsius_t target) {
const uint8_t blue = pel_intensity(start, current, target);
if (blue != old_intensity) {
old_intensity = blue;
@ -70,7 +70,7 @@ PrinterEventLEDs printerEventLEDs;
#if HAS_HEATED_BED
void PrinterEventLEDs::onBedHeating(const_float_t start, const_float_t current, const_float_t target) {
void PrinterEventLEDs::onBedHeating(const celsius_t start, const celsius_t current, const celsius_t target) {
const uint8_t red = pel_intensity(start, current, target);
if (red != old_intensity) {
old_intensity = red;
@ -82,7 +82,7 @@ PrinterEventLEDs printerEventLEDs;
#if HAS_HEATED_CHAMBER
void PrinterEventLEDs::onChamberHeating(const_float_t start, const_float_t current, const_float_t target) {
void PrinterEventLEDs::onChamberHeating(const celsius_t start, const celsius_t current, const celsius_t target) {
const uint8_t green = pel_intensity(start, current, target);
if (green != old_intensity) {
old_intensity = green;

View File

@ -41,21 +41,21 @@ private:
public:
#if HAS_TEMP_HOTEND
static inline LEDColor onHotendHeatingStart() { old_intensity = 0; return leds.get_color(); }
static void onHotendHeating(const_float_t start, const_float_t current, const_float_t target);
static void onHotendHeating(const celsius_t start, const celsius_t current, const celsius_t target);
#endif
#if HAS_HEATED_BED
static inline LEDColor onBedHeatingStart() { old_intensity = 127; return leds.get_color(); }
static void onBedHeating(const_float_t start, const_float_t current, const_float_t target);
static void onBedHeating(const celsius_t start, const celsius_t current, const celsius_t target);
#endif
#if HAS_HEATED_CHAMBER
static inline LEDColor onChamberHeatingStart() { old_intensity = 127; return leds.get_color(); }
static void onChamberHeating(const_float_t start, const_float_t current, const_float_t target);
static void onChamberHeating(const celsius_t start, const celsius_t current, const celsius_t target);
#endif
#if HAS_TEMP_HOTEND || HAS_HEATED_BED || HAS_HEATED_CHAMBER
static inline void onHeatingDone() { leds.set_white(); }
static inline void onHeatingDone() { leds.set_white(); }
static inline void onPidTuningDone(LEDColor c) { leds.set_color(c); }
#endif

View File

@ -36,10 +36,10 @@ void handle_status_leds() {
static millis_t next_status_led_update_ms = 0;
if (ELAPSED(millis(), next_status_led_update_ms)) {
next_status_led_update_ms += 500; // Update every 0.5s
float max_temp = TERN0(HAS_HEATED_BED, _MAX(thermalManager.degTargetBed(), thermalManager.degBed()));
celsius_t max_temp = TERN0(HAS_HEATED_BED, _MAX(thermalManager.degTargetBed(), thermalManager.wholeDegBed()));
HOTEND_LOOP()
max_temp = _MAX(max_temp, thermalManager.degHotend(e), thermalManager.degTargetHotend(e));
const int8_t new_red = (max_temp > 55.0) ? HIGH : (max_temp < 54.0 || old_red < 0) ? LOW : old_red;
max_temp = _MAX(max_temp, thermalManager.wholeDegHotend(e), thermalManager.degTargetHotend(e));
const int8_t new_red = (max_temp > 55) ? HIGH : (max_temp < 54 || old_red < 0) ? LOW : old_red;
if (new_red != old_red) {
old_red = new_red;
#if PIN_EXISTS(STAT_LED_RED)