9651 views|24 replies

9707

Posts

24

Resources
The OP
 

LSM6DSL wrist flip screen detection code [Copy link]

 
 
LSM6DSL wrist flip screen detection code, tested using NUCLEO-L4R5ZI board
For configuration method, please refer to this post
and 2.2
of the data sheet
The sensor driver uses STMems_Standard_C_drivers
链接已隐藏,如需查看请登录或者注册
There is an error in the official code that makes it impossible to set the detection axis other than the X axis
The reason is that the following function only reads LSM6DSL_A_WRIST_TILT_MASK but does not write it back, so you need to modify it yourself
int32_t lsm6dsl_tilt_src_set(lsm6dsl_ctx_t *ctx,lsm6dsl_a_wrist_tilt_mask_t *val)
Main configuration code
  1. void wrist_tilt(void) { lsm6dsl_all_sources_t lsm6dsl_all_sources; /* * Initialize mems driver interface */ dev_ctx.write_reg = platform_write; dev_ctx.read_reg = platform_read; dev_ctx.handle = &hi2c1; /* * Check device ID */ whoamI = 0; lsm6dsl_device_id_get(&dev_ctx, &whoamI); if ( whoamI != LSM6DSL_ID ) while(1); /*manage here device not found */ /* * Restore default configuration */ lsm6dsl_reset_set(&dev_ctx, PROPERTY_ENABLE); do { lsm6dsl_reset_get(&dev_ctx, &rst); } while (rst); /* * Enable Block Data Update */ lsm6dsl_block_data_update_set(&dev_ctx, PROPERTY_ENABLE); //1) Turn on the accelerometer, lsm6dsl_xl_data_rate_set(&dev_ctx, LSM6DSL_XL_ODR_26Hz); /* * Set full scale */ lsm6dsl_xl_full_scale_set(&dev_ctx, LSM6DSL_2g); //2) AWT is enabled, uint8_t wrist = PROPERTY_ENABLE; lsm6dsl_wrist_tilt_sens_set(&dev_ctx, wrist); ///3) Configure the AWT interrupt pin, lsm6dsl_int2_route_t lsm6dsl_int2_route; lsm6dsl_int2_route.int2_wrist_tilt = PROPERTY_ENABLE; lsm6dsl_pin_int2_route_set(&dev_ctx,lsm6dsl_int2_route); ///4) Configure detection axis, lsm6dsl_a_wrist_tilt_mask_t lsm6dsl_a_wrist_tilt_mask; lsm6dsl_a_wrist_tilt_mask.wrist_tilt_mask_zneg = PROPERTY_ENABLE; lsm6dsl_a_wrist_tilt_mask.wrist_tilt_mask_zpos = PROPERTY_ENABLE; lsm6dsl_tilt_src_set(&dev_ctx,&lsm6dsl_a_wrist_tilt_mask); ///5) Configure threshold, uint8_t threshold = 0x20; //1 LSB = 15.625 mg. Default value: 20h (500 mg). lsm6dsl_tilt_th reshold_set(&dev_ctx,&threshold); // /6) Configure duration uint8_t latency = 0x0f;//1 LSB = 40 ms. Default value: 0Fh (600 ms). lsm6dsl_tilt_latency_set(&dev_ctx,&latency); while(1) { if(int2_flag == 1) { int2_flag = 0; lsm6dsl_all_sources_get(&dev_ctx,&lsm6dsl_all_sources); if(lsm6dsl_all_sources.reg.wrist_tilt_ia.wrist_tilt_ia_zneg == 1 || lsm6dsl_all_sources.reg.wrist_tilt_ia.wrist_tilt_ia_zpos == 1) { snprintf(data_out, MAX_BUF_SIZE, "wrist tilt ia.\r\n") ; tx_com((uint8_t*)data_out, strlen(data_out)); } } } }
复制代码
Project file:
游客,如果您要查看本帖隐藏内容请回复

This post is from MEMS sensors

Latest reply

Thanks, I'll learn from you.   Details Published on 2024-6-19 09:43
Personal signature虾扯蛋,蛋扯虾,虾扯蛋扯虾
 
 

3

Posts

0

Resources
2
 
How is the algorithm for turning on the screen by raising your hand and turning your wrist to turn on the screen implemented? Does anyone know?
This post is from MEMS sensors

Comments

This is implemented inside the sensor.  Details Published on 2018-8-15 16:06
 
 
 

9707

Posts

24

Resources
3
 
381503442 posted on 2018-8-15 15:17 How is the algorithm for turning on the screen by raising your hand and turning your wrist to turn on the screen implemented? Does anyone know?
This is implemented inside the sensor
This post is from MEMS sensors
 
 
 

4

Posts

0

Resources
4
 
Just need it~ Thank you OP
This post is from MEMS sensors
 
 
 

4

Posts

0

Resources
5
 
littleshrimp posted on 2018-8-15 16:06 This is implemented inside the sensor
I followed your code to set it up, but the Sensor cannot be interrupted. Does this mean that the detection axis should be set according to the direction of the Layout?
This post is from MEMS sensors

Comments

Are there any interruptions in other directions?  Details Published on 2018-8-27 09:25
 
 
 

9707

Posts

24

Resources
6
 
ialvins posted on 2018-8-27 09:01 I followed your code to set it up, but it doesn't cause the Sensor to interrupt. Does this mean that the detection axis should be set according to the direction of the Layout?
Are there interruptions in other directions?
This post is from MEMS sensors
 
 
 

4

Posts

0

Resources
7
 
littleshrimp posted on 2018-8-27 09:25 Is there any interruption in other directions?
I tried to open all three axes, and there was no interruption no matter how I swung it.... Currently I am connecting it to the recorder and I dare not swing it too hard. I would like to ask if the forum owner has any testing methods? Or test videos? Thank you
This post is from MEMS sensors
 
 
 

9707

Posts

24

Resources
8
 
It should be rotating along an axis that is not perpendicular to the ground, not swinging.
This post is from MEMS sensors
 
 
 

4

Posts

0

Resources
9
 
Ok thank you, I'll give it a try!
This post is from MEMS sensors
 
 
 

9

Posts

1

Resources
10
 
Great code, thanks for sharing
This post is from MEMS sensors
 
 
 

2

Posts

0

Resources
11
 
Thanks for sharing
This post is from MEMS sensors
 
 
 

3

Posts

0

Resources
12
 
Thanks for sharing
This post is from MEMS sensors
 
 
 

3

Posts

0

Resources
13
 
Thanks for sharing
This post is from MEMS sensors
 
 
 

3

Posts

0

Resources
14
 
Thanks, learning
This post is from MEMS sensors
 
 
 

61

Posts

1

Resources
15
 
Download and try
This post is from MEMS sensors
Personal signature

intersil Techwell应用工程师

 
 
 

19

Posts

0

Resources
16
 
I want to study it too!!!
This post is from MEMS sensors
 
 
 

2

Posts

0

Resources
17
 
Learned
This post is from MEMS sensors
 
 
 

3

Posts

0

Resources
18
 

Has anyone ever encountered a situation where, when setting up AWT, only the enable state can be written, and the other states are useless?

The set MASK bug has been fixed, but I can still only read. I have tried writing src, latency, and threshold, but there are no errors when writing. However, when reading, I find that the values are still the same. In the end, only the X axis has a setting (from the MASK, only one direction of X is set, even if I try to set all 6 directions). The wrist_tilt_ia bit reported by func_src2 is set. It stands to reason that the direction can be read from WRIST_TILT_IA, but in fact, this register reads all 0.

It feels like the function can be enabled, but not configured, only the default X axis.

This post is from MEMS sensors

Comments

Did you write the code yourself or use a sample program?  Details Published on 2020-4-15 10:53
 
 
 

9707

Posts

24

Resources
19
 
Hero's End Published on 2020-4-15 09:10 Has anyone encountered that when setting AWT, only the enable state can be written, and the other states are useless? The BUG of set MASK has been solved, but it still...

Did you write the code yourself or use a routine?

This post is from MEMS sensors
Personal signature虾扯蛋,蛋扯虾,虾扯蛋扯虾
 
 
 

3

Posts

0

Resources
20
 
littleshrimp posted on 2020-4-15 10:53 Did you write the code yourself or use a sample program?

The sample code is used for reg access, and the rest are written by myself

This post is from MEMS sensors

Comments

Please send me your code and I will try it for you.  Details Published on 2020-5-27 21:08
 
 
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list