/* Calculate gas resistance from raw gas resitance value and gas range BME680 datasheet.  */
static uint32_t bme680_convert_gas(bme680_sensor_t *dev, uint16_t gas, uint8_t gas_range)
/* Calculate gas resistance from raw gas resitance value and gas range BME680 datasheet.  */
static uint32_t bme680_convert_gas(bme680_sensor_t *dev, uint16_t gas, uint8_t gas_range)
{
    if (!dev) return 0;
    bme680_calib_data_t* cd = &dev->calib_data;
    float var1 = (1340.0 + 5.0 * cd->range_sw_err) * lookup_table[gas_range][0];
    return var1 * lookup_table[gas_range][1] / (gas - 512.0 + var1);
}