// --------------------------------------------------------------------------------------------
// test the Smart-Its Output board

// --------------------------------------------------------------------------------------------
// last modified: 09.03.2003 

// --------------------------------------------------------------------------------------------
// COPYRIGHT (c) 2002, 2003 by Albrecht Schmidt - http://www.comp.lancs.ac.uk/~albrecht/
// Lancaster University, http://www.comp.lancs.ac.uk/
// 
// This program 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 2 of the License, or
// (at your option) any later version.
//
// This program 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.

// --------------------------------------------------------------------------------------------
// developed/improved for various prototypes 
// in the Smart-Its Project (http://www.smart-its.org) and
// in the Equator IRC (http://www.equator.ac.uk)

// --------------------------------------------------------------------------------------------
// compiled with
// CCS PCM C Compiler, Version 3.080

#include "core16.c" 
#include "outp_v1.c" 



#use rs232(baud=115200,xmit=PIN_C6,rcv=PIN_C7) 
main()
{
   int i;
   init_core();

   led_off();

   led_off1();

   i=0;
   
   restart_wdt();

   init_output_board(OUTPUT_OFF);

   while(1) {

   	restart_wdt();
	
	// switch them on one after another...
	for (i=1;i<5;i++){
		set_output(i, OUTPUT_ON);
		delay_ms(300);
		restart_wdt();
	}
	
	delay_ms(500);
	restart_wdt();
	
	// switch them off one after another...
	for (i=1;i<5;i++){
		set_output(i, OUTPUT_OFF);
		delay_ms(100);
		restart_wdt();
	}
	
	// show dimming...
	for (i=0;i<1000;i++){
		restart_wdt();
		set_output(1, OUTPUT_OFF);
		delay_ms(3);
		set_output(1, OUTPUT_ON);
		delay_ms(1);
	}
	
	for (i=0;i<1000;i++){
		restart_wdt();
		set_output(1, OUTPUT_OFF);
		delay_ms(2);
		set_output(1, OUTPUT_ON);
		delay_ms(2);
	}
	
	for (i=0;i<1000;i++){
		restart_wdt();
		set_output(1, OUTPUT_OFF);
		delay_ms(1);
		set_output(1, OUTPUT_ON);
		delay_ms(3);
	}
	
	set_output(1, OUTPUT_ON);
	
	led_on1();
	delay_ms(200);
	led_off1();		
   }
}