COSA
An Object-Oriented Platform for Arduino Programming
|
#include <HCSR04.hh>
Public Member Functions | |
HCSR04 (Job::Scheduler *scheduler, Board::DigitalPin trigger, Board::DigitalPin echo) | |
uint16_t | distance () const |
bool | read (uint16_t &distance) |
void | schedule (uint16_t ms) |
virtual void | on_change (uint16_t distance) |
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 () |
virtual void | run () |
void | detach () |
Linkage * | succ () const |
Linkage * | pred () const |
void | attach (Linkage *pred) |
Protected Attributes | |
uint32_t | m_period |
uint32_t | m_expires |
Scheduler * | m_scheduler |
Linkage * | m_succ |
Linkage * | m_pred |
Device driver for Ultrasonic range module HC-SR04. Subclass and implement the change event handler, on_change(). Attach to a scheduler to perform periodic read and check of change.
Connect HC-SR04 module to echo and trigger pin, and VCC and ground.
The driver will turn off interrupt handling during data read from the device.
|
inline |
|
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.
|
inline |
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
|
inlinevirtual |
|
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.
|
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.
bool HCSR04::read | ( | uint16_t & | distance | ) |
Read distance in millimeter from device. Return true(1) if successful otherwise false(0).
[out] | distance | reading. |
Definition at line 24 of file HCSR04.cpp.
|
inlineinherited |
Reschedule after a new period.
Definition at line 76 of file Periodic.hh.
|
inlinevirtualinherited |
|
inline |
|
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.
|
protectedinherited |
|
protectedinherited |
Double linked list pointers.
Definition at line 93 of file Linkage.hh.