Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Build Android control interfaces for Bluetooth Low Energy, Bluetooth, WebSocket, MQTT, TCP, and UDP protocols for your project

License

NotificationsYou must be signed in to change notification settings

UmerCodez/DroidPad

Repository files navigation

GitHub LicenseJetpack Compose BadgeGitHub Release

Create Customizable Control Interfaces for Bluetooth Low Energy, Bluetooth, WebSocket, MQTT, TCP, and UDP Protocols with Simple Drag-and-Drop Functionality.


Key Features:

  1. Drag-and-Drop Control Pad Creation
    Design your control pads by dragging and dropping components like buttons, sliders, switches, Joystick and D-PAD.

  2. Multi-Protocol Support and Seamless Server Connections
    Easily configure your control pad to support network protocols such asBluetooth LE, WebSocket, MQTT, TCP, and UDP. Once connected, you can interact with the control pad’s components—includingbuttons, sliders, switches, joysticks, and D-PADs—to send real-time commands directly to the connected server or BLE client, where these commands can be processed.

  3. Switch Connection Type Anytime
    You can change the connection type of a control pad at any time without creating a duplicate for a different connection.

  4. Update UI From your Script
    You can change the state of SWITCH,SLIDER,LED and GAUGE from your script

Supported Components

  1. Switch
  2. Button
  3. Slider
  4. DPAD
  5. Joystick
  6. Steering Wheel
  7. LED
  8. GAUGE
  9. LOG
  10. Accelerometer and Gyroscope (If supported by the device)

How It Works (4 steps)

Step 1: Create a Control Pad

Start by creating a new control pad. Provide a unique name to identify your control pad.

Step 2: Design Your Control Pad

After creating the control pad, click on theBuild icon and use the drag-and-drop interface to add components like switches, buttons, and sliders etc.

Assign a uniqueID to each component. This ID will be sent to the server during interactions.

Step 3: Configure Connection Settings

Tap'Settings, choose a connection type (TCP, Bluetooth LE, UDP, WebSocket, or MQTT), enter the server address and port. You can switch between connection types anytime

Step 4: Connect and Interact

a. Click on thePlay icon to start interacting with your control pad.
b. Tap theConnect button in the bottom-right corner to establish a connection with the server.

Reading Interactions

When users interact with the control pad, JSON-formatted or CSV messages are generated based on the type of component used.These string messages enable receivers to understand and process interactions sent from the control pad. Below are the formats and details for each interaction:


SWITCH

Toggling a switch generates the following JSON:

{"id":"the id you specified","type":"SWITCH","state":true}

ForBluetooth andBluetooth LE connections, toggling a switch generates aCSV message in the format:<id>,SWITCH,<state>.

  • Thestate field indicates whether the switch ison (true) oroff (false).

BUTTON

Pressing or releasing a button generates this JSON:

{"id":"the id you specified","type":"BUTTON","state":"PRESS"}

ForBluetooth andBluetooth LE connections, pressing or releasing a button generates aCSV message in the format:<id>,BUTTON,<state>.

  • Thestate field can have following values:
    • "PRESS": When the button is being pressed (finger on the button).
    • "RELEASE": When the button is released (finger lifted off after pressing).
    • "CLICK": Indicates tap gesture

DPAD (Directional Pad)

Pressing or releasing a button on DPAD generates this JSON:

{"id":"the id you specified","type":"DPAD","button":"RIGHT","state":"CLICK"}

ForBluetooth andBluetooth LE connections, pressing or releasing a button on DPAD generates aCSV message in the format:<id>,DPAD,<button>,<state>.

  • Thestate field can have following values:
    • "PRESS": When the button is being pressed (finger on the button).
    • "RELEASE": When the button is released (finger lifted off after pressing).
    • "CLICK": Indicates tap gesture
  • Thebutton field can be"LEFT","RIGHT","UP" or"DOWN"

STEERING WHEEL

Rotating a steering wheel generates this JSON:

{"id":"your id","type":"STEERING_WHEEL","angle":45.233445}

ForBluetooth andBluetooth LE connections theCSV is<id>,STEERING_WHEEL,<angle>

  • whereangle is rotation angle of the steering wheel in degrees
    • Positive values indicate clockwise rotation
    • Negative values indicate counter-clockwise (anti-clockwise) rotation

JOYSTICK

Moving joystick handle generates this JSON:

{"id":"the id you specified","type":"JOYSTICK","x":0.71150637,"y":-0.13367589}

ForBluetooth andBluetooth LE :<id>,JOYSTICK,<x>,<y>

Note : Joystick is not rotatable in the Builder Screen

The values of x and y range:

  • From -1.0 to 1.0 for both axes.
  • Positive x values indicate movement to the right, and negative values indicate movement to the left.
  • Positive y values indicate upward movement, and negative values indicate downward movement.

SLIDER

Dragging the slider thumb generates the following JSON:

{"id":"the id you specified","type":"SLIDER","value":1.4}

ForBluetooth andBluetooth LE connections, dragging the slider thumb generates aCSV message in the format:<id>,SLIDER,<value>.

  • Thevalue field represents the current position of the slider.
  • The value is always within the range of the minimum and maximum values specified during the slider's configuration.

