26 #if defined(CONF_DSENSOR) 109 unsigned int get()
const {
return sensor;}
118 void mode(
bool makeActive)
const {
167 unsigned int sample(
unsigned int size = 10,
int wait = 2)
const {
168 if (size == 0) size = 1;
169 unsigned int sum(
get());
170 for (
unsigned int i = 1; i < size; ++i) {
184 #else // CONF_DSENSOR 185 #warning Enable CONF_DSENSOR to use Sensor.H 186 #endif // CONF_DSENSOR void ds_passive(volatile unsigned *sensor)
set sensor mode to passive (light sensor detects ambient light)
void active() const
Set the sensor to active (provide voltage to connector)
void ds_active(volatile unsigned *sensor)
set sensor mode to active (light sensor emits light, rotation works)
void delay(unsigned ms)
delay approximately ms mSec
Interface: console input / output.
#define SENSOR_3
Sensor on input pad 3.
void mode(bool makeActive) const
Set the sensor (mode) to active or passive.
void strobe(const int ms) const
Turn sensor off, wait for {ms} milliSeconds, then then turn it back on.
#define SENSOR_1
< the raw sensors
#define BATTERY
Battery sensor.
void strobe() const
Quickly turn sensor off then back on.
Port
List of sensor identifiers (IDs).
void passive() const
Set the sensor to passive (turn off voltage to connector)
~Sensor()
Destroy this sensor instance.
Interface: direct reading of sensors.
void on() const
Turn the sensor on (provide voltage to connector)
#define SENSOR_2
Sensor on input pad 2.
void off() const
Turn the sensor off (turn off voltage to connector)
unsigned int sample(unsigned int size=10, int wait=2) const
Get the average of {size} samples, waiting {wait} mSec between each sample.
volatile unsigned int & sensor
The address of our sensor value.
Sensor(const Port port, bool makeActive=false)
Construct a new sensor instance.
Battery-sensor interface (RCX Internal).