int16_t interpolate_i16(int16_t low_point_value, int16_t high_point_value, uint8_t range, int16_t difference){ //Note: limited ranges! Built for purpose. NOTE: difference parameter changed from int8_t to int16_t because of overflowing. return ( low_point_value + ( ( (high_point_value - low_point_value) * difference) / range ) ); } //NOTE: ATTINY44A #define INTERNAL_THERMOMETER_M40C_ADC_VALUE 230 #define INTERNAL_THERMOMETER_25C_ADC_VALUE 300 #define INTERNAL_THERMOMETER_85C_ADC_VALUE 370 #define INTERNAL_THERMOMETER_M40C_TEMPERATURE -40 #define INTERNAL_THERMOMETER_25C_TEMPERATURE 25 #define INTERNAL_THERMOMETER_85C_TEMPERATURE 85 int8_t measure_convert_return_internal_temperature_celsius_x1(){ //Function to measure convert and return temperature in celsius x1 format using internal diode thermometer. NOTE: ususable without EEPROM stored calibration to offset result. adc_set_refs_internal_1v1_bandgap(); //Switch reference selection to Internal 1V1 bandgap adc_ad_channel_switch(AD_CHANNEL_INTERNAL_THERMOMETER); //Switch AD channel to internal thermometer _delay_ms(1); //1ms settling time required before conversion! uint16_t adc_value = adc_read_ad_channel_ui16_noise_reduction(); //Get ADC value from function that does ADC noise reduction during conversion adc_set_refs_vcc(); //Switch reference selection back to VCC. Internal 1.1V bandgap reference is mainly used here if(adc_value