button
This commit is contained in:
parent
ca07bb0f10
commit
10a5c563a3
|
@ -324,13 +324,13 @@ namespace ratgdo {
|
||||||
}
|
}
|
||||||
this->previousMotorState = this->motorState;
|
this->previousMotorState = this->motorState;
|
||||||
}
|
}
|
||||||
if (this->motionState == MotionState::MOTION_STATE_DETECTED) {
|
if (this->motionState == this->previousMotionState) {
|
||||||
MotionState val = static_cast<MotionState>(this->motionState);
|
MotionState val = static_cast<MotionState>(this->motionState);
|
||||||
ESP_LOGD(TAG, "Motion state %s", motion_state_to_string(val));
|
ESP_LOGD(TAG, "Motion state %s", motion_state_to_string(val));
|
||||||
for (auto* child : this->children_) {
|
for (auto* child : this->children_) {
|
||||||
child->on_motion_state(val);
|
child->on_motion_state(val);
|
||||||
}
|
}
|
||||||
this->motionState = MotionState::MOTION_STATE_CLEAR;
|
this->previousMotionState = this->motionState;
|
||||||
}
|
}
|
||||||
if (this->buttonState != this->previousButtonState) {
|
if (this->buttonState != this->previousButtonState) {
|
||||||
ButtonState val = static_cast<ButtonState>(this->buttonState);
|
ButtonState val = static_cast<ButtonState>(this->buttonState);
|
||||||
|
|
|
@ -95,14 +95,15 @@ namespace ratgdo {
|
||||||
uint8_t previousObstructionState { ObstructionState::OBSTRUCTION_STATE_UNKNOWN };
|
uint8_t previousObstructionState { ObstructionState::OBSTRUCTION_STATE_UNKNOWN };
|
||||||
uint8_t previousMotorState { MotorState::MOTOR_STATE_UNKNOWN };
|
uint8_t previousMotorState { MotorState::MOTOR_STATE_UNKNOWN };
|
||||||
uint8_t previousButtonState { ButtonState::BUTTON_STATE_UNKNOWN };
|
uint8_t previousButtonState { ButtonState::BUTTON_STATE_UNKNOWN };
|
||||||
|
uint8_t previousMotionState { MotionState::MOTION_STATE_UNKNOWN };
|
||||||
|
|
||||||
uint8_t obstructionState { ObstructionState::OBSTRUCTION_STATE_UNKNOWN };
|
|
||||||
uint8_t motionState { MotionState::MOTION_STATE_CLEAR };
|
|
||||||
uint8_t motorState { MotorState::MOTOR_STATE_UNKNOWN };
|
|
||||||
uint8_t lockState { LockState::LOCK_STATE_UNKNOWN };
|
|
||||||
uint8_t lightState { LightState::LIGHT_STATE_UNKNOWN };
|
|
||||||
uint8_t doorState { DoorState::DOOR_STATE_UNKNOWN };
|
uint8_t doorState { DoorState::DOOR_STATE_UNKNOWN };
|
||||||
|
uint8_t lightState { LightState::LIGHT_STATE_UNKNOWN };
|
||||||
|
uint8_t lockState { LockState::LOCK_STATE_UNKNOWN };
|
||||||
|
uint8_t obstructionState { ObstructionState::OBSTRUCTION_STATE_UNKNOWN };
|
||||||
|
uint8_t motorState { MotorState::MOTOR_STATE_UNKNOWN };
|
||||||
uint8_t buttonState { ButtonState::BUTTON_STATE_UNKNOWN };
|
uint8_t buttonState { ButtonState::BUTTON_STATE_UNKNOWN };
|
||||||
|
uint8_t motionState { MotionState::MOTION_STATE_UNKNOWN };
|
||||||
|
|
||||||
void set_output_gdo_pin(InternalGPIOPin* pin) { this->output_gdo_pin_ = pin; };
|
void set_output_gdo_pin(InternalGPIOPin* pin) { this->output_gdo_pin_ = pin; };
|
||||||
void set_input_gdo_pin(InternalGPIOPin* pin) { this->input_gdo_pin_ = pin; };
|
void set_input_gdo_pin(InternalGPIOPin* pin) { this->input_gdo_pin_ = pin; };
|
||||||
|
|
|
@ -57,8 +57,10 @@ namespace ratgdo {
|
||||||
case MOTION_STATE_DETECTED:
|
case MOTION_STATE_DETECTED:
|
||||||
return "DETECTED";
|
return "DETECTED";
|
||||||
case MOTION_STATE_CLEAR:
|
case MOTION_STATE_CLEAR:
|
||||||
default:
|
|
||||||
return "CLEAR";
|
return "CLEAR";
|
||||||
|
case MOTION_STATE_UNKNOWN:
|
||||||
|
default:
|
||||||
|
return "UNKNOWN";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -51,6 +51,7 @@ namespace ratgdo {
|
||||||
enum MotionState : uint8_t {
|
enum MotionState : uint8_t {
|
||||||
MOTION_STATE_CLEAR = 0,
|
MOTION_STATE_CLEAR = 0,
|
||||||
MOTION_STATE_DETECTED = 1,
|
MOTION_STATE_DETECTED = 1,
|
||||||
|
MOTION_STATE_UNKNOWN = 2,
|
||||||
};
|
};
|
||||||
const char* motion_state_to_string(MotionState state);
|
const char* motion_state_to_string(MotionState state);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue