【平头哥RVB2601创意应用开发】超声波压感sensor调试和LED/OLED显示
[复制链接]
1. 时间过得真快啊,转眼两周了,今年的五一很特别,继续封控,哈哈,希望早日解封吧。
2. 继上次I2C可以正常读取超声波压感sensor数据后,我又很顺利的调试校准了sensor,并通过LED和OLED做了显示。
3. Sensor校准后通过串口抓到的数据如下:
1)初始化
Welcome boot2.0!
build: Mar 5 2021 15:34:41
load img & jump to [prim]
load&jump 0x18017000,0x18017000,152628
xip...
j 0x18017044
[ 0.020]<I>INIT Build:Apr 7 2022,17:03:34
===main, 138
===main, 139
[charon] usp+zforce driver version:1.0.0
[charon] dev0(0X27) toggle via fd reg
[charon] bd read dev0(0X27) whoami (rc:0 ,whoami:0X1 ,is_otp_part:1)
[charon] fd read dev0(0X27) whoami successfully (whoami:0X62)
[charon] read dev0(0X27) si rev failed! (si_rev:0XFF)
[charon] set dev0(0X27) high power mode
[charon] dev0(0X27) read tx freq:0X8
[charon] dev0(0X27) write misc regs ok!
[charon] dev0(0X27) write zforce regs ok!
[charon] dev0(0X27) write zforce gain(0x1844=0X55, rc:0)
[charon] set dev0(0X27) i2c clk src: 4MHz
[charon] dev0(0X27) fw dl start...(fw size:3397 bytes)
[charon] dev0(0X27) fw dl completed
[charon] set dev0(0X27) high power mode
[charon] dev0(0X27) cali stage 0
[charon] dev0(0X27) zforce_offset 1172
[charon] dev0(0X27) zforce_offset 1102
[charon] dev0(0X27) zforce_offset 1074
[charon] dev0(0X27) zforce_offset 1078
[charon] dev0(0X27) zforce_offset 1075
[charon] dev0(0X27) offset_middle 14 ,offset_up 15 ,offset_down 13
[charon] dev0(0X27) cali stage 1
[charon] dev0(0X27) zforce_offset 1072
[charon] dev0(0X27) zforce_offset 1072
[charon] dev0(0X27) zforce_offset 1068
[charon] dev0(0X27) zforce_offset 1064
[charon] dev0(0X27) zforce_offset 1068
[charon] dev0(0X27) offset_middle 14 ,offset_up 15 ,offset_down 13
[charon] dev0(0X27) set 0x1880=0x08
[charon] dev0(0X27) set 0x1881=0x06
[charon] dev0(0X27) set 0x1882=0xa0
[charon] dev0(0X27) set 0x1883=0x00
[charon] dev0(0X27) set 0x1884=0x03
[charon] dev0(0X27) set 0x1885=0xff
[charon] dev0(0X27) set 0x1886=0x00
[charon] dev0(0X27) set 0x1887=0x00
[charon] dev0(0X27) set 0x1888=0x05
[charon] dev0(0X27) set 0x1889=0x01
[charon] dev0(0X27) set 0x188a=0x00
[charon] dev0(0X27) set 0x188b=0xac
[charon] dev0(0X27) set 0x188c=0x07
[charon] dev0(0X27) set 0x188d=0xa8
[charon] dev0(0X27) set 0x188e=0x19
[charon] dev0(0X27) set 0x188f=0x00
[charon] dev0(0X27) set 0x1890=0x33
[charon] dev0(0X27) set 0x1891=0x03
[charon] dev0(0X27) set 0x1892=0x56
[charon] dev0(0X27) set 0x1893=0x05
[charon] dev0(0X27) set usp max contrast 0x1154=0xff
[charon] dev0(0X27) set usp noise rms 0x1157=0x0d
[charon] dev0(0X27) set zforce gain 0x1844=0x55
[charon] dev0(0X27) set zforce contrast 0x115c=0x19
[charon] dev0(0X27) set zforce noise 0x115e=0x06
[charon] dev0(0X27) set sensitivity level to 3
[charon] dev0(0X27) set algo mode(2[USP+ZForce])
[charon] dev0(0X27) init done(rc:0)!
2)正常polling数据:
[charon] dev0(0X27) ,adc 924 ,1072, key 1[released][charon]
[charon] dev0(0X27) ,adc 933 ,1072, key 1[released][charon]
[charon] dev0(0X27) ,adc 924 ,1080, key 1[released][charon]
[charon] dev0(0X27) ,adc 939 ,1080, key 1[released][charon]
[charon] dev0(0X27) ,adc 928 ,1080, key 1[released][charon]
[charon] dev0(0X27) ,adc 933 ,1080, key 1[released][charon]
[charon] dev0(0X27) ,adc 935 ,1080, key 1[released][charon]
[charon] dev0(0X27) ,adc 906 ,1072, key 1[released][charon]
[charon] dev0(0X27) ,adc 936 ,1080, key 1[released][charon]
[charon] dev0(0X27) ,adc 926 ,1080, key 1[released][charon]
[charon] dev0(0X27) ,adc 928 ,1080, key 1[released][charon]
[charon] dev0(0X27) ,adc 938 ,1080, key 1[released][charon]
[charon] dev0(0X27) ,adc 901 ,1096, key 1[released][charon]
[charon] dev0(0X27) ,adc 872 ,1144, key 1[released][charon]
[charon] dev0(0X27) ,adc 868 ,1216, key 1[released][charon]
[charon] dev0(0X27) ,adc 852 ,1304, key 1[released][charon]
[charon] dev0(0X27) ,adc 848 ,1376, key 1[released][charon]
[charon] dev0(0X27) ,adc 831 ,1432, key 1[released][charon]
[charon] dev0(0X27) ,adc 826 ,1472, key 1[released][charon]
[charon] dev0(0X27) ,adc 818 ,1496, key 1[released][charon]
[charon] dev0(0X27) ,adc 813 ,1528, key 1[released][charon]
[charon] dev0(0X27) ,adc 800 ,1568, key 1[released][charon]
[charon] dev0(0X27) ,adc 802 ,1624, key 1[released][charon]
[charon] dev0(0X27) ,adc 810 ,1704, key 1[released][charon]
[charon] dev0(0X27) ,adc 763 ,1784, key 1[released][charon]
[charon] dev0(0X27) ,adc 777 ,1864, key 1[released][charon]
[charon] dev0(0X27) ,adc 744 ,1968, key 1[released][charon]
[charon] dev0(0X27) ,adc 751 ,2000, key 1[released][charon]
[charon] dev0(0X27) ,adc 752 ,2008, key 1[released][charon]
[charon] dev0(0X27) ,adc 727 ,2024, key 1[released][charon]
[charon] dev0(0X27) ,adc 721 ,2032, key 1[released][charon]
[charon] dev0(0X27) ,adc 723 ,2032, key 1[released][charon]
[charon] dev0(0X27) ,adc 719 ,2032, key 1[released][charon]
[charon] dev0(0X27) ,adc 703 ,2040, key 1[released][charon]
[charon] dev0(0X27) ,adc 709 ,2040, key 1[released][charon]
[charon] dev0(0X27) ,adc 700 ,2040, key 1[released][charon]
[charon] dev0(0X27) ,adc 707 ,2040, key 1[released][charon]
[charon] dev0(0X27) ,adc 688 ,2040, key 1[released][charon]
[charon] dev0(0X27) ,adc 683 ,2040, key 1[released][charon]
[charon] dev0(0X27) ,adc 688 ,2040, key 1[released][charon]
[charon] dev0(0X27) ,adc 680 ,2040, key 1[released][charon]
[charon] dev0(0X27) ,adc 679 ,2040, key 1[released][charon]
[charon] dev0(0X27) ,adc 674 ,2040, key 1[released][charon]
[charon] dev0(0X27) ,adc 672 ,2040, key 1[released][charon]
[charon] dev0(0X27) ,adc 670 ,2040, key 1[released][charon]
[charon] dev0(0X27) ,adc 672 ,2040, key 1[released][charon]
[charon] dev0(0X27) ,adc 654 ,2040, key 1[released][charon]
[charon] dev0(0X27) ,adc 674 ,2040, key 1[released][charon]
[charon] dev0(0X27) ,adc 662 ,2040, key 1[released][charon]
[charon] dev0(0X27) ,adc 676 ,2040, key 1[released][charon]
[charon] dev0(0X27) ,adc 664 ,2040, key 1[released][charon]
[charon] dev0(0X27) ,adc 656 ,2032, key 1[released][charon]
[charon] dev0(0X27) ,adc 658 ,2024, key 1[released][charon]
[charon] dev0(0X27) ,adc 657 ,2000, key 1[released][charon]
[charon] dev0(0X27) ,adc 655 ,1976, key 2[pressed][charon]
[charon] dev0(0X27) ,adc 667 ,1944, key 2[pressed][charon]
[charon] dev0(0X27) ,adc 679 ,1872, key 2[pressed][charon]
[charon] dev0(0X27) ,adc 671 ,1832, key 2[pressed][charon]
[charon] dev0(0X27) ,adc 657 ,1800, key 2[pressed][charon]
从log可以看到按压时key会从1变成2,在代码里加入如下片段,
while (1) {
lv_task_handler();
for (i = 0; i < BUTTON_NUM; i++) {
ccl_tp_dev_t *dev = &ccl_tp_dev[i];
ccl_tp_if_get_adc(dev);
ccl_tp_if_get_btn_status(dev);
debug_info("dev%d(%#X) ,adc %d ,%d, key %d[%s]",
dev->dev_idx,
dev->i2c_addr,
dev->info.usp_adc,
dev->info.zforce_adc,
dev->info.btn_status,
(dev->info.btn_status == 2) ? "pressed" : "released");
if(dev->info.btn_status == 2){
csi_gpio_pin_write(&r, GPIO_PIN_HIGH);
csi_gpio_pin_write(&g, GPIO_PIN_HIGH);
csi_gpio_pin_write(&b, GPIO_PIN_LOW);
lable_press();
} else {
csi_gpio_pin_write(&r, GPIO_PIN_HIGH);
csi_gpio_pin_write(&g, GPIO_PIN_HIGH);
csi_gpio_pin_write(&b, GPIO_PIN_HIGH);
lable_release();
}
}
debug_info("\r\n");
aos_msleep(10);
lv_tick_inc(1);
}
...
即https://bbs.eeworld.com.cn/thread-1198665-1-1.html里关于LED的控制,可以看到如下视频的效果:
4. 为了进一步加强交互体验,我还加入了OLED的显示,代码如下:
lv_obj_t *p;
static void lable_test(void)
{
p = lv_label_create(lv_scr_act(), NULL);
lv_label_set_long_mode(p, LV_LABEL_LONG_BREAK);
lv_label_set_align(p, LV_LABEL_ALIGN_CENTER);
lv_obj_set_pos(p, 0, 4);
lv_obj_set_size(p, 128, 60);
lv_label_set_text(p, "THEAD\nMARQUEE\nDEMO");
}
static void lable_press(void)
{
lv_label_set_text(p, "");
lv_label_set_text(p, "Press");
}
static void lable_release(void)
{
lv_label_set_text(p, "");
lv_label_set_text(p, "Release");
}
最终的视频效果如下:
5. 以上就是我计划完成的作品:基于RISC-V处理器的超声波压感按键,最后再次感谢EEWORLD和平头哥提供的这次机会。
|