COSA
An Object-Oriented Platform for Arduino Programming
Keypad::Key Class Reference

#include <Keypad.hh>

Inheritance diagram for Keypad::Key:
Inheritance graph
Collaboration diagram for Keypad::Key:
Collaboration graph

Public Member Functions

 Key (Board::AnalogPin pin, Keypad *keypad, const uint16_t *map)
 
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)
 
uint16_t sample_await ()
 
virtual void on_interrupt (uint16_t arg)
 
virtual void enable ()
 
virtual void disable ()
 
virtual void clear ()
 

Static Public 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 ()
 

Protected Member Functions

bool sample_request (Board::AnalogPin pin, uint8_t ref)
 
virtual void on_event (uint8_t type, uint16_t value)
 

Protected 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 Protected Attributes

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

Detailed Description

Internal analog pin sampler to detect key down. Samples are maps to key code.

Definition at line 74 of file Keypad.hh.

Constructor & Destructor Documentation

Keypad::Key::Key ( Board::AnalogPin  pin,
Keypad keypad,
const uint16_t *  map 
)
inline

Construct sampler of analog pin with given zero terminated map.

Parameters
[in]pinanalog pin.
[in]keypadto callback on key down detect.
[in]mapanalog to key map.

Definition at line 82 of file Keypad.hh.

Member Function Documentation

uint16_t AnalogPin::bandgap ( uint16_t  vref = 1100)
staticinherited

Get power supply voltage in milli-volt. May be used for low battery detection. Uses the internal 1V1 bandgap reference.

Parameters
[in]vrefreference voltage in milli-volt (default is 1100 mv).
Returns
milli-volt.

Definition at line 33 of file AnalogPin_static.cpp.

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

Clear interrupt.

Reimplemented in InputCapture, and ExternalInterrupt.

Definition at line 59 of file Interrupt.hh.

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

Disable interrupt handler.

Reimplemented in InputCapture, AnalogComparator, PinChangeInterrupt, and ExternalInterrupt.

Definition at line 53 of file Interrupt.hh.

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

Enable interrupt handler.

Reimplemented in InputCapture, PinChangeInterrupt, ExternalInterrupt, and AnalogComparator.

Definition at line 47 of file Interrupt.hh.

void AnalogPin::on_event ( uint8_t  type,
uint16_t  value 
)
protectedvirtualinherited

Handle analog pin periodic sampling and sample completed event. Will call virtual method on_change() if the pin value has changed since latest sample.

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

Reimplemented from Event::Handler.

Reimplemented in AnalogPins.

Definition at line 51 of file AnalogPin.cpp.

void AnalogPin::on_interrupt ( uint16_t  arg)
virtualinherited

Interrupt service on conversion completion.

Parameters
[in]argsample value.

Reimplemented from Interrupt::Handler.

Reimplemented in AnalogPins.

Definition at line 65 of file AnalogPin.cpp.

AnalogPin::operator uint16_t ( )
inlineinherited

Sample analog pin. Wait for conversion to complete before returning with sample value.

Returns
sample value.

Definition at line 159 of file AnalogPin.hh.

AnalogPin& AnalogPin::operator>> ( uint16_t &  var)
inlineinherited

Sample analog pin. Wait for conversion to complete before returning with sample value.

Parameters
[out]varvariable to receive the value.
Returns
analog pin.

Definition at line 147 of file AnalogPin.hh.

Board::AnalogPin AnalogPin::pin ( ) const
inlineinherited

Get analog pin.

Returns
pin identity.

Definition at line 69 of file AnalogPin.hh.

static void AnalogPin::powerdown ( )
inlinestaticinherited

Disable analog conversion.

Definition at line 123 of file AnalogPin.hh.

static void AnalogPin::powerup ( )
inlinestaticinherited

Enable analog conversion.

Definition at line 113 of file AnalogPin.hh.

void AnalogPin::prescale ( uint8_t  factor)
staticinherited

Set analog conversion clock prescale (2..128, step power 2).

Parameters
[in]factorprescale.

Definition at line 26 of file AnalogPin_static.cpp.

void AnalogPin::reference ( Board::Reference  ref)
inlineinherited

Set reference voltage for conversion.

Parameters
[in]refreference voltage.

Definition at line 51 of file AnalogPin.hh.

Board::Reference AnalogPin::reference ( ) const
inlineinherited

Get reference voltage for conversion.

Returns
reference voltage.

Definition at line 60 of file AnalogPin.hh.

uint16_t AnalogPin::sample ( Board::AnalogPin  pin,
Board::Reference  ref = Board::AVCC_REFERENCE 
)
staticinherited

Sample analog pin. Wait for conversion to complete before returning with sample value.

Parameters
[in]pinnumber.
[in]refreference voltage.
Returns
sample value.

Definition at line 50 of file AnalogPin_static.cpp.

uint16_t AnalogPin::sample ( )
inlineinherited

Sample analog pin. Wait for conversion to complete before returning with sample value.

Returns
sample value.

Definition at line 135 of file AnalogPin.hh.

uint16_t AnalogPin::sample_await ( )
inherited

Await conversion to complete. Returns sample value

Returns
sample value.

Definition at line 38 of file AnalogPin.cpp.

bool AnalogPin::sample_request ( uint8_t  event = Event::NULL_TYPE)
inlineinherited

Request sample of analog pin. Pushes given event on completion. Default event is null/no event pushed for sample_await().

Parameters
[in]eventto push on completion.
Returns
bool.

Definition at line 171 of file AnalogPin.hh.

bool AnalogPin::sample_request ( Board::AnalogPin  pin,
uint8_t  ref 
)
protectedinherited

Internal request sample of analog pin. Set up sampling of given pin with given reference voltage.

Parameters
[in]pinnumber.
[in]refreference voltage.
Returns
bool.

Definition at line 24 of file AnalogPin.cpp.

uint16_t AnalogPin::value ( ) const
inlineinherited

Get latest sample.

Returns
sample value.
Note
atomic

Definition at line 79 of file AnalogPin.hh.

Member Data Documentation

uint8_t AnalogPin::m_event
protectedinherited

Event to push on completion.

Definition at line 205 of file AnalogPin.hh.

const Board::AnalogPin AnalogPin::m_pin
protectedinherited

Analog channel number.

Definition at line 202 of file AnalogPin.hh.

Board::Reference AnalogPin::m_reference
protectedinherited

ADC reference voltage type.

Definition at line 203 of file AnalogPin.hh.

uint16_t AnalogPin::m_value
protectedinherited

Latest sample value.

Definition at line 204 of file AnalogPin.hh.

AnalogPin * AnalogPin::sampling_pin = NULL
staticprotectedinherited

Current sampling pin if any.

Definition at line 201 of file AnalogPin.hh.


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