Esp32-RBGridUI
Library for creating UIs for the RBController app
Loading...
Searching...
No Matches
widgets
orientation.h
Go to the documentation of this file.
1
#pragma once
2
3
#include "
widget.h
"
4
5
#include "rbprotocol.h"
6
7
namespace
gridui
{
8
11
class
Orientation
:
public
Widget
{
12
template
<
typename
Self,
typename
Finished>
13
friend
class
builder::BuilderMixin
;
14
15
using
Widget::Widget
;
16
17
public
:
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
};
gridui::Orientation
Definition
orientation.h:11
gridui::Orientation::pitch
float pitch() const
Definition
orientation.h:30
gridui::Orientation::color
std::string color() const
Definition
orientation.h:22
gridui::Orientation::yaw
float yaw() const
Definition
orientation.h:26
gridui::Orientation::joystickX
int32_t joystickX()
Definition
orientation.h:38
gridui::Orientation::setColor
void setColor(const std::string &color)
Definition
orientation.h:18
gridui::Orientation::roll
float roll() const
Definition
orientation.h:34
gridui::Orientation::joystickY
int32_t joystickY()
Definition
orientation.h:47
gridui::WidgetState::set
bool set(const std::string &key, rbjson::Value *value)
Definition
widget.cpp:27
gridui::Widget
Definition
widget.h:178
gridui::Widget::m_state
WidgetState * m_state
Definition
widget.h:265
gridui::Widget::Widget
Widget()
Definition
widget.h:180
gridui::Widget::data
const rbjson::Object & data() const
Definition
widget.h:263
gridui::builder::BuilderMixin
Definition
widget.h:33
gridui
Definition
arm.h:8
widget.h
Generated on Tue Jul 9 2024 10:04:33 for Esp32-RBGridUI by
1.9.8