mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-07-17 04:20:34 +08:00
hysteresis: astyle
This commit is contained in:
@@ -41,7 +41,8 @@
|
||||
#include "systemlib/hysteresis/hysteresis.h"
|
||||
|
||||
|
||||
namespace systemlib {
|
||||
namespace systemlib
|
||||
{
|
||||
|
||||
|
||||
void
|
||||
@@ -52,9 +53,11 @@ Hysteresis::set_state_and_update(const bool new_state)
|
||||
_requested_state = new_state;
|
||||
_last_time_to_change_state = hrt_absolute_time();
|
||||
}
|
||||
|
||||
} else {
|
||||
_requested_state = _state;
|
||||
}
|
||||
|
||||
update();
|
||||
}
|
||||
|
||||
@@ -64,8 +67,8 @@ Hysteresis::update()
|
||||
if (_requested_state != _state) {
|
||||
|
||||
if (hrt_elapsed_time(&_last_time_to_change_state) >= (_state ?
|
||||
_hysteresis_time_from_true_us :
|
||||
_hysteresis_time_from_false_us)) {
|
||||
_hysteresis_time_from_true_us :
|
||||
_hysteresis_time_from_false_us)) {
|
||||
_state = _requested_state;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,7 +43,8 @@
|
||||
|
||||
#include <drivers/drv_hrt.h>
|
||||
|
||||
namespace systemlib {
|
||||
namespace systemlib
|
||||
{
|
||||
|
||||
class Hysteresis
|
||||
{
|
||||
@@ -59,15 +60,18 @@ public:
|
||||
~Hysteresis()
|
||||
{}
|
||||
|
||||
void set_hysteresis_time_from(const bool from_state, const hrt_abstime new_hysteresis_time_us) {
|
||||
void set_hysteresis_time_from(const bool from_state, const hrt_abstime new_hysteresis_time_us)
|
||||
{
|
||||
if (from_state == true) {
|
||||
_hysteresis_time_from_true_us = new_hysteresis_time_us;
|
||||
|
||||
} else {
|
||||
_hysteresis_time_from_false_us = new_hysteresis_time_us;
|
||||
}
|
||||
}
|
||||
|
||||
bool get_state() const {
|
||||
bool get_state() const
|
||||
{
|
||||
return _state;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user