Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
co2ampel
ampel-firmware
Commits
082bc7a1
Commit
082bc7a1
authored
Apr 18, 2021
by
Eric Duminil
Browse files
More balanced html parts
parent
5911f3d9
Pipeline
#2834
passed with stage
in 1 minute and 37 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
ampel-firmware/web_server.cpp
View file @
082bc7a1
...
...
@@ -73,16 +73,15 @@ namespace web_server {
// Show a colored dot on the webpage, with a similar color than on LED Ring.
"hue=(1-(Math.min(Math.max(parseInt(document.title),500),1600)-500)/1100)*120;
\n
"
"document.getElementById('led').style.color=['hsl(',hue,',100%%,50%%)'].join('');
\n
"
"</script>
\n
"
);
body_template
=
PSTR
(
"<div class='pure-g'>
\n
"
"<div class='pure-u-1' id='graph'></div>
\n
"
// Graph placeholder
"</script>
\n
"
"<div class='pure-g'>
\n
"
"<div class='pure-u-1' id='graph'></div>
\n
"
// Graph placeholder
"</div>
\n
"
"<div class='pure-g'>
\n
"
//Sensor table
"<table id='table' class='pure-table-striped pure-u-1 pure-u-md-1-2'>
\n
"
"<tr><th colspan='2'>%s</th></tr>
\n
"
"<table id='table' class='pure-table-striped pure-u-1 pure-u-md-1-2'>
\n
"
);
body_template
=
PSTR
(
"<tr><th colspan='2'>%s</th></tr>
\n
"
"<tr><td>CO<sub>2</sub> concentration</td><td>%5d ppm</td></tr>
\n
"
"<tr><td>Temperature</td><td>%.1f℃</td></tr>
\n
"
"<tr><td>Humidity</td><td>%.1f%%</td></tr>
\n
"
...
...
@@ -211,9 +210,8 @@ namespace web_server {
//NOTE: Splitting in multiple parts in order to use less RAM
char
content
[
2000
];
// Update if needed
// Header size : 1
611
- Body size : 18
00
- Script size : 19
2
0
//
INFO -
Header size : 1
767
- Body size : 18
12
- Script size : 190
9
// Header
snprintf_P
(
content
,
sizeof
(
content
),
header_template
,
sensor
::
co2
,
SENSOR_ID
.
c_str
(),
WiFi
.
localIP
().
toString
().
c_str
()
#ifdef AMPEL_CSV
...
...
@@ -221,6 +219,8 @@ namespace web_server {
#endif
);
Serial
.
print
(
F
(
"INFO - Header size : "
));
Serial
.
print
(
strlen
(
content
));
http
.
setContentLength
(
CONTENT_LENGTH_UNKNOWN
);
http
.
send_P
(
200
,
PSTR
(
"text/html"
),
content
);
...
...
@@ -241,7 +241,9 @@ namespace web_server {
WiFi
.
localIP
().
toString
().
c_str
(),
WiFi
.
localIP
().
toString
().
c_str
(),
get_free_heap_size
(),
max_loop_duration
,
BOARD
,
dd
,
hh
,
mm
,
ss
);
Serial
.
print
(
F
(
" - Body size : "
));
http
.
sendContent
(
content
);
Serial
.
print
(
strlen
(
content
));
// Script
snprintf_P
(
content
,
sizeof
(
content
),
script_template
...
...
@@ -250,6 +252,8 @@ namespace web_server {
#endif
);
Serial
.
print
(
F
(
" - Script size : "
));
Serial
.
println
(
strlen
(
content
));
http
.
sendContent
(
content
);
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment