/* Calculate temperature from raw temperature value BME280 datasheet, page 50.  */
static int16_t bme680_convert_temperature(bme680_sensor_t *dev, uint32_t raw_temperature)
/* Calculate temperature from raw temperature value BME280 datasheet, page 50.  */
static int16_t bme680_convert_temperature(bme680_sensor_t *dev, uint32_t raw_temperature)
{
    if (!dev) return 0;
    bme680_calib_data_t* cd = &dev->calib_data;
    int64_t var1;
    int64_t var2;
    int16_t temperature;
    var1 = ((((raw_temperature >> 3) - ((int32_t)cd->par_t1 << 1))) *
            ((int32_t)cd->par_t2)) >> 11;
    var2 = (((((raw_temperature >> 4) - ((int32_t)cd->par_t1)) *
              ((raw_temperature >> 4) - ((int32_t)cd->par_t1))) >> 12) *
            ((int32_t)cd->par_t3)) >> 14;
    cd->t_fine = (int32_t)(var1 + var2);
    temperature = (cd->t_fine * 5 + 128) >> 8;
    return temperature;
}