COSA
An Object-Oriented Platform for Arduino Programming
AnalogPins Class Reference

#include <AnalogPins.hh>

Inheritance diagram for AnalogPins:
Inheritance graph
Collaboration diagram for AnalogPins:
Collaboration graph

Public Member Functions

 AnalogPins (const Board::AnalogPin *pins, uint16_t *buffer, uint8_t count, Board::Reference ref=Board::AVCC_REFERENCE)
 
uint8_t count () const
 
Board::AnalogPin pin_at (uint8_t ix) const
 
bool samples_request ()
 
virtual void on_interrupt (uint16_t arg)
 
virtual void on_event (uint8_t type, uint16_t value)
 

Private Member Functions

void reference (Board::Reference ref)
 
Board::Reference reference () const
 
Board::AnalogPin pin () const
 
uint16_t value () const
 
uint16_t sample ()
 
AnalogPinoperator>> (uint16_t &var)
 
 operator uint16_t ()
 
bool sample_request (uint8_t event=Event::NULL_TYPE)
 
bool sample_request (Board::AnalogPin pin, uint8_t ref)
 
uint16_t sample_await ()
 
virtual void on_change (uint16_t value)
 
virtual void enable ()
 
virtual void disable ()
 
virtual void clear ()
 

Static Private Member Functions

static void prescale (uint8_t factor)
 
static uint16_t sample (Board::AnalogPin pin, Board::Reference ref=Board::AVCC_REFERENCE)
 
static uint16_t bandgap (uint16_t vref=1100)
 
static void powerup ()
 
static void powerdown ()
 

Private Attributes

const Board::AnalogPin m_pin
 Analog channel number. More...
 
Board::Reference m_reference
 ADC reference voltage type. More...
 
uint16_t m_value
 Latest sample value. More...
 
uint8_t m_event
 Event to push on completion. More...
 

Static Private Attributes

static AnalogPinsampling_pin = NULL
 Current sampling pin if any. More...
 

Detailed Description

Abstract analog pin set. Allow sampling of a set of pins with interrupt or event handler when completed.

Definition at line 30 of file AnalogPins.hh.

Constructor & Destructor Documentation

AnalogPins::AnalogPins ( const Board::AnalogPin pins,
uint16_t *  buffer,
uint8_t  count,
Board::Reference  ref = Board::AVCC_REFERENCE 
)
inline

Construct abstract analog pin set given vector and number of pins, interrupt handler and environment. The vector of pins should be defined in program memory using PROGMEM.

Parameters
[in]pinsvector with analog pins.
[in]bufferanalog pin value storage.
[in]countnumber of pins in vector.
[in]refreference voltage.

Definition at line 41 of file AnalogPins.hh.

Member Function Documentation

uint8_t AnalogPins::count ( ) const
inline

Get number of analog pins in set.

Returns
set size.

Definition at line 56 of file AnalogPins.hh.

virtual void AnalogPins::on_event ( uint8_t  type,
uint16_t  value 
)
inlinevirtual

Default analog pin set event handler function.

Parameters
[in]typethe type of event.
[in]valuethe event value.

Reimplemented from AnalogPin.

Definition at line 91 of file AnalogPins.hh.

void AnalogPins::on_interrupt ( uint16_t  arg)
virtual

Interrupt service on conversion completion.

Parameters
[in]argsample value.

Reimplemented from AnalogPin.

Definition at line 31 of file AnalogPins.cpp.

Board::AnalogPin AnalogPins::pin_at ( uint8_t  ix) const
inline

Get analog pin in set.

Parameters
[in]ixindex.
Returns
pin number.

Definition at line 66 of file AnalogPins.hh.

bool AnalogPins::samples_request ( )

Request sample of analog pin set.

Definition at line 24 of file AnalogPins.cpp.


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