// do something... void dispatchCommand() { int commandNumber = atoi(commandBuffer); if (DEBUG) { Serial.print("command buffer is: "); Serial.println(commandBuffer); Serial.println("accumulated data:"); Serial.println(dataBuffer); } int dataAsInt; switch (commandNumber) { case CLEAR: clearLineHistory(); lcd.clear(); break; case ROW_ONE_TEXT: writeLine(1, dataBuffer); break; case ROW_TWO_TEXT: writeLine(2, dataBuffer); break; case PLACE_STRING: writeString(dataBuffer); break; case WRITE_ASCII: writeAscii(dataBuffer); break; case SCROLL_LEFT: dataAsInt = atoi(dataBuffer); dataAsInt > 0 ? dataAsInt : DEFAULT_SCROLL_DELAY; lcd.leftScroll(LINE_SIZE, dataAsInt > 0 ? dataAsInt : DEFAULT_SCROLL_DELAY); lcd.clear(); // should i or not? break; case SCROLL_UP: writeLine(1, lineHistory[2]); writeLine(2, dataBuffer); break; case MAKE_CHAR: recvCharData(); break; case SET_GAUGE: setGauge(); break; case SEND_CMD: lcd.commandWrite(atoi(dataBuffer)); break; case PRINT: lcd.print(atoi(dataBuffer)); break; case RESET: clearLineHistory(); resetGauges(); lcd.clear(); break; default: lcd.clear(); lcd.printIn("Undef'd Command"); } }
void logoScreen() { int copywrite[] = { 128,159,145,149,151,149,145,159 }; // (c) symbol defineCharacter(1, copywrite); // screen one. lcd.clear(); moveToChar(1,0); lcd.printIn("PerLCD v1.0"); moveToChar(2,0); lcd.print(1); lcd.printIn(" kevin montuori"); delay(2000); lcd.clear(); }
void setup() { // Init the WiServer with our sendPage function that we defined above Serial.begin(9200); Serial.println("Loading.."); // Output some bits and peices to screen lcd.init(); lcd.clear(); lcd.cursorTo(1,0); lcd.printIn("Wireless LCD Shield"); lcd.cursorTo(2,0); lcd.printIn("MilesBurton.com 2009"); lcd.cursorTo(3,0); lcd.printIn("Powered by WiShield"); lcd.cursorTo(4,0); lcd.printIn("Loading..."); // Initalise and connect Wifi WiServer.init(sendPage); // Confirm we're finished loading Serial.println("Finished loading..."); // Update the LCD lcd.cursorTo(4,0); lcd.printIn("Ready..."); }
/* * We'll have the WiServer call this function whenever a resource needs to be sent * @param URL null-terminated URL of the resource to send */ boolean sendPage(char* URL) { Serial.println(URL); // Request for the main page (checked last because other URL's also start with '/') if (strcmp(URL, "/") == 0) { WiServer.print("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">"); WiServer.print("<html xmlns=\"http://www.w3.org/1999/xhtml\" dir=\"ltr\" lang=\"en-gb\" xml:lang=\"en-gb\">"); WiServer.print("<head>"); WiServer.print("</head><body>"); WiServer.print("<script src=\"http://download.milesburton.com/Arduino/WiServer/htmlScript.js\" type=\"text/javascript\"></script>"); WiServer.print("</body></html>"); return true; } else{ // Consider a URL to be a request to output to a URL // Each forward slash represents a new line (4 lines max) int j = 1; // Start at char 1 of the URL (ignore the first /) lcd.clear(); // Clear LCD Serial.println("Writing to LCD"); int len = strlen(URL); // Loop through each line for(int i=1;i<5;i++) { Serial.print("Writing to line"); Serial.print(i); Serial.print('\n'); lcd.cursorTo(i,0); // Move to line // Read next page of URL for(j=j;j<len;j++) { if(((j+2)<=len) && URL[j]=='%' && URL[j+1]=='2' && URL[j+2]=='0') { lcd.print(' '); j+=2; continue; } if(URL[j]=='/') { j++; break; // If the current char is a /, break out read for the next line } lcd.print(URL[j]); // Write out char in URL to LCD Serial.print(URL[j]); // Send to Serial also } Serial.print('\n'); // Write a new line for easy reading } Serial.println("...Waiting for next command..."); return true; // Return 200 to page } }
void setup() { pinMode(13, OUTPUT); //we'll use the debug LED to output a heartbeat pinMode(sig, OUTPUT); lcd.init(); //optionally, now set up our application-specific display settings, overriding whatever the lcd did in lcd.init() //lcd.commandWrite(0x0F);//cursor on, display on, blink on. (nasty!) lcd.clear(); val = analogRead(potPin); sprintf(buffer,"%4d",val); lcd.printIn("Poti:"); lcd.cursorTo(1, 10); lcd.printIn(buffer); }
void lcd_init() { lcd.init(); lcd.clear(); }