Skip to content

Commit b8a45f5

Browse files
committed
CSS viewport
1 parent 5b3a35b commit b8a45f5

File tree

2 files changed

+16
-14
lines changed

2 files changed

+16
-14
lines changed

arduino-modbus-rtu-tcp-gateway/04-webserver.ino

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ void recvWeb(EthernetClient &client) {
155155

156156
// Do all actions before the "please wait" redirects (5s delay at the moment)
157157
if (reqPage == PAGE_WAIT) {
158+
delay(500); // wait for the wait page to load
158159
switch (action) {
159160
case ACT_WEB:
160161
for (byte s = 0; s < maxSockNum; s++) {

arduino-modbus-rtu-tcp-gateway/05-pages.ino

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,16 @@ void sendPage(EthernetClient &client, byte reqPage) {
4747
chunked.print(F("<!DOCTYPE html>"
4848
"<html>"
4949
"<head>"
50-
"<meta"));
50+
"<meta charset=utf-8>"
51+
"<meta name=viewport content='width=device-width"));
5152
if (reqPage == PAGE_WAIT) { // redirect to new IP and web port
52-
chunked.print(F(" http-equiv=refresh content=5;url=http://"));
53+
chunked.print(F("'>"
54+
"<meta http-equiv=refresh content='5; url=http://"));
5355
chunked.print(IPAddress(data.config.ip));
5456
chunked.print(F(":"));
5557
chunked.print(data.config.webPort);
5658
}
57-
chunked.print(F(">"
59+
chunked.print(F("'>"
5860
"<title>Modbus RTU &rArr; Modbus TCP/UDP Gateway</title>"
5961
"<style>"
6062
/*
@@ -66,10 +68,9 @@ void sendPage(EthernetClient &client, byte reqPage) {
6668
CSS Classes
6769
w - wrapper (includes m + c)
6870
m - navigation menu (left)
69-
c - wrapper for the content of a page (incl. smaller header)
70-
d - content of the page
71-
q - row inside a content (top aligned)
72-
r - row inside a content (center-aligned)
71+
c - wrapper for the content of a page (incl. smaller header and main)
72+
q - row inside a content (default: top-aligned)
73+
r - row inside a content (adds: center-aligned)
7374
i - short input (byte or IP address octet)
7475
n - input type=number
7576
s - select input with numbers
@@ -82,10 +83,10 @@ void sendPage(EthernetClient &client, byte reqPage) {
8283
"body,.w,.c,.q{display:flex}"
8384
"body,.c{flex-flow:column}"
8485
".w{flex-grow:1;min-height:0}"
85-
".m{flex:0 0 20vw;padding:1px}"
86+
".m{flex:0 0 20vw}"
8687
".c{flex:1}"
87-
".d{overflow:auto;padding:15px}"
88-
".q{padding:1px}"
88+
".m,main{overflow:auto;padding:15px}"
89+
".m,.q{padding:1px}"
8990
".r{align-items:center}"
9091
"h1,h4{padding:10px}"
9192
"h1,.m,h4{background:#0067AC;margin:1px}"
@@ -139,7 +140,7 @@ void sendPage(EthernetClient &client, byte reqPage) {
139140
"<h4>"));
140141
stringPageName(chunked, reqPage);
141142
chunked.print(F("</h4>"
142-
"<div class=d>"
143+
"<main>"
143144
"<form method=post>"));
144145

145146
// PLACE FUNCTIONS PROVIDING CONTENT HERE
@@ -173,7 +174,7 @@ void sendPage(EthernetClient &client, byte reqPage) {
173174
chunked.print(F("<p><div class=q><label><input type=submit value='Save & Apply'></label><input type=reset value=Cancel></div>"));
174175
}
175176
chunked.print(F("</form>"
176-
"</div>"));
177+
"</main>"));
177178
tagDivClose(chunked); // close tags <div class=c> <div class=w>
178179
chunked.end(); // closing tags not required </body></html>
179180
}
@@ -621,9 +622,9 @@ void tagLabelDiv(ChunkedPrint &chunked, const __FlashStringHelper *label) {
621622
tagLabelDiv(chunked, label, false);
622623
}
623624
void tagLabelDiv(ChunkedPrint &chunked, const __FlashStringHelper *label, bool top) {
624-
chunked.print(F("<div class=\"q"));
625+
chunked.print(F("<div class='q"));
625626
if (!top) chunked.print(F(" r"));
626-
chunked.print(F("\"><label> "));
627+
chunked.print(F("'><label> "));
627628
if (label) {
628629
chunked.print(label);
629630
chunked.print(F(":"));

0 commit comments

Comments
 (0)