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

#include <AnalogComparator.hh>

Inheritance diagram for AnalogComparator:
Inheritance graph
Collaboration diagram for AnalogComparator:
Collaboration graph

Public Types

enum  Mode { ON_TOGGLE_MODE = 0, ON_FALLING_MODE = _BV(ACIS1), ON_RISING_MODE = (_BV(ACIS1) | _BV(ACIS0)) }
 

Public Member Functions

 AnalogComparator (Mode mode=ON_TOGGLE_MODE, bool bandgap=false)
 
 AnalogComparator (Board::AnalogPin pin, Mode mode=ON_TOGGLE_MODE)
 
virtual void enable ()
 
virtual void disable ()
 
virtual void on_interrupt (uint16_t arg=0)
 
virtual void clear ()
 
virtual void on_event (uint8_t type, uint16_t value)
 

Protected Attributes

Mode m_mode
 Compare mode. More...
 
uint8_t m_pin
 Analog channel. More...
 

Static Protected Attributes

static AnalogComparators_comparator = NULL
 Current comparator. More...
 
static const uint8_t AIN1 = 254
 Default reference voltage. More...
 
static const uint8_t VBG = 255
 Bandgap voltage reference. More...
 

Friends

void ANALOG_COMP_vect (void)
 

Detailed Description

Analog Comparator; compare input values on the positive pin AIN0 (D6) and negative pin AIN1 (D7), bandgap voltage or ADCn. Note: only one instance can be active/enabled at a time.

Definition at line 32 of file AnalogComparator.hh.

Member Enumeration Documentation

Enumerator
ON_TOGGLE_MODE 
ON_FALLING_MODE 
ON_RISING_MODE 

Definition at line 34 of file AnalogComparator.hh.

Constructor & Destructor Documentation

AnalogComparator::AnalogComparator ( Mode  mode = ON_TOGGLE_MODE,
bool  bandgap = false 
)
inline

Construct analog comparator handler. Compare AIN0 (D6) with AIN1 (D7) or bandgap voltage (1V1).

Parameters
[in]modecomparator mode.

Definition at line 45 of file AnalogComparator.hh.

AnalogComparator::AnalogComparator ( Board::AnalogPin  pin,
Mode  mode = ON_TOGGLE_MODE 
)
inline

Construct analog comparator handler. Compare AIN0 (D6) with given analog pin (ADCn).

Parameters
[in]pinanalog pin to compare with.
[in]modecomparator mode.

Definition at line 56 of file AnalogComparator.hh.

Member Function Documentation

virtual void Interrupt::Handler::clear ( )
inlinevirtualinherited

Clear interrupt.

Reimplemented in InputCapture, and ExternalInterrupt.

Definition at line 59 of file Interrupt.hh.

virtual void AnalogComparator::disable ( )
inlinevirtual

Disable analog comparator handler.

Note
atomic

Reimplemented from Interrupt::Handler.

Definition at line 83 of file AnalogComparator.hh.

virtual void AnalogComparator::enable ( )
inlinevirtual

Enable analog comparator handler.

Note
atomic

Reimplemented from Interrupt::Handler.

Definition at line 66 of file AnalogComparator.hh.

virtual void Event::Handler::on_event ( uint8_t  type,
uint16_t  value 
)
inlinevirtualinherited

Default null event handler. Should be redefined by sub-classes. Called by Event::dispatch().

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

Reimplemented in Menu::RotaryController, Rotary::Dial< T >, AnalogPin, Job, TWI::Slave, ProtoThread, AnalogPins, and Periodic.

Definition at line 107 of file Event.hh.

void AnalogComparator::on_interrupt ( uint16_t  arg = 0)
virtual

Default interrupt service on comparator output rise, fall or toggle.

Parameters
[in]argargument from interrupt service routine.

Reimplemented from Interrupt::Handler.

Definition at line 26 of file AnalogComparator.cpp.

Friends And Related Function Documentation

void ANALOG_COMP_vect ( void  )
friend

Interrupt Service Routine

Member Data Documentation

const uint8_t AnalogComparator::AIN1 = 254
staticprotected

Default reference voltage.

Definition at line 100 of file AnalogComparator.hh.

Mode AnalogComparator::m_mode
protected

Compare mode.

Definition at line 102 of file AnalogComparator.hh.

uint8_t AnalogComparator::m_pin
protected

Analog channel.

Definition at line 103 of file AnalogComparator.hh.

AnalogComparator * AnalogComparator::s_comparator = NULL
staticprotected

Current comparator.

Definition at line 99 of file AnalogComparator.hh.

const uint8_t AnalogComparator::VBG = 255
staticprotected

Bandgap voltage reference.

Definition at line 101 of file AnalogComparator.hh.


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