COSA
An Object-Oriented Platform for Arduino Programming
|
#include <DHT.hh>
Classes | |
union | data_t |
Public Types | |
enum | InterruptMode { ON_LOW_LEVEL_MODE = 0, ON_CHANGE_MODE = _BV(ISC00), ON_FALLING_MODE = _BV(ISC01), ON_RISING_MODE = (_BV(ISC01) | _BV(ISC00)) } |
enum | Mode { OUTPUT_MODE = 0, INPUT_MODE = 1 } |
enum | Direction { MSB_FIRST = 0, LSB_FIRST = 1 } |
Public Member Functions | |
DHT (Board::ExternalInterruptPin pin=Board::EXT0) | |
int16_t | humidity () const |
int16_t | temperature () const |
bool | sample_request () |
bool | sample_await () |
bool | sample () |
bool | sample (int16_t &humidity, int16_t &temperature) |
virtual void | enable () |
virtual void | disable () |
virtual void | clear () |
void | clear () const |
void | mode (Mode mode) |
Mode | mode () const |
void | _set () const |
void | _set (int value) const |
void | set () const |
void | set (int value) const |
void | high () const |
void | on () const |
void | _clear () const |
void | low () const |
void | off () const |
void | _toggle () const |
void | toggle () const |
void | _write (int value) const |
void | write (int value) const |
void | write (uint8_t value, OutputPin &clk, Direction order=MSB_FIRST) const |
void | write (uint16_t value, uint8_t bits, uint16_t us) const |
OutputPin & | operator<< (int value) |
void | pulse (uint16_t us) const |
uint8_t | pin () const |
bool | is_set () const |
bool | is_high () const |
bool | is_on () const |
bool | is_clear () const |
bool | is_low () const |
bool | is_off () const |
bool | read () const |
uint8_t | read (OutputPin &clk, Direction order=MSB_FIRST) const |
operator bool () const | |
Pin & | operator>> (uint8_t &var) |
Static Public Member Functions | |
static void | mode (Board::DigitalPin pin, Mode mode) |
static Mode | mode (Board::DigitalPin pin) |
static void | mode (Board::DigitalPin pin, uint8_t initial=0) |
static void | toggle (Board::DigitalPin pin) |
static void | _write (Board::DigitalPin pin, uint8_t value) |
static void | write (Board::DigitalPin pin, int value) |
static uint8_t | MASK (uint8_t pin) |
static volatile uint8_t * | PIN (uint8_t pin) |
static volatile uint8_t * | DDR (uint8_t pin) |
static volatile uint8_t * | PORT (uint8_t pin) |
static bool | read (Board::DigitalPin pin) |
Static Public Attributes | |
static const int16_t | INIT_HUMIDITY_SAMPLE = 1000 |
static const int16_t | INIT_TEMPERATURE_SAMPLE = 850 |
Protected Types | |
enum | { INIT, IDLE, REQUEST, RESPONSE, SAMPLING, COMPLETED } |
Protected Member Functions | |
virtual void | on_interrupt (uint16_t arg=0) |
virtual void | on_sample_completed (bool valid) |
bool | is_valid () |
virtual void | adjust_data ()=0 |
volatile uint8_t * | PIN () const |
volatile uint8_t * | DDR () const |
volatile uint8_t * | PORT () const |
volatile uint8_t * | PCIMR () const |
Protected Attributes | |
volatile uint8_t | m_state |
uint16_t | m_start |
uint8_t | m_value |
uint8_t | m_bits |
uint8_t | m_ix |
data_t | m_data |
int16_t | m_humidity |
int16_t | m_temperature |
volatile uint8_t *const | m_sfr |
const uint8_t | m_mask |
const uint8_t | m_pin |
Static Protected Attributes | |
static const uint16_t | MIN_PERIOD = 2048 |
static const uint16_t | LOW_THRESHOLD = 50 |
static const uint16_t | BIT_THRESHOLD = 100 |
static const uint16_t | HIGH_THRESHOLD = 200 |
static const uint8_t | DATA_MAX = 5 |
static const uint8_t | DATA_LAST = DATA_MAX - 1 |
Friends | |
IOStream & | operator<< (IOStream &outs, DHT &dht) |
DHT11/22 Humidity & Temperature Sensor common device driver. Uses external interrupt on high to low transition to capture serial data from the device. Please note that excessive interrupt sources may affect the capture.
|
protected |
|
inherited |
|
inherited |
Enumerator | |
---|---|
ON_LOW_LEVEL_MODE | |
ON_CHANGE_MODE | |
ON_FALLING_MODE | |
ON_RISING_MODE |
Definition at line 35 of file ExternalInterrupt.hh.
|
inherited |
|
inline |
|
inlineinherited |
Clear the output pin. Unprotected version.
Definition at line 114 of file OutputPin.hh.
|
inlineinherited |
Set the output pin. Unprotected version.
Definition at line 75 of file OutputPin.hh.
|
inlineinherited |
Set the output pin with the given value. Zero(0) to clear and non-zero to set. Unprotected version.
[in] | value | to set. |
Definition at line 184 of file OutputPin.hh.
|
inlineinherited |
Toggle the output pin. Unprotected version.
Definition at line 153 of file OutputPin.hh.
|
inlineinherited |
Set the output pin with the given value. Zero(0) to clear and non-zero to set. Unprotected version.
[in] | value | to set. |
Definition at line 219 of file OutputPin.hh.
|
inlinestaticinherited |
Set the given output pin with the given value. Zero(0) to clear and non-zero to set. Unprotected version when pin and value are constants.
[in] | pin | number (must be constant). |
[in] | value | to write (must be constant). |
Definition at line 345 of file OutputPin.hh.
|
protectedpure virtual |
|
virtualinherited |
Clear external interrupt flag.
Reimplemented from Interrupt::Handler.
Definition at line 205 of file ExternalInterrupt.cpp.
|
inlineinherited |
|
inlinestaticinherited |
|
inlineprotectedinherited |
|
virtualinherited |
Disable external interrupt handler.
Reimplemented from Interrupt::Handler.
Definition at line 199 of file ExternalInterrupt.cpp.
|
virtualinherited |
Enable external interrupt handler.
Reimplemented from Interrupt::Handler.
Definition at line 190 of file ExternalInterrupt.cpp.
|
inlineinherited |
|
inline |
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
|
protected |
|
inlineinherited |
|
inlinestaticinherited |
|
inlinestaticinherited |
Set output pin to mode.
[in] | pin | number. |
[in] | initial | value. |
Definition at line 56 of file OutputPin.hh.
|
inlineinherited |
|
inlineinherited |
|
inlinestaticinherited |
|
inlinestaticinherited |
|
inlineinherited |
|
inlineinherited |
|
protectedvirtual |
The device driver interrupt level state machine.
[in] | arg | argument from interrupt service routine. |
Reimplemented from ExternalInterrupt.
|
inlineprotectedvirtual |
|
inlineinherited |
|
inlineinherited |
Set the output pin with the given value. Zero(0) to clear and non-zero to set. Output operator syntax.
[in] | value | to write. |
Definition at line 364 of file OutputPin.hh.
|
inlineinherited |
|
inlineprotectedinherited |
|
inlinestaticinherited |
|
inlineinherited |
|
inlineprotectedinherited |
|
inlinestaticinherited |
|
inlineprotectedinherited |
|
inlineinherited |
Toggle the output pin to form a pulse with given width in micro-seconds.
[in] | us | pulse width in micro seconds |
Definition at line 378 of file OutputPin.hh.
|
inlineinherited |
|
inlinestaticinherited |
|
inline |
|
inline |
bool DHT::sample_await | ( | ) |
bool DHT::sample_request | ( | ) |
|
inlineinherited |
|
inlineinherited |
Set the output pin with the given value. Zero(0) to clear and non-zero to set.
[in] | value | to set. |
Definition at line 201 of file OutputPin.hh.
|
inline |
|
inlineinherited |
|
inlinestaticinherited |
Toggle the output pin. Atomic per definition
[in] | pin | number. |
Definition at line 173 of file OutputPin.hh.
|
inlineinherited |
Set the output pin with the given value. Zero(0) to clear and non-zero to set.
[in] | value | to write. |
Definition at line 236 of file OutputPin.hh.
|
inherited |
Shift out given byte to the output pin using the given clock output pin. Shift out according to given direction. Data (bits) are transfered on clock transition. Interrupts are allowed during the shift out.
[in] | value | to write. |
[in] | clk | output pin. |
[in] | order | bit first. |
Definition at line 24 of file OutputPin.cpp.
|
inherited |
Shift out given value and number of bits to the output pin using the given pulse length in micro-seconds. Shift out from LSB(0) to MSB(bits-1). This operation is synchronized and will turn off interrupt handling during the transmission period.
[in] | value | to write. |
[in] | bits | to write. |
[in] | us | micro-second bit period. |
Definition at line 46 of file OutputPin.cpp.
|
inlinestaticinherited |
Set the given output pin with the given value. Zero(0) to clear and non-zero to set.
[in] | pin | number. |
[in] | value | to write. |
Definition at line 306 of file OutputPin.hh.
|
staticprotected |
|
staticprotected |
|
static |
|
static |
|
staticprotected |
|
protectedinherited |
|
protectedinherited |
|
protected |
|
protected |
|
protected |
|
staticprotected |