我有十六进制格式的IR序列,我想通过点击按钮从设备传输。我找不到任何解释通过示例实现它的文档。任何帮助将不胜感激。
修改
十六进制代码示例:E172E817(NEC格式) 这个十六进制代码是使用adafruit的IR库从arduino远程投影仪捕获的
我尝试使用以下代码传输它:
consumerIRManager.transmit(70000,new int[]{57714,59415});
当我运行它时,没有错误,但它不传输任何IR代码。
答案 0 :(得分:2)
我相信你需要的是GitHub上的AndroidInfrared项目。它具有发出NEC Ir命令的特定命令:
ConsumerIrManager manager = ConsumerIrManager.getSupportConsumerIrManager(context);
// Check whether IrEmitter is avaiable on the device.
if (!manager.hasIrEmitter()) {
Log.e("AndroidInfraredDemo", "Cannot found IR Emitter on the device");
}
// Build IR Command with predefined schemes.
IrCommand necCommand = IrCommand.NEC.buildNEC(32, 0x723F);
manager.transmit(necCommand);
答案 1 :(得分:0)
选中此
//Check for SDK version
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
//create an instance of ConsumerIrManager class
ConsumerIrManager cIr = (ConsumerIrManager) getApplicationContext().getSystemService(Context.CONSUMER_IR_SERVICE);
//Check weather device has the IR hardware component or not
boolean feature_consumer_ir = cIr.hasIrEmitter();
if (feature_consumer_ir) {
Log.i("Test",cIr.getCarrierFrequencies().toString());
Toast.makeText(this, "Yep this device has the IR Hardware Component", Toast.LENGTH_SHORT).show();
}else
{ Toast.makeText(this, "This Phone Does't have any IR Hardware Component", Toast.LENGTH_SHORT).show();
}
}
现在,如果您要发送信号,请使用
int[] pattern=new int[2];
pattern[0]=1000000; // delay time in micro seconds
pattern[1]=1000000; // delay time in micro seconds
int frequency=57437537;
//call transmit method with pattern and frequency parameters using ConsumerIrManager object
cIr.transmit(frequency, pattern);
您会看到红外设备将发送信号。要知道天气正在发送或不将您的设备放在另一台设备的摄像头前,红外发射器会闪烁
注意: 现在的问题是,您需要了解红外信号的频率,即您需要对信号进行解码。
要解码红外信号,这可能对您有帮助 Is it possible to capture/receive IR signals in an Android application?