thermferm/devices.c

changeset 209
c5b1dfd83e81
parent 203
47e5109c7f53
child 212
a76cbe676bf1
equal deleted inserted replaced
208:934d45d9751d 209:c5b1dfd83e81
38 38
39 int dht11_pin = -1; 39 int dht11_pin = -1;
40 int dht11_temperature = -1; 40 int dht11_temperature = -1;
41 int dht11_humidity = -1; 41 int dht11_humidity = -1;
42 int dht11_valid = FALSE; 42 int dht11_valid = FALSE;
43 int dht11_t_offset = 0;
44 int dht11_h_offset = 0;
45 43
46 44
47 static uint8_t sizecvt(const int read_value) { 45 static uint8_t sizecvt(const int read_value) {
48 /* 46 /*
49 * digitalRead() and friends from wiringpi are defined as returning a value 47 * digitalRead() and friends from wiringpi are defined as returning a value
142 if ((j >= 40) && (dht11_dat[4] == ((dht11_dat[0] + dht11_dat[1] + dht11_dat[2] + dht11_dat[3]) & 0xFF))) { 140 if ((j >= 40) && (dht11_dat[4] == ((dht11_dat[0] + dht11_dat[1] + dht11_dat[2] + dht11_dat[3]) & 0xFF))) {
143 got_correct_data = 1; 141 got_correct_data = 1;
144 142
145 int h = dht11_dat[0] + dht11_dat[1]; 143 int h = dht11_dat[0] + dht11_dat[1];
146 int t = (dht11_dat[2] & 0x7F) + dht11_dat[3]; 144 int t = (dht11_dat[2] & 0x7F) + dht11_dat[3];
147 t += dht11_t_offset;
148 h += dht11_h_offset;
149 145
150 if ((dht11_dat[2] & 0x80) != 0) 146 if ((dht11_dat[2] & 0x80) != 0)
151 t *= -1; 147 t *= -1;
152 148
153 dht11_temperature = t; 149 dht11_temperature = t;

mercurial