SensESP 2.7.2
Universal Signal K sensor toolkit ESP32
Loading...
Searching...
No Matches
truth_text.cpp
Go to the documentation of this file.
1#include "truth_text.h"
2
3namespace sensesp {
4
6 if (input.length() == 0) {
7 return false;
8 }
9
10 if (input.equalsIgnoreCase("On") || input.equalsIgnoreCase("Yes") ||
11 input.equalsIgnoreCase("True") || input.equalsIgnoreCase("T") ||
12 input.equalsIgnoreCase("Y")) {
13 return true;
14 }
15
16 if (input.toInt() != 0) {
17 return true;
18 }
19
20 return false;
21}
22
24 if (input.length() == 0) {
25 return false;
26 }
27
28 if (input.equalsIgnoreCase("Off") || input.equalsIgnoreCase("No") ||
29 input.equalsIgnoreCase("False") || input.equalsIgnoreCase("F") ||
30 input.equalsIgnoreCase("N") || input.equalsIgnoreCase("0") ||
31 input.equalsIgnoreCase("0.0")) {
32 return true;
33 }
34
35 return false;
36}
37
41
48
50 if (input) {
51 this->emit(truth_value_[1]);
52 } else {
53 this->emit(truth_value_[0]);
54 }
55}
56
57} // namespace sensesp
Construct a new transform based on a single function.
static bool is_valid_false(String value)
static bool is_valid_true(String value)
Definition truth_text.cpp:5
virtual void set_input(String input, uint8_t input_channel=0) override
The main Transform class. A transform is identified primarily by the type of value that is produces (...
Definition transform.h:54
virtual void set_input(bool input, uint8_t input_channel=0) override
TruthToText(String true_value="ON", String false_value="OFF")
void emit(T new_value)