BreadMote  1.0
Your remote breadboard. Add an app to your hardware in minutes
BreadMote Class Reference

#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)
 

Detailed Description

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

Member Function Documentation

void BreadMote::addButton ( const char *  name,
void(*)()  f 
)

Creates a button on the app.

Parameters
namethe button's name
fa function with no arguments and no return value, e.g.
void onButton()
See also
onCommand(const char*, bool)
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.

Parameters
namethe check box's name
fa function with only a bool as an argument and no return value, e.g.
void onCheckBox(bool)
valuethe check box's current value. true if checked, false otherwise
See also
onCommand(const char*, bool)
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.

Parameters
namethe label's name. Label names can be formattable (e.g. "Hello %s!")
valuethe 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.

Parameters
namethe radio group's name.
fa function with only an as an argument and no return value, e.g.
void onRadioGroup(bool)
optionsthe list of choices
numOptionsthe number of options. This must match the length of options
selectedOptionthe currently selected option. 0 <= selectedOption <= numOptions
See also
onCommand(const char*, int)
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.

Parameters
namethe slider's name
fa function with only an int as an argument and no return value, e.g.
void onSlider(int)
minminimum slider value
maxmaximum slider value
valuethe slider's current value. min <= value <= max
See also
onCommand(const char*, int)
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.

Parameters
namethe switch's name
fa function with only a bool as an argument and no return value, e.g.
void onSwitch(bool)
valuethe switch's current value. true if on, false otherwise
See also
onCommand(const char*, bool)
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.

Parameters
namethe text field's name
fa function with only a const char* as an argument and no return value, e.g.
void onText(const char*)
valuethe text field's current text
See also
onCommand(const char*, const char*)
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.

Parameters
namethe time picker's name. Note: the time value will be automatically displayed after the name.
fa function with two ints as arguments and no return value, e.g.
void onTimePicked(int, int)
hourthe hour displayed by the time picker
minutethe minute displayed by the time picker
See also
onCommand(const char*, const char*)
int BreadMote::getAvailableBytes ( )
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.

Returns
The number of bytes available to be read from your hardware's radio
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.

Parameters
tagused to identify the source of a log message. It usually identifies where the log occurs
messagethe 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.

char BreadMote::readByte ( )
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.

Returns
An available byte from your hardware's radio
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.

Parameters
namethe 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.

Parameters
namethe name of the component to be enabled
isEnabledtrue if the component is enabled, false otherwise
void BreadMote::update ( const char *  name,
int  value 
)

Updates a previously created slider or radio group.

Parameters
namethe name of the component
valuethe component's new value
void BreadMote::update ( const char *  name,
bool  value 
)

Updates a previously created switch, button or checkbox.

Parameters
namethe name of the component
valuethe component's new value
void BreadMote::update ( const char *  name,
const char *  value 
)

Updates a previously created text field or time picker

Parameters
namethe name of the component
valuethe component's new value
void BreadMote::write ( char *  bytes,
int  numBytes 
)
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.

Parameters
bytesbytes to be written to your hardware's radio
numBytesthe length of bytes