120 printf(
"Start to scan and connect, button mask: 0x%08X\n", kExpectedButtonMask);
123 printf(
"Retry to scan and connect, button mask: 0x%08X\n", kExpectedButtonMask);
131 if (
const auto ble_client = g_codex_pad.
ble_client(); ble_client !=
nullptr) {
132 printf(
"Remote Bluetooth Device Address: %s\n", ble_client->getPeerAddress().toString().c_str());
134 printf(
"Remote Bluetooth Device Address: unknown\n");
145 printf(
"Set remote tx power to 0dBm successfully\n");
148 printf(
"Connected\n");
153 Serial.begin(115200);
171 printf(
"Disconnected, start to reconnect\n");
186 if (g_codex_pad.
pressed(button)) {
187 printf(
"Button %s: pressed\n", ButtonToString(button).c_str());
192 else if (g_codex_pad.
released(button)) {
193 printf(
"Button %s: released\n", ButtonToString(button).c_str());
198 else if (g_codex_pad.
holding(button)) {
199 printf(
"Button %s: holding\n", ButtonToString(button).c_str());
207 constexpr uint8_t kAxisValueChangeThreshold = 2;
217 printf(
"L(X: %3" PRIu8
", Y: %3" PRIu8
"), R(X: %3" PRIu8
", Y: %3" PRIu8
")\n",
const std::array< uint8_t, 3 > remote_firmware_version() const
获取CodexPad的固件版本
const std::string & remote_model_number() const
获取CodexPad的型号
bool ScanAndConnect(const uint32_t button_mask)
扫描附近的 CodexPad 设备,并自动连接到一个按键状态与指定掩码匹配的设备。
bool pressed(const Button button) const
查询按键是否被按下
const std::string & remote_device_name() const
获取CodexPad的型号
NimBLEClient * ble_client() const
获取 BLE 客户端对象
uint8_t axis_value(const Axis axis) const
获取轴值
bool HasAxisValueChanged(const Axis axis, const uint8_t threshold) const
查询轴值是否发生变化
bool set_remote_tx_power(const TxPower power)
设置发射功率,连接状态下调用,立即生效于当前连接,下次连接生效
bool is_connected() const
是否连接
bool released(const Button button) const
查询按键是否被释放
void Update()
更新,需要在Loop中不断调用
bool holding(const Button button) const
查询按键是否被持续按下