-
Notifications
You must be signed in to change notification settings - Fork 1
/
stationPage.h
173 lines (156 loc) · 7.58 KB
/
stationPage.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
#ifndef stationPage_ino
#define stationPage_ino "Jan 2, 2021"
/*
*
* Converts the airport conditions stored as a integer to the airport condition String
* and for a bonus appends the wind conditions to the string
*
*
*/
static char metr_Retval[16];
char* metr_cond(unsigned short int airportnumber){
metr_Retval[0] = '\0';
// add metr condition
switch(mtrsf[airportnumber].mtrstat){
case UNKWN:
strcat( metr_Retval, "Not Reporting"); //"Unknown";
return metr_Retval;
break;
case VFR:
strcat( metr_Retval, "VFR");
break;
case MVFR:
strcat( metr_Retval, "MVFR");
break;
case LIFR:
strcat( metr_Retval, "LIFR");
break;
case IFR:
strcat( metr_Retval, "IFR");
break;
default:
strcat( metr_Retval, "????");
}
strcat( metr_Retval, " ");
strcat( metr_Retval, b2cs(mtrsf[airportnumber].mtrspeed)); // mtrspeed wind in knots
if( mtrsf[airportnumber].mtrgusts > mtrsf[airportnumber].mtrspeed) { // Display gust speed in button even if it is less then WIND_THRESHOLD
strcat( metr_Retval, " G");
strcat( metr_Retval, b2cs(mtrsf[airportnumber].mtrgusts));
}
strcat( metr_Retval, " kts");
return metr_Retval;
} //metrcnd(int)
/*
*
* Airport button page
* Button press identifies airport by flashing it's LED
*
*
* lEDButton()
*
*
*/
static const unsigned int lB_RetvalMax = (342 + RTMAXLN); // 342 + Raw Text maxlength
static char lB_Retval[lB_RetvalMax]; //[320]; //[275]; // note lighting "ϟϟ " adds 30 bytes "☇☇☇ " adds 44 bytes also allow for stations# > 99
char* lEDButton(byte airportnumber){ //unsigned short int airportnumber){
lB_Retval[0] = '\0';
strcat(lB_Retval, "<td><a style=\"color:");
strcat(lB_Retval, CRGBtoHex(leds[airportnumber])); //.c_str());
if( mtrsf[airportnumber].mtrgusts > WIND_THRESHOLD || mtrsf[airportnumber].mtrspeed > WIND_THRESHOLD) { // Yellow text is hard to read so shadow all around the chars
strcat(lB_Retval, ";text-shadow: -1px -1px #000000, 1px -1px #000000, -1px 1px #000000, 1px 1px #000000"); //; \">"; // +84 chars
}
strcat(lB_Retval, "; \">");
if(mtrsf[airportnumber].mtrlighting) strcat_P(lB_Retval, lightingSymb); // "⚡⚡ "); // "ϟϟ "); // +15 chars
strcat( lB_Retval, "<div class=\"tooltip\">");
strcat_P( lB_Retval, airports[airportnumber]); //.c_str());
if(mtrsf[airportnumber].mtrlighting) strcat_P( lB_Retval, lightingSymb ); //" ⚡⚡"); //" ϟϟ" ⚡ High Voltage (looks light a lighting bolt) // +15 chars
strcat( lB_Retval, "<span class=\"tooltiptext\">");
strncat( lB_Retval, mtrsf[airportnumber].rawText, RTMAXLN);
strcat( lB_Retval, "</span></div>");
strcat( lB_Retval, " <button ");
strcat( lB_Retval, " type=\"submit\" name='wxid' value='");
strcat( lB_Retval, b2cs(airportnumber));
strcat( lB_Retval, "' formmethod=\"get\">"); //?fname=value1&name2=value2 > \n";
// add metr condition
// mtrstat 1 VFR, 2 MVFR, 3 LIFR, 4 IFR 0 unknown 99 NULL maybe use leds[] color Green = VFR, Blue = MVFR, Magenta = LIFR, Red = IFR, Yellow = VFR+Wind, Black = unknown
strcat( lB_Retval, metr_cond(airportnumber) );
strcat( lB_Retval, " ");
strcat( lB_Retval, "</button>");
strcat( lB_Retval, "</a></td>\n");
return lB_Retval;
} // lEDButton(airportnumber)
/*
* Station Page (int)
* call with number of to display in the table of stations
*/
void stationPage(int columns){
// if(wxbusy) return;
Serial.print(F("Hello from Stations "));
Serial.print(columns); Serial.print(F(" x ")); Serial.print( (int) ceil(actualNumAirports / columns));
Serial.print(F("\tClient IP = ")); Serial.println(server.client().remoteIP().toString());
Serial.print(F("\tActual Num Airports = ")); Serial.print(actualNumAirports);
server.setContentLength(CONTENT_LENGTH_UNKNOWN);
server.send_P( 200, "text/html", htmlHeadStr);
server.sendContent_P(htmlReloadStr);
/* ***** Allready Pre loaded in htmlStr *****
* "<!DOCTYPE html> <html>\n"
* "<head>\n"
* "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, user-scalable=no\">\n"
* "<title>WX_Sectional</title>\n"
* "<script type=\"text/javascript\">setTimeout(\"location.reload()\",120000);</script>\n";
*/
server.sendContent(F("<style>html { font-family: Helvetica; display: inline-block; margin: 0px auto; text-align: center;}\n"
"table.center { margin-left:auto; margin-right:auto; }"
"table, th, td { border: 1px solid black; }\n"
"button {display: block;width: 180px;background-color: #34495e;border: none;color: white;padding: 13px 30px;text-decoration:"
"none;font-size: 15px; margin: 0px auto 25px;cursor: pointer;border-radius: 4px;}\n"
".tooltip {\n position: relative;\n display: inline-block;\n border-bottom: 1px\n dotted black;\n }\n"
".tooltip .tooltiptext {\n visibility: hidden;\n width: 180px;\n background-color: black;\n color: #fff;\n text-align: center;\n border-radius: 6px;\n padding: 5px 0;\n position: absolute;\n z-index: 1;\n bottom: 150%;\n left: 25%;\n margin-left: -60px;\n }\n"
".tooltip .tooltiptext::after {\n content: \"\";\n position: absolute;\n top: 100%;\n left: 50%;\n margin-left: -5px;\n border-width: 5px;\n border-style: solid;\n border-color: black transparent transparent transparent;\n }\n"
".tooltip:hover .tooltiptext {\n visibility: visible;\n }\n"
"</style>\n"
"</head>\n"
"<body>"
"<h1><a href=\"/\">ESP8266 WX_Sectional LED</a></h1>\n"
"<h3>"));
if(lightningLeds.size() > 0) server.sendContent_P(lightingSymb); // Display Lighting symbols in page header
server.sendContent(F(" Stations "));
if(lightningLeds.size() > 0) server.sendContent_P(lightingSymb); // Display Lighting symbols in page header
server.sendContent(F( "</h3>\n"
"<form action=\"/wxID\">\n"
"<table class=\"center\" border=\"3\">\n"
"\n<tr>"));
int row = 1; // int maxrow = 3; // iphone 3 macbook 8;
for(int i=0; i < NUM_AIRPORTS; i++){
if( mtrsf[i].mtrstat < NOTUSED ){ // 99 for NULL location skip it
server.sendContent(lEDButton(i));
row++;
if(row > columns){
row = 1;
server.sendContent(F("</tr>\n<tr>"));
}
} // else { Serial.print("Null station found "); Serial.println(i); }
};
server.sendContent(F("</tr>\n"
"</table>"
"</form>\n"
"</body>\n"
"</html>\n"));
server.client().stop();
#ifdef DEBUG
showFree(true);
#endif
return;
} // stationPage()
/*
* TODO create a jump page that determins screen size the call with option that cover width
*
*/
void stationPage0(){
stationPage((int) 999);
loop_time = loop_interval - 15;
}
void stationPage8x8() { stationPage((int) 8); } // For a Desktop large screen device
void stationPage4x16(){ stationPage((int) 4); } // For a Mobile device horz
void stationPage2x32(){ stationPage((int) 2); } // For a Mobile device vert
#endif