local gearT = {
    [-1] = "R",
    [0] = "N",
    [1] = "1",
    [2] = "2",
    [3] = "3",
    [4] = "4",
    [5] = "5",
    [6] = "6",
    [7] = "7",
    [8] = "8"
    
}
local avg_fuel_per_km = 2.5

-- Make sure 'car.fuel' exists and is a valid number
local fuel = car.fuel or 0

-- Calculate the estimated range
local range_km = 0
if avg_fuel_per_km > 0 then
  range_km = fuel / avg_fuel_per_km
end


local white = rgb(1,1,1)
local orange = rgb(1,.2,0)

function update(dt)
    display.text({ text = string.format("%02d:%02d", sim.timeHours, sim.timeMinutes), pos = vec2(1011.5, 1350.7), letter = vec2(25, 60), font ='e92_big', color = white, alignment =0.9, width = 0, spacing = 1 })
    display.text({ text = math.floor(car.speedKmh/1.609344 ), pos = vec2(-90.8, 1815.3), letter = vec2(50, 100), font = 'c7_big', color = white, alignment =1, width = 255, spacing = -3})
    display.text({ text = string.format("%02d", car.distanceDrivenTotalKm ), pos = vec2(295, 1917), letter = vec2(17.5, 35), font = 'audi_vln_hd', color = white, alignment =1, width = 250, spacing = 1 })
    display.text({ text = string.format("%01d", car.distanceDrivenSessionKm),pos = vec2(308, 1946), letter = vec2(17.5, 35), font = 'audi_vln_hd', color = white, alignment =1, width = 250, spacing = 1 })
    display.text({ text = string.format("%02d", sim.ambientTemperature), pos = vec2(1304.6, 1350.3), letter = vec2(25, 60), font ='e92_big', color = white, alignment =0.0, width = 0, spacing =0 })
    display.text({ text = "F", pos = vec2(1364.6, 1350.3), letter = vec2(20, 60), font ='e92_big', color = white, alignment =0.0, width = 0, spacing =0 })
    display.text({ text = math.floor(car.fuel ), pos = vec2(1750, 1760), letter = vec2(25,50), font = 'audi_vln_hd', color = white, alignment =0.5, width = 255, spacing = 1})
    display.text({ text = gearT[car.gear], pos = vec2(645.6, 1538.1), letter = vec2(90, 180), font = 'c7_big', color = orange, alignment =0.5, width = 0, spacing = 1 })

   end



  
   