Skip to content

UI Layout

RadioKit uses a virtual coordinate system which is independent of the actual screen size of the device. The default canvas size is 200x100 (landscape) or 100x200 (portrait).


(0,100) +--------------------------+ (200,100)
| |
| Coord system (0-200) |
| |
(0,0) +--------------------------+ (200,0)
  • Origin: (0,0) is the bottom-left corner.
  • Anchor: x, y coordinates refer to the center of the widget.
  • Canvas Range: 0-200 on both axes. Values outside this range are clamped.
  • Rotation: 0-360 degrees. Positive is clockwise.

RadioKit uses an explicit Height & Width model. Each widget defines its physical dimensions in the virtual 200x200 canvas.

finalHeight = height
finalWidth = (width != 0) ? width : (height x defaultAspect)
  • height — Primary size control (vertical span, 0-200). Default is 10.
  • width — Horizontal span (0-200).
    • If 0 (default), the widget uses its internal Default Aspect Ratio.
    • If non-zero, it overrides the aspect ratio.
    • Fixed Aspect Widgets: Some widgets (Buttons, Knobs, Joysticks) enforce a fixed aspect ratio (e.g. 1.0). For these, the width parameter is ignored.
WidgetAspect RatioNotes
PushButton / ToggleButton1.0Square
SlideSwitch2.5Wider than tall
Slider5.0Wide horizontal
GasPedal5.0Same as Slider
Knob / SteeringWheel1.0Square
Joystick1.0Square
LED1.0Square
Text4.0Wide text area
MultipleButton / Select1.0Square
RK_Slider slider({
.x = 100, .y = 50,
.height = 15, // 15 units tall
.width = 120, // 120 units wide (override)
.rotation = 0,
.label = "Throttle"
});

Result: A wide, tall slider.


All widgets share these common parameters in their Props struct:

ParameterTypeDescriptionDefault
x, yuint8Center position (0-200)100, 100
heightuint8Physical height (0-200)10
widthuint8Physical width (0-200)0 (Auto)
rotationint16Rotation in degrees (clockwise)0
labelconst char*Text label above widgetnullptr
iconconst char*Icon name from skinnullptr
// Top-left corner
RK_Button btn1({ .x = 20, .y = 180, .height = 10, .width = 0, .rotation = 0, .label = "TL" });
// Center
RK_Button btn2({ .x = 100, .y = 100, .height = 10, .width = 0, .rotation = 0, .label = "Center" });
// Bottom-right
RK_Button btn3({ .x = 180, .y = 20, .height = 10, .width = 0, .rotation = 0, .label = "BR" });

Layout settings are managed through RadioKit.config in setup().

void setup() {
RadioKit.config.name = "MyRobot";
RadioKit.config.description = "Robot Controller";
RadioKit.config.theme = RK_DEFAULT;
RadioKit.config.orientation = RK_LANDSCAPE; // or RK_PORTRAIT
RadioKit.config.width = 200; // 0 = auto (default)
RadioKit.config.height = 200; // 0 = auto (default)
RadioKit.begin();
RadioKit.startBLE("MyRobot");
}
ParameterDefaultDescription
orientationRK_LANDSCAPERK_LANDSCAPE or RK_PORTRAIT (affects default aspect)
width0 (auto)Canvas width in virtual units (0-200)
height0 (auto)Canvas height in virtual units (0-200)

Note: Setting width and height to 0 enables auto-sizing based on widget positions.


Set via RadioKit.config.theme:

ThemeDescription
RK_DEFAULTLight blue, modern (default)
RK_DARKDark mode
RK_RETROCRT green phosphor
RK_NEONCyberpunk neon
RK_MINIMALFlat, minimal
RK_FUTURISTICFuturistic
RK_MILITARYMilitary style
RK_CYBERPUNKCyberpunk aesthetic
"custom-url"Custom skin from GitHub

Icons are referenced by string name. Standard names ensure cross-theme compatibility:

CategoryIcons
Power"power", "power-off", "battery"
Connectivity"wifi", "bluetooth", "usb", "antenna"
Actions"play", "pause", "stop", "record"
Sensors"temperature", "pressure", "gyro"
Navigation"arrow-up", "arrow-down", "home"
Generic"settings", "menu", "info", "warning"

Example:

RK_Button btn({
.x = 50, .y = 50,
.height = 15,
.width = 0,
.rotation = 0,
.icon = "wifi",
.label = "WiFi"
});

Widgets can be modified at runtime via their rk interface:

void loop() {
RadioKit.update();
// Change label dynamically
status.rk.label = "ALERT!";
RadioKit.pushMetaUpdate(status.widgetId);
// Change position
slider.rk.x = newX;
slider.rk.y = newY;
// Update value
slider.rk.value = 50;
RadioKit.pushUpdate(slider.widgetId);
}
MethodDescription
widget.rk.labelUpdate label text
widget.rk.iconUpdate icon name
widget.rk.x/yUpdate position
widget.rk.heightUpdate physical height
widget.rk.widthUpdate physical width
widget.rk.rotationUpdate rotation
widget.rk.valueUpdate current value (input widgets)

  1. Use consistent spacing — Maintain 10-20 unit gaps between widgets.
  2. Group related controls — Place related widgets near each other.
  3. Respect safe zones — Keep critical controls away from edges (10-20 unit margin).
  4. Use appropriate height — Buttons: 15-20, Sliders: 10-12.
  5. Leverage width override — Make sliders wide (e.g. width=80), knobs square (width=0).
  6. Test on different screens — Virtual coordinates ensure consistency.
  7. Max 16 widgets — Plan your layout to fit within RADIOKIT_MAX_WIDGETS.