当前位置:网站首页>基于OpenHarmony的智能金属探测器
基于OpenHarmony的智能金属探测器
2022-07-05 10:43:00 【InfoQ】
一、简介

二、运行效果

三、功能实现


uint8_t Mpu_Read_Bytes(uint8_t const regAddr, uint8_t *pData, uint8_t len)
Mpu_Data.mag_x = (MPU_BUFF[16] << 8) | MPU_BUFF[15]; // x轴磁场数据
Mpu_Data.mag_y = (MPU_BUFF[18] << 8) | MPU_BUFF[17]; // y轴磁场数据
Mpu_Data.mag_z = (MPU_BUFF[20] << 8) | MPU_BUFF[19]; // z轴磁场数据
Gauss_Mag_z = Mpu_Calc.mag_z * 0.15f * 0.01f;
const uint16_t calibrateCount = 1000; // 测量最大次数为1000
const uint16_t calibrateFrequency = 5; // 每测量5次取一次有效值
const uint16_t calibrateAverageCount = 100; // 取100次有效值
if(i < calibrateCount){
i++;
if(i%calibrateFrequency == calibrateFrequency){
Mag_z_buff[j++] = Gauss_Mag_z;
if(j >= calibrateAverageCount){
i = calibrateCount;
Mag_z_Flag = true;
for(k=0;k<calibrateAverageCount;k++){
origin_mag_z += Mag_z_buff[k];
}
origin_mag_z = origin_mag_z / calibrateAverageCount;
// 校准完成,蓝灯亮,发送给应用端 "CalibrateOK"
BLUE_LED_ON();
memset(buff,0x00,sizeof(buff));
sprintf(buff,"angle:%s","CalibrateOK");
ESP8266_send_data(buff,strlen(buff));
}
}
}
// 先挂载,再send
hdc_std shell mount -oremount,rw /
hdc_std file send libtcpserverapi.z.so system/lib/module/libtcpserverapi.z.so
import tcpserverapi from '@ohos.tcpserverapi'
// 调用initServer接口 初始化 TCP 服务器
tcpserverapi.initServer()
// 调用recvMsg 获取并解析Geek_Lite_Board开发板发送过来的角度
tcpserverapi.recvMsg().then((result) => {
var resultAngle = result.angle;
})


Flex(options?: { direction?: FlexDirection, wrap?: FlexWrap, justifyContent?: FlexAlign, alignItems?: ItemAlign, alignContent?: FlexAlign })
aboutToAppear() {
var intervalID = setInterval(() => {
tcpserverapi.recvMsg().then((result) => {
}
}
}
if (resultMetal.match("metal:")) {
this.metal = resultMetal.slice(6);
console.info('=======' + this.metal)
if (this.metal === 'Detected') {
this.detectionState = '发现金属';
this.detection = $r("app.media.img_detected");
this.isDisplay = false;
}
else if (this.metal === 'UnDetected' || this.metal ==='CalibrateOK') {
this.detectionState = '检测中';
this.detection = $r("app.media.img_detecting");
this.isDisplay = true;
}
}
import media from '@ohos.multimedia.media';
// OH media对象
private player = media.createAudioPlayer();
play():void
四、总结
五、参考链接

边栏推荐
- 脚手架开发基础
- Taro advanced
- App各大应用商店/应用市场网址汇总
- Sqlserver regularly backup database and regularly kill database deadlock solution
- Operation of simulated examination platform of special operation certificate examination question bank for safety production management personnel of hazardous chemical production units in 2022
- 微信核酸检测预约小程序系统毕业设计毕设(8)毕业设计论文模板
- 脚手架开发进阶
- Bracket matching problem (STL)
- 数组、、、
- 关于vray 5.2的使用(自研笔记)
猜你喜欢
微信核酸检测预约小程序系统毕业设计毕设(8)毕业设计论文模板
关于vray 5.2的使用(自研笔记)
关于 “原型” 的那些事你真的理解了吗?【上篇】
Web3 Foundation grant program empowers developers to review four successful projects
2022 Pengcheng cup Web
赛克瑞浦动力电池首台产品正式下线
32: Chapter 3: development of pass service: 15: Browser storage media, introduction; (cookie,Session Storage,Local Storage)
Go-3-the first go program
小红书自研KV存储架构如何实现万亿量级存储与跨云多活
Do you really understand the things about "prototype"? [part I]
随机推荐
websocket
PWA (Progressive Web App)
beego跨域问题解决方案-亲试成功
【js学习笔记五十四】BFC方式
In the year of "mutual entanglement" of mobile phone manufacturers, the "machine sea tactics" failed, and the "slow pace" playing method rose
Scaffold development foundation
埋点111
[可能没有默认的字体]Warning: imagettfbbox() [function.imagettfbbox]: Invalid font filename……
【广告系统】Parameter Server分布式训练
关于vray5.2怎么关闭日志窗口
2022年化工自动化控制仪表考试试题及在线模拟考试
沟通的艺术III:看人之间 之倾听
Bidirectional RNN and stacked bidirectional RNN
Share Net lightweight ORM
Explanation of message passing in DGL
Crawler (9) - scrape framework (1) | scrape asynchronous web crawler framework
正则表达式
Array
跨页面通讯
2022 Pengcheng cup Web