Andrew Hopewell
/
IR_Remote11_26_2010
main.cpp@0:709833852ff3, 2010-11-26 (annotated)
- Committer:
- AndyHope
- Date:
- Fri Nov 26 18:51:00 2010 +0000
- Revision:
- 0:709833852ff3
Test program for infrared LIRC functions
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
AndyHope | 0:709833852ff3 | 1 | #include "mbed.h" |
AndyHope | 0:709833852ff3 | 2 | #include "Infrared.h" |
AndyHope | 0:709833852ff3 | 3 | |
AndyHope | 0:709833852ff3 | 4 | Serial pc(USBTX, USBRX); // tx, rx |
AndyHope | 0:709833852ff3 | 5 | |
AndyHope | 0:709833852ff3 | 6 | DigitalOut led1 (LED1); |
AndyHope | 0:709833852ff3 | 7 | DigitalOut led2 (LED2); |
AndyHope | 0:709833852ff3 | 8 | |
AndyHope | 0:709833852ff3 | 9 | Infrared TV(p21); |
AndyHope | 0:709833852ff3 | 10 | Infrared DVR(p21); |
AndyHope | 0:709833852ff3 | 11 | |
AndyHope | 0:709833852ff3 | 12 | int main() { |
AndyHope | 0:709833852ff3 | 13 | |
AndyHope | 0:709833852ff3 | 14 | // these declared values will eventually be read off the SD micro card |
AndyHope | 0:709833852ff3 | 15 | TV.phead = 350; TV.shead = 6100; TV.pone = 350; TV.sone = 1739; // values are time in us |
AndyHope | 0:709833852ff3 | 16 | TV.pzero = 350; TV.szero = 690; TV.ptoggle = 0; TV.stoggle = 0; |
AndyHope | 0:709833852ff3 | 17 | TV.frequency = 38000; TV.ptrail = 350; TV.plead = 0; TV.foot = 0; |
AndyHope | 0:709833852ff3 | 18 | TV.gap = 46000; TV.postdata = 0; TV.toggleMask = 0; TV.data = 0; |
AndyHope | 0:709833852ff3 | 19 | TV.preData = 0; TV.command = 0; TV.dutycycle = 50; |
AndyHope | 0:709833852ff3 | 20 | TV.preDataBits = 0; TV.dataBits = 15; TV.postDataBits = 0; |
AndyHope | 0:709833852ff3 | 21 | |
AndyHope | 0:709833852ff3 | 22 | TV.inversionMask = 10; |
AndyHope | 0:709833852ff3 | 23 | |
AndyHope | 0:709833852ff3 | 24 | // commands |
AndyHope | 0:709833852ff3 | 25 | TV.on = 0x41A2; TV.chup = 0x4222; TV.chdn = 0x4122; TV.volup = 0x40A2; TV.voldn = 0x42A2; |
AndyHope | 0:709833852ff3 | 26 | TV.one = 0x4202; TV.two = 0x4102; TV.three = 0x4302; TV.four = 0x4082; TV.five = 0x4282; |
AndyHope | 0:709833852ff3 | 27 | TV.six = 0x4182; TV.seven = 0x4382; TV.eight = 0x4042; TV.nine = 0x4242; TV.zero = 0x4142; |
AndyHope | 0:709833852ff3 | 28 | TV.mute = 0x43A2; |
AndyHope | 0:709833852ff3 | 29 | |
AndyHope | 0:709833852ff3 | 30 | DVR.phead = 400; DVR.shead = 6100; DVR.pone = 400; DVR.sone = 1700; // values are time in us |
AndyHope | 0:709833852ff3 | 31 | DVR.pzero = 400; DVR.szero = 2800; DVR.ptoggle = 0; DVR.stoggle = 0; |
AndyHope | 0:709833852ff3 | 32 | DVR.frequency = 56000; DVR.ptrail = 400; DVR.plead = 0; DVR.foot = 0; |
AndyHope | 0:709833852ff3 | 33 | DVR.gap = 6200; DVR.postdata = 0; DVR.toggleMask = 0; DVR.data = 0; |
AndyHope | 0:709833852ff3 | 34 | DVR.preData = 0; DVR.command = 0; DVR.dutycycle = 50; |
AndyHope | 0:709833852ff3 | 35 | DVR.preDataBits = 0; DVR.dataBits = 16; DVR.postDataBits = 0; |
AndyHope | 0:709833852ff3 | 36 | |
AndyHope | 0:709833852ff3 | 37 | // commands |
AndyHope | 0:709833852ff3 | 38 | DVR.on = 0x0800; DVR.up = 0x6800; DVR.down = 0x7800; DVR.left = 0x7000; DVR.right = 0x6000; |
AndyHope | 0:709833852ff3 | 39 | DVR.menu = 0x2C00; DVR.enter = 0x4000; |
AndyHope | 0:709833852ff3 | 40 | |
AndyHope | 0:709833852ff3 | 41 | char deviceSel = 0; |
AndyHope | 0:709833852ff3 | 42 | |
AndyHope | 0:709833852ff3 | 43 | TV.convertTiming(); |
AndyHope | 0:709833852ff3 | 44 | TV.maskBit(); |
AndyHope | 0:709833852ff3 | 45 | DVR.convertTiming(); |
AndyHope | 0:709833852ff3 | 46 | DVR.maskBit(); |
AndyHope | 0:709833852ff3 | 47 | |
AndyHope | 0:709833852ff3 | 48 | |
AndyHope | 0:709833852ff3 | 49 | while(1){ |
AndyHope | 0:709833852ff3 | 50 | |
AndyHope | 0:709833852ff3 | 51 | |
AndyHope | 0:709833852ff3 | 52 | TV.sendCodeSharpTV(TV.on); |
AndyHope | 0:709833852ff3 | 53 | |
AndyHope | 0:709833852ff3 | 54 | led1 = !led1; |
AndyHope | 0:709833852ff3 | 55 | wait(3); |
AndyHope | 0:709833852ff3 | 56 | |
AndyHope | 0:709833852ff3 | 57 | /* |
AndyHope | 0:709833852ff3 | 58 | if(SEL){ |
AndyHope | 0:709833852ff3 | 59 | deviceSel = !deviceSel; |
AndyHope | 0:709833852ff3 | 60 | led1 = !led1; |
AndyHope | 0:709833852ff3 | 61 | led2 = !led2; |
AndyHope | 0:709833852ff3 | 62 | while(SEL); |
AndyHope | 0:709833852ff3 | 63 | wait(0.03); |
AndyHope | 0:709833852ff3 | 64 | }// if |
AndyHope | 0:709833852ff3 | 65 | |
AndyHope | 0:709833852ff3 | 66 | if(ON){ |
AndyHope | 0:709833852ff3 | 67 | if(deviceSel){ |
AndyHope | 0:709833852ff3 | 68 | DVR.sendCodeDish(DVR.on); |
AndyHope | 0:709833852ff3 | 69 | }// if |
AndyHope | 0:709833852ff3 | 70 | else{ |
AndyHope | 0:709833852ff3 | 71 | TV.sendCodeSharpTV(TV.on); |
AndyHope | 0:709833852ff3 | 72 | }// else |
AndyHope | 0:709833852ff3 | 73 | }// if |
AndyHope | 0:709833852ff3 | 74 | |
AndyHope | 0:709833852ff3 | 75 | if(OneUP){ |
AndyHope | 0:709833852ff3 | 76 | if(deviceSel){ |
AndyHope | 0:709833852ff3 | 77 | DVR.sendCodeDish(DVR.menu); |
AndyHope | 0:709833852ff3 | 78 | }// if |
AndyHope | 0:709833852ff3 | 79 | else{ |
AndyHope | 0:709833852ff3 | 80 | TV.sendCodeSharpTV(TV.chup); |
AndyHope | 0:709833852ff3 | 81 | }// else |
AndyHope | 0:709833852ff3 | 82 | }// if |
AndyHope | 0:709833852ff3 | 83 | |
AndyHope | 0:709833852ff3 | 84 | if(OneDN){ |
AndyHope | 0:709833852ff3 | 85 | if(deviceSel){ |
AndyHope | 0:709833852ff3 | 86 | DVR.sendCodeDish(DVR.enter); |
AndyHope | 0:709833852ff3 | 87 | }// if |
AndyHope | 0:709833852ff3 | 88 | else{ |
AndyHope | 0:709833852ff3 | 89 | TV.sendCodeSharpTV(TV.chdn); |
AndyHope | 0:709833852ff3 | 90 | }// else |
AndyHope | 0:709833852ff3 | 91 | } |
AndyHope | 0:709833852ff3 | 92 | |
AndyHope | 0:709833852ff3 | 93 | if(TwoUP){ |
AndyHope | 0:709833852ff3 | 94 | if(deviceSel){ |
AndyHope | 0:709833852ff3 | 95 | DVR.sendCodeDish(DVR.up); |
AndyHope | 0:709833852ff3 | 96 | }// if |
AndyHope | 0:709833852ff3 | 97 | else{ |
AndyHope | 0:709833852ff3 | 98 | TV.sendCodeSharpTV(TV.volup); |
AndyHope | 0:709833852ff3 | 99 | }// else |
AndyHope | 0:709833852ff3 | 100 | }// if |
AndyHope | 0:709833852ff3 | 101 | |
AndyHope | 0:709833852ff3 | 102 | if(TwoDN){ |
AndyHope | 0:709833852ff3 | 103 | if(deviceSel){ |
AndyHope | 0:709833852ff3 | 104 | DVR.sendCodeDish(DVR.down); |
AndyHope | 0:709833852ff3 | 105 | }// if |
AndyHope | 0:709833852ff3 | 106 | else{ |
AndyHope | 0:709833852ff3 | 107 | TV.sendCodeSharpTV(TV.voldn); |
AndyHope | 0:709833852ff3 | 108 | }// else |
AndyHope | 0:709833852ff3 | 109 | }// if |
AndyHope | 0:709833852ff3 | 110 | */ |
AndyHope | 0:709833852ff3 | 111 | }// while |
AndyHope | 0:709833852ff3 | 112 | }// main |