Loading...
Searching...
No Matches
Public Member Functions | List of all members
Bind Class Reference

The Bind class provides a framework for creating interactive applications with BindCanvas. More...

`#include <Bind.h>`

## 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.
bool | init (Stream &stream, void(&setupCallback)(int16_t, int16_t))
| Initializes the Bind framework with communication and screen setup.
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.
void | sync (const uint8_t *buffer, size_t size)
| Synchronizes the bind with the current state.
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.
void | sync (BindSwitch &obj)
| Synchronizes the BindSwitch object with the BindCanvas screen.
void | sync (BindButton &obj)
| Synchronizes the BindButton object with the BindCanvas screen.
void | sync (BindKnob &obj)
| Synchronizes the BindKnob object with the BindCanvas screen.
void | sync (BindSeekBar &obj)
| Synchronizes the BindSeekBar object with the BindCanvas screen.
void | sync (BindJoystick &obj)
| Synchronizes the BindJoystick object with the BindCanvas screen.
void | sync (BindColorPicker &obj)
| Synchronizes the BindColorPicker object with the BindCanvas screen.
void | sync (BindTextInput &obj)
| Synchronizes the BindTextInput object with the BindCanvas screen.
void | sync (BindDialog &obj)
| Synchronizes the BindDialog object with the BindCanvas screen.

## Detailed Description

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.

Note
  To ensure smooth operation and responsiveness, regularly call the 'sync' function to synchronize your Bind objects with the current state of the BindCanvas screen. Failing to do so may result in missed events, such as button clicks or user interactions with your UI elements.

## Constructor & Destructor Documentation

## ◆ Bind()

Bind::Bind | ( | void(*)(int16_t, int16_t) | _setupCallback | ) |
| 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.

Parameters

  _setupCallback | A pointer to the setup callback function that initializes the Bind screen.

## Member Function Documentation

## ◆ init()

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:

1. It configures the communication device for the Bind framework using a 'Stream' object. The 'stream' can represent any serial port, including hardware, software serial, or Bluetooth classic serial.
2. It sets the screen setup callback. This callback function is automatically invoked by BindCanvas upon establishing a connection. It plays a crucial role in configuring the screen and ensuring that all screen objects are synchronized properly. You will receive two parameters: 'w' for screen width and 'h' for screen height in density-independent pixels (dp). These values allow you to maintain consistent object positioning and size across various devices with different screen dimensions.
   Note
     For more information about density-independent pixels (dp) visit: http://en.wikipedia.org/wiki/Device-independent_pixel
   Parameters

     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.

   Returns
     Returns 'true' if initialization is successful; otherwise, returns 'false'.

## ◆ isReady()

bool Bind::isReady | ( |  | ) |
| 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.

Returns
  True if the object is ready; otherwise, false.

## ◆ sync() [1/13]

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.

Attention
  To ensure smooth operation and prevent data loss or lag, regularly run the following line of code. It's recommended to execute it a few times per second, and faster is even better! Try to achieve a rate more than 10Hz for optimal performance."

Note
  Not needed if using ESP32 as the sync function is called automatically.

## ◆ sync() [2/13]

void Bind::sync | ( | BindButton & | obj | ) |

Synchronizes the BindButton object with the BindCanvas screen.

This function synchronizes the BindButton object with the BindCanvas screen. It adds the object to the canvas, refreshes the existing object, or removes it.

Parameters

  obj | A reference to the 'BindButton' object for data synchronization.

## ◆ sync() [3/13]

void Bind::sync | ( | BindColorPicker & | obj | ) |

Synchronizes the BindColorPicker object with the BindCanvas screen.

This function synchronizes the BindColorPicker object with the BindCanvas screen. It adds the object to the canvas, refreshes the existing object, or removes it.

Parameters

  obj | A reference to the 'BindColorPicker' object for data synchronization.

## ◆ sync() [4/13]

void Bind::sync | ( | BindDialog & | obj | ) |

Synchronizes the BindDialog object with the BindCanvas screen.

This function synchronizes the BindDialog object with the BindCanvas screen. It shows the dialog box Imeadiatly.

Note
  The dialog box will be shown only once and will be removed after the user interaction. to show the dialog again you need to call this function again, it can be the same dialog box object or a new one.
  You can only have 5 dialog boxes at the same time. So if you burst dialog boxes, only the first 5 will be shown and the rest will be ignored. You can show as many dialog boxes as you want but until the other dialog boxes are closed.

Parameters

  obj | A reference to the 'BindDialog' object for data synchronization.

## ◆ sync() [5/13]

void Bind::sync | ( | BindJoystick & | obj | ) |

Synchronizes the BindJoystick object with the BindCanvas screen.

This function synchronizes the BindJoystick object with the BindCanvas screen. It adds the object to the canvas, refreshes the existing object, or removes it.

Parameters

  obj | A reference to the 'BindJoystick' object for data synchronization.

## ◆ sync() [6/13]

void Bind::sync | ( | BindKnob & | obj | ) |

Synchronizes the BindKnob object with the BindCanvas screen.

This function synchronizes the BindKnob object with the BindCanvas screen. It adds the object to the canvas, refreshes the existing object, or removes it.

Parameters

  obj | A reference to the 'BindKnob' object for data synchronization.

## ◆ sync() [7/13]

void Bind::sync | ( | BindSeekBar & | obj | ) |

Synchronizes the BindSeekBar object with the BindCanvas screen.

This function synchronizes the BindSeekBar object with the BindCanvas screen. It adds the object to the canvas, refreshes the existing object, or removes it.

Parameters

  obj | A reference to the 'BindSeekBar' object for data synchronization.

## ◆ sync() [8/13]

void Bind::sync | ( | BindSwitch & | obj | ) |

Synchronizes the BindSwitch object with the BindCanvas screen.

This function synchronizes the BindSwitch object with the BindCanvas screen. It adds the object to the canvas, refreshes the existing object, or removes it.

Parameters

  obj | A reference to the 'BindSwitch' object for data synchronization.

## ◆ sync() [9/13]

void Bind::sync | ( | BindTextInput & | obj | ) |

Synchronizes the BindTextInput object with the BindCanvas screen.

This function synchronizes the BindTextInput object with the BindCanvas screen. It adds the object to the canvas, refreshes the existing object, or removes it.

Parameters

  obj | A reference to the 'BindTextInput' object for data synchronization.

## ◆ sync() [10/13]

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

Parameters

  str | The text data to be printed in the 'BindTerminal' object.
  obj | A pointer to the 'BindTerminal' object for data synchronization.

## ◆ sync() [11/13]

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.

Parameters

  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.

## ◆ sync() [12/13]

void Bind::sync | ( | const uint8_t * | buffer,
|  | size_t | size
| ) |  |

Synchronizes the bind with the current state.

Similar to sync() but uses the buffer directly to be used in some cases that the regular stream object is not available. for example ble, wifi or any other custom communication.

Parameters

  buffer | a pointer to the buffer that contains the data to be processed.
  size | size of the buffer.

## ◆ sync() [13/13]

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.

Parameters

  chartData | The data to be synchronized with the 'BindChart' object.
  obj | A reference to the 'BindChart' object for data synchronization.

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

- Bind.h
- Bind.cpp