Skip to content

Commit 0cdc34e

Browse files
committed
lis3dh library updates for tilt functions - Block Speck Updates
v1.4.140 The block speck is additive. No changes to existing blocks.
1 parent 53a9cd6 commit 0cdc34e

File tree

2 files changed

+52
-7
lines changed

2 files changed

+52
-7
lines changed

Learn/Simple Libraries/Sensor/liblis3dh/BLOCKS.txt

Lines changed: 51 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434

3535

3636
// BLOCK: LIS3DH initialize SCK(dropdown: pin), SDI(dropdown: pin), CS(dropdown: pin)
37+
// + Optional Temperature Calibration setting (appears when temp block added to project - see below)
38+
// + Optional Tilt Averaging Factor setting (appears when tilt block added to project - see below)
3739

3840
// Example:
3941
LIS3DH initialize SCK 8, SDI 7, CS 6
@@ -43,25 +45,32 @@
4345

4446

4547

46-
// BLOCK: LIS3DH read(dropdown: accelerometer 1000ths of g's ; adc mV)
48+
// BLOCK: LIS3DH read(dropdown: accelerometer 1000ths of g's ; adc mV ; tilt degrees)
4749
*if accel* store X-axis in (item), store Y-axis in (item), store Z-axis in (item)
4850
*if adc* store AD1 in (item), store AD2 in (item), store AD3 in (item)
51+
*if tilt* store X-axis in (item), store Y-axis in (item), store Z-axis in (item), store Motion Intensity in (item)
4952

5053
// Examples: (Assuming variables x, y, and z have been created with blocks)
5154
LIS3DH read accelerometer (1000ths of g), store x axis in x, y axis in y, z axis in z
5255
LIS3DH read adc (mV), store ad1 in x, ad2 in y, ad3 in z
5356

57+
// Examples: (Assuming variables x, y, z and m have been created with blocks)
58+
LIS3DH read tilt (degrees), store x axis in x, y axis in y, z axis in z, motion intensity in m
59+
60+
5461
// Emits: (assuming global pointer name is LIS3DH_1)
5562
lis3dh_accel_mg(LIS3DH_1, &x, &y, &z);
5663
lis3dh_adc_mV(LIS3DH_1, &x, &y, &z);
64+
lis3dh_tilt(LIS3DH_1, &x, &y, &z, &m);
5765

5866

59-
60-
// BLOCK: Temperature calibrate units(dropdown: F or C), ambient temperature(actualTempC/actualTempF)
67+
68+
// BLOCK: (OPTIONAL INIT ITEM - Appears when temperature read block added to project)
69+
// Set ambient temperature to ambient temperature(actualTempC/actualTempF), (dropdown: F or C)
6170

6271
// Examples:
63-
Temperature calibrate units C, ambient temperature 23
64-
Temperature calibrate units F, ambient temperature 85
72+
Set ambient temperature to 23, C
73+
Set ambient temperature to 85, F
6574

6675
// Emits: (assuming global pointer name is LIS3DH_1)
6776
lis3dh_tempCal_C(LIS3DH_1, 23);
@@ -70,14 +79,50 @@
7079

7180

7281
// BLOCK: Temperature read units(dropdown: F or C), store in (item)
73-
* WARN! * MUST SET AMBIENT TEMPERATURE WITH CALIBRATION BLOCK
82+
* WARN! * MUST SET AMBIENT TEMPERATURE IN INIT BLOCK
7483

7584
// Examples: (Assuming variable t has been created with a block)
7685
Temperature read units F, store in t
7786

7887
// Emits: (assuming global pointer name is LIS3DH_1)
7988
t = lis3dh_temp_C(LIS3DH_1);
8089
t = lis3dh_temp_F(LIS3DH_1);
90+
91+
92+
93+
94+
// BLOCK: Tilt, store in (x, y, z, motion)
95+
* WARN! * MUST SET TILT AVERAGE FACTOR IN INIT BLOCK
96+
97+
// Examples: (Assuming variables x, y, z, motion have been created with a block)
98+
LIS3DH read tilt angles x, y, z, motion, store in x, y, z, motion
99+
100+
// Emits: (assuming global pointer name is LIS3DH_1)
101+
lis3dh_tilt(LIS3DH_1, x, y, z, motion);
102+
103+
@details Angle to each axis in degrees,
104+
X relative to ground (-90 to 90)
105+
Y relative to ground (-90 to 90)
106+
Z relative to gravity (-90 to 90)
107+
Motion is the sum of g-force on all axis relative to gravity at ground level (1G).
108+
0 is motionless, larger positve or negative values represent more intense motion.
109+
The motion value could be used on it's own for projects requiring vibration sensing.
110+
111+
112+
113+
// BLOCK: (OPTIONAL INIT ITEM - Appears when tilt read block added to project)
114+
// Set Tilt Averaging Factor value percent
115+
//
116+
// note for Block creator- default value is 100 which means averaging disabled. (ie. 100% of new data)
117+
118+
// Examples:
119+
Set Tilt Averaging Factor to 100
120+
Set Tilt Averaging Factor to 50
121+
122+
// Emits: (assuming global pointer name is LIS3DH_1)
123+
lis3dh_tiltConfig(LIS3DH_1, 100);
124+
lis3dh_tiltConfig(LIS3DH_1, 50);
125+
81126

82127

83128
*/

version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v1.4.139
1+
v1.4.140

0 commit comments

Comments
 (0)