mirror of
https://github.com/kevinveenbirkenbach/physical-interface.git
synced 2024-12-04 23:17:20 +01:00
Optimized template
This commit is contained in:
parent
be51e2db35
commit
ac374dc040
@ -3,6 +3,7 @@ return
|
|||||||
"<!DOCTYPE html>"
|
"<!DOCTYPE html>"
|
||||||
"<html>"
|
"<html>"
|
||||||
"<head>"
|
"<head>"
|
||||||
|
"<meta charset=\"UTF-8\">"
|
||||||
"<title>"+String(titel)+"</title>"
|
"<title>"+String(titel)+"</title>"
|
||||||
"<link rel=\"stylesheet\" href=\"https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css\">"
|
"<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://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js\"></script>"
|
||||||
@ -14,7 +15,7 @@ return
|
|||||||
"<div class=\"container\">"
|
"<div class=\"container\">"
|
||||||
"<h1>"+String(titel)+"</h1>"
|
"<h1>"+String(titel)+"</h1>"
|
||||||
"<p>An REST-API Arduino microcontroller, which allows you to interact with hardware and the physical environment.</p>"
|
"<p>An REST-API Arduino microcontroller, which allows you to interact with hardware and the physical environment.</p>"
|
||||||
"<h2>Actors <i class=\"fas fa-cogs\"></i></h2>"
|
"<h2>Actions <i class=\"fas fa-cogs\"></i></h2>"
|
||||||
"<h3>Remote Plugs <i class=\"fas fa-plug\"></i></h3>"
|
"<h3>Remote Plugs <i class=\"fas fa-plug\"></i></h3>"
|
||||||
"<form method=\"get\" >"
|
"<form method=\"get\" >"
|
||||||
"<div class=\"form-group\">"
|
"<div class=\"form-group\">"
|
||||||
@ -33,8 +34,11 @@ return
|
|||||||
"</div>"
|
"</div>"
|
||||||
"<input type=\"submit\" class=\"btn btn-secondary\">"
|
"<input type=\"submit\" class=\"btn btn-secondary\">"
|
||||||
"</form>"
|
"</form>"
|
||||||
"<h2>Sensors <i class=\"fas fa-thermometer\"></i></h2>"
|
"<h2>Data <i class=\"fas fa-database\"></i></h2>"
|
||||||
"<p>The sensor datas can be reached <a href=\"?format=json\">here</a>.</p>"
|
"<pre>"
|
||||||
|
+ getJson() +
|
||||||
|
"</pre>"
|
||||||
|
"<p>The sensor datas in plane text can be reached <a href=\"?format=json\">here</a>.</p>"
|
||||||
"<hr />"
|
"<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>"
|
"<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>"
|
||||||
|
@ -23,9 +23,6 @@
|
|||||||
// Configuration
|
// Configuration
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
// Templates
|
|
||||||
#include "homepage_template.h"
|
|
||||||
|
|
||||||
// Define Constants
|
// Define Constants
|
||||||
const int pin_ritter = 13;
|
const int pin_ritter = 13;
|
||||||
const int pin_pir = 14;
|
const int pin_pir = 14;
|
||||||
@ -121,18 +118,6 @@ void setIrColor(decode_type_t type,int data, int bits) {
|
|||||||
Serial.print("The code \"" + String(data) + "\" with \"" + String(bits) + "\"was send in format \"" + getDecodeType(type) + "\".");
|
Serial.print("The code \"" + String(data) + "\" with \"" + String(bits) + "\"was send in format \"" + getDecodeType(type) + "\".");
|
||||||
}
|
}
|
||||||
|
|
||||||
String getJsonDht(void){
|
|
||||||
return "{\"temperature\":\""+String(dht.readTemperature())+"\",\"humidity\":\""+String(dht.readHumidity())+"\"}";
|
|
||||||
}
|
|
||||||
|
|
||||||
String getJsonPir(void){
|
|
||||||
return "{\"motion\":\""+String(digitalRead(pin_pir))+"\"";
|
|
||||||
}
|
|
||||||
|
|
||||||
String getJson(void){
|
|
||||||
return "{\"DHT\":"+String(getJsonDht())+",\"PIR\":"+String(getJsonPir())+"}";
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isParameterDefined(String parameter_name){
|
bool isParameterDefined(String parameter_name){
|
||||||
for (uint8_t parameter_index = 0; parameter_index < server.args(); parameter_index++) {
|
for (uint8_t parameter_index = 0; parameter_index < server.args(); parameter_index++) {
|
||||||
if(server.argName(parameter_index)==parameter_name){
|
if(server.argName(parameter_index)==parameter_name){
|
||||||
@ -155,6 +140,21 @@ void controller(void){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
String getJsonDht(void){
|
||||||
|
return "{\"temperature\":\""+String(dht.readTemperature())+"\",\"humidity\":\""+String(dht.readHumidity())+"\"}";
|
||||||
|
}
|
||||||
|
|
||||||
|
String getJsonPir(void){
|
||||||
|
return "{\"motion\":\""+String(digitalRead(pin_pir))+"\"}";
|
||||||
|
}
|
||||||
|
|
||||||
|
String getJson(void){
|
||||||
|
return "{\"DHT\":"+String(getJsonDht())+",\"PIR\":"+String(getJsonPir())+"}";
|
||||||
|
}
|
||||||
|
|
||||||
|
#include "homepage_template.h"
|
||||||
|
|
||||||
void view(void){
|
void view(void){
|
||||||
if(server.arg("format")=="json"){
|
if(server.arg("format")=="json"){
|
||||||
server.send ( 200, "text/html", getJson());
|
server.send ( 200, "text/html", getJson());
|
||||||
|
Loading…
Reference in New Issue
Block a user