GKD.RoboCtrl
载入中...
搜索中...
未找到
controlpad.cpp
1
#include "device/controlpad.h"
2
#include "
core/async.hpp
"
3
#include "ctrl/robot.h"
4
#include "
device/base.hpp
"
5
#include "
io/serial.h
"
6
7
using namespace
roboctrl::device
;
8
9
struct
_controlpad_recive_pkg
10
{
11
int
ch0;
12
int
ch1;
13
int
ch2;
14
int
ch3;
15
int
ch4;
16
int
s1;
17
int
s2;
18
int
mouse_x;
19
int
mouse_y;
20
int
mouse_z;
21
int
mouse_l;
22
int
mouse_r;
23
int
key;
24
} __attribute__((
packed
));
25
26
control_pad::control_pad(
const
control_pad::info_type
& info)
27
:info_{info},
28
device_base
{0
ms
}
29
{
30
auto
& serial =
roboctrl::get<io::serial>
(info.serial_name);
31
serial.on_data(2,[&](
const
_controlpad_recive_pkg
&
pkg
)->
roboctrl::awaitable<void>
{
32
log_info(
"{}-{}-{}-{}-{}"
,
pkg
.ch0,
pkg
.ch1,
pkg
.ch2,
pkg
.ch3,
pkg
.ch4);
33
co_return
;
34
});
35
}
async.hpp
异步任务上下文组件。
base.hpp
设备抽象基类与通用概念。
roboctrl::async::awaitable
asio::awaitable< T > awaitable
协程任务类型。
Definition
async.hpp:42
roboctrl::device
设备模块
Definition
base.hpp:25
serial.h
串口裸 IO 封装。
_controlpad_recive_pkg
Definition
controlpad.cpp:10
roboctrl::device::control_pad::info_type
Definition
controlpad.h:15
roboctrl::device::device_base
设备基础类,提供判断设备离线的基础功能
Definition
base.hpp:38
device
controlpad.cpp
制作者
1.9.8