![]() |
JQI Arduino Libraries
Arduino for the modern scientist.
|
Template class implementation of Setlist, for device-specific behavior. More...
#include <SetListArduino.h>
Classes | |
struct | SetListCallback |
Data struct for storing setlist lines. More... | |
Public Types | |
typedef void(* | SpecificSetListCallback )(Device *, int *) |
Type definition for device-specific callback function. More... | |
Public Member Functions | |
SetListDevice (Device &device) | |
Constructor for SetListDevice. More... | |
void | insertToSetList (int pos, GenericSetListCallback function, int *params) |
Inserts callback function into the _setlist of SetListDevice. More... | |
int | getSetListFunc (int pos) |
Returns the pointer value for a SpecificSetListCallback. More... | |
int * | getSetListParams (int pos) |
Returns a pointer to the parameters to be passed to a SetList callback. More... | |
int | getSetListLength () |
Returns the length of a SetListDevice's currently programmed setlist. More... | |
void | clearSetList () |
Clears device's SetList table. More... | |
void | executeSetList (int pos) |
Executes callback function at a particular SetList line. More... | |
![]() | |
SetListBase () | |
Static Private Member Functions | |
static void | _holdValue (Device *, int *params) |
Empty SpecificSetListCallback function to be executed when no state change is needed on Device. More... | |
Private Attributes | |
Device * | _device |
Pointer to the controlled device. More... | |
SetListCallback | _setlist [MAX_SETLIST_LINES] |
List of callback functions & params. More... | |
int | _setlistLength |
Length of device's SetList. More... | |
Template class implementation of Setlist, for device-specific behavior.
SetListDevice inherits from SetListBase. Each device connected to the Arduino will have its own instance of SetListDevice, which manages a list of callback functions and arguments to execute when the Arduino receives a trigger from the computer.
Device |
typedef void(* SetListDevice< Device >::SpecificSetListCallback)(Device *, int *) |
Type definition for device-specific callback function.
|
inline |
Constructor for SetListDevice.
Creates an instance of SetListDevice.
Interesting point of info: be careful about how you instantiate these objects! Calling, eg,
SetListDevice newDevice(DDS1);
is different from calling
SetListDevice newDevice = new SetListDevice(DDS1);
The first will add newDevice
to the stack, while the second method adds it to the heap. For our purposes, SetListDevice() is called from SetListArduino. We want newDevice
to persist after that call passes out of scope, so we should have the compiler allocate memory in the heap.
|
inlinestaticprivate |
Empty SpecificSetListCallback function to be executed when no state change is needed on Device.
|
inlinevirtual |
Clears device's SetList table.
This function doesn't actually overwrite SetListDevice::_setlist. Rather, it resets the counter SetListDevice::_setlistLength to zero.
Reimplemented from SetListBase.
|
inlinevirtual |
Executes callback function at a particular SetList line.
If #SETLIST_DEBUG is set, will print diagnostic information to serial terminal.
pos | Integer specifying the SetList line. |
Reimplemented from SetListBase.
|
inlinevirtual |
Returns the pointer value for a SpecificSetListCallback.
Used for debugging information.
pos | Integer index specifying the SetList line. |
Reimplemented from SetListBase.
|
inlinevirtual |
Returns the length of a SetListDevice's currently programmed setlist.
Reimplemented from SetListBase.
|
inlinevirtual |
Returns a pointer to the parameters to be passed to a SetList callback.
Used for debugging information.
pos | Integer index specifying the SetList line. |
Reimplemented from SetListBase.
|
inlinevirtual |
Inserts callback function into the _setlist of SetListDevice.
pos | Integer indexing the location to place the callback function in SetListDevice::_setlist. |
function | GenericSetListCallback, which will be executed when the Arduino receives the right trigger from the computer. It is passed in as a GenericSetListCallback, but is re-cast as a SpecificSetListCallback using reinterpret_cast . It is done this way to remain agnostic about the type of SetListDevice when it is passed from SetListArduino. In your Arduino sketch, you should define this function and its behavior. |
params | Array of parameters to pass to the callback function. Note, its length is limited by MAX_PARAM_NUM |
Reimplemented from SetListBase.
|
private |
Pointer to the controlled device.
|
private |
List of callback functions & params.
This member data contains the device's actual SetList. The length is limited by MAX_SETLIST_LINES.
|
private |
Length of device's SetList.
Counter to keep track of how many SetList lines have been programmed to SetListDevice.