local M = {}


local function onInit()
	timer2 = 0
	timer = 0
	timer3 = 0
	cycleStarting = 0
	cycleComplete = 0
    electrics.values["sdd_tour_tlight_running_1"] = 1
	electrics.values["sdd_tour_tlight_running_2"] = 1
    electrics.values["sdd_tour_tlight_running_3"] = 1
    electrics.values["sdd_tour_tlight_running_4"] = 1
    electrics.values["sdd_tour_tlight_running_5"] = 1
    electrics.values["sdd_tour_tlight_running_6"] = 1
    electrics.values["sdd_tour_tlight_running_7"] = 1
    electrics.values["sdd_tour_tlight_running_8"] = 1
    electrics.values["sdd_tour_tlight_running_9"] = 1
    electrics.values["sdd_tour_tlight_running_10"] = 1
    electrics.values["sdd_tour_tlight_running_11"] = 1
    electrics.values["sdd_tour_tlight_running_12"] = 1
    electrics.values["sdd_tour_tlight_running_13"] = 1
    electrics.values["sdd_tour_tlight_running_14"] = 1
	electrics.values["sdd_tour_tlight_running_15"] = 1
	electrics.values["sdd_tour_tlight_running_16"] = 1
	electrics.values["sdd_tour_tlight_running_17"] = 1
	electrics.values["sdd_tour_tlight_running_18"] = 1
	electrics.values["sdd_tour_tlight_running_19"] = 1
	electrics.values["sdd_tour_tlight_running_20"] = 1
	electrics.values["sdd_tour_tlight_running_21"] = 1
	electrics.values["sdd_tour_tlight_running_22"] = 1
	electrics.values["sdd_tour_tlight_running_23"] = 1
end

local function onReset()
	timer2 = 0
	timer = 0
	timer3 = 0
	cycleStarting = 0
	cycleComplete = 0
--Running light starting sequence
    electrics.values["sdd_tour_tlight_running_1"] = 1
	electrics.values["sdd_tour_tlight_running_2"] = 1
    electrics.values["sdd_tour_tlight_running_3"] = 1
    electrics.values["sdd_tour_tlight_running_4"] = 1
    electrics.values["sdd_tour_tlight_running_5"] = 1
    electrics.values["sdd_tour_tlight_running_6"] = 1
    electrics.values["sdd_tour_tlight_running_7"] = 1
    electrics.values["sdd_tour_tlight_running_8"] = 1
    electrics.values["sdd_tour_tlight_running_9"] = 1
    electrics.values["sdd_tour_tlight_running_10"] = 1
    electrics.values["sdd_tour_tlight_running_11"] = 1
    electrics.values["sdd_tour_tlight_running_12"] = 1
    electrics.values["sdd_tour_tlight_running_13"] = 1
    electrics.values["sdd_tour_tlight_running_14"] = 1
	   electrics.values["sdd_tour_tlight_running_15"] = 1
	   electrics.values["sdd_tour_tlight_running_16"] = 1
	   electrics.values["sdd_tour_tlight_running_17"] = 1
	   electrics.values["sdd_tour_tlight_running_18"] = 1
	   electrics.values["sdd_tour_tlight_running_19"] = 1
	   electrics.values["sdd_tour_tlight_running_20"] = 1
	   electrics.values["sdd_tour_tlight_running_21"] = 1
	   electrics.values["sdd_tour_tlight_running_22"] = 1
	    electrics.values["sdd_tour_tlight_running_23"] = 1
end

