beautypg.com

Wavetronix Click 500 (programmable controller) (CLK-500) - Developer Guide User Manual

Page 104

background image

CHAPTER 9 • DIGITAL INPUT/OUTPUT 103

#GLOBAL_INIT
{
inputRawPrev[0] = INPUT_OFF;
inputRawPrev[1] = INPUT_OFF;
tickCounter[0] = 0;
tickCounter[1] = 0;
}

inputRawCurr[0] = ClickDioCheck(D1);
inputRawCurr[1] = ClickDioCheck(D2);

for (i=0; i<2; i++)
{
if (inputRawCurr[i] == inputRawPrev[i])
{
tickCounter[i]++;
}
else
{
tickCounter[i] = 0;
}
inputRawPrev[i] = inputRawCurr[i];
if (tickCounter[i] >= REQUIRED_ISR_TICK_COUNT)
{
if (i == 0) Input1Red = inputRawCurr[i];
if (i == 1) Input2Yellow = inputRawCurr[i];
}
}
}

void ChangeSignalLight( void )
{
switch (SignalLightState)
{
case RED_INDICATION:
SignalLightState = GREEN_INDICATION;
ClickDioSet(D1, 0);
ClickDioSet(D2, 0);
ClickLedOff(RED1);
ClickLedOff(YELLOW1);
ClickUtilTimerSet(&SignalLightTimer,
TIME_GREEN_MS);