The Bind class provides a framework for creating interactive applications with BindCanvas. More...
#include <Bind.hpp>
Public Member Functions | |
Bind (void(*_setupCallback)(int16_t, int16_t)) | |
Constructs a Bind object with a setup callback function. | |
bool | isReady () |
Checks if the bind object is in a ready state. | |
void | sync (BindView *obj) |
Synchronizes a BindView object with the BindCanvas screen. | |
void | sync (BindView &obj) |
Synchronizes a BindView object with the BindCanvas screen. Same as sync(BindView *obj) but uses the object refrence to prevent common mistakes. | |
void | sync () |
Synchronizes the bind with the current state. | |
bool | init (Stream *stream, void(*setupCallback)(int16_t, int16_t)) |
Initializes the Bind framework with communication and screen setup. | |
bool | init (Stream &stream, void(&setupCallback)(int16_t, int16_t)) |
Initializes the Bind framework with communication and screen setup. | |
void | join (BindButton *screenButton, void(*clickCallback)(void)) |
Binds a Button object to a click callback function. | |
void | join (BindButton &screenButton, void(&clickCallback)(void)) |
Binds a Button object to a click callback function. | |
void | join (BindKnob *screenKnob, void(*changeCallback)(int16_t)) |
Binds a Dial Knob object to a change callback function. | |
void | join (BindKnob &screenKnob, void(&changeCallback)(int16_t)) |
Binds a Dial Knob object to a change callback function. | |
void | join (BindSwitch *screenSwitch, void(*clickCallback)(bool)) |
Binds a ON/OFF Switch object to a click callback function. | |
void | join (BindSwitch &screenSwitch, void(&clickCallback)(bool)) |
Binds a ON/OFF Switch object to a click callback function. | |
void | join (BindSeekBar *screenSeekBar, void(*changeCallback)(int16_t)) |
Binds a SeekBar object to a change callback function. | |
void | join (BindSeekBar &screenSeekBar, void(&changeCallback)(int16_t)) |
Binds a SeekBar object to a change callback function. | |
void | join (BindJoystick *screenJoystick, void(*changeCallback)(int16_t, int16_t)) |
Binds a Joystick object to a change callback function. | |
void | join (BindJoystick &screenJoystick, void(&changeCallback)(int16_t, int16_t)) |
Binds a Joystick object to a change callback function. | |
void | join (BindColorPicker *screenColorPicker, void(*clickCallback)(uint8_t, uint8_t, uint8_t)) |
Binds a Color Picker object to a click callback function. | |
void | join (BindColorPicker &screenColorPicker, void(&clickCallback)(uint8_t, uint8_t, uint8_t)) |
Binds a Color Picker object to a click callback function. | |
void | sync (float chartData, BindChart &obj) |
Synchronizes chart data of a BindChart object. | |
void | sync (const char *str, int32_t textColor, bool autoScroll, bool newLine, bool bold, bool italic, BindTerminal &obj) |
Prints terminal data in a BindTerminal object. | |
void | sync (const char *str, BindTerminal &obj) |
Prints terminal data in a BindTerminal object. | |
The Bind class provides a framework for creating interactive applications with BindCanvas.
Bind is a versatile class that enables you to build applications that interact with BindCanvas. It provides functions for binding and synchronizing various UI elements, including buttons, knobs, switches, seekbars, joysticks, color pickers, terminals, and many more. You can use Bind to connect your c++ programme to the BindCanvas screen, manage user interactions, and update UI elements in real time.
![]()
Sample app created by Bind | ![]()
Sample app created by Bind |
To use Bind effectively, you can define a setup callback function to configure the initial state of your application, including screen setup and object synchronization. Bind also allows you to set the communication device, such as a serial port, for data exchange with BindCanvas.
|
inline |
Constructs a Bind object with a setup callback function.
This constructor creates a Bind object and associates it with a setup callback function. The setup callback is in charge of configuring the initial state of the Bind object, which includes screen rotation and syncing all the objects. To put it simply, 'setupCallback' is where you construct the application view.
_setupCallback | A pointer to the setup callback function that initializes the Bind screen. |
bool Bind::init | ( | Stream & | stream, |
void(&)(int16_t, int16_t) | setupCallback | ||
) |
Initializes the Bind framework with communication and screen setup.
This function serves a dual purpose:
stream | A reference to the 'Stream' object representing the communication device. |
setupCallback | A reference to the screen setup callback function. This function receives 'w' for width and 'h' for height. It ensures consistent object positioning and size across devices. |
bool Bind::init | ( | Stream * | stream, |
void(*)(int16_t, int16_t) | setupCallback | ||
) |
Initializes the Bind framework with communication and screen setup.
This function serves a dual purpose:
stream | A pointer to the 'Stream' object representing the communication device. |
setupCallback | A pointer to the screen setup callback function. This function receives 'w' for width and 'h' for height. It ensures consistent object positioning and size across devices. |
|
inline |
Checks if the bind object is in a ready state.
This function checks whether the Bind object is in a ready state, which indicates whether it is connected or not.
void Bind::join | ( | BindButton & | screenButton, |
void(&)(void) | clickCallback | ||
) |
Binds a Button object to a click callback function.
This function establishes a connection between a Button object and a click callback function. It takes two parameters: a reference to the 'BindButton' object, 'screenButton,' and a reference to a callback function, 'clickCallback,' which handles button click events.
screenButton | A reference to the 'BindButton' object to bind. |
clickCallback | A reference to the callback function that responds to button clicks. |
void Bind::join | ( | BindButton * | screenButton, |
void(*)(void) | clickCallback | ||
) |
Binds a Button object to a click callback function.
This function establishes a connection between a Button object and a click callback function. It takes two parameters: a pointer to the 'BindButton' object, 'screenButton,' and a pointer to a callback function, 'clickCallback,' which handles button click events.
screenButton | A pointer to the 'BindButton' object to bind. |
clickCallback | A pointer to the callback function that responds to button clicks. |
void Bind::join | ( | BindColorPicker & | screenColorPicker, |
void(&)(uint8_t, uint8_t, uint8_t) | clickCallback | ||
) |
Binds a Color Picker object to a click callback function.
This function establishes a connection between a Color Picker object and a click callback function. It takes two parameters: a reference to the 'BindColorPicker' object, 'screenColorPicker,' and a reference to a callback function, 'clickCallback,' which handles color selection events.
screenColorPicker | A reference to the 'BindColorPicker' object to bind. |
clickCallback | A reference to the callback function that responds to color selection events. |
void Bind::join | ( | BindColorPicker * | screenColorPicker, |
void(*)(uint8_t, uint8_t, uint8_t) | clickCallback | ||
) |
Binds a Color Picker object to a click callback function.
This function establishes a connection between a Color Picker object and a click callback function. It takes two parameters: a pointer to the 'BindColorPicker' object, 'screenColorPicker,' and a pointer to a callback function, 'clickCallback,' which handles color selection events.
screenColorPicker | A pointer to the 'BindColorPicker' object to bind. |
clickCallback | A pointer to the callback function that responds to color selection events. |
void Bind::join | ( | BindJoystick & | screenJoystick, |
void(&)(int16_t, int16_t) | changeCallback | ||
) |
Binds a Joystick object to a change callback function.
This function establishes a connection between a Joystick object and a change callback function. It takes two parameters: a reference to the 'BindJoystick' object, 'screenJoystick,' and a reference to a callback function, 'changeCallback,' which handles changes in the joystick's position.
screenJoystick | A reference to the 'BindJoystick' object to bind. |
changeCallback | A reference to the callback function that responds to joystick position changes. |
void Bind::join | ( | BindJoystick * | screenJoystick, |
void(*)(int16_t, int16_t) | changeCallback | ||
) |
Binds a Joystick object to a change callback function.
This function establishes a connection between a Joystick object and a change callback function. It takes two parameters: a pointer to the 'BindJoystick' object, 'screenJoystick,' and a pointer to a callback function, 'changeCallback,' which handles changes in the joystick's position.
screenJoystick | A pointer to the 'BindJoystick' object to bind. |
changeCallback | A pointer to the callback function that responds to joystick position changes. |
void Bind::join | ( | BindKnob & | screenKnob, |
void(&)(int16_t) | changeCallback | ||
) |
Binds a Dial Knob object to a change callback function.
This function establishes a connection between a Dial Knob object and a change callback function. It takes two parameters: a reference to the 'BindKnob' object, 'screenKnob,' and a reference to a callback function, 'changeCallback,' which handles changes in the dial knob's value.
screenKnob | A reference to the 'BindKnob' object to bind. |
changeCallback | A reference to the callback function that responds to dial knob value changes. |
void Bind::join | ( | BindKnob * | screenKnob, |
void(*)(int16_t) | changeCallback | ||
) |
Binds a Dial Knob object to a change callback function.
This function establishes a connection between a Dial Knob object and a change callback function. It takes two parameters: a pointer to the 'BindKnob' object, 'screenKnob,' and a pointer to a callback function, 'changeCallback,' which handles changes in the dial knob's value.
screenKnob | A pointer to the 'BindKnob' object to bind. |
changeCallback | A pointer to the callback function that responds to dial knob value changes. |
void Bind::join | ( | BindSeekBar & | screenSeekBar, |
void(&)(int16_t) | changeCallback | ||
) |
Binds a SeekBar object to a change callback function.
This function establishes a connection between a SeekBar object and a change callback function. It takes two parameters: a reference to the 'BindSeekBar' object, 'screenSeekBar,' and a reference to a callback function, 'changeCallback,' which handles SeekBar value changes. The callback receives an integer parameter representing the new value of the seekbar.
screenSeekBar | A reference to the 'BindSeekBar' object to bind. |
changeCallback | A reference to the callback function that responds to SeekBar changes. |
void Bind::join | ( | BindSeekBar * | screenSeekBar, |
void(*)(int16_t) | changeCallback | ||
) |
Binds a SeekBar object to a change callback function.
This function establishes a connection between a SeekBar object and a change callback function. It takes two parameters: a pointer to the 'BindSeekBar' object, 'screenSeekBar,' and a pointer to a callback function, 'changeCallback,' which handles SeekBar value changes. The callback receives an integer parameter representing the new value of the seekbar.
screenSeekBar | A pointer to the 'BindSeekBar' object to bind. |
changeCallback | A pointer to the callback function that responds to SeekBar changes. |
void Bind::join | ( | BindSwitch & | screenSwitch, |
void(&)(bool) | clickCallback | ||
) |
Binds a ON/OFF Switch object to a click callback function.
This function establishes a connection between a Switch object and a click callback function. It takes two parameters: a reference to the 'BindSwitch' object, 'screenSwitch,' and a reference to a callback function, 'clickCallback,' which handles switch state changes.
screenSwitch | A reference to the 'BindSwitch' object to bind. |
clickCallback | A reference to the callback function that responds to switch state changes. |
void Bind::join | ( | BindSwitch * | screenSwitch, |
void(*)(bool) | clickCallback | ||
) |
Binds a ON/OFF Switch object to a click callback function.
This function establishes a connection between a Switch object and a click callback function. It takes two parameters: a pointer to the 'BindSwitch' object, 'screenSwitch,' and a pointer to a callback function, 'clickCallback,' which handles switch state changes.
screenSwitch | A pointer to the 'BindSwitch' object to bind. |
clickCallback | A pointer to the callback function that responds to switch state changes. |
void Bind::sync | ( | ) |
Synchronizes the bind with the current state.
This function synchronizes the Bind object with the current state by reading data from the canvas and managing user interactions with Bind views, such as button presses or connection requests. In simpler terms, it reads the screen.
void Bind::sync | ( | BindView * | obj | ) |
Synchronizes a BindView object with the BindCanvas screen.
This function synchronizes a 'BindView' object, 'obj,' with the BindCanvas screen, ensuring that the object reflects the most up-to-date data and appearance as intended.
obj | A pointer to the 'BindView' object (e.g. BindButton, BindSeekbar) to synchronize. |
void Bind::sync | ( | const char * | str, |
BindTerminal & | obj | ||
) |
Prints terminal data in a BindTerminal object.
This function prints terminal data with this simple format: textColor is white autoScroll is enable always adds a new line No bold, no italic
str | The text data to be printed in the 'BindTerminal' object. |
obj | A pointer to the 'BindTerminal' object for data synchronization. |
void Bind::sync | ( | const char * | str, |
int32_t | textColor, | ||
bool | autoScroll, | ||
bool | newLine, | ||
bool | bold, | ||
bool | italic, | ||
BindTerminal & | obj | ||
) |
Prints terminal data in a BindTerminal object.
This function synchronizes terminal data, including text, text color, formatting options, and terminal behavior, with a 'BindTerminal' object.
str | The text data to be printed in the 'BindTerminal' object. |
textColor | The color of the text. |
autoScroll | Determines whether auto-scrolling is enabled. |
newLine | Determines whether a new line is added after the text. |
bold | Indicates whether the text should be bold. |
italic | Indicates whether the text should be italic. |
obj | A reference to the 'BindTerminal' object for data synchronization. |
void Bind::sync | ( | float | chartData, |
BindChart & | obj | ||
) |
Synchronizes chart data of a BindChart object.
This function synchronizes the chart data represented by a float value with a 'BindChart' object. It takes two parameters: the 'chartData' to be synchronized and a pointer to the 'BindChart' object, 'obj' so that it knows the data blong to which chart. This function updates the chart data on the screen immediately.