예제 #1
0
void spyglassLcdInit(void)
{
	// LCD function set
	spyglassLcdWrite(0,LCD_FUNCTION_DEFAULT);
	// clear LCD
	spyglassLcdWrite(0,1<<LCD_CLR);
	delay(60000);	// wait 60ms
	// set entry mode
	spyglassLcdWrite(0,1<<LCD_ENTRY_MODE | 1<<LCD_ENTRY_INC);
	// set display to on
	spyglassLcdWrite(0,1<<LCD_ON_CTRL | 1<<LCD_ON_DISPLAY );
	// move cursor to home
	spyglassLcdWrite(0,1<<LCD_HOME);
	// set data address to 0
	spyglassLcdWrite(0,1<<LCD_DDRAM | 0x00);

	// set contrast
	spyglassSetLcdContrast(20);
}
예제 #2
0
void systickHandler(void)
{
	uint16_t tms;
	uint8_t ts,tm,th;
	uint8_t pb;

	// set timer for 10ms interval
	TCNT2 = (unsigned char)-TIMER_INTERVAL;
	// count up on uptime
	UptimeMs += 10;

	// if we at a 100ths millisecond interval, update the display
	if(!(UptimeMs % 100))
	{
		// redirect rprintf() output to spyglass LCD
		rprintfInit(spyglassLcdWriteChar);
		
		// print banner message
		spyglassLcdGotoXY(0,0);
		rprintfProgStrM("**** SpyglassUI ****");

		// read pushbuttons and take appropriate action
		pb = spyglassGetPushbuttons();
		spyglassLcdGotoXY(0,1);
		rprintf("Buttons:    ");
		rprintfNum(2,8,FALSE,'0',pb);

		if((pb & 0x01) && (Contrast < 255))
			Contrast++;
		if((pb & 0x02) && (Contrast > 0))
			Contrast--;
		if(pb & 0x08)
			spyglassSetLeds(0x01);
		if(pb & 0x10)
			spyglassSetLeds(0x02);
		
		// show display contrast
		spyglassLcdGotoXY(0,2);
		rprintf("LCD Contrast:    ");
		rprintfNum(10,3,FALSE,' ',Contrast);
		spyglassSetLcdContrast(Contrast);

		// show time
		tms = (UptimeMs)%1000;
		ts  = (UptimeMs/1000)%60;
		tm  = (UptimeMs/60000l)%60;
		th  = (UptimeMs/3600000l);
		spyglassLcdGotoXY(0,3);
		rprintf("Time:");
		rprintfNum(10,3,FALSE,' ',th);
		rprintfChar(':');
		rprintfNum(10,2,FALSE,'0',tm);
		rprintfChar(':');
		rprintfNum(10,2,FALSE,'0',ts);
		rprintfChar('.');
		rprintfNum(10,3,FALSE,'0',tms);
		rprintf("ms");
		
		// return rprintf() output to serial port
		rprintfInit(uartSendByte);
	}
}
예제 #3
0
void serviceLocal(void)
{
	int c;

	// a little command-prompt utility to play with the spyglass UI
	// all commands are single characters

	if( (c = uartGetByte()) != -1)
	{
		// echo command to terminal
		uartSendByte(c);
		// process command
		switch(c)
		{
		case 'i': spyglassLcdInit(); break;
		case 'h':
			rprintfInit(spyglassLcdWriteChar);
			spyglassLcdGotoXY(0,0);
			rprintf("*** HELLO WORLD  ***");
			rprintfInit(uartSendByte);
			break;
		case 'p':
			rprintf("Pushbutton State: 0x%x\r\n", spyglassGetPushbuttons());
			break;
		case '+': if(Contrast<255) Contrast++; rprintf("\r\nLCD Contrast: %d\r\n", Contrast); spyglassSetLcdContrast(Contrast); break;
		case '-': if(Contrast>0)   Contrast--; rprintf("\r\nLCD Contrast: %d\r\n", Contrast); spyglassSetLcdContrast(Contrast); break;
		case 'l': spyglassSetLeds(0x00); break;
		case 'L': spyglassSetLeds(0xFF); break;
		case 'b': spyglassSetBeeper(0); break;
		case 'B': spyglassSetBeeper(1); break;
		case 'x':
			i2cDeviceSearch();
			break;
		case '?':
			rprintfProgStrM("\r\n");
			rprintfProgStrM("--- Spyglass Commands: ---\r\n");
			rprintfProgStrM("(i) Initialize Spyglass LCD\r\n");
			rprintfProgStrM("(h) Print 'Hello World' message to Spyglass LCD\r\n");
			rprintfProgStrM("(p) Get Spyglass pushbutton state\r\n");
			rprintfProgStrM("(+) Increase contrast number (lightens contrast)\r\n");
			rprintfProgStrM("(-) Decrease contrast number (darkens contrast)\r\n");
			rprintfProgStrM("(l) Set Spyglass User LEDs to OFF\r\n");
			rprintfProgStrM("(L) Set Spyglass User LEDs to ON\r\n");
			rprintfProgStrM("(b) Set Spyglass beeper to OFF\r\n");
			rprintfProgStrM("(B) Set Spyglass beeper to ON\r\n");
			rprintfProgStrM("--- General Commands: ---\r\n");
			rprintfProgStrM("(x) Search for I2C devices on the bus\r\n");
			rprintfProgStrM("(?) Help\r\n");
			break;
		case '\r':
		default:
			break;
		}
		// print new prompt
		rprintfProgStrM("\r\ncmd>");
	}
}