LSM6DSO FSM手势识别的两种数组形式的疑问 ?
<p>请教各位,刚接触LSM6DSO的FSM,本来想识别shake手势,结果在 lsm6dso_fsm.c里找不到shake手势的数组,并且是这种形式:</p><p>/* Program: glance */<br />
const uint8_t lsm6so_prg_glance[] = {<br />
0xb2, 0x10, 0x24, 0x20, 0x17, 0x17, 0x66, 0x32,<br />
0x66, 0x3c, 0x20, 0x20, 0x02, 0x02, 0x08, 0x08,<br />
0x00, 0x04, 0x0c, 0x00, 0xc7, 0x66, 0x33, 0x73,<br />
0x77, 0x64, 0x88, 0x75, 0x99, 0x66, 0x33, 0x53,<br />
0x44, 0xf5, 0x22, 0x00,<br />
};</p>
<p>/* Program: motion */<br />
const uint8_t lsm6so_prg_motion[] = {<br />
0x51, 0x10, 0x16, 0x00, 0x00, 0x00, 0x66, 0x3c,<br />
0x02, 0x00, 0x00, 0x7d, 0x00, 0xc7, 0x05, 0x99,<br />
0x33, 0x53, 0x44, 0xf5, 0x22, 0x00,<br />
};</p>
<p>而在另外一个代码里,找到一个这样的shake手势数组(unico转换出来的):</p>
<p>const ucf_line_t shake[] = {<br />
{.address = 0x10, .data = 0x00,},<br />
{.address = 0x11, .data = 0x00,},<br />
{.address = 0x01, .data = 0x80,},<br />
{.address = 0x04, .data = 0x00,},<br />
{.address = 0x05, .data = 0x00,},<br />
{.address = 0x5F, .data = 0x43,},<br />
{.address = 0x46, .data = 0x01,},<br />
{.address = 0x47, .data = 0x00,},<br />
{.address = 0x0A, .data = 0x00,},</p>
<p>。。。。。</p>
<p> {.address = 0x09, .data = 0x00,},<br />
{.address = 0x09, .data = 0x00,},<br />
{.address = 0x09, .data = 0x01,},<br />
{.address = 0x09, .data = 0x01,},<br />
{.address = 0x09, .data = 0x00,},<br />
{.address = 0x09, .data = 0x00,},<br />
{.address = 0x09, .data = 0xE2,},<br />
{.address = 0x09, .data = 0x00,},<br />
{.address = 0x09, .data = 0x1E,},<br />
{.address = 0x09, .data = 0x00,},<br />
{.address = 0x09, .data = 0x13,},</p>
<p>。。。。</p>
<p>}</p>
<p>这两种数组格式都不一样,没法将这个 shake数组导入到上面那个工程里。</p>
<p>并且很奇怪,第二种数组连续多个address是一样的,是什么意义呢?这种方式能不能同时支持多个手势呢?找不到工程代码使用这种数组的例子。</p>
<p>谢谢大佬帮忙解答!</p>
<p>LSM6DSO 的Shake detection例程可以在官方的github页面找到,对应的链接是:</p>
<p>https://github.com/STMicroelectronics/STMems_Finite_State_Machine/tree/master/application_examples</p>
<p>第一种原始数组通过类似lsm6dsox_ln_pg_write的函数配置</p>
<p></p>
<p>第二种数组通过类似下边方法配置</p>
<p></p>
<p>LSM6DSO的examples里只提供了RAW方式的示例,第二种示例可以参考LSM6DSOX的代码</p>
<p> <br />
https://github.com/STMicroelectronics/STMems_Standard_C_drivers/tree/master/lsm6dsox_STdC/examples</p>
<p>"第二种数组连续多个address是一样的,是什么意义呢?"</p>
<p>可以参考下边文档,第49、50、52页有一个示例。</p>
<p></p>
<p> </p>
<p> </p>
littleshrimp 发表于 2021-7-23 15:14
LSM6DSO 的Shake detection例程可以在官方的github页面找到,对应的链接是:
https://github.com/STMicr ...
<p>厉害,玩的透彻!</p>
littleshrimp 发表于 2021-7-23 15:14
LSM6DSO 的Shake detection例程可以在官方的github页面找到,对应的链接是:
https://github.com/STMicr ...
<p>版主厉害,非常感谢 ,辛苦了!</p>
<p>另外,是否有方法可以将第二种数组转换成第一种数组呢?</p>
<p>因为我需要在 lsm6dso_fsm.c里处理 shake 手势,这个文件有多种手势处理,但就是缺了shake手势。</p>
<div class='shownolgin' data-isdigest='no'>littleshrimp 发表于 2021-7-23 15:44
"第二种数组连续多个address是一样的,是什么意义呢?"
可以参考下边文档,第49、50、52页有一个示 ...
<p>原来是地址递增了。奇怪,为什么不干脆生成绝对地址呢。</p>
</div><script>showreplylogin();</script><script type="text/javascript">(function(d,c){var a=d.createElement("script"),m=d.getElementsByTagName("script"),eewurl="//counter.eeworld.com.cn/pv/count/";a.src=eewurl+c;m.parentNode.insertBefore(a,m)})(document,523)</script> <div class='shownolgin' data-isdigest='no'>kinggate1 发表于 2021-7-23 19:47
版主厉害,非常感谢 ,辛苦了!
另外,是否有方法可以将第二种数组转换成第一种数组呢?
因为我需 ...
<p>你可以参考一下lsm6dso_reg.c里的lsm6dso_ln_pg_write函数,再对照一下an5226文档和第二种数组同,应该就能弄明白它们两者的规律。</p>
<pre>
<code class="language-cpp">int32_t lsm6dso_ln_pg_write(stmdev_ctx_t *ctx, uint16_t address,
uint8_t *buf, uint8_t len)
{
lsm6dso_page_rw_t page_rw;
lsm6dso_page_sel_t page_sel;
lsm6dso_page_address_tpage_address;
uint16_t addr_pointed;
int32_t ret;
uint8_t i ;
addr_pointed = address;
ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_EMBEDDED_FUNC_BANK);
if (ret == 0)
{
ret = lsm6dso_read_reg(ctx, LSM6DSO_PAGE_RW, (uint8_t *) &page_rw, 1);
}
if (ret == 0)
{
page_rw.page_rw = 0x02; /* page_write enable*/
ret = lsm6dso_write_reg(ctx, LSM6DSO_PAGE_RW, (uint8_t *) &page_rw, 1);
}
if (ret == 0)
{
ret = lsm6dso_read_reg(ctx, LSM6DSO_PAGE_SEL, (uint8_t *) &page_sel, 1);
}
if (ret == 0)
{
page_sel.page_sel = ((uint8_t)(addr_pointed >> 8) & 0x0FU);
page_sel.not_used_01 = 1;
ret = lsm6dso_write_reg(ctx, LSM6DSO_PAGE_SEL, (uint8_t *) &page_sel, 1);
}
if (ret == 0)
{
page_address.page_addr = (uint8_t)(addr_pointed & 0x00FFU);
ret = lsm6dso_write_reg(ctx, LSM6DSO_PAGE_ADDRESS,
(uint8_t *)&page_address, 1);
}
if (ret == 0)
{
for (i = 0; ((i < len) && (ret == 0)); i++)
{
ret = lsm6dso_write_reg(ctx, LSM6DSO_PAGE_VALUE, &buf, 1);
addr_pointed++;
/* Check if page wrap */
if (((addr_pointed % 0x0100U) == 0x00U) && (ret == 0))
{
ret = lsm6dso_read_reg(ctx, LSM6DSO_PAGE_SEL, (uint8_t *)&page_sel, 1);
if (ret == 0)
{
page_sel.page_sel = ((uint8_t)(addr_pointed >> 8) & 0x0FU);
page_sel.not_used_01 = 1;
ret = lsm6dso_write_reg(ctx, LSM6DSO_PAGE_SEL,
(uint8_t *)&page_sel, 1);
}
}
}
page_sel.page_sel = 0;
page_sel.not_used_01 = 1;
ret = lsm6dso_write_reg(ctx, LSM6DSO_PAGE_SEL, (uint8_t *) &page_sel, 1);
}
if (ret == 0)
{
ret = lsm6dso_read_reg(ctx, LSM6DSO_PAGE_RW, (uint8_t *) &page_rw, 1);
}
if (ret == 0)
{
page_rw.page_rw = 0x00; /* page_write disable */
ret = lsm6dso_write_reg(ctx, LSM6DSO_PAGE_RW, (uint8_t *) &page_rw, 1);
}
if (ret == 0)
{
ret = lsm6dso_mem_bank_set(ctx, LSM6DSO_USER_BANK);
}
return ret;
}</code></pre>
<p> </p>
</div><script>showreplylogin();</script> <div class='shownolgin' data-isdigest='no'>littleshrimp 发表于 2021-7-23 20:05
你可以参考一下lsm6dso_reg.c里的lsm6dso_ln_pg_write函数,再对照一下an5226文档和第二种数组同,应该就 ...
<p>好的,我好好研究一下。<img height="47" src="https://bbs.eeworld.com.cn/static/editor/plugins/hkemoji/sticker/facebook/handshake.gif" width="47" /></p>
</div><script>showreplylogin();</script>
页:
[1]