mirror of
https://github.com/kevinveenbirkenbach/physical-interface.git
synced 2024-11-13 05:41:05 +01:00
Optimized parameters
This commit is contained in:
parent
ac374dc040
commit
d67ecb4bf9
@ -15,25 +15,41 @@ return
|
||||
"<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>Actions <i class=\"fas fa-cogs\"></i></h2>"
|
||||
"<h3>Remote Plugs <i class=\"fas fa-plug\"></i></h3>"
|
||||
"<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=\"plug_id\">Plug-ID:</label>"
|
||||
"<input type=\"number\" class= \"form-control\" id=\"plug_id\" name=\"plug_id\">"
|
||||
"<label for=\""+ parameter_plug_id +"\">Plug-ID:</label>"
|
||||
"<input type=\"number\" class= \"form-control\" id=\""+ parameter_plug_id +"\" name=\""+ parameter_plug_id +"\">"
|
||||
"</div>"
|
||||
"<div class=\"form-group\">"
|
||||
"<label class=\"checkbox-inline\" for=\"on\">"
|
||||
"<input type=\"radio\" id=\"on\" name=\"status\" value=\"1\">"
|
||||
"<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=\"status\" value=\"0\">"
|
||||
"<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() +
|
||||
|
@ -30,6 +30,11 @@ const int pin_tmp = 12;
|
||||
const uint16_t pin_ir_reciever = 2;
|
||||
const uint16_t pin_ir_send = 4;
|
||||
const unsigned long ritter_group_address = 13043702;
|
||||
const char* parameter_plug_id="plug_id";
|
||||
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";
|
||||
|
||||
// Define variables
|
||||
decode_results results;
|
||||
@ -115,7 +120,7 @@ void setRitterSwitch(int unit, int state)
|
||||
|
||||
void setIrColor(decode_type_t type,int data, int bits) {
|
||||
// irsend.send(type, data, 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) + "\".");
|
||||
}
|
||||
|
||||
bool isParameterDefined(String parameter_name){
|
||||
@ -128,14 +133,14 @@ bool isParameterDefined(String parameter_name){
|
||||
}
|
||||
|
||||
void controller(void){
|
||||
if(isParameterDefined("ir_code") && isParameterDefined("ir_decode_type") && isParameterDefined("ir_data")){
|
||||
setIrColor(static_cast<decode_type_t>(server.arg("ir_decode_type").toInt()),server.arg("ir_data").toInt(),server.arg("ir_bits").toInt());
|
||||
if(isParameterDefined(parameter_ir_type) && isParameterDefined(parameter_ir_data) && isParameterDefined(parameter_ir_bits)){
|
||||
setIrColor(static_cast<decode_type_t>(server.arg(parameter_ir_type).toInt()),server.arg(parameter_ir_data).toInt(),server.arg(parameter_ir_bits).toInt());
|
||||
}
|
||||
if(isParameterDefined("plug_id") && isParameterDefined("status")){
|
||||
if(server.arg("plug_id")=="group"){
|
||||
setRitterGroup(server.arg("status").toInt());
|
||||
if(isParameterDefined(parameter_plug_id) && isParameterDefined(parameter_plug_status)){
|
||||
if(server.arg(parameter_plug_id)=="group"){
|
||||
setRitterGroup(server.arg(parameter_plug_status).toInt());
|
||||
}else{
|
||||
setRitterSwitch(server.arg("plug_id").toInt(),server.arg("status").toInt());
|
||||
setRitterSwitch(server.arg(parameter_plug_id).toInt(),server.arg(parameter_plug_status).toInt());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user