![]() |
BreadMote
1.0
Your remote breadboard. Add an app to your hardware in minutes
|
#include <BreadMote.h>
Public Member Functions | |
void | read () |
void | update (const char *name, int value) |
void | update (const char *name, bool value) |
void | update (const char *name, const char *value) |
void | addSlider (const char *name, void(*f)(int), int min, int max, int value) |
void | addSwitch (const char *name, void(*f)(bool), bool value) |
void | addButton (const char *name, void(*f)()) |
void | addCheckBox (const char *name, void(*f)(bool), bool value) |
void | addTextField (const char *name, void(*f)(const char *), const char *value) |
void | addLabel (const char *name, const char *value) |
void | addTimePicker (const char *name, void(*f)(char, char), char hour, char minute) |
void | addRadioGroup (const char *name, void(*f)(int), const char **options, unsigned char numOptions, unsigned char selectedOption) |
void | remove (const char *name) |
void | setEnabled (const char *name, bool isEnabled) |
void | logError (const char *tag, const char *message) |
Protected Member Functions | |
char | readByte () |
int | getAvailableBytes () |
void | write (char *bytes, int numBytes) |
This class handles all communication between your hardware's radio and the BreadMote application, allowing you to create a custom app interface for your hardware. It also allows you to easily handle what each user interaction from the app does.
Be sure to checkout the short and easy to follow examples found here
void BreadMote::addButton | ( | const char * | name, |
void(*)() | f | ||
) |
Creates a button on the app.
name | the button's name |
f | a function with no arguments and no return value, e.g. void onButton() |
void BreadMote::addCheckBox | ( | const char * | name, |
void(*)(bool) | f, | ||
bool | value | ||
) |
Creates a check box on the app which can be used to toggle a boolean.
name | the check box's name |
f | a function with only a bool as an argument and no return value, e.g. void onCheckBox(bool) |
value | the check box's current value. true if checked, false otherwise |
void BreadMote::addLabel | ( | const char * | name, |
const char * | value | ||
) |
Creates a text field on the app which can be used to display a value. A label cannot be interacted with by a user.
name | the label's name. Label names can be formattable (e.g. "Hello %s!" ) |
value | the text displayed by the label. If name is formattable, param will be inserted. Otherwise, param will be displayed next to name |
void BreadMote::addRadioGroup | ( | const char * | name, |
void(*)(int) | f, | ||
const char ** | options, | ||
unsigned char | numOptions, | ||
unsigned char | selectedOption | ||
) |
Creates a radio group on the app. A radio group is a group of options where only one option can be selected at a time.
name | the radio group's name. |
f | a function with only an as an argument and no return value, e.g. void onRadioGroup(bool) |
options | the list of choices |
numOptions | the number of options. This must match the length of options |
selectedOption | the currently selected option. 0 <= selectedOption <= numOptions |
void BreadMote::addSlider | ( | const char * | name, |
void(*)(int) | f, | ||
int | min, | ||
int | max, | ||
int | value | ||
) |
Creates a slider (aka seek bar) on the app which can be used to select from a range of integers.
name | the slider's name |
f | a function with only an int as an argument and no return value, e.g. void onSlider(int) |
min | minimum slider value |
max | maximum slider value |
value | the slider's current value. min <= value <= max |
void BreadMote::addSwitch | ( | const char * | name, |
void(*)(bool) | f, | ||
bool | value | ||
) |
Creates a switch on the app which can be used to toggle a boolean.
name | the switch's name |
f | a function with only a bool as an argument and no return value, e.g. void onSwitch(bool) |
value | the switch's current value. true if on, false otherwise |
void BreadMote::addTextField | ( | const char * | name, |
void(*)(const char *) | f, | ||
const char * | value | ||
) |
Creates an editable text field on the app which can be used to send text.
name | the text field's name |
f | a function with only a const char* as an argument and no return value, e.g. void onText(const char*) |
value | the text field's current text |
void BreadMote::addTimePicker | ( | const char * | name, |
void(*)(char, char) | f, | ||
char | hour, | ||
char | minute | ||
) |
Creates a time picker on the app which can be used to send time values.
name | the time picker's name. Note: the time value will be automatically displayed after the name. |
f | a function with two ints as arguments and no return value, e.g. void onTimePicked(int, int) |
hour | the hour displayed by the time picker |
minute | the minute displayed by the time picker |
|
protected |
Automatically called to check how many bytes are available from your hardware's radio (e.g. your Wi-Fi module via Serial). This method should not be called directly and will be called internally by the BreadMote class.
You must implement this method.
void BreadMote::logError | ( | const char * | tag, |
const char * | message | ||
) |
Displays a log message on the app. This can be useful for debugging or display error messages to the user.
tag | used to identify the source of a log message. It usually identifies where the log occurs |
message | the message you would like logged |
void BreadMote::read | ( | ) |
Checks to see if there are any messages available to read from your hardware's radio.
This should be called in your hardware's main loop.
|
protected |
Automatically called to read a single byte from your hardware's radio (e.g. your Wi-Fi module via Serial). This will only be called if getAvailableBytes() returns a value > 0. This method should not be called directly and will be called internally by the BreadMote class.
You must implement this method.
void BreadMote::remove | ( | const char * | name | ) |
Removes the specified component from the app. Note: once a component is removed, it can no longer be updated.
name | the name of the component to be removed |
void BreadMote::setEnabled | ( | const char * | name, |
bool | isEnabled | ||
) |
Enables or disables the specified component on the app. An enabled component can be be interacted with by a user. Note: By default, all components are enabled when created.
name | the name of the component to be enabled |
isEnabled | true if the component is enabled, false otherwise |
void BreadMote::update | ( | const char * | name, |
int | value | ||
) |
Updates a previously created slider or radio group.
name | the name of the component |
value | the component's new value |
void BreadMote::update | ( | const char * | name, |
bool | value | ||
) |
Updates a previously created switch, button or checkbox.
name | the name of the component |
value | the component's new value |
void BreadMote::update | ( | const char * | name, |
const char * | value | ||
) |
Updates a previously created text field or time picker
name | the name of the component |
value | the component's new value |
|
protected |
Automatically called to write bytes to your hardware's radio. This method should not be called directly and will be called internally by the BreadMote class.
You must implement this method.
bytes | bytes to be written to your hardware's radio |
numBytes | the length of bytes |