brickOS C++ v0.9.0
|
Touch-sensor interface (passive mode). More...
#include <c++/TouchSensor.H>
Public Types | |
enum | Port { S1 = 0 , S2 , S3 , Battery } |
List of sensor identifiers (IDs). More... | |
Public Member Functions | |
TouchSensor (const Sensor::Port port) | |
construct a TouchSensor connected to pad {port} | |
bool | pressed () const |
determine if touch sensor is pressed | |
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. | |
Touch-sensor interface (passive mode).
The Touch Sensor Class - using a touch sensor in passive mode
At construction time you specify the RCX connector pad to which the touchSensor is attached.
Definition at line 44 of file TouchSensor.H.
|
inherited |
List of sensor identifiers (IDs).
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
Possible Sensor Port Values
Enumerator | |
---|---|
S1 | RCX sensor port 1. |
S2 | RCX sensor port 2. |
S3 | RCX sensor port 3. |
Battery | RCX battery sensor. |
|
inline |
construct a TouchSensor connected to pad {port}
port | and input port of the RCX |
Definition at line 51 of file TouchSensor.H.
|
inlineinherited |
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().
|
inlineinherited |
Get the current sensor reading.
Definition at line 109 of file Sensor.H.
References Sensor::sensor.
Referenced by TemperatureSensor::C(), and Sensor::sample().
|
inlineinherited |
Set the sensor (mode) to active or passive.
makeActive | - T/F - Where true means to go active (voltage is supplied to the connector pad) |
Definition at line 118 of file Sensor.H.
References Sensor::active(), and Sensor::passive().
|
inlineinherited |
Turn the sensor off (turn off voltage to connector)
Definition at line 145 of file Sensor.H.
References Sensor::passive().
Referenced by Sensor::strobe(), Sensor::strobe(), and Sensor::~Sensor().
|
inlineinherited |
Turn the sensor on (provide voltage to connector)
Definition at line 139 of file Sensor.H.
References Sensor::active().
Referenced by Sensor::strobe(), and Sensor::strobe().
|
inlineinherited |
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().
|
inline |
determine if touch sensor is pressed
Definition at line 56 of file TouchSensor.H.
References Sensor::sensor, and TOUCH.
|
inlineinherited |
Get the average of {size} samples, waiting {wait} mSec between each sample.
size | - Number of samples to average (default = 10 samples) |
wait | - time (in mS) to wait between samples (default = 2mS) |
Definition at line 167 of file Sensor.H.
References delay(), and Sensor::get().
|
inlineinherited |
Quickly turn sensor off then back on.
Definition at line 151 of file Sensor.H.
References Sensor::off(), and Sensor::on().
|
inlineinherited |
Turn sensor off, wait for {ms} milliSeconds, then then turn it back on.
ms | - Number of milliSeconds to wait between off and back on |
Definition at line 158 of file Sensor.H.
References delay(), Sensor::off(), and Sensor::on().
|
protectedinherited |
The address of our sensor value.
Definition at line 181 of file Sensor.H.
Referenced by Sensor::active(), LightSensor::get(), Sensor::get(), RotationSensor::off(), RotationSensor::on(), Sensor::passive(), RotationSensor::pos(), and pressed().