ESP  0.1
The Example-based Sensor Predictions (ESP) system tries to bring machine learning to the maker community.
FirmataStream Class Reference

Input stream for reading analog data from an Arduino running Firmata. To use an FirmataStream in your application, pass it to useInputStream() in your setup() function. More...

#include <istream.h>

Inheritance diagram for FirmataStream:
InputStream Stream

Public Member Functions

 FirmataStream (uint32_t port)
 
virtual bool start () final
 
virtual void stop () final
 
virtual int getNumInputDimensions () final
 
void useAnalogPin (int i)
 
- Public Member Functions inherited from InputStream
 InputStream ()
 
virtual ~InputStream ()=default
 
virtual int getNumOutputDimensions ()
 
void useNormalizer (normalizeFunc f)
 
void useNormalizer (vectorNormalizeFunc f)
 
void onDataReadyEvent (onDataReadyCallback callback)
 
template<typename T1 , typename arg , class T >
void onDataReadyEvent (T1 *owner, void(T::*listenerMethod)(arg))
 
void setLabelsForAllDimensions (const vector< string > labels)
 
void setLabelsForAllDimensions (std::initializer_list< string > list)
 
const vector< string > & getLabels () const
 
- Public Member Functions inherited from Stream
 Stream ()
 
void toggle ()
 
bool hasStarted ()
 

Additional Inherited Members

- Public Types inherited from InputStream
using normalizeFunc = std::function< double(double)>
 
using vectorNormalizeFunc = std::function< vector< double >(vector< double >)>
 
typedef std::function< void(GRT::MatrixDouble)> onDataReadyCallback
 
- Protected Member Functions inherited from InputStream
vector< double > normalize (vector< double >)
 
- Protected Attributes inherited from InputStream
vector< string > InputStream_labels_
 
onDataReadyCallback data_ready_callback_
 
normalizeFunc normalizer_
 
vectorNormalizeFunc vectorNormalizer_
 
- Protected Attributes inherited from Stream
std::atomic_bool has_started_
 

Detailed Description

Input stream for reading analog data from an Arduino running Firmata. To use an FirmataStream in your application, pass it to useInputStream() in your setup() function.

Constructor & Destructor Documentation

FirmataStream::FirmataStream ( uint32_t  port)

Create a FirmataStream instance. Assumes the Arduino is communicating at 57600 baud.

Parameters
portthe index of the (USB) serial port to use.

Member Function Documentation

int FirmataStream::getNumInputDimensions ( )
finalvirtual

Get the number of dimensions of the data that's provided by the input stream (before it's run through the normalizer, if any).

Implements InputStream.

bool FirmataStream::start ( )
finalvirtual

Start the stream.

Reimplemented from Stream.

void FirmataStream::stop ( )
finalvirtual

Reimplemented from Stream.

void FirmataStream::useAnalogPin ( int  i)

Include readings from the specified analog pin in the data reported by this FirmataStream. Data will be ordered according to the sequence of calls to this function (i.e. readings from the pin passed to the first call to useAnalogPin() will appear first in the data provided by the FirmataStream).

Parameters
ian analog pin to read from

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