- Timestamp:
- 08/13/12 16:55:07 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
firmware/ShutterController/ShutterController.ino
r14357 r14359 17 17 #include "ShutterController.h" 18 18 19 //#define USE_DHCP_FOR_IP_ADDRESS19 #define USE_DHCP_FOR_IP_ADDRESS 20 20 #define ENABLE_ETHERNET 21 21 #define SAMPLES 100 … … 94 94 ***********************************************************************************************************************/ 95 95 96 // HTTP Request message 97 PROGMEM prog_char content_404[] = "HTTP/1.1 404 Not Found\nServer: arduino\nContent-Type: text/html\n\n<html><head><title>Arduino Web Server - Error 404</title></head><body><h1>Error 404: Sorry, that page cannot be found!</h1></body>"; 98 PGM_P page_404[] PROGMEM = { content_404 }; // table with 404 page 96 // HTTP Request message 97 prog_char content_404[] PROGMEM = "HTTP/1.1 404 Not Found\nServer: arduino\nContent-Type: text/html\n\n<html>" 98 "<head><title>Arduino Web Server - Error 404</title></head>" 99 "<body><h1>Error 404: Sorry, that page cannot be found!</h1></body>"; 100 PROGMEM const char *page_404[] = { content_404 }; // table with 404 page 99 101 100 102 // HTML Header for pages 101 PROGMEM prog_char content_main_header[] = "HTTP/1.0 200 OK\nServer: arduino\nCache-Control: no-store, no-cache, must-revalidate\nPragma: no-cache\nConnection: close\nContent-Type: text/html\n"; 102 PROGMEM prog_char content_main_top[] = "<html><head><meta http-equiv=\"refresh\" content=\"5\"><title>Arduino Web Server</title><style type=\"text/css\">table{border-collapse:collapse;}td{padding:0.25em 0.5em;border:0.5em solid #C8C8C8;}</style></head><body><h1>Arduino Web Server</h1>"; 103 PROGMEM prog_char content_main_menu[] = "<table width=\"500\"><tr><td align=\"center\"><a href=\"/\">Page 1</a></td></tr></table>"; 104 PROGMEM prog_char content_main_footer[] = "</body></html>"; 103 const prog_char content_main_header[] PROGMEM= "HTTP/1.0 200 OK\nServer: arduino\nCache-Control: no-store, no-cache, must-revalidate\n" 104 "Pragma: no-cache\nConnection: close\nContent-Type: text/html\n"; 105 106 const prog_char content_main_top[] PROGMEM = "<html><head><meta http-equiv=\"refresh\" content=\"5\"/><title>Arduino Web Server</title>" 107 "<style type=\"text/css\">table{border-collapse:collapse;}td{padding:0.25em 0.5em;border:0.5em solid #C8C8C8;}</style>" 108 "</head><body><h1>Arduino Web Server</h1>"; 109 110 111 const prog_char content_main_menu[] PROGMEM = "<table width=\"500\"><tr><td align=\"center\"><a href=\"/\">Page 1</a></td></tr></table>"; 112 const prog_char content_main_footer[] PROGMEM = "</body></html>"; 105 113 PGM_P contents_main[] PROGMEM = { content_main_header, content_main_top, content_main_menu, content_main_footer }; // table with 404 page 114 106 115 #define CONT_HEADER 0 107 116 #define CONT_TOP 1 … … 111 120 112 121 // Page 1 113 PROGMEM prog_char http_uri1[] = "/";114 PROGMEM prog_char content_title1[] = "<h2>Shutter Lid Control - Beta</h2>";122 const PROGMEM prog_char http_uri1[] = "/"; 123 const PROGMEM prog_char content_title1[] = "<h2>Shutter Lid Control - Beta</h2>"; 115 124 #ifdef DEBUG 116 PROGMEM prog_char content_page1[] = "<hr /><form action=\"/__output__\" method=\"POST\">" 125 // To Be Fixed 126 const PROGMEM prog_char content_page1[] = "<hr /><form action=\"/__output__\" method=\"POST\">" 117 127 "<button name=\"Button1\" value=\"valueButton1\" type=\"submit\">Move Motor 1 OUT </button><p>" 118 128 "<button name=\"Button2\" value=\"valueButton2\" type=\"submit\">Move Motor 1 IN </button><p>" … … 121 131 "<button name=\"Button5\" value=\"valueButton5\" type=\"submit\">Open Lid</button><p>" 122 132 "<button name=\"Button6\" value=\"valueButton6\" type=\"submit\">Close Lid</button><p>" 123 "Motor Current 1 = \ "\002\" A <p> Motor Current 2 = \"\002\" A <p> Hall Sensor 1 = \"\002\" ADC counts <p> Hall Sensor 2 = \"\002\"ADC counts<p>"133 "Motor Current 1 = \002 A <p> Motor Current 2 = \002 A <p> Hall Sensor 1 = \002 ADC counts <p> Hall Sensor 2 = \002 ADC counts<p>" 124 134 "</form></p>"; 125 135 #else 126 PROGMEM prog_char content_page1[] = "<hr /><form action=\"/__output__\" method=\"POST\">" 127 "<button name=\"Button5\" value=\"valueButton5\" type=\"submit\">Open Lid</button><p>" 128 "<button name=\"Button6\" value=\"valueButton6\" type=\"submit\">Close Lid</button><p>" 129 "Motor Current 1 = \"\002\" A <p> Motor Current 2 = \"\002\" A <p> Hall Sensor 1 = \"\002\" ADC counts <p> Hall Sensor 2 = \"\002\" ADC counts<p>" 130 "</form></p>"; 136 const PROGMEM prog_char content_page1[] = "<hr/><form action=\"/__output__\" method=\"POST\">" 137 "<button name=\"Button5\" value=\"valueButton5\" type=\"submit\">Open Lid</button><p/>" 138 "<button name=\"Button6\" value=\"valueButton6\" type=\"submit\">Close Lid</button><p/>" 139 "<span id=\"cur1\" value=\"\002\"> Motor Current 1 = \002 A </span><p/><span id=\"cur2\" value=\"\002\"> Motor Current 2 = \002 A </span><p/>" 140 "<span id=\"pos1\" value=\"\002\"> Hall Sensor 1 = \002 ADC ounts </span><p/><span id=\"pos2\" valus=\"\002\"> Hall Sensor 2 = \002 ADC counts</span><p/>" 141 "</form></p>"; 142 //<br/></body></html> 131 143 #endif 132 144 133 145 // Page 5 134 PROGMEM prog_char http_uri5[] = "/__output__"; 135 PROGMEM prog_char content_title5[] = "<h2>Shutter Lid Control - Beta</h2>"; 146 147 const PROGMEM prog_char http_uri5[] = "/__output__"; 148 const PROGMEM prog_char content_title5[] = "<h2>Shutter Lid Control - Beta</h2>"; 136 149 #ifdef DEBUG 137 PROGMEM prog_char content_page5[] = "<hr /><form action=\"/__output__\" method=\"POST\">" 150 // To Be Fixed 151 const PROGMEM prog_char content_page5[] = "<hr /><form action=\"/__output__\" method=\"POST\">" 138 152 "<button name=\"Button1\" value=\"valueButton1\" type=\"submit\">Move Motor 1 OUT </button><p>" 139 153 "<button name=\"Button2\" value=\"valueButton2\" type=\"submit\">Move Motor 1 IN </button><p>" … … 147 161 "received a POST request</p></form></p>"; 148 162 #else 149 PROGMEM prog_char content_page5[] = "<hr /><form action=\"/__output__\" method=\"POST\">" 150 "<button name=\"Button5\" value=\"valueButton5\" type=\"submit\">Open Lid</button><p>" 151 "<button name=\"Button6\" value=\"valueButton6\" type=\"submit\">Close Lid</button><p>" 152 "Motor Current 1 = \"\002\" A <p> Motor Current 2 = \"\002\" A <p> Hall Sensor 1 = \"\002\" ADC ounts <p> Hall Sensor 2 = \"\002\" ADC counts<p>" 153 "Lid 1 Status : \"\002\"<p>" 154 "Lid 2 Status : \"\002\"<p><p>" 155 "received a POST request</p></form></p>"; 163 const PROGMEM prog_char content_page5[] = "<hr/><form action=\"/__output__\" method=\"POST\">" 164 "<button name=\"Button5\" value=\"valueButton5\" type=\"submit\">Open Lid</button><p/>" 165 "<button name=\"Button6\" value=\"valueButton6\" type=\"submit\">Close Lid</button><p/>" 166 "<span id=\"cur1\" value=\"\002\"> Motor Current 1 = \002 A </span><p/><span id=\"cur2\" value=\"\002\"> Motor Current 2 = \002 A </span><p/>" 167 "<span id=\"pos1\" value=\"\002\"> Hall Sensor 1 = \002 ADC ounts </span><p/><span id=\"pos2\" value=\"\002\"> Hall Sensor 2 = \002 ADC counts</span><p/>" 168 "<span id=\"lid1\" value=\"\002\"> Lid 1 Status : \002</span><p/>" 169 "<span id=\"lid2\" value=\"\002\"> Lid 2 Status : \002</span><p/>" 170 "<p/>received a POST request</form><p/>"; 171 // <br/></body></html> 156 172 #endif 157 173 … … 169 185 // They also show up in your bookmarked sites, on the tabs in tabbed browsers, and as the icon for Internet shortcuts 170 186 // on your desktop or other folders in Windows. 171 PROGMEM prog_char http_uri6[] = "/favicon.ico"; // favicon Request message172 173 PROGMEM prog_char content_image_header[] = "HTTP/1.1 200 OK\nServer: arduino\nContent-Length: \002\nContent-Type: image/\002\n\r\n";187 const PROGMEM prog_char http_uri6[] = "/favicon.ico"; // favicon Request message 188 189 const PROGMEM prog_char content_image_header[] = "HTTP/1.1 200 OK\nServer: arduino\nContent-Length: \002\nContent-Type: image/\002\n\r\n"; 174 190 175 191 #ifdef USE_ARDUINO_ICON 176 192 177 PROGMEM prog_char content_favicon_data[] = {193 const PROGMEM prog_char content_favicon_data[] = { 178 194 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x10, 0x10, 0x10, 0x00, 0x01, 0x00, 0x04, 0x00, 0x28, 0x01, 0x00, 0x00, 0x16, 0x00, 179 195 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x01, 0x00, 0x04, 0x00, 0x00, 0x00, … … 195 211 #else 196 212 197 PROGMEM prog_char content_favicon_data[] = {213 const PROGMEM prog_char content_favicon_data[] = { 198 214 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x10, 0x10, 0x10, 0x00, 0x01, 0x00, 0x04, 0x00, 0x28, 0x01, 0x00, 0x00, 0x16, 0x00, 199 215 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x01, 0x00, 0x04, 0x00, 0x00, 0x00, … … 218 234 PGM_P image_header PROGMEM = content_image_header; 219 235 PGM_P data_for_images [] PROGMEM = { content_favicon_data}; // real data 220 int size_for_images [] PROGMEM = { sizeof(content_favicon_data)};236 const int size_for_images [] PROGMEM = { sizeof(content_favicon_data)}; 221 237 // declare table for all URIs 222 238 PGM_P http_uris[] PROGMEM = { http_uri1, http_uri5, http_uri6 }; // URIs … … 226 242 PGM_P image_header PROGMEM = NULL; 227 243 PGM_P data_for_images [] PROGMEM = { }; // real data 228 int size_for_images [] PROGMEM = { };244 const int size_for_images [] PROGMEM = { }; 229 245 // declare table for all URIs 230 246 PGM_P http_uris[] PROGMEM = { http_uri1, http_uri5 }; // URIs … … 664 680 665 681 // Append the data sent in the original HTTP request 666 client.print("<br 682 client.print("<br/>"); 667 683 // send POST variables 668 684 client.print(requestContent); … … 799 815 Serial.println(" -> Case 1"); 800 816 #endif 801 if (nSubstituteIndex < 2){ 802 client.print("<b>"); 803 client.print(_currentValue[nSubstituteIndex]); 804 client.print("</b>"); 805 } 806 else if ( (nSubstituteIndex >= 2) && 807 (nSubstituteIndex < 4) ) { 808 client.print("<b>"); 809 client.print(_sensorValue[nSubstituteIndex-2]); 810 client.print("</b>"); 817 if (nSubstituteIndex < 4){ 818 //client.print("<b>"); 819 client.print(_currentValue[nSubstituteIndex/2]); 820 //client.print("</b>"); 811 821 } 812 822 else if ( (nSubstituteIndex >= 4) && 813 (nSubstituteIndex < 6) ) { 814 client.print("<b>"); 815 client.print(_StatusLabel[_LidStatus[nSubstituteIndex-4]]); 816 client.print("</b>"); 823 (nSubstituteIndex < 8) ) { 824 //client.print("<b>"); 825 client.print(_sensorValue[nSubstituteIndex/2-2]); 826 //client.print("</b>"); 827 } 828 else if ( (nSubstituteIndex >= 8) && 829 (nSubstituteIndex < 12) ) { 830 //client.print("<b>"); 831 client.print(_StatusLabel[_LidStatus[nSubstituteIndex/2-4]]); 832 //client.print("</b>"); 817 833 818 834 }
Note:
See TracChangeset
for help on using the changeset viewer.