-- This Source Code Form is subject to the terms of the bCDDL, v. 1.1.
-- If a copy of the bCDDL was not distributed with this
-- file, You can obtain one at http://beamng.com/bCDDL-1.1.txt

local M = {}

local function onInit()
 electrics.values.w166parSpeedoLow = 0
 electrics.values.w166parSpeedoHigh = 0
 electrics.values.w166parSpeedo = 0
end

local function updateGFX(dt)
electrics.values.w166parSpeedoLow = electrics.values.wheelspeed
electrics.values.w166parSpeedoHigh = 70 / 3.6 + (electrics.values.wheelspeed / 2)
 if electrics.values.wheelspeed < 140 / 3.6 then 
    electrics.values.w166parSpeedo = electrics.values.w166parSpeedoLow  
 else
    electrics.values.w166parSpeedo = electrics.values.w166parSpeedoHigh
 end	
end

-- public interface

M.onInit      = onInit
M.onReset     = onInit
M.updateGFX = updateGFX

return M
