diff --git a/Marlin/src/HAL/AVR/HAL.h b/Marlin/src/HAL/AVR/HAL.h index e825b4def3af..c7454a523477 100644 --- a/Marlin/src/HAL/AVR/HAL.h +++ b/Marlin/src/HAL/AVR/HAL.h @@ -229,7 +229,7 @@ class MarlinHAL { SBI(DIDR0, ch); } - // Begin ADC sampling on the given channel + // Begin ADC sampling on the given channel. Called from Temperature::isr! static void adc_start(const uint8_t ch) { #ifdef MUX5 ADCSRB = ch > 7 ? _BV(MUX5) : 0; diff --git a/Marlin/src/HAL/DUE/HAL.h b/Marlin/src/HAL/DUE/HAL.h index 9a02c9a0dcf5..d00c4d3da102 100644 --- a/Marlin/src/HAL/DUE/HAL.h +++ b/Marlin/src/HAL/DUE/HAL.h @@ -209,7 +209,7 @@ class MarlinHAL { // Called by Temperature::init for each sensor at startup static void adc_enable(const uint8_t ch) {} - // Begin ADC sampling on the given channel + // Begin ADC sampling on the given channel. Called from Temperature::isr! static void adc_start(const uint8_t ch) { adc_result = analogRead(ch); } // Is the ADC ready for reading? diff --git a/Marlin/src/HAL/ESP32/HAL.cpp b/Marlin/src/HAL/ESP32/HAL.cpp index e204e0b6fe2b..767f65d341bc 100644 --- a/Marlin/src/HAL/ESP32/HAL.cpp +++ b/Marlin/src/HAL/ESP32/HAL.cpp @@ -244,7 +244,8 @@ void MarlinHAL::adc_start(const pin_t pin) { const adc1_channel_t chan = get_channel(pin); uint32_t mv; esp_adc_cal_get_voltage((adc_channel_t)chan, &characteristics[attenuations[chan]], &mv); - adc_result = mv * 1023.0f / float(ADC_REFERENCE_VOLTAGE) / 1000.0f; + + adc_result = mv * isr_float_t(1023) / isr_float_t(ADC_REFERENCE_VOLTAGE) / isr_float_t(1000); // Change the attenuation level based on the new reading adc_atten_t atten; diff --git a/Marlin/src/HAL/ESP32/HAL.h b/Marlin/src/HAL/ESP32/HAL.h index 8b26c3471d39..f7e4383a85f4 100644 --- a/Marlin/src/HAL/ESP32/HAL.h +++ b/Marlin/src/HAL/ESP32/HAL.h @@ -74,6 +74,7 @@ // Types // ------------------------ +typedef double isr_float_t; // FPU ops are used for single-precision, so use double for ISRs. typedef int16_t pin_t; class Servo; @@ -205,7 +206,7 @@ class MarlinHAL { // Called by Temperature::init for each sensor at startup static void adc_enable(const pin_t pin) {} - // Begin ADC sampling on the given channel + // Begin ADC sampling on the given pin. Called from Temperature::isr! static void adc_start(const pin_t pin); // Is the ADC ready for reading? diff --git a/Marlin/src/HAL/LPC1768/HAL.h b/Marlin/src/HAL/LPC1768/HAL.h index eefacae99549..0f26509129d5 100644 --- a/Marlin/src/HAL/LPC1768/HAL.h +++ b/Marlin/src/HAL/LPC1768/HAL.h @@ -234,7 +234,7 @@ class MarlinHAL { FilteredADC::enable_channel(pin); } - // Begin ADC sampling on the given pin + // Begin ADC sampling on the given pin. Called from Temperature::isr! static uint32_t adc_result; static void adc_start(const pin_t pin) { adc_result = FilteredADC::read(pin) >> (16 - HAL_ADC_RESOLUTION); // returns 16bit value, reduce to required bits diff --git a/Marlin/src/HAL/NATIVE_SIM/HAL.h b/Marlin/src/HAL/NATIVE_SIM/HAL.h index ee2e31fc7fa4..49a5b6ea560b 100644 --- a/Marlin/src/HAL/NATIVE_SIM/HAL.h +++ b/Marlin/src/HAL/NATIVE_SIM/HAL.h @@ -242,7 +242,7 @@ class MarlinHAL { // Called by Temperature::init for each sensor at startup static void adc_enable(const uint8_t ch); - // Begin ADC sampling on the given channel + // Begin ADC sampling on the given channel. Called from Temperature::isr! static void adc_start(const uint8_t ch); // Is the ADC ready for reading? diff --git a/Marlin/src/HAL/SAMD51/HAL.h b/Marlin/src/HAL/SAMD51/HAL.h index 3b09a885a53b..abcc28098776 100644 --- a/Marlin/src/HAL/SAMD51/HAL.h +++ b/Marlin/src/HAL/SAMD51/HAL.h @@ -190,7 +190,7 @@ class MarlinHAL { // Called by Temperature::init for each sensor at startup static void adc_enable(const uint8_t ch) {} - // Begin ADC sampling on the given channel + // Begin ADC sampling on the given pin. Called from Temperature::isr! static void adc_start(const pin_t pin); // Is the ADC ready for reading? diff --git a/Marlin/src/HAL/STM32/HAL.h b/Marlin/src/HAL/STM32/HAL.h index f5e8c1187da7..d88342b889b5 100644 --- a/Marlin/src/HAL/STM32/HAL.h +++ b/Marlin/src/HAL/STM32/HAL.h @@ -127,6 +127,8 @@ // Types // ------------------------ +typedef double isr_float_t; // FPU ops are used for single-precision, so use double for ISRs. + #ifdef STM32G0B1xx typedef int32_t pin_t; #else @@ -241,7 +243,7 @@ class MarlinHAL { // Called by Temperature::init for each sensor at startup static void adc_enable(const pin_t pin) { pinMode(pin, INPUT); } - // Begin ADC sampling on the given channel + // Begin ADC sampling on the given pin. Called from Temperature::isr! static void adc_start(const pin_t pin) { adc_result = analogRead(pin); } // Is the ADC ready for reading? diff --git a/Marlin/src/HAL/STM32F1/HAL.h b/Marlin/src/HAL/STM32F1/HAL.h index ceb17b48848b..a42dd89b8d27 100644 --- a/Marlin/src/HAL/STM32F1/HAL.h +++ b/Marlin/src/HAL/STM32F1/HAL.h @@ -280,7 +280,7 @@ class MarlinHAL { // Called by Temperature::init for each sensor at startup static void adc_enable(const pin_t pin) { pinMode(pin, INPUT_ANALOG); } - // Begin ADC sampling on the given channel + // Begin ADC sampling on the given pin. Called from Temperature::isr! static void adc_start(const pin_t pin); // Is the ADC ready for reading? diff --git a/Marlin/src/HAL/TEENSY31_32/HAL.h b/Marlin/src/HAL/TEENSY31_32/HAL.h index 50c0f411cf92..dc0d2d3fa939 100644 --- a/Marlin/src/HAL/TEENSY31_32/HAL.h +++ b/Marlin/src/HAL/TEENSY31_32/HAL.h @@ -166,7 +166,7 @@ class MarlinHAL { // Called by Temperature::init for each sensor at startup static void adc_enable(const pin_t ch) {} - // Begin ADC sampling on the given channel + // Begin ADC sampling on the given channel. Called from Temperature::isr! static void adc_start(const pin_t ch); // Is the ADC ready for reading? diff --git a/Marlin/src/HAL/TEENSY35_36/HAL.h b/Marlin/src/HAL/TEENSY35_36/HAL.h index e4c57f8d1e10..c45f2aa49307 100644 --- a/Marlin/src/HAL/TEENSY35_36/HAL.h +++ b/Marlin/src/HAL/TEENSY35_36/HAL.h @@ -173,7 +173,7 @@ class MarlinHAL { // Called by Temperature::init for each sensor at startup static void adc_enable(const pin_t) {} - // Begin ADC sampling on the given channel + // Begin ADC sampling on the given pin. Called from Temperature::isr! static void adc_start(const pin_t pin); // Is the ADC ready for reading? diff --git a/Marlin/src/HAL/TEENSY40_41/HAL.h b/Marlin/src/HAL/TEENSY40_41/HAL.h index a21e65285409..ea874da2faea 100644 --- a/Marlin/src/HAL/TEENSY40_41/HAL.h +++ b/Marlin/src/HAL/TEENSY40_41/HAL.h @@ -195,7 +195,7 @@ class MarlinHAL { // Called by Temperature::init for each sensor at startup static void adc_enable(const pin_t pin) {} - // Begin ADC sampling on the given channel + // Begin ADC sampling on the given pin. Called from Temperature::isr! static void adc_start(const pin_t pin); // Is the ADC ready for reading? diff --git a/Marlin/src/lcd/e3v2/marlinui/ui_status_480x272.cpp b/Marlin/src/lcd/e3v2/marlinui/ui_status_480x272.cpp index 2a4909d921b6..ba6814a57a10 100644 --- a/Marlin/src/lcd/e3v2/marlinui/ui_status_480x272.cpp +++ b/Marlin/src/lcd/e3v2/marlinui/ui_status_480x272.cpp @@ -196,13 +196,13 @@ FORCE_INLINE void _draw_heater_status(const heater_id_t heater, const uint16_t x #else #define HOTEND_STATS 1 #endif - static celsius_t old_temp[HOTEND_STATS] = ARRAY_N_1(HOTEND_STATS, 500), - old_target[HOTEND_STATS] = ARRAY_N_1(HOTEND_STATS, 500); - static bool old_on[HOTEND_STATS] = ARRAY_N_1(HOTEND_STATS, false); + static celsius_t old_temp[HOTEND_STATS] = { 0 }, + old_target[HOTEND_STATS] = { 0 }; + static bool old_on[HOTEND_STATS] = { false }; #endif #if HAS_HEATED_BED - static celsius_t old_bed_temp = 500, old_bed_target = 500; + static celsius_t old_bed_temp = 0, old_bed_target = 0; static bool old_bed_on = false; #if HAS_LEVELING static bool old_leveling_on = false;