not started state where collector does not switch
This commit is contained in:
parent
4f7f775dd5
commit
1d47154445
@ -25,6 +25,8 @@ protected:
|
|||||||
int week_counter = 0;
|
int week_counter = 0;
|
||||||
int month_counter = 0;
|
int month_counter = 0;
|
||||||
|
|
||||||
|
boolean started = false;
|
||||||
|
|
||||||
void add_month(int from ) ;
|
void add_month(int from ) ;
|
||||||
void switch_logic(float in , float out);
|
void switch_logic(float in , float out);
|
||||||
|
|
||||||
@ -37,6 +39,7 @@ public:
|
|||||||
|
|
||||||
void add_week(float in , float out) ;
|
void add_week(float in , float out) ;
|
||||||
void add(float in , float out) ;
|
void add(float in , float out) ;
|
||||||
|
void start(); // fake data before, no switching
|
||||||
|
|
||||||
String week_data( int at);
|
String week_data( int at);
|
||||||
String month_data(int at);
|
String month_data(int at);
|
||||||
|
@ -43,6 +43,7 @@ void collector_setup(){
|
|||||||
last_in = next_rand(last_in);
|
last_in = next_rand(last_in);
|
||||||
last_out = next_rand(last_out);
|
last_out = next_rand(last_out);
|
||||||
}
|
}
|
||||||
|
collector.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
void collector_loop(){
|
void collector_loop(){
|
||||||
@ -70,18 +71,23 @@ void Collector::add(float in , float out)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Collector::start(){
|
||||||
|
started = true;
|
||||||
|
week_counter = 0;
|
||||||
|
month_counter = 0;
|
||||||
|
}
|
||||||
|
|
||||||
void Collector::switch_logic(float in , float out){
|
void Collector::switch_logic(float in , float out){
|
||||||
u_int8_t on;
|
if( !started ) return ;
|
||||||
String msg;
|
if(out > (in + 1.0) ){
|
||||||
if(in < out){
|
digitalWrite( RELAY , 1);
|
||||||
on = 1 ;
|
DEBUG_OUT.println("Switching on");
|
||||||
msg = "Switching on";
|
}else if( in > (out - 0.5 ) ) {
|
||||||
}else{
|
digitalWrite( RELAY , 0);
|
||||||
on = 0 ;
|
DEBUG_OUT.println( "Switching off" );
|
||||||
msg = "Switching off";
|
} else {
|
||||||
|
DEBUG_OUT.println( "No Switching" );
|
||||||
}
|
}
|
||||||
digitalWrite( RELAY , on);
|
|
||||||
DEBUG_OUT.println(msg);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Collector::add_week(float in , float out){
|
void Collector::add_week(float in , float out){
|
||||||
|
Loading…
Reference in New Issue
Block a user