108 * It is possible to have read errors or extreme values. |
108 * It is possible to have read errors or extreme values. |
109 * This can happen with bad connections so we compare the |
109 * This can happen with bad connections so we compare the |
110 * value with the previous one. If the difference is too |
110 * value with the previous one. If the difference is too |
111 * much, we don't send that value. That also means that if |
111 * much, we don't send that value. That also means that if |
112 * the next value is ok again, it will be marked invalid too. |
112 * the next value is ok again, it will be marked invalid too. |
113 * Maximum error is 20 degrees for now. |
113 * Maximum error is 40 degrees for now. |
114 */ |
114 */ |
115 deviation = 20000; |
115 deviation = 40000; |
116 if ((unit->air_temperature == 0) || |
116 if ((unit->air_temperature == 0) || |
117 (unit->air_temperature && (temp > (int)unit->air_temperature - deviation) && (temp < ((int)unit->air_temperature + deviation)))) { |
117 (unit->air_temperature && (temp > (int)unit->air_temperature - deviation) && (temp < ((int)unit->air_temperature + deviation)))) { |
118 unit->air_temperature = temp; |
118 unit->air_temperature = temp; |
119 unit->air_state = 0; |
119 unit->air_state = 0; |
120 } else { |
120 } else { |
133 break; |
133 break; |
134 |
134 |
135 if (unit->beer_address) { |
135 if (unit->beer_address) { |
136 rc = read_w1_28(unit->beer_address, &temp); |
136 rc = read_w1_28(unit->beer_address, &temp); |
137 if (rc == DEVPRESENT_YES) { |
137 if (rc == DEVPRESENT_YES) { |
138 deviation = 20000; |
138 deviation = 40000; |
139 if ((unit->beer_temperature == 0) || |
139 if ((unit->beer_temperature == 0) || |
140 (unit->beer_temperature && (temp > (int)unit->beer_temperature - deviation) && (temp < ((int)unit->beer_temperature + deviation)))) { |
140 (unit->beer_temperature && (temp > (int)unit->beer_temperature - deviation) && (temp < ((int)unit->beer_temperature + deviation)))) { |
141 unit->beer_temperature = temp; |
141 unit->beer_temperature = temp; |
142 unit->beer_state = 0; |
142 unit->beer_state = 0; |
143 } else { |
143 } else { |