Optimized template

This commit is contained in:
Kevin Veen-Birkenbach 2020-05-11 14:37:53 +02:00
parent cb3644b514
commit 022ebabe67
3 changed files with 41 additions and 61 deletions

View File

@ -24,6 +24,7 @@ The following links can be helpful for maintaining this code and understanding t
##### Transistor
- https://www.elektronik-kompendium.de/sites/bau/0201291.htm
- https://components101.com/transistors/s8050-transistor-pinout-equivalent-datasheet
- https://cdn-reichelt.de/documents/datenblatt/A100/PN2222A-FSC.pdf
##### IR-Reciever
- https://www.elecrow.com/download/Infrared%20receiver%20vs1838b.pdf

View File

@ -1,63 +1,41 @@
String homepage_template(void){
return
"<!DOCTYPE html>"
"<html>"
"<head>"
"<meta charset=\"UTF-8\">"
"<title>"+String(titel)+"</title>"
"<link rel=\"stylesheet\" href=\"https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css\">"
"<script src=\"https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js\"></script>"
"<script src=\"https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js\"></script>"
"<link rel=\"stylesheet\" href=\"https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.13.0/css/all.min.css\">"
"<script src=\"https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.13.0/js/all.min.js\"></script>"
"</head>"
"<body>"
"<div class=\"container\">"
"<h1>"+String(titel)+"</h1>"
"<p>An REST-API Arduino microcontroller, which allows you to interact with hardware and the physical environment.</p>"
"<h2>Controller <i class=\"fas fa-cogs\"></i></h2>"
"<h3>Remote Plug Controller<i class=\"fas fa-plug\"></i></h3>"
"<form method=\"get\" >"
"<div class=\"form-group\">"
"<label for=\""+ parameter_plug_id +"\">"+ parameter_plug_id +":</label>"
"<input type=\"number\" class= \"form-control\" id=\""+ parameter_plug_id +"\" name=\""+ parameter_plug_id +"\">"
String homepage = "";
homepage = homepage +
"<!DOCTYPE html>"
"<html>"
"<head>"
"<meta charset=\"UTF-8\">"
"<title>"+String(titel)+"</title>"
"<link rel=\"stylesheet\" href=\"https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css\">"
"<script src=\"https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js\"></script>"
"<script src=\"https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js\"></script>"
"<link rel=\"stylesheet\" href=\"https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.13.0/css/all.min.css\">"
"<script src=\"https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.13.0/js/all.min.js\"></script>"
"</head>"
"<body>"
"<div class=\"container\">"
"<h1>"+String(titel)+"</h1>"
"<p>An REST-API Arduino microcontroller, which allows you to interact with hardware and the physical environment.</p>"
"<h2>Controller <i class=\"fas fa-cogs\"></i></h2>"
"<form method=\"get\" >";
for(const char* parameter : parameter_list)
homepage = homepage +
"<div class=\"form-group\">"
"<label for=\""+ parameter +"\">"+ parameter +":</label>"
"<input type=\"number\" class= \"form-control\" id=\""+ parameter +"\" value=\"" + server.arg(parameter) +"\" name=\""+ parameter +"\">"
"</div>";
homepage = homepage +
"<input type=\"submit\" class=\"btn btn-secondary\">"
"</form>"
"<h2>Data <i class=\"fas fa-database\"></i></h2>"
"<pre>"
+ getJson() +
"</pre>"
"<p>The sensor datas in plane text can be reached <a href=\"?format=json\">here</a>.</p>"
"<hr />"
"<p><small>Please check out the <a href=\"https://github.com/kevinveenbirkenbach/physical-interface\">git-repository</a> to get more information about this software.</small></p>"
"</div>"
"<div class=\"form-group\">"
"<label class=\"checkbox-inline\" for=\"on\">"
"<input type=\"radio\" id=\"on\" name=\""+ parameter_plug_status +"\" value=\"1\">"
"<i class=\"fas fa-toggle-on\"></i> on"
"</label>"
"<label class=\"checkbox-inline\" for=\"off\">"
"<input type=\"radio\" id=\"off\" name=\""+ parameter_plug_status +"\" value=\"0\">"
"<i class=\"fas fa-toggle-off\"></i> off"
"</label>"
"</div>"
"<input type=\"submit\" class=\"btn btn-secondary\">"
"</form>"
"<h3>Infared Controller <i class=\"fas fa-plug\"></i></h3>"
"<form method=\"get\" >"
"<div class=\"form-group\">"
"<label for=\""+ parameter_ir_type +"\">"+ parameter_ir_type +":</label>"
"<input type=\"number\" class= \"form-control\" id=\""+ parameter_ir_type +"\" name=\""+ parameter_ir_type +"\">"
"</div>"
"<div class=\"form-group\">"
"<label for=\""+ parameter_ir_data +"\">"+ parameter_ir_data +":</label>"
"<input type=\"number\" class= \"form-control\" id=\""+ parameter_ir_data +"\" name=\""+ parameter_ir_data +"\">"
"</div>"
"<div class=\"form-group\">"
"<label for=\""+ parameter_ir_bits +"\">"+ parameter_ir_bits +":</label>"
"<input type=\"number\" class= \"form-control\" id=\""+ parameter_ir_bits +"\" name=\""+ parameter_ir_bits +"\">"
"</div>"
"<input type=\"submit\" class=\"btn btn-secondary\">"
"</form>"
"<h2>Data <i class=\"fas fa-database\"></i></h2>"
"<pre>"
+ getJson() +
"</pre>"
"<p>The sensor datas in plane text can be reached <a href=\"?format=json\">here</a>.</p>"
"<hr />"
"<p><small>Please check out the <a href=\"https://github.com/kevinveenbirkenbach/physical-interface\">git-repository</a> to get more information about this software.</small></p>"
"</div>"
"<body>"
"<html>";
"<body>"
"<html>";
return homepage;
}

View File

@ -35,6 +35,7 @@ const char* parameter_plug_status="plug_status";
const char* parameter_ir_type="ir_type";
const char* parameter_ir_data="ir_data";
const char* parameter_ir_bits="ir_bits";
const char* parameter_list[]={parameter_plug_id,parameter_plug_status,parameter_ir_type,parameter_ir_data,parameter_ir_bits};
// Define variables
decode_results results;
@ -125,7 +126,7 @@ void setRitterSwitch(int unit, int state)
}
void setIrColor(decode_type_t type,int data, int bits) {
// irsend.send(type, data, bits);
irsend.send(type, data, bits);
Serial.print("The code \"" + String(data) + "\" with \"" + String(bits) + "\" was send in format \"" + getDecodeType(type) + "\".");
}