COSA
An Object-Oriented Platform for Arduino Programming
|
#include <Touch.hh>
Public Member Functions | |
Touch (Job::Scheduler *scheduler, Board::DigitalPin pin, uint16_t threshold=250) | |
virtual void | on_touch ()=0 |
void | period (uint32_t time) |
uint32_t | period () const |
void | reschedule () |
void | expire_at (uint32_t time) |
uint32_t | expire_at () const |
void | expire_after (uint32_t time) |
int32_t | expire_after () const |
uint32_t | time () const |
bool | is_started () const |
bool | start () |
bool | stop () |
virtual void | on_expired () |
void | detach () |
Linkage * | succ () const |
Linkage * | pred () const |
void | attach (Linkage *pred) |
Protected Member Functions | |
virtual void | run () |
virtual void | on_event (uint8_t type, uint16_t value) |
Protected Attributes | |
const uint16_t | THRESHOLD |
uint32_t | m_start |
uint8_t | m_sampling |
uint8_t | m_touched |
uint32_t | m_period |
uint32_t | m_expires |
Scheduler * | m_scheduler |
Linkage * | m_succ |
Linkage * | m_pred |
Static Protected Attributes | |
static const uint16_t | SAMPLE_RATE = 16 |
Private Types | |
enum | Mode { OUTPUT_MODE = 0, INPUT_MODE = 1 } |
enum | Direction { MSB_FIRST = 0, LSB_FIRST = 1 } |
Private Member Functions | |
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 | 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 |
volatile uint8_t * | PIN () const |
volatile uint8_t * | DDR () const |
volatile uint8_t * | PORT () 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) |
volatile uint8_t * | PCIMR () const |
Static Private 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) |
Private Attributes | |
volatile uint8_t *const | m_sfr |
const uint8_t | m_mask |
const uint8_t | m_pin |
Touch Capacitive Sensor using periodic discharging to detect a sensor touch. Uses the Cosa IOPin to allow changing of data direction and the watchdog for periodic reading. A callback, virtual member function is called on detection.
Connect a 1-10 M ohm pullup resistor to the selected pin.
Touch::Touch | ( | Job::Scheduler * | scheduler, |
Board::DigitalPin | pin, | ||
uint16_t | threshold = 250 |
||
) |
|
inlineinherited |
Attach given linkage as predecessor. Will check and detach if already attached.
[in] | pred | linkage to attach. |
Definition at line 71 of file Linkage.hh.
|
inlineinherited |
Detach this link. Unlink from any list.
Definition at line 125 of file Linkage.hh.
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
|
inlineprotectedvirtualinherited |
Periodic event handler; dispatch the run() function on timeout events and reschedule the periodic job.
[in] | type | the type of event. |
[in] | value | the event value. |
Reimplemented from Job.
Definition at line 91 of file Periodic.hh.
|
inlinevirtualinherited |
Job member function that is called Scheduler::dispatch() when the job time has expired. This function is normally called from an interrupt service routine. The default implementation will push a timeout event with the job as target. The default event handler will call the job run() virtual member function. Override this function if the job should be executed during the interrupt service routine.
|
pure virtual |
Callback virtual member function; Should be implemented by sub-class.
|
inlineinherited |
Set timeout period.
[in] | time | period of timeout. |
Definition at line 57 of file Periodic.hh.
|
inlineinherited |
|
inlineinherited |
Return predecessor in sequence.
Definition at line 60 of file Linkage.hh.
|
inlineinherited |
Reschedule after a new period.
Definition at line 76 of file Periodic.hh.
|
protectedvirtual |
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
|
protectedinherited |
|
protectedinherited |
Time period. Time unit is defined by the scheduler.
Definition at line 100 of file Periodic.hh.
|
protectedinherited |
Definition at line 94 of file Linkage.hh.
|
protected |
|
protectedinherited |
|
protectedinherited |
Double linked list pointers.
Definition at line 93 of file Linkage.hh.
|
staticprotected |
|
protected |