#include <c++/RotationSensor.H>
Inheritance diagram for RotationSensor:
Public Types | |
enum | Port { S1 = 0, S2, S3, Battery } |
List of sensor identifiers (IDs). Possible Sensor Port Values. More... | |
Public Member Functions | |
RotationSensor (const Port port, int position=0) | |
Create an instance of an active rotation sensor which is attached at {port}. | |
~RotationSensor () | |
Destroy this instance. | |
void | on () const |
turn on rotation tracking | |
void | off () const |
turn off rotation tracking | |
void | pos (int position) const |
set the current absolute postion | |
int | pos () const |
get the current absolute postion | |
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 | 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. | |
Private Attributes | |
volatile int & | rsensor |
the raw sensor value |
Provide an interface to rotation sensor hardware attached to the RCX
At construction time you specify the RCX connector pad to which the rotation sensor is attached and its initial position (default = 0).
Additionally, RotationSensor provides methods to:
Definition at line 46 of file RotationSensor.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
|
|
Create an instance of an active rotation sensor which is attached at {port}.
Turn on tracking of the sensor Set the current position Definition at line 53 of file RotationSensor.H. References on(), pos(), ROTATION_1, ROTATION_2, ROTATION_3, and rsensor. |
|
Destroy this instance. Turn off tracking of this sensor Definition at line 71 of file RotationSensor.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::sensor. Referenced by Sensor::mode(), Sensor::on(), and Sensor::Sensor(). |
|
Get the current sensor reading.
Reimplemented in LightSensor. Definition at line 109 of file Sensor.H. References Sensor::sensor. Referenced by TemperatureSensor::C(), and Sensor::sample(). |
|
Set the sensor (mode) to active or passive.
Definition at line 118 of file Sensor.H. References Sensor::active(), and Sensor::passive(). |
|
turn off rotation tracking
Reimplemented from Sensor. Definition at line 84 of file RotationSensor.H. References ds_rotation_off(). Referenced by ~RotationSensor(). |
|
turn on rotation tracking
Reimplemented from Sensor. Definition at line 79 of file RotationSensor.H. References ds_rotation_on(). Referenced by RotationSensor(). |
|
Set the sensor to passive (turn off voltage to connector).
Definition at line 127 of file Sensor.H. References ds_passive(), and Sensor::sensor. Referenced by Sensor::mode(), Sensor::off(), and Sensor::Sensor(). |
|
get the current absolute postion
Definition at line 96 of file RotationSensor.H. References rsensor. Referenced by RotationSensor(). |
|
set the current absolute postion
Definition at line 90 of file RotationSensor.H. References ds_rotation_set(). |
|
Get the average of {size} samples, waiting {wait} mSec between each sample.
Reimplemented in LightSensor. Definition at line 167 of file Sensor.H. References delay(), and Sensor::get(). |
|
Turn sensor off, wait for {ms} milliSeconds, then then turn it back on.
Definition at line 158 of file Sensor.H. References delay(), Sensor::off(), and Sensor::on(). |
|
Quickly turn sensor off then back on.
Definition at line 151 of file Sensor.H. References Sensor::off(), and Sensor::on(). |
|
the raw sensor value
Definition at line 109 of file RotationSensor.H. Referenced by pos(), and RotationSensor(). |
|
The address of our sensor value.
Definition at line 181 of file Sensor.H. Referenced by Sensor::active(), Sensor::get(), Sensor::passive(), and Sensor::Sensor(). |
brickOS is released under the
Mozilla Public License.
Original code copyright 1998-2002 by the authors. |