From adcf19a71cdc6477481630fbbb466a46b98c9c3e Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Fri, 21 May 2021 00:20:53 +0200 Subject: [PATCH 1/6] Remove confusing dead code, fix indentation --- Firmware/Marlin_main.cpp | 34 +++++++++------------------------- 1 file changed, 9 insertions(+), 25 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 31fe24bf32..6447931c75 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -9768,31 +9768,15 @@ static uint16_t nFSCheckCount=0; #ifdef PAT9125 fsensor_autoload_check_stop(); #endif //PAT9125 -//-// if (degHotend0() > EXTRUDE_MINTEMP) -if(0) - { - Sound_MakeCustom(50,1000,false); - loading_flag = true; - enquecommand_front_P((PSTR("M701"))); - } - else - { -/* - lcd_update_enable(false); - show_preheat_nozzle_warning(); - lcd_update_enable(true); -*/ - eFilamentAction=FilamentAction::AutoLoad; - bFilamentFirstRun=false; - if(target_temperature[0]>=EXTRUDE_MINTEMP){ - bFilamentPreheatState=true; -// mFilamentItem(target_temperature[0],target_temperature_bed); - menu_submenu(mFilamentItemForce); - } else { - menu_submenu(lcd_generic_preheat_menu); - lcd_timeoutToStatus.start(); - } - } + eFilamentAction=FilamentAction::AutoLoad; + bFilamentFirstRun=false; + if(target_temperature[0]>=EXTRUDE_MINTEMP){ + bFilamentPreheatState=true; + menu_submenu(mFilamentItemForce); + } else { + menu_submenu(lcd_generic_preheat_menu); + lcd_timeoutToStatus.start(); + } } } else From 6958d1926cceee403daa62b1a01249ce996ef2d4 Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Fri, 21 May 2021 00:41:11 +0200 Subject: [PATCH 2/6] Move IR sensor PCB checks into it's own function --- Firmware/Marlin_main.cpp | 89 +++++++++++++++++++++------------------- 1 file changed, 47 insertions(+), 42 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 6447931c75..b2437502dc 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -9702,15 +9702,56 @@ void manage_inactivity_IR_ANALOG_Check(uint16_t &nFSCheckCount, ClFsensorPCB isV nFSCheckCount = 0; } } + +void manage_inactivity_IR_ANALOG_CheckPCB() +{ + static uint16_t nFSCheckCount=0; + static uint16_t minVolt = Voltage2Raw(6.F), maxVolt = 0; + + // detect min-max, some long term sliding window for filtration may be added + // avoiding floating point operations, thus computing in raw + if( current_voltage_raw_IR > maxVolt )maxVolt = current_voltage_raw_IR; + if( current_voltage_raw_IR < minVolt )minVolt = current_voltage_raw_IR; + +#if 0 // Start: IR Sensor debug info + { // debug print + static uint16_t lastVolt = ~0U; + if( current_voltage_raw_IR != lastVolt ){ + printf_P(PSTR("fs volt=%4.2fV (min=%4.2f max=%4.2f)\n"), Raw2Voltage(current_voltage_raw_IR), Raw2Voltage(minVolt), Raw2Voltage(maxVolt) ); + lastVolt = current_voltage_raw_IR; + } + } +#endif // End: IR Sensor debug info + //! The trouble is, I can hold the filament in the hole in such a way, that it creates the exact voltage + //! to be detected as the new fsensor + //! We can either fake it by extending the detection window to a looooong time + //! or do some other countermeasures + + //! what we want to detect: + //! if minvolt gets below ~0.3V, it means there is an old fsensor + //! if maxvolt gets above 4.6V, it means we either have an old fsensor or broken cables/fsensor + //! So I'm waiting for a situation, when minVolt gets to range <0, 1.5> and maxVolt gets into range <3.0, 5> + //! If and only if minVolt is in range <0.3, 1.5> and maxVolt is in range <3.0, 4.6>, I'm considering a situation with the new fsensor + if( minVolt >= IRsensor_Ldiode_TRESHOLD && minVolt <= IRsensor_Lmax_TRESHOLD + && maxVolt >= IRsensor_Hmin_TRESHOLD && maxVolt <= IRsensor_Hopen_TRESHOLD + ){ + manage_inactivity_IR_ANALOG_Check(nFSCheckCount, ClFsensorPCB::_Old, ClFsensorPCB::_Rev04, _i("FS v0.4 or newer") ); ////MSG_FS_V_04_OR_NEWER c=18 + } + //! If and only if minVolt is in range <0.0, 0.3> and maxVolt is in range <4.6, 5.0V>, I'm considering a situation with the old fsensor + //! Note, we are not relying on one voltage here - getting just +5V can mean an old fsensor or a broken new sensor - that's why + //! we need to have both voltages detected correctly to allow switching back to the old fsensor. + else if( minVolt < IRsensor_Ldiode_TRESHOLD + && maxVolt > IRsensor_Hopen_TRESHOLD && maxVolt <= IRsensor_VMax_TRESHOLD + ){ + manage_inactivity_IR_ANALOG_Check(nFSCheckCount, ClFsensorPCB::_Rev04, oFsensorPCB=ClFsensorPCB::_Old, _i("FS v0.3 or older")); ////MSG_FS_V_03_OR_OLDER c=18 + } +} #endif void manage_inactivity(bool ignore_stepper_queue/*=false*/) //default argument set in Marlin.h { #ifdef FILAMENT_SENSOR -bool bInhibitFlag = false; -#ifdef IR_SENSOR_ANALOG -static uint16_t nFSCheckCount=0; -#endif // IR_SENSOR_ANALOG + bool bInhibitFlag = false; if (mmu_enabled == false) { @@ -9724,44 +9765,8 @@ static uint16_t nFSCheckCount=0; if (!moves_planned() && !IS_SD_PRINTING && !is_usb_printing && (lcd_commands_type != LcdCommands::Layer1Cal) && ! eeprom_read_byte((uint8_t*)EEPROM_WIZARD_ACTIVE)) { #ifdef IR_SENSOR_ANALOG - static uint16_t minVolt = Voltage2Raw(6.F), maxVolt = 0; - // detect min-max, some long term sliding window for filtration may be added - // avoiding floating point operations, thus computing in raw - if( current_voltage_raw_IR > maxVolt )maxVolt = current_voltage_raw_IR; - if( current_voltage_raw_IR < minVolt )minVolt = current_voltage_raw_IR; - -#if 0 // Start: IR Sensor debug info - { // debug print - static uint16_t lastVolt = ~0U; - if( current_voltage_raw_IR != lastVolt ){ - printf_P(PSTR("fs volt=%4.2fV (min=%4.2f max=%4.2f)\n"), Raw2Voltage(current_voltage_raw_IR), Raw2Voltage(minVolt), Raw2Voltage(maxVolt) ); - lastVolt = current_voltage_raw_IR; - } - } -#endif // End: IR Sensor debug info - //! The trouble is, I can hold the filament in the hole in such a way, that it creates the exact voltage - //! to be detected as the new fsensor - //! We can either fake it by extending the detection window to a looooong time - //! or do some other countermeasures - - //! what we want to detect: - //! if minvolt gets below ~0.3V, it means there is an old fsensor - //! if maxvolt gets above 4.6V, it means we either have an old fsensor or broken cables/fsensor - //! So I'm waiting for a situation, when minVolt gets to range <0, 1.5> and maxVolt gets into range <3.0, 5> - //! If and only if minVolt is in range <0.3, 1.5> and maxVolt is in range <3.0, 4.6>, I'm considering a situation with the new fsensor - if( minVolt >= IRsensor_Ldiode_TRESHOLD && minVolt <= IRsensor_Lmax_TRESHOLD - && maxVolt >= IRsensor_Hmin_TRESHOLD && maxVolt <= IRsensor_Hopen_TRESHOLD - ){ - manage_inactivity_IR_ANALOG_Check(nFSCheckCount, ClFsensorPCB::_Old, ClFsensorPCB::_Rev04, _i("FS v0.4 or newer") ); ////MSG_FS_V_04_OR_NEWER c=18 - } - //! If and only if minVolt is in range <0.0, 0.3> and maxVolt is in range <4.6, 5.0V>, I'm considering a situation with the old fsensor - //! Note, we are not relying on one voltage here - getting just +5V can mean an old fsensor or a broken new sensor - that's why - //! we need to have both voltages detected correctly to allow switching back to the old fsensor. - else if( minVolt < IRsensor_Ldiode_TRESHOLD - && maxVolt > IRsensor_Hopen_TRESHOLD && maxVolt <= IRsensor_VMax_TRESHOLD - ){ - manage_inactivity_IR_ANALOG_Check(nFSCheckCount, ClFsensorPCB::_Rev04, oFsensorPCB=ClFsensorPCB::_Old, _i("FS v0.3 or older")); ////MSG_FS_V_03_OR_OLDER c=18 - } + // Attempt to detect a change in the IR PCB version + manage_inactivity_IR_ANALOG_CheckPCB(); #endif // IR_SENSOR_ANALOG if (fsensor_check_autoload()) { From 1db73d7e5537a6ef19bca619df956af40706b17a Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Fri, 21 May 2021 00:44:06 +0200 Subject: [PATCH 3/6] Improve comments --- Firmware/Marlin_main.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index b2437502dc..65450d0295 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -9755,7 +9755,6 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) //default argument s if (mmu_enabled == false) { -//-// if (mcode_in_progress != 600) //M600 not in progress if (!PRINTER_ACTIVE) bInhibitFlag=(menu_menu==lcd_menu_show_sensors_state); //Block Filament sensor actions if PRINTER is not active and Support::SensorInfo menu active #ifdef IR_SENSOR_ANALOG bInhibitFlag=bInhibitFlag||bMenuFSDetect; // Block Filament sensor actions if Settings::HWsetup::FSdetect menu active @@ -9764,6 +9763,7 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) //default argument s { if (!moves_planned() && !IS_SD_PRINTING && !is_usb_printing && (lcd_commands_type != LcdCommands::Layer1Cal) && ! eeprom_read_byte((uint8_t*)EEPROM_WIZARD_ACTIVE)) { + // idling: housekeeping and autoload checks #ifdef IR_SENSOR_ANALOG // Attempt to detect a change in the IR PCB version manage_inactivity_IR_ANALOG_CheckPCB(); @@ -9786,6 +9786,7 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) //default argument s } else { + // printing: runout detection #ifdef PAT9125 fsensor_autoload_check_stop(); #endif //PAT9125 From 490be77ad4a0443b96dcad218a0f4e60793d1c94 Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Fri, 21 May 2021 15:50:05 +0200 Subject: [PATCH 4/6] Rewrite filament sensor PCB upgrade logic - Ensure the upgrade logic only runs if the previous PCB version is unknown or if an upgrade is actually possible. - Ensure the check only runs until a reliable detection can be made, then stop checking. - Ensure the detection doesn't run forever: limit the number of total autodetection attempts until the next FW reset. --- Firmware/Marlin_main.cpp | 73 ++++++++++++++++++++++++---------------- Firmware/fsensor.cpp | 5 +++ Firmware/fsensor.h | 9 +++-- Firmware/ultralcd.cpp | 1 + 4 files changed, 57 insertions(+), 31 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 65450d0295..d146ddc7d0 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -9679,34 +9679,15 @@ static void handleSafetyTimer() #endif //SAFETYTIMER #ifdef IR_SENSOR_ANALOG -#define FS_CHECK_COUNT 16 -/// Switching mechanism of the fsensor type. -/// Called from 2 spots which have a very similar behavior -/// 1: ClFsensorPCB::_Old -> ClFsensorPCB::_Rev04 and print _i("FS v0.4 or newer") -/// 2: ClFsensorPCB::_Rev04 -> oFsensorPCB=ClFsensorPCB::_Old and print _i("FS v0.3 or older") -void manage_inactivity_IR_ANALOG_Check(uint16_t &nFSCheckCount, ClFsensorPCB isVersion, ClFsensorPCB switchTo, const char *statusLineTxt_P) { - bool bTemp = (!CHECK_ALL_HEATERS); - bTemp = bTemp && (menu_menu == lcd_status_screen); - bTemp = bTemp && ((oFsensorPCB == isVersion) || (oFsensorPCB == ClFsensorPCB::_Undef)); - bTemp = bTemp && fsensor_enabled; - if (bTemp) { - nFSCheckCount++; - if (nFSCheckCount > FS_CHECK_COUNT) { - nFSCheckCount = 0; // not necessary - oFsensorPCB = switchTo; - eeprom_update_byte((uint8_t *)EEPROM_FSENSOR_PCB, (uint8_t)oFsensorPCB); - printf_IRSensorAnalogBoardChange(); - lcd_setstatuspgm(statusLineTxt_P); - } - } else { - nFSCheckCount = 0; - } -} - void manage_inactivity_IR_ANALOG_CheckPCB() { - static uint16_t nFSCheckCount=0; static uint16_t minVolt = Voltage2Raw(6.F), maxVolt = 0; + static ClFsensorPCB nFsensorPCB = oFsensorPCB; + static uint16_t nFSCheckCount = FS_CHECK_COUNT; + + // only attempt detection when cold and idling in the status screen + if (!fsensor_enabled || CHECK_ALL_HEATERS || menu_menu != lcd_status_screen) + return; // detect min-max, some long term sliding window for filtration may be added // avoiding floating point operations, thus computing in raw @@ -9722,10 +9703,13 @@ void manage_inactivity_IR_ANALOG_CheckPCB() } } #endif // End: IR Sensor debug info + //! The trouble is, I can hold the filament in the hole in such a way, that it creates the exact voltage //! to be detected as the new fsensor //! We can either fake it by extending the detection window to a looooong time //! or do some other countermeasures + ClFsensorPCB tempFsensorPCB; + const char *statusLineTxt_P; //! what we want to detect: //! if minvolt gets below ~0.3V, it means there is an old fsensor @@ -9735,7 +9719,8 @@ void manage_inactivity_IR_ANALOG_CheckPCB() if( minVolt >= IRsensor_Ldiode_TRESHOLD && minVolt <= IRsensor_Lmax_TRESHOLD && maxVolt >= IRsensor_Hmin_TRESHOLD && maxVolt <= IRsensor_Hopen_TRESHOLD ){ - manage_inactivity_IR_ANALOG_Check(nFSCheckCount, ClFsensorPCB::_Old, ClFsensorPCB::_Rev04, _i("FS v0.4 or newer") ); ////MSG_FS_V_04_OR_NEWER c=18 + tempFsensorPCB = ClFsensorPCB::_Rev04; + statusLineTxt_P = _i("FS v0.4 or newer"); ////MSG_FS_V_04_OR_NEWER c=18 } //! If and only if minVolt is in range <0.0, 0.3> and maxVolt is in range <4.6, 5.0V>, I'm considering a situation with the old fsensor //! Note, we are not relying on one voltage here - getting just +5V can mean an old fsensor or a broken new sensor - that's why @@ -9743,7 +9728,34 @@ void manage_inactivity_IR_ANALOG_CheckPCB() else if( minVolt < IRsensor_Ldiode_TRESHOLD && maxVolt > IRsensor_Hopen_TRESHOLD && maxVolt <= IRsensor_VMax_TRESHOLD ){ - manage_inactivity_IR_ANALOG_Check(nFSCheckCount, ClFsensorPCB::_Rev04, oFsensorPCB=ClFsensorPCB::_Old, _i("FS v0.3 or older")); ////MSG_FS_V_03_OR_OLDER c=18 + tempFsensorPCB = ClFsensorPCB::_Old; + statusLineTxt_P = _i("FS v0.3 or older"); ////MSG_FS_V_03_OR_OLDER c=18 + } + //! Ambiguous range + else + { + tempFsensorPCB = ClFsensorPCB::_Undef; + } + + if (tempFsensorPCB != ClFsensorPCB::_Undef) + { + --oFSCheckCount; + + if (tempFsensorPCB != nFsensorPCB) + { + // latest detection changed, reset internal counters + nFsensorPCB = tempFsensorPCB; + nFSCheckCount = FS_CHECK_COUNT; + } + else if(!--nFSCheckCount) + { + // consistent PCB match, set detected sensor type and stop attempts + oFSCheckCount = 0; + oFsensorPCB = tempFsensorPCB; + eeprom_update_byte((uint8_t *)EEPROM_FSENSOR_PCB, (uint8_t)oFsensorPCB); + printf_IRSensorAnalogBoardChange(); + lcd_setstatuspgm(statusLineTxt_P); + } } } #endif @@ -9765,8 +9777,11 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) //default argument s { // idling: housekeeping and autoload checks #ifdef IR_SENSOR_ANALOG - // Attempt to detect a change in the IR PCB version - manage_inactivity_IR_ANALOG_CheckPCB(); + if (oFSCheckCount) + { + // Attempt to detect an upgrade of the filament sensor PCB + manage_inactivity_IR_ANALOG_CheckPCB(); + } #endif // IR_SENSOR_ANALOG if (fsensor_check_autoload()) { diff --git a/Firmware/fsensor.cpp b/Firmware/fsensor.cpp index 4eac7bd08d..ec231c6543 100755 --- a/Firmware/fsensor.cpp +++ b/Firmware/fsensor.cpp @@ -123,6 +123,7 @@ uint16_t fsensor_oq_sh_sum; #ifdef IR_SENSOR_ANALOG ClFsensorPCB oFsensorPCB; ClFsensorActionNA oFsensorActionNA; +uint16_t oFSCheckCount = FS_CHECK_COUNT * 3; bool bIRsensorStateFlag=false; unsigned long nIRsensorLastTime; #endif //IR_SENSOR_ANALOG @@ -208,6 +209,10 @@ void fsensor_init(void) oFsensorPCB = (ClFsensorPCB)eeprom_read_byte((uint8_t*)EEPROM_FSENSOR_PCB); oFsensorActionNA = (ClFsensorActionNA)eeprom_read_byte((uint8_t*)EEPROM_FSENSOR_ACTION_NA); + // disable checking for PCB updates if already at the newest version + if(oFsensorPCB == ClFsensorPCB::_Newest) + oFSCheckCount = 0; + // If the fsensor is not responding even at the start of the printer, // set this flag accordingly to show N/A in Settings->Filament sensor. // This is even valid for both fsensor board revisions (0.3 or older and 0.4). diff --git a/Firmware/fsensor.h b/Firmware/fsensor.h index 7eb09ab8b5..d342a8544f 100755 --- a/Firmware/fsensor.h +++ b/Firmware/fsensor.h @@ -83,15 +83,20 @@ extern uint8_t fsensor_log; //! @} #endif //PAT9125 +#ifdef IR_SENSOR_ANALOG #define VOLT_DIV_REF 5 -#ifdef IR_SENSOR_ANALOG #define IR_SENSOR_STEADY 10 // [ms] +// number of required consistent consecutive filament sensor check attempts +#define FS_CHECK_COUNT 16 +// number of remaining filament sensor checks to be done +extern uint16_t oFSCheckCount; + enum class ClFsensorPCB:uint_least8_t { _Old=0, - _Rev04=1, + _Rev04=1, _Newest=1, _Undef=EEPROM_EMPTY_VALUE }; diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 02b9d30807..7c5f912fe4 100755 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -7327,6 +7327,7 @@ static bool lcd_selftest_IRsensor(bool bStandalone) } if((bPCBrev04 ? 1 : 0) != (uint8_t)oFsensorPCB){ // safer then "(uint8_t)bPCBrev04" oFsensorPCB=bPCBrev04 ? ClFsensorPCB::_Rev04 : ClFsensorPCB::_Old; + oFSCheckCount = 0; printf_IRSensorAnalogBoardChange(); eeprom_update_byte((uint8_t*)EEPROM_FSENSOR_PCB,(uint8_t)oFsensorPCB); } From 28cb62b3c9f58ed8afaeb183534bc58056cf7528 Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Fri, 21 May 2021 16:00:39 +0200 Subject: [PATCH 5/6] Add missing space in serial output --- Firmware/ultralcd.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 7c5f912fe4..60ca57a36e 100755 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -7301,7 +7301,7 @@ void lcd_belttest() #ifdef IR_SENSOR_ANALOG // called also from marlin_main.cpp void printf_IRSensorAnalogBoardChange(){ - printf_P(PSTR("Filament sensor board change detected: revision%S\n"), FsensorIRVersionText()); + printf_P(PSTR("Filament sensor board change detected: revision %S\n"), FsensorIRVersionText()); } static bool lcd_selftest_IRsensor(bool bStandalone) From f92019c2052d259a15eb5b7ee5781ee111cf504d Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Fri, 21 May 2021 16:25:20 +0200 Subject: [PATCH 6/6] Move adc refs/functions away from fsensor .. into temperature.* where the ADC conversion is currently performed. Fixes build on the MK3 variant. --- Firmware/fsensor.h | 10 ++-------- Firmware/temperature.h | 9 +++++++++ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/Firmware/fsensor.h b/Firmware/fsensor.h index d342a8544f..8df75fea08 100755 --- a/Firmware/fsensor.h +++ b/Firmware/fsensor.h @@ -84,8 +84,6 @@ extern uint8_t fsensor_log; #endif //PAT9125 #ifdef IR_SENSOR_ANALOG -#define VOLT_DIV_REF 5 - #define IR_SENSOR_STEADY 10 // [ms] // number of required consistent consecutive filament sensor check attempts @@ -112,12 +110,8 @@ extern ClFsensorActionNA oFsensorActionNA; extern const char* FsensorIRVersionText(); extern bool fsensor_IR_check(); -constexpr uint16_t Voltage2Raw(float V){ - return ( V * 1023 * OVERSAMPLENR / VOLT_DIV_REF ) + 0.5F; -} -constexpr float Raw2Voltage(uint16_t raw){ - return VOLT_DIV_REF*(raw / (1023.F * OVERSAMPLENR) ); -} + +#include "temperature.h" constexpr uint16_t IRsensor_Ldiode_TRESHOLD = Voltage2Raw(0.3F); // ~0.3V, raw value=982 constexpr uint16_t IRsensor_Lmax_TRESHOLD = Voltage2Raw(1.5F); // ~1.5V (0.3*Vcc), raw value=4910 constexpr uint16_t IRsensor_Hmin_TRESHOLD = Voltage2Raw(3.0F); // ~3.0V (0.6*Vcc), raw value=9821 diff --git a/Firmware/temperature.h b/Firmware/temperature.h index 0bf9447244..9e805b4ea3 100755 --- a/Firmware/temperature.h +++ b/Firmware/temperature.h @@ -42,6 +42,15 @@ #endif //SYSTEM_TIMER_2 +// voltage conversion functions +#define VOLT_DIV_REF 5 + +constexpr uint16_t Voltage2Raw(float V){ + return ( V * 1023 * OVERSAMPLENR / VOLT_DIV_REF ) + 0.5F; +} +constexpr float Raw2Voltage(uint16_t raw){ + return VOLT_DIV_REF*(raw / (1023.F * OVERSAMPLENR) ); +} // public functions void tp_init(); //initialize the heating