|
PropWare
3.0.0.229
C++ objects and CMake build system for Parallax Propeller
|
30 #define RoomTemperature_Degrees_Celcius 23
37 int x, y, z, ax, ay, az, motion;
43 print(
"Demo code for Parallax LIS3DH Accelerometer %c \r",
CLREOL);
53 print(
"WhoAmI : %d (%s) %c \r\r",
62 print(
"================================================================================ %c \r",
CLREOL);
63 print(
"Room temperature calibration is %dC. Change this value in the code if incorrect! %c \r", RoomTemperature_Degrees_Celcius,
CLREOL);
64 print(
"================================================================================ %c \r",
CLREOL);
83 print(
" Raw : x = %d, y = %d, z = %d %c \r",
x, y, z,
CLREOL );
85 }
else {
print(
" Raw : data not ready %c \r",
CLREOL ); }
90 print(
" mg : x = %d, y = %d, z = %d %c \r",
x, y, z,
CLREOL );
92 }
else {
print(
" mg : data not ready %c \r",
CLREOL ); }
98 print(
" adc : 1 = %d, 2 = %d, 3 = %d %c \r",
x, y, z,
CLREOL );
101 print(
" mV : 1 = %d, 2 = %d, 3 = %d %c \r",
x, y, z,
CLREOL );
111 print(
" tilt : ax = %d, ay = %d, az = %d, motion = %d%c \r", ax, ay, az, motion,
CLREOL );
113 }
else {
print(
" tilt : data not ready %c \r",
CLREOL ); }
void lis3dh_tempCal_C(lis3dh_t *device, int actualTempC)
Sets the actual temperature to provide a reference for the relative temperature sensor.
int lis3dh_getRange(lis3dh_t *device)
Reads the g measurement range; one of +/- 2, +/-4, +/- 8, +- 16 g.
void lis3dh_setResolution(lis3dh_t *device, int bits)
Sets the bit resolution for the sensor readings. 8-bit, 10-bit or 12-bit.
int lis3dh_tilt(lis3dh_t *device, int *ax, int *ay, int *az, int *motion)
Gets tilt angle measurements for each axis, and magnitude of motion.
int lis3dh_accel_mg(lis3dh_t *device, int *xmg, int *ymg, int *zmg)
Gets mg (milli-g's) accelerometer measurements from all three axis (x, y, z).
void lis3dh_setRange(lis3dh_t *device, int range)
Sets the g measurement range to +/- 2, +/-4, +/- 8, +- 16 g.
int lis3dh_accel(lis3dh_t *device, int *x, int *y, int *z)
Gets raw accelerometer measurements from all three axis (x, y, z).
Simplifies reading Parallax LIS3DH 3-Axis Accelerometer Module with ADC.
int print(const char *format,...) __attribute__((format(printf
Print format "..." args to the default simple terminal device. The output is limited to 256 bytes.
void lis3dh_adc(lis3dh_t *device, int *ad1, int *ad2, int *ad3)
Gets raw adc measurements from all three ADC channels.
lis3dh_t * lis3dh_init(int pinSCK, int pinSDI, int pinCS)
Initialize the sensor with typical configuration for reading axis and adc. Uses 3-Wire SPI mode.
int lis3dh_getWhoAmI(lis3dh_t *device)
Reads the sensor identification register (WhoAmI).
int lis3dh_temp_C(lis3dh_t *device)
Reads the calibrated (referenced) temperature value from the sensor.
void lis3dh_adc_mV(lis3dh_t *device, int *ad1, int *ad2, int *ad3)
Gets mV adc measurements from all three ADC channels.
int lis3dh_getResolution(lis3dh_t *device)
Reads the bit resolution setting from the sensor. 8-bit, 10-bit or 12-bit.
int lis3dh_tempRaw(lis3dh_t *device)
Reads the raw relative temperature value from the sensor.