Skip to content

Commit

Permalink
Status complete and working
Browse files Browse the repository at this point in the history
  • Loading branch information
lavielp committed Dec 29, 2013
1 parent 332d43b commit 601efea
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 12 deletions.
4 changes: 3 additions & 1 deletion GarageOpener.ino
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ void loop() {

if (c == '\n' && currentLineIsBlank) {
writeHTTPHeaders(client);
writeHTTPLEDPage(client);
//writeHTTPIndex(client);
//writeHTTPLEDPage(client);
writeHTTPLEDStatusPage(client);
break;
}

Expand Down
45 changes: 34 additions & 11 deletions WebPages.ino
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ void writeHTTPHeaders(EthernetClient &CL) {
}

void writeHTTPIndex(EthernetClient &CL){
CL.println("<!DOCTYPE html>");
CL.println("<html>");
CL.println("<head>");
CL.println("<title>Arduino Web Page</title>");
CL.println("</head>");
CL.println("<body>");
CL.println("<h1>Hello World!</h1>");
CL.println("<p>A web page from the arduino server</p>");
CL.println("<p>Using a seperate for the web page</p>");
CL.println("</body>");
CL.println("</html>");
CL.println("<!DOCTYPE html>");
CL.println("<html>");
CL.println("<head>");
CL.println("<title>Arduino Web Page</title>");
CL.println("</head>");
CL.println("<body>");
CL.println("<h1>Hello World!</h1>");
CL.println("<p>A web page from the arduino server</p>");
CL.println("<p>Using a seperate for the web page</p>");
CL.println("</body>");
CL.println("</html>");
}

void writeHTTPLEDPage(EthernetClient &CL) {
Expand All @@ -36,6 +36,21 @@ void writeHTTPLEDPage(EthernetClient &CL) {
CL.println("</html>");
}

void writeHTTPLEDStatusPage(EthernetClient &CL) {
CL.println("<!DOCTYPE html>");
CL.println("<html>");
CL.println("<head>");
CL.println("<title>Arduino Read Switch State</title>");
CL.println("<meta http-equiv=\"refresh\" content=\"1\">");
CL.println("</head>");
CL.println("<body>");
CL.println("<h1>Switch</h1>");
CL.println("<p>Switch state is: </p>");
getSwitchState(CL);
CL.println("</body>");
CL.println("</html>");
}

void processCheckbox(EthernetClient &CL) {
if(HTTP_req.indexOf("LED2=2") > -1) {
if (LED_status) {
Expand All @@ -53,3 +68,11 @@ void processCheckbox(EthernetClient &CL) {
CL.println("<input type=\"checkbox\" name=\"LED2\" value=\"2\" onclick=\"submit();\">LED2");
}
}

void getSwitchState(EthernetClient &CL) {
if (digitalRead(onOffSwitchPin)) {
CL.println("<p>ON</p>");
} else {
CL.println("<p>OFF</p>");
}
}

0 comments on commit 601efea

Please sign in to comment.