|
PropWare
3.0.0.229
C++ objects and CMake build system for Parallax Propeller
|
25 #define RoomTemperature_Degrees_Celcius 23
29 void Example_ReadSensor();
30 void Example_ReadSensorContinuously();
41 print(
"Demo code for Parallax LIS3DH Accelerometer %c \r\r",
CLREOL);
49 Example_ReadSensorContinuously();
64 void Example_ReadSensor_XYZ() {
70 print(
" x = %d, y = %d, z = %d %c \r\r",
x, y, z,
CLREOL );
81 void Example_ReadSensor_XYZ_mg() {
88 print(
" x = %d mg, y = %d mg, z = %d mg %c \r\r",
x, y, z,
CLREOL );
99 void Example_ReadSensor_ADC() {
105 print(
"AD1 = %d, AD2 = %d, AD3 = %d %c \r\r",
113 void Example_ReadSensor_ADCmV() {
119 print(
"AD1 = %d mV, AD2 = %d mV, AD3 = %d mV %c \r\r",
127 void Example_CheckResolution() {
147 void Example_ReadSensor_WhoAmI() {
149 print(
"WhoAmI : %d (%s) %c \r\r",
165 void Example_ReadSensor() {
172 Example_ReadSensor_WhoAmI();
175 Example_CheckResolution();
178 Example_ReadSensor_XYZ();
181 Example_ReadSensor_XYZ_mg();
184 Example_ReadSensor_ADC();
187 Example_ReadSensor_ADCmV();
197 void Example_ReadSensorContinuously() {
206 print(
"WhoAmI : %d (%s) %c \r\r",
215 print(
"================================================================================ %c \r",
CLREOL);
216 print(
"Room temperature calibration is %dC. Change this value in the code if incorrect! %c \r", RoomTemperature_Degrees_Celcius,
CLREOL);
217 print(
"================================================================================ %c \r",
CLREOL);
233 print(
" Raw : x = %d, y = %d, z = %d %c \r",
x, y, z,
CLREOL );
235 }
else {
print(
" Raw : data not ready %c \r",
CLREOL ); }
240 print(
" mg : x = %d, y = %d, z = %d %c \r",
x, y, z,
CLREOL );
242 }
else {
print(
" mg : data not ready %c \r",
CLREOL ); }
248 print(
" adc : 1 = %d, 2 = %d, 3 = %d %c \r",
x, y, z,
CLREOL );
251 print(
" mV : 1 = %d, 2 = %d, 3 = %d %c \r",
x, y, z,
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.
void lis3dh_shutdown(lis3dh_t *device)
Shutdown the sensor, set configuration defaults with sensor disabled and clear buffers.
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.