/* * 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 } }
int defineCharacter(int ascii, int *data) { int baseAddress = (ascii * 8) + 64; lcd.commandWrite(baseAddress); for (int i = 0; i < 8; i++) lcd.print(data[i]); return ascii; }
// 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 printDebugChar(char someChar) { moveToChar(2, 15); lcd.print(someChar); }
void writeCharAt(int row, int col, char character) { moveToChar(row, col); lcd.print(character); }