/* Pack two data bytes into single value and take into account sign bit.  */
static int16_t dht_convert_data(dht_sensor_type_t sensor_type, uint8_t msb, uint8_t lsb)
/* Pack two data bytes into single value and take into account sign bit.  */
static int16_t dht_convert_data(dht_sensor_type_t sensor_type, uint8_t msb, uint8_t lsb)
{
    int16_t data;
    if (sensor_type == DHT_TYPE_DHT22 || sensor_type == DHT_TYPE_SI7021) {
        data = msb & 0x7F;
        data <<= 8;
        data |= lsb;
        if (msb & BIT(7)) {
            data = 0 - data;
        }
    }
    else {
        data = msb * 10;
    }
    return data;
}