Driver for a binary on/off presence device
Diff: Presence.cpp
- Revision:
- 1:9d2b641a9280
- Parent:
- 0:21320a151be0
- Child:
- 3:c255f4943339
--- a/Presence.cpp Wed Dec 10 14:06:35 2014 +0000 +++ b/Presence.cpp Wed Feb 04 17:21:13 2015 +0000 @@ -1,5 +1,5 @@ /* - Presence.cpp - presence sensor library + presence.cpp - presence sensor library Developed by Andrea Corrado & Eric Gowland Connect to a hardware device that is boolean present/not present. Such as PIR or Rangefinder with appropriate signalling. @@ -12,16 +12,16 @@ -Presence::Presence(PinName pin, bool true_on_rise, int debounce_time_ms):_myint(pin), _led1(LED1) +presence::presence(PinName pin, bool true_on_rise, int debounce_time_ms):_myint(pin), _led1(LED1) { debounce_ms = debounce_time_ms; _true_on_rise = true_on_rise; // if(true_on_rise) { -// _myint.rise(this, &Presence::presence_interrupt_off); -// _myint.fall(this, &Presence::presence_interrupt_on); +// _myint.rise(this, &presence::presence_interrupt_off); +// _myint.fall(this, &presence::presence_interrupt_on); // } else { -// _myint.rise(this, &Presence::presence_interrupt_on); -// _myint.fall(this, &Presence::presence_interrupt_off); +// _myint.rise(this, &presence::presence_interrupt_on); +// _myint.fall(this, &presence::presence_interrupt_off); // } _detection=false; // debounce_timer.start(); @@ -29,14 +29,14 @@ } -void Presence::presence_interrupt_off(){ +void presence::presence_interrupt_off(){ if(debounce_timer.read_ms() > debounce_ms) { _detection=false; _led1=1; } } -void Presence::presence_interrupt_on() //Detection of motion. +void presence::presence_interrupt_on() //Detection of motion. { //Always trigger detection.. _detection=true; @@ -44,7 +44,7 @@ debounce_timer.reset(); // Reset counter to 0... } -bool Presence::isPresent(){ +bool presence::isPresent(){ // if (debounce_timer.read_ms() > debounce_ms) { //Poll the pin and update value... _detection = (_true_on_rise && _myint == 1) || (!_true_on_rise && _myint == 0);