#include <config.h>
#include <sys/h8.h>
#include <sys/bitops.h>
Go to the source code of this file.
Defines | |
#define | SENSOR_1 AD_C |
< the raw sensors | |
#define | SENSOR_2 AD_B |
Sensor on input pad 2. | |
#define | SENSOR_3 AD_A |
Sensor on input pad 3. | |
#define | BATTERY AD_D |
Battery sensor. | |
#define | LIGHT_RAW_BLACK 0xffc0 |
< active light sensor: estimated raw values | |
#define | LIGHT_RAW_WHITE 0x5080 |
active light sensor raw white value | |
#define | LIGHT(a) (147 - ds_scale(a)/7) |
map light sensor to 0..LIGHT_MAX | |
#define | LIGHT_MAX LIGHT(LIGHT_RAW_WHITE) |
maximum decoded value | |
#define | LIGHT_1 LIGHT(SENSOR_1) |
light sensor on input 1 | |
#define | LIGHT_2 LIGHT(SENSOR_2) |
light sensor on input 2 | |
#define | LIGHT_3 LIGHT(SENSOR_3) |
light sensor on input 3 | |
#define | ROTATION_1 (ds_rotations[2]) |
rotation sensor on input 1 | |
#define | ROTATION_2 (ds_rotations[1]) |
rotation sensor on input 2 | |
#define | ROTATION_3 (ds_rotations[0]) |
rotation sensor on input 3 | |
#define | TOUCH(a) ((unsigned int)(a) < 0x8000) |
Convert raw data to touch sensor (0: off, else pressed). | |
#define | TOUCH_1 TOUCH(SENSOR_1) |
touch sensor on input 1 | |
#define | TOUCH_2 TOUCH(SENSOR_2) |
touch sensor on input 2 | |
#define | TOUCH_3 TOUCH(SENSOR_3) |
touch sensor on input 3 | |
#define | ds_scale(x) ((unsigned int)(x)>>6) |
mask off bottom 6 bits | |
#define | ds_unscale(x) ((unsigned int)(x)<<6) |
leave room for bottom 6 bits | |
Functions | |
void | ds_active (volatile unsigned *sensor) |
set sensor mode to active (light sensor emits light, rotation works) | |
void | ds_passive (volatile unsigned *sensor) |
set sensor mode to passive (light sensor detects ambient light) | |
void | ds_rotation_set (volatile unsigned *sensor, int pos) |
set rotation to an absolute value | |
void | ds_rotation_on (volatile unsigned *sensor) |
start tracking rotation sensor | |
void | ds_rotation_off (volatile unsigned *sensor) |
stop tracking rotation sensor | |
Variables | |
unsigned char | ds_activation |
activation bitmask | |
unsigned char | ds_rotation |
rotation bitmask | |
volatile int | ds_rotations [3] |
rotational position |
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 |
< the raw sensors
Sensor on input pad 1
Definition at line 61 of file dsensor.h.
Referenced by ds_active(), ds_passive(), ds_rotation_off(), and ds_rotation_on().
#define SENSOR_2 AD_B |
Sensor on input pad 2.
Definition at line 62 of file dsensor.h.
Referenced by ds_active(), ds_passive(), ds_rotation_off(), and ds_rotation_on().
#define SENSOR_3 AD_A |
Sensor on input pad 3.
Definition at line 63 of file dsensor.h.
Referenced by ds_active(), ds_passive(), ds_rotation_off(), and ds_rotation_on().
#define TOUCH | ( | a | ) | ((unsigned int)(a) < 0x8000) |
void ds_active | ( | volatile unsigned * | sensor | ) | [inline] |
void ds_passive | ( | volatile unsigned * | sensor | ) | [inline] |
void ds_rotation_off | ( | volatile unsigned * | sensor | ) | [inline] |
void ds_rotation_on | ( | volatile unsigned * | sensor | ) | [inline] |
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) |
unsigned char ds_activation |
activation bitmask
unsigned char ds_rotation |
rotation bitmask
volatile int ds_rotations[3] |
rotational position
brickOS is released under the
Mozilla Public License.
Original code copyright 1998-2005 by the authors. |