6°A PIO IX TP1. Ejercicio 1. ALMADA, Santiago MAVER, Francisco
Dependencies: LinkedList
Diff: DS1820.cpp
- Revision:
- 10:d297ce9ce422
- Parent:
- 9:3821ca0b7f14
- Child:
- 11:1a3c3002b50c
--- a/DS1820.cpp Thu Jan 29 19:27:32 2015 +0000 +++ b/DS1820.cpp Fri Jan 30 11:07:10 2015 +0000 @@ -361,18 +361,16 @@ } answer = reading +0.0; // convert to floating point if ((FAMILY_CODE == FAMILY_CODE_DS18B20 ) || (FAMILY_CODE == FAMILY_CODE_DS1822 )) { - answer = answer / 8.0; + answer = answer / 16.0; } else { remaining_count = RAM[6]; count_per_degree = RAM[7]; - answer = answer - 0.25 + (count_per_degree - remaining_count) / count_per_degree; + answer = floor(answer/2.0) - 0.25 + (count_per_degree - remaining_count) / count_per_degree; } - if (scale=='C' or scale=='c') - answer = answer / 2.0; - else + if (scale=='F' or scale=='f') // Convert to deg F - answer = answer * 9.0 / 10.0 + 32.0; + answer = answer * 9.0 / 5.0 + 32.0; } return answer; }