Bind
C++ UI toolkit for Arduino
 
Loading...
Searching...
No Matches
BindColorPicker Class Reference

BindColorPicker Class. More...

#include <BindColorPicker.hpp>

Inheritance diagram for BindColorPicker:
BindView

Public Member Functions

void setCallback (void(*callback)(uint8_t, uint8_t, uint8_t))
 Set the Callback function for the color picker.
 
void invokeCallback (uint8_t redIn, uint8_t greenIn, uint8_t blueIn)
 
uint16_t getBytes (uint8_t *out) override
 Serialize the color picker object into bytes.
 

Public Attributes

int16_t x = 0
 The x-coordinate position of the color picker on the screen.
 
int16_t y = 0
 The y-coordinate position of the color picker on the screen.
 
uint8_t cmdId = 0
 Command identifier to add or refresh the color picker. See the notes for possible cmdId values.
 
int16_t dimSize = 200
 The dimensions (size) of the color picker.
 
uint8_t red = 0
 The initial value for the red component of the selected color (0-255).
 
uint8_t green = 0
 The initial value for the green component of the selected color (0-255).
 
uint8_t blue = 0
 The initial value for the blue component of the selected color (0-255).
 
- Public Attributes inherited from BindView
int16_t tag
 

Detailed Description

BindColorPicker Class.

BindColorPicker

The BindColorPicker class is part of the Bind framework for Arduino, designed to facilitate the creation of interactive user interface elements. Specifically, it represents a color picker element that can be displayed and controlled on the BindCanvas Android app interface.

This class allows you to define a color picker's properties, including its position, size, and the initial RGB color values. You can synchronize these properties with BindCanvas to provide a visual color selection component in your Arduino projects.

To use the BindColorPicker class effectively, you can set its attributes such as the position (x and y coordinates), dimensions (size), and initial color (red, green, and blue values). The cmdId parameter specifies whether to add the color picker to the BindCanvas or refresh an existing one.

Note
: Possible cmdId values for a BindView and corresponding effects:
  • BIND_ADD_OR_REFRESH_CMD: Adds the object to the canvas (screen) or refreshes the existing one.
  • BIND_DATA_ONLY_CMD: Refreshes the existing object without moving or resizing; updates data, such as text.
  • BIND_REMOVE_CMD: Removes the object from the canvas (screen).
  • BIND_DISABLE_CMD: Disables the object.
  • BIND_ENABLE_CMD: Enables the object.
  • BIND_HIDE_CMD: Hides the object.
  • BIND_VISIBLE_CMD: Restores the object's visibility.

Additionally, you should regularly call bind.sync() in your main loop to ensure that the color picker reflects the user interactions and properly calls the colorPicker callback

Example usage:

BindColorPicker colorPicker;
void colorPicker_changed(uint8_t red, uint8_t green, uint8_t blue){
// custom actions based on the color picker value
}
- and in the onConnection() callback:
colorPicker.x = 30;
colorPicker.y = 100;
colorPicker.dimSize = 200;
colorPicker.red = 255;
colorPicker.green = 0;
colorPicker.blue = 0;
colorPicker.cmdId = BIND_ADD_OR_REFRESH_CMD;
colorPicker.setCallback(colorPicker_changed);
bind.sync(colorPicker);
BindColorPicker Class.
Definition BindColorPicker.hpp:56
int16_t dimSize
The dimensions (size) of the color picker.
Definition BindColorPicker.hpp:68
uint8_t cmdId
Command identifier to add or refresh the color picker. See the notes for possible cmdId values.
Definition BindColorPicker.hpp:67
uint8_t blue
The initial value for the blue component of the selected color (0-255).
Definition BindColorPicker.hpp:71
uint8_t green
The initial value for the green component of the selected color (0-255).
Definition BindColorPicker.hpp:70
void setCallback(void(*callback)(uint8_t, uint8_t, uint8_t))
Set the Callback function for the color picker.
Definition BindColorPicker.hpp:84
int16_t y
The y-coordinate position of the color picker on the screen.
Definition BindColorPicker.hpp:66
uint8_t red
The initial value for the red component of the selected color (0-255).
Definition BindColorPicker.hpp:69
int16_t x
The x-coordinate position of the color picker on the screen.
Definition BindColorPicker.hpp:65
Note
check the BindColorPicker examples for more information.

Member Function Documentation

◆ getBytes()

uint16_t BindColorPicker::getBytes ( uint8_t *  out)
inlineoverridevirtual

Serialize the color picker object into bytes.

This function serializes the color picker object into a byte array, allowing it to be sent and displayed on BindCanvas.

Parameters
outA pointer to the byte array where the serialized data will be stored.
Returns
The offset representing the length of the serialized data.

Reimplemented from BindView.

◆ setCallback()

void BindColorPicker::setCallback ( void(*)(uint8_t, uint8_t, uint8_t)  callback)
inline

Set the Callback function for the color picker.

This callback function is called when the color picker value is changed. The signature of the callback function should be like:

void callback(uint8_t red, uint8_t green, uint8_t blue)
Parameters
callback

The documentation for this class was generated from the following files: