android 模拟IR输出
#define IR_HEAD0 0 #define IR_HEAD1 1 #define IR_TIME_BASE 2 #define IR_CODE_0 3 #define IR_CODE_1 4 #define IR_CODE_END 5 #define TIMER_9000US 10500 #define TIMER_4500US 5710 #define TIMER_560US 720 #define TIMER_1680US 2135
SendIR(const U16 head, const U16 keycode,const BOOL outreverse) { S8 TranselateBitPos; U8 Ir_trans_sta; int count = 0; U8 head0 = head >> 8; U8 head1 = head &0x00ff; Ir_trans_sta=IR_HEAD0; TranselateBitPos=32; printf("\n yanxi head:%d keycode:%d outreverse:%d",head,keycode,outreverse); while(TranselateBitPos>=0) { switch(Ir_trans_sta) { case IR_HEAD0: Ir_trans_sta= IR_HEAD1; for(count=TIMER_9000US;count>0;count--) SetGpioDeviceStatus(LED_WORK,!outreverse); break; case IR_HEAD1: Ir_trans_sta= IR_TIME_BASE; for(count=TIMER_4500US;count>0;count--) SetGpioDeviceStatus(LED_WORK,outreverse); break; case IR_TIME_BASE: if(TranselateBitPos>24) { if( ((head0>>(32-TranselateBitPos)) && 0x1) == 0x1 ) Ir_trans_sta= IR_CODE_1; else Ir_trans_sta= IR_CODE_0; } else if(TranselateBitPos>16) { if( ((head1>>(24-TranselateBitPos)) && 0x1) == 0x1 ) Ir_trans_sta= IR_CODE_1; else Ir_trans_sta= IR_CODE_0; } else if(TranselateBitPos>8) { if( ((keycode>>(16-TranselateBitPos)) && 0x1) == 0x1 ) Ir_trans_sta= IR_CODE_1; else Ir_trans_sta= IR_CODE_0; } else if(TranselateBitPos>0) { if( ((keycode>>(8-TranselateBitPos)) && 0x1) == 0x1 ) Ir_trans_sta= IR_CODE_0; else Ir_trans_sta= IR_CODE_1; } else { Ir_trans_sta= IR_CODE_END; } for(count=TIMER_560US;count>0;count--) SetGpioDeviceStatus(LED_WORK,!outreverse); break; case IR_CODE_0: Ir_trans_sta= IR_TIME_BASE; for(count=TIMER_560US;count>0;count--) SetGpioDeviceStatus(LED_WORK,outreverse); TranselateBitPos--; break; case IR_CODE_1: Ir_trans_sta= IR_TIME_BASE; for(count=TIMER_1680US;count>0;count--) SetGpioDeviceStatus(LED_WORK,outreverse); TranselateBitPos--; break; case IR_CODE_END: Ir_trans_sta= IR_HEAD0; SetGpioDeviceStatus(LED_WORK,outreverse); TranselateBitPos=-1;//force to exit. break; default:break; } } }
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。