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
Get firmware version of the CodexPad.
const std::string & remote_model_number() const
Get model number of the CodexPad.
bool ScanAndConnect(const uint32_t button_mask)
Scans for nearby CodexPad devices and automatically connects to a device whose button state matches t...
@ kLeftStickX
Left stick X axis.
@ kRightStickY
Right stick Y axis.
@ kLeftStickY
Left stick Y axis.
@ kRightStickX
Right stick X axis.
bool pressed(const Button button) const
check if a button is pressed
@ kTriangleY
Triangle or Y.
const std::string & remote_device_name() const
Get model number of the CodexPad.
NimBLEClient * ble_client() const
Get the BLE client object.
uint8_t axis_value(const Axis axis) const
Get axis value.
bool HasAxisValueChanged(const Axis axis, const uint8_t threshold) const
check if an axis value has changed
bool set_remote_tx_power(const TxPower power)
Set transmission power, only effective when connected, immediately effective for current connection,...
bool is_connected() const
Is connected.
bool released(const Button button) const
check if a button is released
void Update()
Update, need to be called in Loop.
bool holding(const Button button) const
check if a button is held