35const std::string kBluetoothDeviceAddress =
"E4:66:E5:A2:24:5D";
40 printf(
"Start to connect %s\n", kBluetoothDeviceAddress.c_str());
43 while (!g_codex_pad.
Connect(kBluetoothDeviceAddress, 5000)) {
44 printf(
"Retry to connect %s\n", kBluetoothDeviceAddress.c_str());
49 printf(
"Remote firmware revision: %u.%u.%u\n",
54 if (
const auto ble_client = g_codex_pad.
ble_client(); ble_client !=
nullptr) {
55 printf(
"Remote Bluetooth Device Address: %s\n", ble_client->getPeerAddress().toString().c_str());
57 printf(
"Remote Bluetooth Device Address: unknown\n");
68 printf(
"Set remote tx power to 0dBm successfully\n");
71 printf(
"Connected\n");
94 printf(
"Disconnected, start to reconnect\n");
99 static uint32_t s_print_time = 0;
100 if (s_print_time == 0 || s_print_time + 30 < millis()) {
101 s_print_time = millis();
104 "Up:%u, Down:%u, Left:%u, Right:%u, Square(X):%u, Triangle(Y):%u, Cross(A):%u, Circle(B):%u, L1:%u, L2:%u, L3:%u, R1:%u, R2:%u, "
106 "Start:%u, Home:%u, L(X:%3u, Y:%3u), R(X:%3u, Y:%3u)\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.
@ kLeftStickX
Left stick X axis.
@ kRightStickY
Right stick Y axis.
@ kLeftStickY
Left stick Y axis.
@ kRightStickX
Right stick X axis.
bool Connect(const std::string &bluetooth_device_address, const uint32_t timeout_ms=5000)
Connect.
@ 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 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.
void Update()
Update, need to be called in Loop.
bool button_state(const Button button) const
check if a button is pressed or held