Example |
#include <stdio.h>
#include "lib.h"
void main( void )
{
int ch, open, connected;
ComOpen( COM9 );
Sound(TSTANDARD, VHIGH, SMEDIUM, SHIGH, 0);
open = TRUE;
connected = FALSE;
for(;;)
{
if(connected != UsbIsConnected())
{
connected = UsbIsConnected();
Sound(TVLONG, VHIGH, connected ? SHIGH : SLOW, 0);
}
if((ch=getchar()) == TRIGGER_KEY)
{
if(!open)
{
Sound(TSTANDARD, VHIGH, SMEDIUM, SHIGH, 0);
ComOpen( COM9 );
open = TRUE;
}
else
{
PutCom2(COM9, 'X');
}
}
else if(ch == CLR_KEY && open)
{
ComClose(COM9);
Sound(TLONG, VHIGH, SERROR, 0);
connected = open = FALSE;
}
Idle();
}
}
|