9 namespace dfrobot_sen0395 {
11 template<
typename... Ts>
14 void play(Ts...
x) { this->
parent_->enqueue(make_unique<ResetSystemCommand>()); }
17 template<
typename... Ts>
20 TEMPLATABLE_VALUE(int8_t, factory_reset)
21 TEMPLATABLE_VALUE(int8_t, start_after_power_on)
22 TEMPLATABLE_VALUE(int8_t, turn_on_led)
23 TEMPLATABLE_VALUE(int8_t, presence_via_uart)
24 TEMPLATABLE_VALUE(int8_t, sensitivity)
25 TEMPLATABLE_VALUE(
float, delay_after_detect)
26 TEMPLATABLE_VALUE(
float, delay_after_disappear)
27 TEMPLATABLE_VALUE(
float, det_min1)
28 TEMPLATABLE_VALUE(
float, det_max1)
29 TEMPLATABLE_VALUE(
float, det_min2)
30 TEMPLATABLE_VALUE(
float, det_max2)
31 TEMPLATABLE_VALUE(
float, det_min3)
32 TEMPLATABLE_VALUE(
float, det_max3)
33 TEMPLATABLE_VALUE(
float, det_min4)
34 TEMPLATABLE_VALUE(
float, det_max4)
37 this->
parent_->enqueue(make_unique<PowerCommand>(0));
38 if (this->factory_reset_.has_value() && this->factory_reset_.value(x...) ==
true) {
39 this->
parent_->enqueue(make_unique<FactoryResetCommand>());
41 if (this->det_min1_.has_value() && this->det_max1_.has_value()) {
42 if (this->det_min1_.value() >= 0 && this->det_max1_.value() >= 0) {
43 this->
parent_->enqueue(make_unique<DetRangeCfgCommand>(
44 this->det_min1_.value_or(-1), this->det_max1_.value_or(-1), this->det_min2_.value_or(-1),
45 this->det_max2_.value_or(-1), this->det_min3_.value_or(-1), this->det_max3_.value_or(-1),
46 this->det_min4_.value_or(-1), this->det_max4_.value_or(-1)));
49 if (this->delay_after_detect_.has_value() && this->delay_after_disappear_.has_value()) {
50 float detect = this->delay_after_detect_.value(x...);
51 float disappear = this->delay_after_disappear_.value(x...);
52 if (detect >= 0 && disappear >= 0) {
53 this->
parent_->enqueue(make_unique<SetLatencyCommand>(detect, disappear));
56 if (this->start_after_power_on_.has_value()) {
57 int8_t
val = this->start_after_power_on_.value(x...);
59 this->
parent_->enqueue(make_unique<SensorCfgStartCommand>(val));
62 if (this->turn_on_led_.has_value()) {
63 int8_t
val = this->turn_on_led_.value(x...);
65 this->
parent_->enqueue(make_unique<LedModeCommand>(val));
68 if (this->presence_via_uart_.has_value()) {
69 int8_t
val = this->presence_via_uart_.value(x...);
71 this->
parent_->enqueue(make_unique<UartOutputCommand>(val));
74 if (this->sensitivity_.has_value()) {
75 int8_t
val = this->sensitivity_.value(x...);
80 this->
parent_->enqueue(make_unique<SensitivityCommand>(val));
83 this->
parent_->enqueue(make_unique<SaveCfgCommand>());
84 this->
parent_->enqueue(make_unique<PowerCommand>(1));
DfrobotSen0395Component * parent_
Implementation of SPI Controller mode.
Helper class to easily give an object a parent of type T.