当前位置:网站首页>基于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
四、总结
五、参考链接

边栏推荐
- Data types ntext and varchar are incompatible in the not equal to operator - 95 small pang
- Array
- Broyage · fusion | savoir que le site officiel de chuangyu mobile end est en ligne et commencer le voyage de sécurité numérique!
- Explanation of full vulnerability script of network security C module of secondary vocational group script containing 4 vulnerabilities
- websocket
- Data type
- 2022 chemical automation control instrument examination questions and online simulation examination
- 2022鹏城杯web
- LSTM applied to MNIST dataset classification (compared with CNN)
- When using gbase 8C database, an error is reported: 80000502, cluster:%s is busy. What's going on?
猜你喜欢
磨砺·聚变|知道创宇移动端官网焕新上线,开启数字安全之旅!
【DNS】“Can‘t resolve host“ as non-root user, but works fine as root
Operation of simulated examination platform of special operation certificate examination question bank for safety production management personnel of hazardous chemical production units in 2022
Go-3-the first go program
Talk about the understanding of fault tolerance mechanism and state consistency in Flink framework
关于vray5.2怎么关闭日志窗口
微信核酸检测预约小程序系统毕业设计毕设(7)中期检查报告
[vite] 1371 - develop vite plug-ins by hand
Explanation of message passing in DGL
go语言学习笔记-初识Go语言
随机推荐
微信核酸检测预约小程序系统毕业设计毕设(7)中期检查报告
Question bank and answers of special operation certificate examination for main principals of hazardous chemical business units in 2022
数组、、、
脚手架开发基础
风控模型启用前的最后一道工序,80%的童鞋在这都踩坑
About the use of Vray 5.2 (self research notes)
What are the top ten securities companies? Is it safe to open an account online?
小红书自研KV存储架构如何实现万亿量级存储与跨云多活
2022 t elevator repair operation certificate examination questions and answers
[可能没有默认的字体]Warning: imagettfbbox() [function.imagettfbbox]: Invalid font filename……
【js学习笔记五十四】BFC方式
Coneroller执行时候的-26374及-26377错误
Web Components
2022 mobile crane driver examination question bank and simulation examination
微信核酸检测预约小程序系统毕业设计毕设(8)毕业设计论文模板
Beego cross domain problem solution - successful trial
沟通的艺术III:看人之间 之倾听
Operators
matlab cov函数详解
PWA (Progressive Web App)