--[[
---------------------------------------------------------------------------
Remote Train Control Program for Windows

© Copyright 2019 by Mark DiVecchio

	This file is part of Remote Train Control.

	Remote Train Control is free software: you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation, either version 3 of the License, or
	(at your option) any later version.

	Remote Train Control is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with Remote Train Control.  If not, see <http://www.gnu.org/licenses/>.

 Home Page : http://www.silogic.com/trains/RTC_Running.html
---------------------------------------------------------------------------]]
-- Semicolons are not required in Lua code
title = "LED Test"

local SwitchCase = 0;

require("defines");
require("functions");
-- Counter Label
Counter01Label = "Switch Case";
--[[---------------------------------------------------------------------------------------]]
function setup(Engine, TIU)
	-- this function is called once when the [Run Script] button is pushed
	print("setup()");
	SetLED(1, clGreen, "Speed");	-- set status LED to green
	SetLED(2, clClear, "%");	-- set status LED to clear	
	SetLED(3, clRed, "Error");	-- set status LED to red		
	SetLED(4, clYellow, "Warning");	-- set status LED to yellow	
	return true;
end
--[[---------------------------------------------------------------------------------------]]
function loop()	-- parameters not used
	-- Always call Sleep() at least once in this function since it returns true;
	Sleep(0.1);
	SetCounter(COUNTER01, SwitchCase);
	-- cycle the LED through different colors and states
	if (SwitchCase == 0) then
		SwitchCase = 1;
		SetLED(1,clYellow);
		SetLED(2,clGreen);
		SetLED(3,clClear);
		SetLED(4,clRed);
		return true;
		end
	if (SwitchCase == 1) then
		SwitchCase = 2;
		SetLED(1,clRed);
		SetLED(2,clYellow);
		SetLED(3,clGreen);
		SetLED(4,clClear);
		return true;
		end
	if (SwitchCase == 2) then
		SwitchCase = 3;
		SetLED(1,clClear);
		SetLED(2,clRed);
		SetLED(3,clYellow);
		SetLED(4,clGreen);		
		return true;
		end
	if (SwitchCase == 3) then
		SwitchCase = 0;
		SetLED(1,clGreen);
		SetLED(2,clClear);
		SetLED(3,clRed);
		SetLED(4,clYellow);		
		return true;
		end	
	return true;
end
--[[---------------------------------------------------------------------------------------]]
function cleanup()
--
	SetLED(1, clClear);
	SetLED(2, clClear);
	SetLED(3, clClear);
	SetLED(4, clClear);
	print("Finished");

return true;
end
--[[---------------------------------------------------------------------------------------]]

