pushpull sensor logik
This commit is contained in:
parent
472eba7977
commit
dcae074b55
@ -176,6 +176,8 @@ void Treppe::print_state_on_change() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Treppe::task(){
|
void Treppe::task(){
|
||||||
|
//Serial.printf("LDR: %f\n", ((float)analogRead(A0))/1023.*3.68);
|
||||||
|
|
||||||
if(finish){
|
if(finish){
|
||||||
direction = switch_direction;
|
direction = switch_direction;
|
||||||
state = switch_state;
|
state = switch_state;
|
||||||
@ -194,40 +196,12 @@ void Treppe::task(){
|
|||||||
fsm_outputs = FSMTreppe_Obj.getExternalOutputs();
|
fsm_outputs = FSMTreppe_Obj.getExternalOutputs();
|
||||||
print_state_on_change();
|
print_state_on_change();
|
||||||
|
|
||||||
if(current_sensor_state[0] && !last_sensor_state[0] && state == 0){
|
// setTick(ticks_treppe);
|
||||||
setTick(0);
|
// setAnAus(1);
|
||||||
setAnAus(1);
|
// setDirection(0);
|
||||||
setDirection(1);
|
// setState(0);
|
||||||
setState(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(current_sensor_state[1] && !last_sensor_state[1] && state == 0){
|
|
||||||
setTick(0);
|
|
||||||
setAnAus(0);
|
|
||||||
setDirection(0);
|
|
||||||
setState(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// first switch - off approach, use timer later
|
|
||||||
if(!current_sensor_state[0] && last_sensor_state[0] && state == 1){
|
|
||||||
setTick(ticks_treppe);
|
|
||||||
setAnAus(1);
|
|
||||||
setDirection(1);
|
|
||||||
setState(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!current_sensor_state[1] && last_sensor_state[1] && state == 1){
|
|
||||||
setTick(ticks_treppe);
|
|
||||||
setAnAus(1);
|
|
||||||
setDirection(0);
|
|
||||||
setState(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
last_sensor_state[0] = current_sensor_state[0];
|
|
||||||
last_sensor_state[1] = current_sensor_state[1];
|
|
||||||
|
|
||||||
ledsequence();
|
ledsequence();
|
||||||
//Serial.printf("LDR: %f\n", ((float)analogRead(A0))/1023.*3.68);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ private:
|
|||||||
void ledsequence();
|
void ledsequence();
|
||||||
void rampe();
|
void rampe();
|
||||||
bool read_sensor(int sensor) {
|
bool read_sensor(int sensor) {
|
||||||
int pegel = !digitalRead(sensor);
|
int pegel = digitalRead(sensor);
|
||||||
return static_cast<bool>(pegel);
|
return static_cast<bool>(pegel);
|
||||||
}
|
}
|
||||||
public:
|
public:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user