#include <c++/Sensor.H>
Inheritance diagram for Sensor:
Public Types | |
enum | Port { S1 = 0, S2, S3, Battery } |
List of sensor identifiers (IDs).Possible Sensor Port Values. More... | |
Public Member Functions | |
Sensor (const Port port, bool makeActive=false) | |
Construct a new sensor instance. | |
~Sensor () | |
Destroy this sensor instance. | |
unsigned int | get () const |
Get the current sensor reading. | |
void | mode (bool makeActive) const |
Set the sensor (mode) to active or passive. | |
void | passive () const |
Set the sensor to passive (turn off voltage to connector). | |
void | active () const |
Set the sensor to active (provide voltage to connector). | |
void | on () const |
Turn the sensor on (provide voltage to connector). | |
void | off () const |
Turn the sensor off (turn off voltage to connector). | |
void | strobe () const |
Quickly turn sensor off then back on. | |
void | strobe (const int ms) const |
Turn sensor off, wait for {ms} milliSeconds, then then turn it back on. | |
unsigned int | sample (unsigned int size=10, int wait=2) const |
Get the average of {size} samples, waiting {wait} mSec between each sample. | |
Protected Attributes | |
volatile unsigned int & | sensor |
The address of our sensor value. |
This is the base class for all sensors.
At construction time you specify the RCX connector pad [Port] to which the sensor is attached and whether it should be powered (active/on) or not (passive/off).
The Sensor class provides methods to:
Definition at line 54 of file Sensor.H.
|
List of sensor identifiers (IDs).Possible Sensor Port Values. S1, S2, S3 are connector pads 1, 2 and 3 on the RCX. Battery is the internal sensor allowing a program to read the current battery voltage in milliVolts
|
|
Construct a new sensor instance. At time of construction identify where the sensor is connected and whether it should be active or passive (default is passive).
|
|
Destroy this sensor instance.
Definition at line 101 of file Sensor.H. References off(). |
|
Set the sensor to active (provide voltage to connector).
Definition at line 133 of file Sensor.H. References ds_active(), and sensor. |
|
Get the current sensor reading.
Reimplemented in LightSensor. Definition at line 109 of file Sensor.H. References sensor. Referenced by TemperatureSensor::C(), and sample(). |
|
Set the sensor (mode) to active or passive.
|
|
Turn the sensor off (turn off voltage to connector).
Reimplemented in RotationSensor. Definition at line 145 of file Sensor.H. References passive(). |
|
Turn the sensor on (provide voltage to connector).
Reimplemented in RotationSensor. Definition at line 139 of file Sensor.H. References active(). Referenced by strobe(). |
|
Set the sensor to passive (turn off voltage to connector).
Definition at line 127 of file Sensor.H. References ds_passive(), and sensor. |
|
Get the average of {size} samples, waiting {wait} mSec between each sample.
Reimplemented in LightSensor. |
|
Turn sensor off, wait for {ms} milliSeconds, then then turn it back on.
|
|
Quickly turn sensor off then back on.
|
|
The address of our sensor value.
Definition at line 181 of file Sensor.H. Referenced by active(), get(), LightSensor::get(), RotationSensor::off(), RotationSensor::on(), passive(), RotationSensor::pos(), and TouchSensor::pressed(). |
brickOS is released under the
Mozilla Public License.
Original code copyright 1998-2005 by the authors. |