Android万能遥控菜单选择添加,Android万能遥控器小应用

在很久很久以前,手机是有红外功能的,后来随着蓝牙技术的成熟,红外逐渐被蓝牙取代,不再是标配了。

红外本身还是有些优点,比如操作简便,成本低。要想在手机上添加红外功能,就要外接一个转换模块。

0818b9ca8b590ca3270a3433284dd417.png

现在市面上通过Headphone音频口外接MCU实现音频转红外的方案很多,拉卡拉是一个成功案例。

我们的目标是做一个具有学习功能的Android手机遥控器,通过音频转红外,控制大多家电设备。

0818b9ca8b590ca3270a3433284dd417.png

1. 硬件设计

0818b9ca8b590ca3270a3433284dd417.png  

0818b9ca8b590ca3270a3433284dd417.png

右声道输出稳频正弦波,为单片机提供电源

左声道作为tx数据线,phone到mcu

mic线作为rx数据线,mcu到phone

command线,接地

右声道电源供电存在问题,Android手机千差万别,手机里的音频codec模块也不尽相同,

D/A转换的放大倍数(增益)也不同,表现在有些人的手机上铃声大,有些铃声小。

这个值是在Android系统底层驱动里设置,一般无法用上层软件改变。

用galaxy nexus,nexus 4都由于放大倍数不够而导致供电不足,

而三星Galaxy S3就能提供足够的电压,一些山寨机的音量也足够大。

所以考虑更改硬件设计,加入钮扣电池,由硬件直接供电,这样比较稳妥。

2. 数据编码

自定义波形组织形式,这里提供两种频率,一种表示下一个bit不变,另一种表示下一个bit变化。

0818b9ca8b590ca3270a3433284dd417.png

自定义一帧数据的组包形式,一般有包头,包尾,校验位和数据。

0818b9ca8b590ca3270a3433284dd417.png

3. 核心代码

两个线程用来收发数据包

Runnable _outputGenerator = new Runnable() {

public void run() {

Thread.currentThread().setPriority(Thread.NORM_PRIORITY);

while (!_stop) {

updateOutputBuffer();

_audioTrack.write(_stereoBuffer, 0, _stereoBuffer.length);

}

}

};

Runnable _inputProcessor = new Runnable() {

public void run() {

Thread.currentThread().setPriority(Thread.MIN_PRIORITY);

while (!_stop) {

int shortsRead = _audioRecord.read(_recBuffer, 0, _recBuffer.length);

processInputBuffer(shortsRead);

}

}

};提供正弦波输出

double powerMutiplier = Math.PI * (double)_powerFrequency / (double)_sampleFrequency * 2;

_stereoBuffer[i*2+1] = (short) boundToShort(

Math.sin(powerMutiplier * _powerFrequencyPos++) * 32760);

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/441593.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

android studio 库工程,Android Studio 添加已有工程方法

准备工作:修改 excluded-paths和android.iml,修改内容详见下图。(目的:过滤和优先在sourcefolder查找,若没有再到JAR包中查找)BorqsUI/LINUX/android/development/tools/idegen$ mm编译出来:[100% 3/3] Install: out/h…

【HDU - 3951】Coin Game (博弈,猜规律,对称博弈)

题干: After hh has learned how to play Nim game, he begins to try another coin game which seems much easier. The game goes like this: Two players start the game with a circle of n coins. They take coins from the circle in turn and every time…

android textview 白色,android – AutoCompleteTextview默认情况下,颜色设置为白色

我在我的Android应用程序中使用了一个AutoCompleteTextView,它正常工作。我唯一遇到的问题是,默认情况下,建议的颜色为白色,我无法看到任何建议。所以当我开始打字时,列表会以白色条目(不可见)扩展,但是当我…

【HDU - 1527】【POJ - 1067】取石子游戏 (威佐夫博弈)

题干: 有两堆石子,数量任意,可以不同。游戏开始由两个人轮流取石子。游戏规定,每次有两种不同的取法,一是可以在任意的一堆中取走任意多的石子;二是可以在两堆中同时取走相同数量的石子。最后把石子全部取…

android okgo参数,Android OkGo基本操作

