52 TEMP_ZERO_OFFSET_CELCIUS = -15,
53 TEMP_ZERO_OFFSET_FAHRENHEIT = 0
56 #if defined( DOXYGEN )
57 static uint16_t temp_table_celcius[];
58 static uint16_t temp_table_fahrenheit[];
61 static uint16_t temp_table_celcius[] PROGMEM = {
62 923,917,911,904,898,891,883,876,868,860,851,843,834,825,815,
63 806,796,786,775,765,754,743,732,720,709,697,685,673,661,649,
64 636,624,611,599,586,574,562,549,537,524,512,500,488,476,464,
65 452,440,429,418,406,396,385,374,364,354,344,334,324,315,306,
66 297,288,279,271,263,255,247,240,233,225,219,212,205,199,193,
71 static uint16_t temp_table_fahrenheit[] PROGMEM = {
72 938, 935, 932, 929, 926, 923, 920, 916, 913, 909, 906, 902, 898,
73 894, 891, 887, 882, 878, 874, 870, 865, 861, 856, 851, 847, 842,
74 837, 832, 827, 822, 816, 811, 806, 800, 795, 789, 783, 778, 772,
75 766, 760, 754, 748, 742, 735, 729, 723, 716, 710, 703, 697, 690,
76 684, 677, 670, 663, 657, 650, 643, 636, 629, 622, 616, 609, 602,
77 595, 588, 581, 574, 567, 560, 553, 546, 539, 533, 526, 519, 512,
78 505, 498, 492, 485, 478, 472, 465, 459, 452, 446, 439, 433, 426,
79 420, 414, 408, 402, 396, 390, 384, 378, 372, 366, 360, 355, 349,
80 344, 338, 333, 327, 322, 317, 312, 307, 302, 297, 292, 287, 282,
81 277, 273, 268, 264, 259, 255, 251, 246, 242, 238, 234, 230, 226,
82 222, 219, 215, 211, 207, 204, 200, 197, 194, 190, 187,
102 static int find_temp(int16_t value, uint16_t* array,
int count);
116 DIDR0 |= (1 << ADC4D);
119 TEMP_DDR |= (1 << TEMP_BIT_PWR);
122 TEMP_PORT &= ~(1 << TEMP_BIT_PWR);
125 TEMP_DDR &= ~(1 << TEMP_BIT_IN);
126 TEMP_PORT &= ~(1 << TEMP_BIT_IN);
129 DIDR0 |= (1 << ADC2D);
130 TEMP_DDR &= ~(1 << 2);
131 TEMP_PORT &= ~(1 << 2);
181 TEMP_PORT |= (1 << TEMP_BIT_PWR);
184 adc_init(ADC_CHAN_ADC4, ADC_TRIG_FREE_RUN,
ADC_REF_AVCC, ADC_PS_128);
194 adc_init(ADC_CHAN_ADC2, ADC_TRIG_FREE_RUN,
ADC_REF_AVCC, ADC_PS_128);
207 TEMP_PORT &= ~(1 << TEMP_BIT_PWR);
210 if (unit == TEMP_UNIT_CELCIUS) {
211 temp = find_temp(res, temp_table_celcius,
sizeof(temp_table_celcius)/
sizeof(
int)) + TEMP_ZERO_OFFSET_CELCIUS;
213 temp = find_temp(res, temp_table_fahrenheit,
sizeof(temp_table_fahrenheit)/
sizeof(
int)) + TEMP_ZERO_OFFSET_FAHRENHEIT;
235 find_temp(int16_t value, uint16_t* array,
int count)
240 table_val = pgm_read_word(&array[i]);
241 if (table_val < value) {