Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

RotationSensor Class Reference

Rotation-sensor interface (active mode). More...

#include <c++/RotationSensor.H>

Inheritance diagram for RotationSensor:

[legend]
Collaboration diagram for RotationSensor:
[legend]
List of all members.

Public Types

enum  Port { S1 = 0, S2, S3, Battery }
 List of sensor identifiers (IDs). Possible Sensor Port Values. More...


Public Methods

 RotationSensor (const Port port, int position=0)
 Create an instance of an active rotation sensor which is attached at {port}. More...

 ~RotationSensor ()
 Destroy this instance. More...

void on () const
 turn on rotation tracking. More...

void off () const
 turn off rotation tracking. More...

void pos (int position) const
 set the current absolute postion. More...

int pos () const
 get the current absolute postion. More...

unsigned int get () const
 Get the current sensor reading. More...

void mode (bool makeActive) const
 Set the sensor (mode) to active or passive. More...

void passive () const
 Set the sensor to passive (turn off voltage to connector). More...

void active () const
 Set the sensor to active (provide voltage to connector). More...

void strobe () const
 Quickly turn sensor off then back on. More...

void strobe (const int ms) const
 Turn sensor off, wait for {ms} milliSeconds, then then turn it back on. More...

unsigned int sample (unsigned int size=10, int wait=2) const
 Get the average of {size} samples, waiting {wait} mSec between each sample. More...


Protected Attributes

volatile unsigned int & sensor
 The address of our sensor value. More...


Private Attributes

volatile int & rsensor
 the raw sensor value. More...


Detailed Description

Rotation-sensor interface (active mode).

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:

See also:
Sensor, LightSensor, TouchSensor

Definition at line 46 of file RotationSensor.H.


Member Enumeration Documentation

enum Sensor::Port [inherited]
 

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

See also:
Battery
Enumeration values:
S1  RCX sensor port 1.
S2  RCX sensor port 2.
S3  RCX sensor port 3.
Battery  RCX battery sensor.

Definition at line 67 of file Sensor.H.

Referenced by LightSensor::LightSensor(), RotationSensor(), Sensor::Sensor(), TemperatureSensor::TemperatureSensor(), and TouchSensor::TouchSensor().


Constructor & Destructor Documentation

RotationSensor::RotationSensor const Port    port,
int    position = 0
[inline]
 

Create an instance of an active rotation sensor which is attached at {port}.

Parameters:
port  the pad to which the rotation sensor is attached
position  initial starting position (default = 0)

Definition at line 53 of file RotationSensor.H.

References on(), Sensor::Port, pos(), ROTATION_1, ROTATION_2, ROTATION_3, rsensor, Sensor::S1, and Sensor::S2.

RotationSensor::~RotationSensor   [inline]
 

Destroy this instance.

Definition at line 71 of file RotationSensor.H.

References off().


Member Function Documentation

void Sensor::active   const [inline, inherited]
 

Set the sensor to active (provide voltage to connector).

See also:
Sensor::passive, Sensor::on, Sensor::off, Sensor::mode

Definition at line 133 of file Sensor.H.

References ds_active(), and Sensor::sensor.

Referenced by Sensor::mode(), Sensor::on(), and Sensor::Sensor().

unsigned int Sensor::get   const [inline, inherited]
 

Get the current sensor reading.

Returns:
unsigned int - The current raw sensor value
See also:
Sensor::sample

Reimplemented in LightSensor.

Definition at line 109 of file Sensor.H.

References Sensor::sensor.

Referenced by TemperatureSensor::C(), and Sensor::sample().

void Sensor::mode bool    makeActive const [inline, inherited]
 

Set the sensor (mode) to active or passive.

Parameters:
makeActive  - T/F - Where true means to go active (voltage is supplied to the connector pad)
See also:
Sensor::off, Sensor::on, Sensor::active, Sensor::passive

Definition at line 118 of file Sensor.H.

References Sensor::active(), and Sensor::passive().

void RotationSensor::off   const [inline]
 

turn off rotation tracking.

Reimplemented from Sensor.

Definition at line 84 of file RotationSensor.H.

References ds_rotation_off(), and Sensor::sensor.

Referenced by ~RotationSensor().

void RotationSensor::on   const [inline]
 

turn on rotation tracking.

Reimplemented from Sensor.

Definition at line 79 of file RotationSensor.H.

References ds_rotation_on(), and Sensor::sensor.

Referenced by RotationSensor().

void Sensor::passive   const [inline, inherited]
 

Set the sensor to passive (turn off voltage to connector).

See also:
Sensor::active, Sensor::on, Sensor::off, Sensor::mode

Definition at line 127 of file Sensor.H.

References ds_passive(), and Sensor::sensor.

Referenced by Sensor::mode(), Sensor::off(), and Sensor::Sensor().

int RotationSensor::pos   const [inline]
 

get the current absolute postion.

Returns:
int the current relative position

Definition at line 96 of file RotationSensor.H.

References rsensor.

Referenced by RotationSensor().

void RotationSensor::pos int    position const [inline]
 

set the current absolute postion.

Parameters:
position  the absolute value to use (typically zero)

Definition at line 90 of file RotationSensor.H.

References ds_rotation_set(), and Sensor::sensor.

unsigned int Sensor::sample unsigned int    size = 10,
int    wait = 2
const [inline, inherited]
 

Get the average of {size} samples, waiting {wait} mSec between each sample.

Parameters:
size  - Number of samples to average (default = 10 samples)
wait  - time (in mS) to wait between samples (default = 2mS)
Returns:
unsigned int - The average of the sampled values
See also:
Sensor::get

Reimplemented in LightSensor.

Definition at line 167 of file Sensor.H.

References delay(), and Sensor::get().

void Sensor::strobe const int    ms const [inline, inherited]
 

Turn sensor off, wait for {ms} milliSeconds, then then turn it back on.

Parameters:
ms  - Number of milliSeconds to wait between off and back on
See also:
Sensor::on, Sensor::off, Sensor::active, Sensor::passive, Sensor::mode

Definition at line 158 of file Sensor.H.

References delay(), Sensor::off(), and Sensor::on().

void Sensor::strobe   const [inline, inherited]
 

Quickly turn sensor off then back on.

See also:
Sensor::on, Sensor::off, Sensor::active, Sensor::passive, Sensor::mode

Definition at line 151 of file Sensor.H.

References Sensor::off(), and Sensor::on().


Member Data Documentation

volatile int& RotationSensor::rsensor [private]
 

the raw sensor value.

Definition at line 109 of file RotationSensor.H.

Referenced by pos(), and RotationSensor().

volatile unsigned int& Sensor::sensor [protected, inherited]
 

The address of our sensor value.

Definition at line 181 of file Sensor.H.

Referenced by Sensor::active(), Sensor::get(), LightSensor::get(), off(), on(), Sensor::passive(), pos(), TouchSensor::pressed(), and Sensor::Sensor().


The documentation for this class was generated from the following file:
brickOS is released under the Mozilla Public License.
Original code copyright 1998-2002 by the authors.

Generated on Tue Dec 10 00:09:19 2002 for brickOS Kernel Developer by doxygen 1.2.15