Interface: direct reading of sensors. More...
#include <config.h>#include <sys/h8.h>#include <sys/bitops.h>

Go to the source code of this file.
Macros | |
| #define | SENSOR_1 AD_C |
| < the raw sensors More... | |
| #define | SENSOR_2 AD_B |
| Sensor on input pad 2. More... | |
| #define | SENSOR_3 AD_A |
| Sensor on input pad 3. More... | |
| #define | BATTERY AD_D |
| Battery sensor. More... | |
| #define | LIGHT_RAW_BLACK 0xffc0 |
| < active light sensor: estimated raw values More... | |
| #define | LIGHT_RAW_WHITE 0x5080 |
| active light sensor raw white value More... | |
| #define | LIGHT(a) (147 - ds_scale(a)/7) |
| map light sensor to 0..LIGHT_MAX More... | |
| #define | LIGHT_MAX LIGHT(LIGHT_RAW_WHITE) |
| maximum decoded value More... | |
| #define | LIGHT_1 LIGHT(SENSOR_1) |
| light sensor on input 1 More... | |
| #define | LIGHT_2 LIGHT(SENSOR_2) |
| light sensor on input 2 More... | |
| #define | LIGHT_3 LIGHT(SENSOR_3) |
| light sensor on input 3 More... | |
| #define | ROTATION_1 (ds_rotations[2]) |
| rotation sensor on input 1 More... | |
| #define | ROTATION_2 (ds_rotations[1]) |
| rotation sensor on input 2 More... | |
| #define | ROTATION_3 (ds_rotations[0]) |
| rotation sensor on input 3 More... | |
| #define | TOUCH(a) ((unsigned int)(a) < 0x8000) |
| Convert raw data to touch sensor (0: off, else pressed) More... | |
| #define | TOUCH_1 TOUCH(SENSOR_1) |
| touch sensor on input 1 More... | |
| #define | TOUCH_2 TOUCH(SENSOR_2) |
| touch sensor on input 2 More... | |
| #define | TOUCH_3 TOUCH(SENSOR_3) |
| touch sensor on input 3 More... | |
| #define | ds_scale(x) ((unsigned int)(x)>>6) |
| mask off bottom 6 bits More... | |
| #define | ds_unscale(x) ((unsigned int)(x)<<6) |
| leave room for bottom 6 bits More... | |
Functions | |
| void | ds_active (volatile unsigned *sensor) |
| set sensor mode to active (light sensor emits light, rotation works) More... | |
| void | ds_passive (volatile unsigned *sensor) |
| set sensor mode to passive (light sensor detects ambient light) More... | |
| void | ds_rotation_set (volatile unsigned *sensor, int pos) |
| set rotation to an absolute value More... | |
| void | ds_rotation_on (volatile unsigned *sensor) |
| start tracking rotation sensor More... | |
| void | ds_rotation_off (volatile unsigned *sensor) |
| stop tracking rotation sensor More... | |
Variables | |
| unsigned char | ds_activation |
| activation bitmask More... | |
| unsigned char | ds_rotation |
| rotation bitmask More... | |
| volatile int | ds_rotations [3] |
| rotational position More... | |
Interface: direct reading of sensors.
Definition in file dsensor.h.
| #define ds_scale | ( | x | ) | ((unsigned int)(x)>>6) |
| #define ds_unscale | ( | x | ) | ((unsigned int)(x)<<6) |
| #define LIGHT | ( | a | ) | (147 - ds_scale(a)/7) |
| #define LIGHT_MAX LIGHT(LIGHT_RAW_WHITE) |
| #define LIGHT_RAW_BLACK 0xffc0 |
| #define LIGHT_RAW_WHITE 0x5080 |
| #define ROTATION_1 (ds_rotations[2]) |
| #define ROTATION_2 (ds_rotations[1]) |
| #define ROTATION_3 (ds_rotations[0]) |
| #define SENSOR_1 AD_C |
| #define TOUCH | ( | a | ) | ((unsigned int)(a) < 0x8000) |
|
inline |
set sensor mode to active (light sensor emits light, rotation works)
| sensor | &SENSOR_1,&SENSOR_2,&SENSOR_3 |
Definition at line 167 of file dsensor.h.
References ds_activation, SENSOR_1, SENSOR_2, and SENSOR_3.
Referenced by Sensor::active().
|
inline |
set sensor mode to passive (light sensor detects ambient light)
| sensor | &SENSOR_1,&SENSOR_2,&SENSOR_3 |
Definition at line 180 of file dsensor.h.
References ds_activation, SENSOR_1, SENSOR_2, and SENSOR_3.
Referenced by Sensor::passive().
|
inline |
stop tracking rotation sensor
| sensor | &SENSOR_1,&SENSOR_2,&SENSOR_3 |
Definition at line 220 of file dsensor.h.
References ds_rotation, SENSOR_1, SENSOR_2, and SENSOR_3.
Referenced by RotationSensor::off().
|
inline |
start tracking rotation sensor
| sensor | &SENSOR_1,&SENSOR_2,&SENSOR_3 |
Definition at line 207 of file dsensor.h.
References ds_rotation, SENSOR_1, SENSOR_2, and SENSOR_3.
Referenced by RotationSensor::on().
| void ds_rotation_set | ( | volatile unsigned * | sensor, |
| int | pos | ||
| ) |
set rotation to an absolute value
| sensor | one of &SENSOR_1, &SENSOR_2, or &SENSOR_3 |
| pos | the current rotational postion (typically use 0 here) |
The axis should be inert during the function call.
Referenced by RotationSensor::pos().
| unsigned char ds_activation |
activation bitmask
Referenced by ds_active(), and ds_passive().
| unsigned char ds_rotation |
rotation bitmask
Referenced by ds_rotation_off(), and ds_rotation_on().
| volatile int ds_rotations[3] |
rotational position
|
brickOS is released under the
Mozilla Public License.
Original code copyright 1998-2005 by the authors. |
1.8.16