SensESP 2.7.2
Universal Signal K sensor toolkit ESP32
Loading...
Searching...
No Matches
angle_correction.cpp
Go to the documentation of this file.
1#include "angle_correction.h"
2
3namespace sensesp {
4
5#define M_PI 3.14159265358979323846
6
12
14 // first the correction
15 float x = input + offset_;
16
17 // then wrap around the values
18 x = fmod(x - min_angle_, 2 * M_PI);
19 if (x < 0) {
20 x += 2 * M_PI;
21 }
22 this->emit(x + min_angle_);
23}
24
26 root["offset"] = offset_;
27 root["min_angle"] = min_angle_;
28}
29
30static const char SCHEMA[] PROGMEM = R"###({
31 "type": "object",
32 "properties": {
33 "offset": { "title": "Constant offset", "description": "Value to be added, in radians", "type": "number" },
34 "min_angle": { "title": "Minimum angle value", "description": "If you have output between -pi and pi, use -3.14159265, otherwise use 0.", "type": "number" }
35 }
36 })###";
37
39
41 String expected[] = {"offset", "min_angle"};
42 for (auto str : expected) {
43 if (!config.containsKey(str)) {
44 return false;
45 }
46 }
47 offset_ = config["offset"];
48 min_angle_ = config["min_angle"];
49 return true;
50}
51
52} // namespace sensesp
#define M_PI
virtual void get_configuration(JsonObject &doc) override
virtual String get_config_schema() override
virtual bool set_configuration(const JsonObject &config) override
virtual void set_input(float input, uint8_t inputChannel=0) override
AngleCorrection(float offset, float min_angle=0, String config_path="")
virtual void load_configuration()
Construct a new transform based on a single function.
const uint8_t PAGE_css_bootstrap[] PROGMEM