local function drawSpeed()
    setInterval(function ()
        currentSpeed = string.format("%3d", math.floor(car.speedKmh))
    end, 0.3, "key")

    clearInterval("key")

    display.text(
	{text = currentSpeed, 
	pos = vec2(29, 30), 
	letter = vec2(155, 180), 
	font = 'fonts/s2000', 
	color =  rgbm(128/255, 255/255, 150/255, 1), 
	width = 200, 
	spacing = -35, }
	)
end

local function drawOdo()
    display.text({
        text = string.format("%06d",car.distanceDrivenTotalKm),
        pos = vec2(55,235),
        letter = vec2(32,80),
        font = 'fonts/s2000_2',
        alignment = 1,
        width = 50,
        spacing = -2,
		color =  rgbm(128/255, 255/255, 150/255, 1), 
    })
end

local function drawOdoSession()
    display.text({
        text = string.format("%6.1f", car.distanceDrivenSessionKm),
        pos = vec2(235,235),
        letter = vec2(32,80),
        font = 'fonts/s2000_2',
        alignment = 0,
        width = -50,
        spacing = -3,
		color =  rgbm(128/255, 255/255, 150/255, 1), 
    })
end

local function drawTextTrip()
    display.text({
        text = "TRIP",
        pos = vec2(220,204),
        letter = vec2(27,50),
        font = 'fonts/bmw',
        alignment = 1,
        width = 60,
        spacing = -5,
		color =  rgbm(128/255, 255/255, 150/255, 1), 
    })
end

local function drawTextA()
    display.text({
        text = "A",
        pos = vec2(295 ,204),
        letter = vec2(27,50),
        font = 'fonts/bmw',
        alignment = 1,
        width = 60,
        spacing = -5,
		color =  rgbm(128/255, 255/255, 150/255, 1), 
    })
end

function script.update(dt)
    drawSpeed()
	drawOdo()
	drawOdoSession()
	drawTextTrip()
	drawTextA()
end