LED

To update the LED, send the following JSON message to the app:

{"id":"the id you specified","type":"LED","state":"ON"}
  • state accepts the following values:

    • "ON" – Turns the LED on
    • "OFF" – Turns the LED off
    • "BLINK" – Makes the LED blink

🎥Video Demo | Changing LED state in DroidPad


GAUGE

To update the Gauge, send the following JSON message to the app::

{"id":"the id you specified","type":"GAUGE","value":120}
  • value is a number input used to update the gauge reading (such as speed, temperature, or progress).

🎥Video Demo | Updating GAUGE value in DroidPad


LOG

Each control pad includes an associated log terminal that displays logs sent from your script.
When you click thelist icon on the control pad, a bottom sheet will appear showing these logs.

To send a log message from your script, use the following JSON payload:

{"type":"LOG","message":"hello world"}

Sensor Readings

image

Accelerometer

Accelerometer data is sent in the following JSON format:

{"type":"ACCELEROMETER","x":0.31892395,"y":-0.97802734,"z":10.049896}

ForBluetooth andBluetooth LE :ACCELEROMTER,<x>,<y>,<z>

Fields

  • x: Acceleration force (in m/s²) applied along thex-axis, including the force of gravity.
  • y: Acceleration force (in m/s²) applied along they-axis, including the force of gravity.
  • z: Acceleration force (in m/s²) applied along thez-axis, including the force of gravity.

Gyroscope

Gyroscope data is sent in the following JSON format:

{"type":"GYROSCOPE","x":0.15387291,"y":-0.22954187,"z":0.08163925}

ForBluetooth andBluetooth LE :GYROSCOPE,<x>,<y>,<z>

Fields

  • x: Rate of rotation around thex-axis inradians per second (rad/s).
  • y: Rate of rotation around they-axis inradians per second (rad/s).
  • z: Rate of rotation around thez-axis inradians per second (rad/s).

Sending JSON Messages to DroidPad

You can send JSON messages to DroidPad to update the UI. All connection types are supported except forBLE. You can update following component

  • SWITCH
  • SLIDER
  • LED

To update aSWITCH,SLIDER,LED, orGAUGE send a JSON object message similar to the ones specified in theSWITCH,SLIDER,LED,GAUGE sections, with the desired value or state.

ForBluetooth Classic andTCP connections, you must send each JSON message on a new line. This is because DroidPad reads the incoming stream line by line. Each JSON message should be on a single line, and multiple messages should be separated by a line feed (\n).

For example:

{"id":"s1","type":"SLIDER","value":1.4}\n{"id":"s1","type":"SLIDER","value":1.5}\n{"id":"s1","type":"SLIDER","value":1.4}

ForMQTT,WebSocket, andUDP connections, you can send formatted JSON without the one-line and line feed restrictions, as these are message-based protocols. ForMQTT you have to publish toDroidPad/feed topic

Important Note for Bluetooth and Bluetooth Low Energy

A long Bluetooth device name can cause advertisement failure (In case of BLE). To avoid this issue, use a shorter name. In your device's Bluetooth settings, change the Bluetooth device name to five or fewer characters, such asdev.

For devices runningAndroid 12 or higher, you also need to ensure that your app has the necessary Bluetooth permissions. To do this, go to the app's system settings and grant the requiredNearby Devices permission. Without this permission, the app won't be able to advertise Bluetooth LE services or access paired devices when using Bluetooth Classic.

Testing the connection

You can test the connections with Websocket,TCP, UDP servers and BLE client provided inhttps://github.com/UmerCodez/droidpad-python-examples

Ardunio Template

See Ardunio code template for CSV and JSON parsingUmerCodez/DroidPad-Arduino-template

Projects

  1. A Tank controlled by an Arduino Uno R4 WiFi using the DroidPad Apphttps://github.com/Klixxy/ArduTank byKlixxy
  2. 3D-printed hexapod with 6-DOF pose control, adaptive gait, and FPV video streaming. Controlled via a Python GUI (TCP/UDP) or the DroidPad Android app. Powered by XIAO ESP32-S3 Sensehttps://github.com/Ozzi06/ESP_Hexapod byOzzi06
  3. Simple websocket server that allows you to use droidpad as a game controllerhttps://github.com/Tofixrs/droidpad-gamepad byTofixrs
  4. A simple server for DroidPad, that can convert DroidPad messages into actual input events on your PC. It can be used alongside DroidPad, to emulate joysticks/keyboards/mouses, and is scriptable using Janet.https://github.com/agent-kilo/jumper
  5. Parse structured data from Sockets Services for Vizzy, written to parse data sended by Droid Pad to control vehicles in Juno:New Origins with a mobile phone or tablethttps://github.com/FourthDing/DataProcessingHelper
  6. droidpad.py is a Python script that serves as a network bridge between an Android device running DroidPad and the Maqueen robot. It receives commands from DroidPad and translates them into Maqueen’s actions, such as movement, LED control, and buzzer activation.

TODOs

  1. TouchPad

[8]ページ先頭

©2009-2025 Movatter.jp