Ignore:
Timestamp:
08/13/12 16:55:07 (12 years ago)
Author:
boccone
Message:
new shutter page
File:
1 edited

Legend:

Unmodified
Added
Removed
  • firmware/ShutterController/ShutterController.ino

    r14357 r14359  
    1717#include "ShutterController.h"
    1818
    19 //#define USE_DHCP_FOR_IP_ADDRESS
     19#define USE_DHCP_FOR_IP_ADDRESS
    2020#define ENABLE_ETHERNET
    2121#define SAMPLES  100
     
    9494***********************************************************************************************************************/
    9595
    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
     97prog_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>";
     100PROGMEM const char *page_404[]               = { content_404 }; // table with 404 page
    99101
    100102// 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>";
     103const 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
     106const 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
     111const prog_char content_main_menu[]   PROGMEM = "<table width=\"500\"><tr><td align=\"center\"><a href=\"/\">Page 1</a></td></tr></table>";
     112const prog_char content_main_footer[] PROGMEM = "</body></html>";
    105113PGM_P contents_main[] PROGMEM = { content_main_header, content_main_top, content_main_menu, content_main_footer }; // table with 404 page
     114
    106115#define CONT_HEADER 0
    107116#define CONT_TOP 1
     
    111120
    112121// Page 1
    113 PROGMEM prog_char http_uri1[] = "/";
    114 PROGMEM prog_char content_title1[] = "<h2>Shutter Lid Control - Beta</h2>";
     122const PROGMEM prog_char http_uri1[] = "/";
     123const PROGMEM prog_char content_title1[] = "<h2>Shutter Lid Control - Beta</h2>";
    115124#ifdef DEBUG
    116 PROGMEM prog_char content_page1[] = "<hr /><form action=\"/__output__\" method=\"POST\">"
     125// To Be Fixed
     126const PROGMEM prog_char content_page1[] = "<hr /><form action=\"/__output__\" method=\"POST\">"
    117127    "<button name=\"Button1\" value=\"valueButton1\" type=\"submit\">Move Motor 1 OUT </button><p>"
    118128    "<button name=\"Button2\" value=\"valueButton2\" type=\"submit\">Move Motor 1 IN </button><p>"
     
    121131    "<button name=\"Button5\" value=\"valueButton5\" type=\"submit\">Open Lid</button><p>"
    122132    "<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>"
    124134    "</form></p>";
    125135#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>";
     136const 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>
    131143#endif
    132144
    133145// Page 5
    134 PROGMEM prog_char http_uri5[] = "/__output__";
    135 PROGMEM prog_char content_title5[] = "<h2>Shutter Lid Control - Beta</h2>";
     146
     147const PROGMEM prog_char http_uri5[] = "/__output__";
     148const PROGMEM prog_char content_title5[] = "<h2>Shutter Lid Control - Beta</h2>";
    136149#ifdef DEBUG
    137 PROGMEM prog_char content_page5[] = "<hr /><form action=\"/__output__\" method=\"POST\">"
     150// To Be Fixed
     151const PROGMEM prog_char content_page5[] = "<hr /><form action=\"/__output__\" method=\"POST\">"
    138152    "<button name=\"Button1\" value=\"valueButton1\" type=\"submit\">Move Motor 1 OUT </button><p>"
    139153    "<button name=\"Button2\" value=\"valueButton2\" type=\"submit\">Move Motor 1 IN </button><p>"
     
    147161    "received a POST request</p></form></p>";
    148162#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>";
     163const 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>
    156172#endif
    157173
     
    169185// They also show up in your bookmarked sites, on the tabs in tabbed browsers, and as the icon for Internet shortcuts
    170186// on your desktop or other folders in Windows.
    171 PROGMEM prog_char http_uri6[] = "/favicon.ico";    // favicon Request message
    172 
    173 PROGMEM prog_char content_image_header[] = "HTTP/1.1 200 OK\nServer: arduino\nContent-Length: \002\nContent-Type: image/\002\n\r\n";
     187const PROGMEM prog_char http_uri6[] = "/favicon.ico";    // favicon Request message
     188
     189const PROGMEM prog_char content_image_header[] = "HTTP/1.1 200 OK\nServer: arduino\nContent-Length: \002\nContent-Type: image/\002\n\r\n";
    174190
    175191#ifdef USE_ARDUINO_ICON
    176192
    177 PROGMEM prog_char content_favicon_data[] = {
     193const PROGMEM prog_char content_favicon_data[] = {
    178194             0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x10, 0x10, 0x10, 0x00, 0x01, 0x00, 0x04, 0x00, 0x28, 0x01, 0x00, 0x00, 0x16, 0x00,
    179195             0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x01, 0x00, 0x04, 0x00, 0x00, 0x00,
     
    195211#else
    196212
    197 PROGMEM prog_char content_favicon_data[] = {
     213const PROGMEM prog_char content_favicon_data[] = {
    198214             0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x10, 0x10, 0x10, 0x00, 0x01, 0x00, 0x04, 0x00, 0x28, 0x01, 0x00, 0x00, 0x16, 0x00,
    199215             0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x01, 0x00, 0x04, 0x00, 0x00, 0x00,
     
    218234PGM_P image_header PROGMEM = content_image_header;
    219235PGM_P data_for_images [] PROGMEM = { content_favicon_data}; // real data
    220 int   size_for_images [] PROGMEM = { sizeof(content_favicon_data)};
     236const int   size_for_images [] PROGMEM = { sizeof(content_favicon_data)};
    221237// declare table for all URIs
    222238PGM_P http_uris[] PROGMEM = { http_uri1, http_uri5, http_uri6 }; // URIs
     
    226242PGM_P image_header PROGMEM = NULL;
    227243PGM_P data_for_images [] PROGMEM = { }; // real data
    228 int   size_for_images [] PROGMEM = { };
     244const int   size_for_images [] PROGMEM = { };
    229245// declare table for all URIs
    230246PGM_P http_uris[] PROGMEM = { http_uri1, http_uri5 }; // URIs
     
    664680
    665681  // Append the data sent in the original HTTP request
    666   client.print("<br />");
     682  client.print("<br/>");
    667683  // send POST variables
    668684  client.print(requestContent);
     
    799815        Serial.println(" -> Case 1");
    800816#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>");
    811821        }
    812822        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>");
    817833       
    818834        }     
Note: See TracChangeset for help on using the changeset viewer.