local function updateGFX(dt) 
 --Startup sequence for running lights

  if electrics.values["lowhighbeam"] == 0 and cycleStarting == 0 then
	cycleStarting = 1
	cycleComplete = 0
  elseif electrics.values["lowhighbeam"] ==  1 and cycleStarting == 1 then
	timer3 = timer3 + dt
	
	if timer3 >= 0.043 then
            electrics.values["sdd_tour_tlight_running_1"] = 1
        end
        if timer3 >= 0.086 then
            electrics.values["sdd_tour_tlight_running_2"] = 1
        end
        if timer3 >= 0.129 then
            electrics.values["sdd_tour_tlight_running_3"] = 1
        end
        if timer3 >= 0.172 then
            electrics.values["sdd_tour_tlight_running_4"] = 1
        end
        if timer3 >= 0.215 then
            electrics.values["sdd_tour_tlight_running_5"] = 1
        end
        if timer3 >= 0.258 then
            electrics.values["sdd_tour_tlight_running_6"] = 1
        end
        if timer3 >= 0.301 then
            electrics.values["sdd_tour_tlight_running_7"] = 1
        end
        if timer3 >= 0.344 then
            electrics.values["sdd_tour_tlight_running_8"] = 1
        end
        if timer3 >= 0.387 then
            electrics.values["sdd_tour_tlight_running_9"] = 1
        end
        if timer3 >= 0.430 then
            electrics.values["sdd_tour_tlight_running_10"] = 1
        end
        if timer3 >= 0.473 then
            electrics.values["sdd_tour_tlight_running_11"] = 1
        end
        if timer3 >= 0.516 then
            electrics.values["sdd_tour_tlight_running_12"] = 1
        end
        if timer3 >= 0.559 then
            electrics.values["sdd_tour_tlight_running_13"] = 1
        end
        if timer3 >= 0.602 then
            electrics.values["sdd_tour_tlight_running_14"] = 1
        end
        if timer3 >= 0.645 then
            electrics.values["sdd_tour_tlight_running_15"] = 1
        end
        if timer3 >= 0.688 then
            electrics.values["sdd_tour_tlight_running_16"] = 1
        end
        if timer3 >= 0.731 then
            electrics.values["sdd_tour_tlight_running_17"] = 1
        end
        if timer3 >= 0.774 then
            electrics.values["sdd_tour_tlight_running_18"] = 1
        end
        if timer3 >= 0.817 then
            electrics.values["sdd_tour_tlight_running_19"] = 1
        end
        if timer3 >= 0.860 then
            electrics.values["sdd_tour_tlight_running_20"] = 1
        end
        if timer3 >= 0.903 then
            electrics.values["sdd_tour_tlight_running_21"] = 1
        end
        if timer3 >= 0.946 then
            electrics.values["sdd_tour_tlight_running_22"] = 1
        end
        if timer3 >= 0.999 then
            electrics.values["sdd_tour_tlight_running_23"] = 1
	cycleStarting = 0
	timer3 = 0
	cycleComplete = 1
	end
  end

  if electrics.values["lowhighbeam"] == 1 and cycleComplete == 1 then
    electrics.values["sdd_tour_tlight_running_1"] = 1
	electrics.values["sdd_tour_tlight_running_2"] = 1
    electrics.values["sdd_tour_tlight_running_3"] = 1
    electrics.values["sdd_tour_tlight_running_4"] = 1
    electrics.values["sdd_tour_tlight_running_5"] = 1
    electrics.values["sdd_tour_tlight_running_6"] = 1
    electrics.values["sdd_tour_tlight_running_7"] = 1
    electrics.values["sdd_tour_tlight_running_8"] = 1
    electrics.values["sdd_tour_tlight_running_9"] = 1
    electrics.values["sdd_tour_tlight_running_10"] = 1
    electrics.values["sdd_tour_tlight_running_11"] = 1
    electrics.values["sdd_tour_tlight_running_12"] = 1
    electrics.values["sdd_tour_tlight_running_13"] = 1
    electrics.values["sdd_tour_tlight_running_14"] = 1
	electrics.values["sdd_tour_tlight_running_15"] = 1
	electrics.values["sdd_tour_tlight_running_16"] = 1
	electrics.values["sdd_tour_tlight_running_17"] = 1
	electrics.values["sdd_tour_tlight_running_18"] = 1
	electrics.values["sdd_tour_tlight_running_19"] = 1
	electrics.values["sdd_tour_tlight_running_20"] = 1
	electrics.values["sdd_tour_tlight_running_21"] = 1
	electrics.values["sdd_tour_tlight_running_22"] = 1
	electrics.values["sdd_tour_tlight_running_23"] = 1
  elseif electrics.values["lowhighbeam"] == 0 and cycleComplete == 0 then
    electrics.values["sdd_tour_tlight_running_1"] = 0
	electrics.values["sdd_tour_tlight_running_2"] = 0
    electrics.values["sdd_tour_tlight_running_3"] = 0
    electrics.values["sdd_tour_tlight_running_4"] = 0
    electrics.values["sdd_tour_tlight_running_5"] = 0
    electrics.values["sdd_tour_tlight_running_6"] = 0
    electrics.values["sdd_tour_tlight_running_7"] = 0
    electrics.values["sdd_tour_tlight_running_8"] = 0
    electrics.values["sdd_tour_tlight_running_9"] = 0
    electrics.values["sdd_tour_tlight_running_10"] = 0
    electrics.values["sdd_tour_tlight_running_11"] = 0
    electrics.values["sdd_tour_tlight_running_12"] = 0
    electrics.values["sdd_tour_tlight_running_13"] = 0
    electrics.values["sdd_tour_tlight_running_14"] = 0
	   electrics.values["sdd_tour_tlight_running_15"] = 0
	   	electrics.values["sdd_tour_tlight_running_16"] = 0
	electrics.values["sdd_tour_tlight_running_17"] = 0
	electrics.values["sdd_tour_tlight_running_18"] = 0
	electrics.values["sdd_tour_tlight_running_19"] = 0
	electrics.values["sdd_tour_tlight_running_20"] = 0
	electrics.values["sdd_tour_tlight_running_21"] = 0
	electrics.values["sdd_tour_tlight_running_22"] = 0
	electrics.values["sdd_tour_tlight_running_23"] = 0
  end
end

-- public interface
M.onInit = onInit
M.onReset = onReset
M.updateGFX = updateGFX

return M