#include "picsys18.h"

void
setup()
{
	pinMode(LED8, OUTPUT) ;
	pinMode(LED9, OUTPUT) ;
	digitalWrite(LED8, HIGH) ;
	digitalWrite(LED9, HIGH) ;

	CLCD_initDefault() ;

	USB_begin() ;
}

void loop()
{
	int c ;
	
	if (USB_attached()) {
		digitalWrite(LED9, LOW) ;

		if (USB_available()) {
			c = USB_getc() ;
			CLCD_putc(c) ;
			USB_putc(c) ;
			if (c == '\r') {
				CLCD_clear() ;
				USB_putc('\n') ;
			}	
		}
	
		digitalWrite(LED8, ((int)millis()) & 0x200) ;
	} else {
		digitalWrite(LED9, HIGH) ;
	}
}

