From 8527865b9f13ea880bd9eb95d8ea13e3eff40bfb Mon Sep 17 00:00:00 2001 From: "Kevin Veen-Birkenbach [aka. Frantz]" Date: Mon, 11 May 2020 22:47:18 +0200 Subject: [PATCH] Implemented delay time --- main/main.ino | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/main/main.ino b/main/main.ino index 3075e21..539acd5 100644 --- a/main/main.ino +++ b/main/main.ino @@ -35,7 +35,8 @@ 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}; +const char* parameter_delay_time_in_ms="delay_time_in_ms"; +const char* parameter_list[]={parameter_plug_id,parameter_plug_status,parameter_ir_type,parameter_ir_data,parameter_ir_bits,parameter_delay_time_in_ms}; // Define variables decode_results results; @@ -159,11 +160,22 @@ void view(void){ } } +int getDelayTime(void){ + if(isParameterDefined(parameter_delay_time_in_ms)){ + int delay_time_in_ms = server.arg(parameter_delay_time_in_ms).toInt(); + if(delay_time_in_ms>0){ + Serial.println("Applying delay time: " + server.arg(parameter_delay_time_in_ms) + "ms"); + return delay_time_in_ms; + } + } + return 0; +} + void handleRequest(void){ Serial.println("Website was called."); + delay(getDelayTime()); controller(); view(); - delay(100); } //Arduino-Setup