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>"); } }
void spyglassInit(void) { i2cInit(); i2cSetBitrate(100); PcfCtrlData = (SPYGLASS_LED0 | SPYGLASS_LED1 | SPYGLASS_BEEPER); spyglassSetLeds(0); spyglassSetBeeper(0); }