| 
    libpropeller
    
   Making PropellerGCC Easier 
   | 
 
Record high and low times simultaniously on any number of pins. More...
#include <pulse_width_reader.h>
Public Member Functions | |
| PulseWidthReader () | |
| void | Start (unsigned int Inputmask) | 
| Launch a new cog to watch and record pulse times.  More... | |
| void | Stop (void) | 
| Free a cog if running.  More... | |
| int | getHighTime (int index) | 
| Get the most recent high pulse duration.  More... | |
| int | getLowTime (int index) | 
| Get the most recent low pulse duration.  More... | |
Record high and low times simultaniously on any number of pins.
Based on ReadPulseWidths.spin v1.0 by David Carrier. Thanks!
Hardware: To read 3.3v signals just connect the signal directly to any I/O pin. To read a 5v signal connect it to any I/O pin through a 3.3kOhm (or higher) resistor. To read a higher voltage, use the following equation to determine the proper series voltage: resistance = (voltage - 3.3v - 0.6v) / 500uA
Example: To use this object, first construct a mask of the pins you are interested in monitoring (in this case pins 2, 10, and 21): mask = (1 << 2) | (1 << 10) | (1 << 21) Then start it: PulseWidthReader pwr(); pwr.Start(mask);
When you want the data simply call: pwr.GetHighTime(2);
The index is the index of the monitored pin out of the count total. In this example the index is: Index | pin 0| 2 1| 10 2| 21
Copyright (c) 2013 Kenneth Bedolla (libpropeller@kennethbedolla.com)
(SRLM): Make members of this class static (since it monitors all the pins...)
(SRLM): Get rid of the terrible "index" system and create a more intuitive start.
(SRLM): Are there any restrictions? Maximum time? Minimum pulse width? etc.
(SRLM): This class seems to have intermittent test failures when run for the first time. A bug?
      
  | 
  inline | 
      
  | 
  inline | 
Get the most recent high pulse duration.
Index starts at 0.
| index | The index (from low to high) of the desired pin (out of all the monitored pins) | 
      
  | 
  inline | 
Get the most recent low pulse duration.
Index starts at 0.
| index | The index (from low to high) of the desired pin (out of all the monitored pins) | 
      
  | 
  inline | 
Launch a new cog to watch and record pulse times.
| Inputmask | The mask of pins to watch. | 

      
  | 
  inline | 
Free a cog if running.
 1.8.4