|
@@ -71,11 +71,7 @@ __C_task void main(void)
|
|
|
if (1 == Flag.newTemp) {
|
|
|
Flag.newTemp = 0;
|
|
|
|
|
|
- if (Temperature < 0) {
|
|
|
- Display[0] = Sym_minus;
|
|
|
- } else {
|
|
|
- Display[0] = Sym_blank;
|
|
|
- }
|
|
|
+ Display[0] = Sym_blank;
|
|
|
Display[1] = IndctrNums[(0x0F & (Temperature>>4))];
|
|
|
Display[2] = IndctrNums[(0x0F & Temperature)];
|
|
|
Display[3] = Sym_gradus;
|
|
@@ -296,7 +292,6 @@ static void ds18b20_StartMeasure(void) {
|
|
|
|
|
|
static void ds18b20_ReadTemperature(void) {
|
|
|
uint8_t temperature[2];
|
|
|
- int8_t digit;
|
|
|
|
|
|
/* Reset, skip ROM and send command to read Scratchpad */
|
|
|
if (ds18b20_Reset() != 0) {
|
|
@@ -312,13 +307,22 @@ static void ds18b20_ReadTemperature(void) {
|
|
|
//ds18b20_reset();
|
|
|
|
|
|
/* Store temperature integer digits */
|
|
|
- digit=temperature[0]>>4;
|
|
|
- digit|=(temperature[1]&0x7)<<4;
|
|
|
+ Temperature = ((temperature[1]&0x7)<<4) | (temperature[0]>>4);
|
|
|
|
|
|
/* Get only integer part of temperature */
|
|
|
- Temperature = digit / 16;
|
|
|
+// Temperature = (int8_t)digit;
|
|
|
+
|
|
|
+ //выделяем с помощью битовой маски дробную часть
|
|
|
+ tempDecimals = (temperature[0] & 15);
|
|
|
+
|
|
|
+ //преобразуем в целое число
|
|
|
+ tempDecimals *= 10; //(tempDecimals << 1) + (tempDecimals << 3);// Умножаем на 10
|
|
|
+ tempDecimals >>= 4; //(tempDecimals >> 4);//делим на 16 или умножаем на 0.0625
|
|
|
+
|
|
|
+ if (tempDecimals > 4) {
|
|
|
+ Temperature ++;
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
Flag.newTemp = 1;
|
|
|
}
|
|
|
|