saved some bytes

This commit is contained in:
2019-05-08 11:05:36 +02:00
parent 63ff73a066
commit a109991e7a
10 changed files with 94 additions and 50 deletions

View File

@ -1,6 +1,6 @@
#include "dht11.h"
Dht11::Dht11(volatile unsigned char *port, volatile unsigned char *inPort, volatile unsigned char *port_ctl, const unsigned char pin): _port(port), _inPort(inPort), _port_ctl(port_ctl), _pin(pin)
Dht11::Dht11(volatile unsigned char * const port, volatile unsigned char * const inPort, volatile unsigned char * const port_ctl, const unsigned char pin): _port(port), _inPort(inPort), _port_ctl(port_ctl), _pin(pin)
{}
uint8_t Dht11::read()
@ -53,9 +53,7 @@ uint8_t Dht11::read()
}
else cnt--;
}
// WRITE TO RIGHT VARS
// as bits[1] and bits[3] are allways zero they are omitted in formulas.
uint8_t sum;
if constexpr(DHT22) sum= bits[0] + bits[1] + bits[2] + bits[3];
else sum = bits[1] + bits[3];