或许不是很全面,也都是从网上粘的,自己记下以后使用方便点。如有不对的地方 欢迎指教。首先添加依赖:implementation com.lzy.net:okgo:3.0.4设置初始化和全局配置:public class App extends Application {Overridepublic void on…

【CodeForces - 334B】Eight Point Sets(水题模拟,有坑)

题干: Gerald is very particular to eight point sets. He thinks that any decent eight point set must consist of all pairwise intersections of three distinct integer vertical straight lines and three distinct integer horizontal straight lines, ex…

一加6怎么刷android p6,一加6秒速跟进安卓P 教你尝鲜速成开发者

今年5月份,谷歌在I/O开发者大会上发布了全新的Android P操作系统,而在Android P系统发布后的没多久,一加手机官方就公开承诺,年度旗舰一加手机6将会成为首批次升级谷歌Android P系统的机型。而现在,一加已经开始兑现此…

*【CodeForces - 1047A】Little C Loves 3 I (水题,构造,三元组问题)

题干: Little C loves number 3 very much. He loves all things about it. Now he has a positive integer nn. He wants to split nn into 33 positive integers a,b,ca,b,c, such that abcnabcn and none of the 33 integers is a multiple of 33. Help him to…

html语言音乐添加路径,HTML5简单实现添加背景音乐的几种方法

这里推荐两种方法,就是两个标签 或者常用 css布局 隐藏播放器 做网站比较实用!html5添加音乐说明:1、src毫无疑问写路径.2、使用hidden"true"表示隐藏音乐播放按钮,相反使用hidden"false"表示开启音乐播放按钮…

【CodeForces - 1047B 】Cover Points (数学,构造,思维)

题干: There are nn points on the plane, (x1,y1),(x2,y2),…,(xn,yn)(x1,y1),(x2,y2),…,(xn,yn). You need to place an isosceles triangle with two sides on the coordinate axis to cover all points (a point is covered if it lies inside the triangle …

html字段隐藏,如何刮取动态隐藏的HTML字段(UuViewState)值?

我在代码中完全实现了请求,但在FormRequest中意识到VIEWSTATE和EVENTVALIDATION是动态的,它们随每个请求而变化。我想做的是刮去它们以便在下一个请求中提供它们。在这两个字段都在HTML代码中提供,但隐藏了<the __VIEWSTAT…

【CodeForces - 1051A】Vasya And Password (构造,水题)

题干: Vasya came up with a password to register for EatForces — a string ss. The password in EatForces should be a string, consisting of lowercase and uppercase Latin letters and digits. But since EatForces takes care of the security of its u…

html5引擎笔试题,最新!HTML5经典面试题型(附答案)

HTML已更新至HTML5,那么HTML5的测试题您也应该知道,这篇文章可以作为您的参考。1.doctype有什么作用呢?如何区分其混合模式和标准模式?所有这些都意味着什么?Doctype的作用是告诉浏览器使用HTML规范的哪个版本来渲染文…

【CodeForces - 1051B】Relatively Prime Pairs (构造,思维,素数,水题)

题干&#xff1a; You are given a set of all integers from ll to rr inclusive, l<rl<r, (r−l1)≤3⋅105(r−l1)≤3⋅105and (r−l)(r−l) is always odd. You want to split these numbers into exactly r−l12r−l12 pairs in such a way that for each pair (i,…

html 弹出加载页面,magnific popup:将整个html页面加载到弹出窗口中

我想用弹出的插件在弹出窗口中加载一个完整的html页面。如果我尝试&#xff1a;Edit images$(#edit-images-btn).magnificPopup({type: ajax});它产生了这个&#xff1a;这在图形上非常符合我的要求&#xff0c;但问题是的内容直接插入到dom中&#xff0c;而不是放在保护性的if…

【CodeForces - 1042A】Benches (优先队列,思维模拟,maxmin问题)

题干&#xff1a; There are nn benches in the Berland Central park. It is known that aiai people are currently sitting on the ii-th bench. Another mm people are coming to the park and each of them is going to have a seat on some bench out of nn available. …

网页html 图片横向摆放,css实现多张图片横向居中显示的方法

先讲一下实现的步骤&#xff1a;最终效果2. 代码实现HTML部分分类小贴士CSS部分.main{width:100%;margin-top:40px;}.main .tag{margin:0 auto;width:200px;font-size:18px;border-bottom:1px solid #878787;text-align:center;margin-bottom:20px;}.main .images{margin:0 aut…

【CodeForces - 1042B】Vitamins(去重方法,二进制或stlmap,水题)

题干&#xff1a; Berland shop sells nn kinds of juices. Each juice has its price cici. Each juice includes some set of vitamins in it. There are three types of vitamins: vitamin "A", vitamin "B" and vitamin "C". Each juice ca…

android 中断处理流程,Android P的native crash处理流程

一、概述Android系统有监控程序异常退出的机制&#xff0c;这便是本文要讲述得debuggerd守护进程。当发生native crash或者主动调用debuggerd时&#xff0c;会输出进程相关的状态信息到文件或者控制台。输出的debuggerd数据 保存在文件/data/tombstones/tombstone_XX&#xff0…

数论中的无数公式 总结

斯特林公式是一条用来取n阶乘近似值的数学公式。一般来说&#xff0c;当n很大的时候&#xff0c;n阶乘的计算量十分大&#xff0c;所以斯特灵公式十分好用&#xff0c;而且&#xff0c;即使在 n很小的时候&#xff0c;斯特灵公式的取值已经十分准确。 公式为&#xff1a; 以下…