Esp32-RBGridUI
Library for creating UIs for the RBController app
Loading...
Searching...
No Matches
orientation.h
Go to the documentation of this file.
1#pragma once
2
3#include "widget.h"
4
5#include "rbprotocol.h"
6
7namespace gridui {
8
11class Orientation : public Widget {
12 template <typename Self, typename Finished>
14
15 using Widget::Widget;
16
17public:
18 void setColor(const std::string& color) {
19 m_state->set("color", new rbjson::String(color));
20 }
21
22 std::string color() const {
23 return data().getString("color");
24 }
25
26 float yaw() const {
27 return data().getDouble("oy");
28 }
29
30 float pitch() const {
31 return data().getDouble("op");
32 }
33
34 float roll() const {
35 return data().getDouble("or");
36 }
37
38 int32_t joystickX() {
39 const auto y = yaw();
40 if (y >= 0) {
41 return y * y * RBPROTOCOL_AXIS_MAX;
42 } else {
43 return y * y * RBPROTOCOL_AXIS_MAX * -1;
44 }
45 }
46
47 int32_t joystickY() {
48 const auto r = roll();
49 if (r >= 0) {
50 return r * r * RBPROTOCOL_AXIS_MAX * -1;
51 } else {
52 return r * r * RBPROTOCOL_AXIS_MAX;
53 }
54 }
55};
56
57};
float pitch() const
Definition orientation.h:30
std::string color() const
Definition orientation.h:22
float yaw() const
Definition orientation.h:26
void setColor(const std::string &color)
Definition orientation.h:18
float roll() const
Definition orientation.h:34
bool set(const std::string &key, rbjson::Value *value)
Definition widget.cpp:25
WidgetState * m_state
Definition widget.h:214
const rbjson::Object & data() const
Definition widget.h:212
Definition arm.h:8