PROGRAMA QUE EMITE MANDOS IRDA DE TV HYUNDAY
ESTE PROGRAMA HACE USO DE UN PROGRAMA PREVIO https://os.mbed.com/users/tony63/code/CAPTURAS_IRDA1/
QUE CAPTURA TRAMAS DE CONTROLES REMOTOS ESTAS TRAMAS SE INCRUSTAN EN ESTE PROGRAMA Y CON EL SE REALIZA UN SISTEMA AUTONOMO QUE EMITE AL AZAR CODIGOS IRDA PARA CULTURIZAR UN USUARIO QUE DE FORMA NEUROTICA CAMBIA Y CAMBIA LOS CANALES ESTO HACE PERDER LA PACIENCIA DE QUIEN LO ACOMPAÑAN.
ESTE APARATO SE INSTALA OCULTA Y LE PASA UNA VERDADERA BROMA AL OPERADOR DEL CONTROL. QUE TERMINA DESISITIENDO DE SU CONDUCTA ENFERMIZA Y TERMINA POR APAGAR EL TV O LLAMAR AL TECNICO.
main.cpp@0:1886145e8e33, 2017-09-29 (annotated)
- Committer:
- tony63
- Date:
- Fri Sep 29 14:37:25 2017 +0000
- Revision:
- 0:1886145e8e33
PROGRAMA PARA EMITIR COMANDOS IRDA, CASO DE TV HYUNDAY
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
tony63 | 0:1886145e8e33 | 1 | /******************** ENLOQUECEDOR DE CONTROL REMOTO TV SMART HYUNDAI************************************************* |
tony63 | 0:1886145e8e33 | 2 | //este programa interfiere de forma loca la operacion de un televisor |
tony63 | 0:1886145e8e33 | 3 | //emite codigos de tv con el fin de fastidiar al televidente |
tony63 | 0:1886145e8e33 | 4 | /*la emision es aleatoria para |
tony63 | 0:1886145e8e33 | 5 | 1 mute |
tony63 | 0:1886145e8e33 | 6 | 2 on/off |
tony63 | 0:1886145e8e33 | 7 | 3 vol+ |
tony63 | 0:1886145e8e33 | 8 | 4 vol- |
tony63 | 0:1886145e8e33 | 9 | 5 canal + |
tony63 | 0:1886145e8e33 | 10 | 6 canal - |
tony63 | 0:1886145e8e33 | 11 | */ |
tony63 | 0:1886145e8e33 | 12 | #include "mbed.h" |
tony63 | 0:1886145e8e33 | 13 | DigitalOut ledA (LED1); |
tony63 | 0:1886145e8e33 | 14 | DigitalOut ledR (LED2); |
tony63 | 0:1886145e8e33 | 15 | DigitalOut ledV (LED3); |
tony63 | 0:1886145e8e33 | 16 | |
tony63 | 0:1886145e8e33 | 17 | DigitalOut led(PTE31);//al transistor del led infrarrojo pin |
tony63 | 0:1886145e8e33 | 18 | int i,j; |
tony63 | 0:1886145e8e33 | 19 | int t; |
tony63 | 0:1886145e8e33 | 20 | //*********************TIEMPO PARA TELEVISOR HYUNDAI START TV**************************************** |
tony63 | 0:1886145e8e33 | 21 | int cabeceraL=9000; |
tony63 | 0:1886145e8e33 | 22 | int cabeceraH=4555; |
tony63 | 0:1886145e8e33 | 23 | int Tdescanso=500; |
tony63 | 0:1886145e8e33 | 24 | int Tlow=630; |
tony63 | 0:1886145e8e33 | 25 | int Thigh=1750; |
tony63 | 0:1886145e8e33 | 26 | int duracion; //duracion de un pulso bajo |
tony63 | 0:1886145e8e33 | 27 | int numb = 33; |
tony63 | 0:1886145e8e33 | 28 | void mute(); |
tony63 | 0:1886145e8e33 | 29 | void vol_up(); |
tony63 | 0:1886145e8e33 | 30 | void vol_dwn(); |
tony63 | 0:1886145e8e33 | 31 | void ch_up(); |
tony63 | 0:1886145e8e33 | 32 | void ch_dwn(); |
tony63 | 0:1886145e8e33 | 33 | void pwr(); |
tony63 | 0:1886145e8e33 | 34 | void repeat(); |
tony63 | 0:1886145e8e33 | 35 | int sendcode(int numb, int *code, int cabeceraL, int cabeceraH, int Tdescanso, int Tlow, int Thigh); |
tony63 | 0:1886145e8e33 | 36 | int code[65]; |
tony63 | 0:1886145e8e33 | 37 | int dato[65]; |
tony63 | 0:1886145e8e33 | 38 | int descanso(int duracion); |
tony63 | 0:1886145e8e33 | 39 | const unsigned muteHY[] = {581,556,555,582,554,556,581,556,1693,1692,1692,1693,1691,1692, |
tony63 | 0:1886145e8e33 | 40 | 555,1692,1694,554,1692,554,1692,554,556,581,554,1692,555,1693,554,1692,1692,1692}; |
tony63 | 0:1886145e8e33 | 41 | const unsigned pwrHY[]={575,548,548,575,549,549,575,548,1686,1686,1686,1687,1685,1687,549,1686, |
tony63 | 0:1886145e8e33 | 42 | 1686,1686,576,548,549,576,549,549,576,549,1687,1687,1686,1686,1687,1686}; |
tony63 | 0:1886145e8e33 | 43 | const unsigned vol_upHY[]={556,582,557,557,581,555,556,583,1693,1692,1694,1693,1694,1694,556, |
tony63 | 0:1886145e8e33 | 44 | 1693,556,1695,1695,583,1695,583,557,557,1694,558,583,1695,585,1695,1696,1696}; |
tony63 | 0:1886145e8e33 | 45 | const unsigned vol_dwnHY[]={563,564,590,563,562,588,563,563,1700,1700,1699,1700,1700,1699,589, |
tony63 | 0:1886145e8e33 | 46 | 1700,588,1700,587,1699,1699,562,588,562,1699,561,1699,561,561,1699,1699,1699}; |
tony63 | 0:1886145e8e33 | 47 | const unsigned ch_upHY[]={581,580,1694,581,580,580,581,580,1695,1696,605,1694,1695,1695,1695,1694,580, |
tony63 | 0:1886145e8e33 | 48 | 580,579,580,580,579,579,581,1695,1695,1695,1696,1696,1696,1695,1697,}; |
tony63 | 0:1886145e8e33 | 49 | const unsigned ch_dwnHY[]={608,607,1700,607,608,608,608,584,1699,1700,608,1699,1698,1698,1699,1699,1699, |
tony63 | 0:1886145e8e33 | 50 | 607,583,606,583,607,584,583,608,1699,1700,1700,1699,1699,1698,1699}; |
tony63 | 0:1886145e8e33 | 51 | |
tony63 | 0:1886145e8e33 | 52 | int main() { |
tony63 | 0:1886145e8e33 | 53 | ledA=1; |
tony63 | 0:1886145e8e33 | 54 | ledR=1; |
tony63 | 0:1886145e8e33 | 55 | ledV=1; |
tony63 | 0:1886145e8e33 | 56 | ledA=0; |
tony63 | 0:1886145e8e33 | 57 | //for(i=0;i<numb;i++){ |
tony63 | 0:1886145e8e33 | 58 | // code[i]=muteHY[i]; |
tony63 | 0:1886145e8e33 | 59 | // } |
tony63 | 0:1886145e8e33 | 60 | |
tony63 | 0:1886145e8e33 | 61 | while(1){ |
tony63 | 0:1886145e8e33 | 62 | |
tony63 | 0:1886145e8e33 | 63 | mute(); |
tony63 | 0:1886145e8e33 | 64 | wait(2); |
tony63 | 0:1886145e8e33 | 65 | mute(); |
tony63 | 0:1886145e8e33 | 66 | wait(2); |
tony63 | 0:1886145e8e33 | 67 | vol_up(); |
tony63 | 0:1886145e8e33 | 68 | wait(1); |
tony63 | 0:1886145e8e33 | 69 | vol_dwn(); |
tony63 | 0:1886145e8e33 | 70 | wait(1); |
tony63 | 0:1886145e8e33 | 71 | ch_up(); |
tony63 | 0:1886145e8e33 | 72 | wait(1); |
tony63 | 0:1886145e8e33 | 73 | ch_dwn(); |
tony63 | 0:1886145e8e33 | 74 | wait(1); |
tony63 | 0:1886145e8e33 | 75 | pwr(); |
tony63 | 0:1886145e8e33 | 76 | wait(5); |
tony63 | 0:1886145e8e33 | 77 | pwr(); |
tony63 | 0:1886145e8e33 | 78 | wait(3); |
tony63 | 0:1886145e8e33 | 79 | //sendcode(numb,code,cabeceraL, cabeceraH, Tdescanso, Tlow, Thigh); |
tony63 | 0:1886145e8e33 | 80 | //wait(5); |
tony63 | 0:1886145e8e33 | 81 | } |
tony63 | 0:1886145e8e33 | 82 | } |
tony63 | 0:1886145e8e33 | 83 | //la funcion descanso hace una modulacon, osea un pulso bajo por el tiempo indicado en duracion |
tony63 | 0:1886145e8e33 | 84 | int descanso(int duracion){ |
tony63 | 0:1886145e8e33 | 85 | Timer t; |
tony63 | 0:1886145e8e33 | 86 | t.reset(); |
tony63 | 0:1886145e8e33 | 87 | t.start(); |
tony63 | 0:1886145e8e33 | 88 | while(1) |
tony63 | 0:1886145e8e33 | 89 | { |
tony63 | 0:1886145e8e33 | 90 | led=1; |
tony63 | 0:1886145e8e33 | 91 | wait_us(8); |
tony63 | 0:1886145e8e33 | 92 | led=0; |
tony63 | 0:1886145e8e33 | 93 | led=0; |
tony63 | 0:1886145e8e33 | 94 | wait_us(9); |
tony63 | 0:1886145e8e33 | 95 | if(t.read_us() > duracion) return 0; |
tony63 | 0:1886145e8e33 | 96 | |
tony63 | 0:1886145e8e33 | 97 | } |
tony63 | 0:1886145e8e33 | 98 | } |
tony63 | 0:1886145e8e33 | 99 | |
tony63 | 0:1886145e8e33 | 100 | int sendcode(int numb, int *code, int cabeceraL, int cabeceraH, int Tdescanso, int Tlow, int Thigh) |
tony63 | 0:1886145e8e33 | 101 | { |
tony63 | 0:1886145e8e33 | 102 | led=0; |
tony63 | 0:1886145e8e33 | 103 | wait_ms(100); |
tony63 | 0:1886145e8e33 | 104 | descanso(cabeceraL); |
tony63 | 0:1886145e8e33 | 105 | wait_us(cabeceraH); |
tony63 | 0:1886145e8e33 | 106 | |
tony63 | 0:1886145e8e33 | 107 | for(i=0;i<numb;i++){ |
tony63 | 0:1886145e8e33 | 108 | if (code[i]>1000){ |
tony63 | 0:1886145e8e33 | 109 | descanso(Tdescanso); |
tony63 | 0:1886145e8e33 | 110 | wait_us(Thigh); |
tony63 | 0:1886145e8e33 | 111 | } |
tony63 | 0:1886145e8e33 | 112 | if (code[i]<1000){ |
tony63 | 0:1886145e8e33 | 113 | descanso(Tdescanso); |
tony63 | 0:1886145e8e33 | 114 | wait_us(Tlow); |
tony63 | 0:1886145e8e33 | 115 | } |
tony63 | 0:1886145e8e33 | 116 | } |
tony63 | 0:1886145e8e33 | 117 | descanso(Tdescanso); |
tony63 | 0:1886145e8e33 | 118 | return 0; |
tony63 | 0:1886145e8e33 | 119 | } |
tony63 | 0:1886145e8e33 | 120 | //*************************rutinas estrategicas de accionar controles********************* |
tony63 | 0:1886145e8e33 | 121 | void vol_up(){ |
tony63 | 0:1886145e8e33 | 122 | for(i=0;i<numb;i++){ |
tony63 | 0:1886145e8e33 | 123 | code[i]=vol_upHY[i]; |
tony63 | 0:1886145e8e33 | 124 | } |
tony63 | 0:1886145e8e33 | 125 | sendcode(numb,code,cabeceraL, cabeceraH, Tdescanso, Tlow, Thigh); |
tony63 | 0:1886145e8e33 | 126 | repeat(); |
tony63 | 0:1886145e8e33 | 127 | for(i=0;i<15;i++){ |
tony63 | 0:1886145e8e33 | 128 | for(j=0;j<2;j++){ |
tony63 | 0:1886145e8e33 | 129 | wait_ms(56); |
tony63 | 0:1886145e8e33 | 130 | repeat(); |
tony63 | 0:1886145e8e33 | 131 | } |
tony63 | 0:1886145e8e33 | 132 | } |
tony63 | 0:1886145e8e33 | 133 | } |
tony63 | 0:1886145e8e33 | 134 | //********************************** |
tony63 | 0:1886145e8e33 | 135 | void vol_dwn(){ |
tony63 | 0:1886145e8e33 | 136 | for(i=0;i<numb;i++){ |
tony63 | 0:1886145e8e33 | 137 | code[i]=vol_dwnHY[i]; |
tony63 | 0:1886145e8e33 | 138 | } |
tony63 | 0:1886145e8e33 | 139 | sendcode(numb,code,cabeceraL, cabeceraH, Tdescanso, Tlow, Thigh); |
tony63 | 0:1886145e8e33 | 140 | repeat(); |
tony63 | 0:1886145e8e33 | 141 | for(i=0;i<15;i++){ |
tony63 | 0:1886145e8e33 | 142 | for(j=0;j<2;j++){ |
tony63 | 0:1886145e8e33 | 143 | wait_ms(56); |
tony63 | 0:1886145e8e33 | 144 | repeat(); |
tony63 | 0:1886145e8e33 | 145 | } |
tony63 | 0:1886145e8e33 | 146 | } |
tony63 | 0:1886145e8e33 | 147 | } |
tony63 | 0:1886145e8e33 | 148 | //***************************************************** |
tony63 | 0:1886145e8e33 | 149 | void ch_up(){ |
tony63 | 0:1886145e8e33 | 150 | for(i=0;i<numb;i++){ |
tony63 | 0:1886145e8e33 | 151 | code[i]=ch_upHY[i]; |
tony63 | 0:1886145e8e33 | 152 | } |
tony63 | 0:1886145e8e33 | 153 | for(i=0;i<30;i++){ |
tony63 | 0:1886145e8e33 | 154 | sendcode(numb,code,cabeceraL, cabeceraH, Tdescanso, Tlow, Thigh); |
tony63 | 0:1886145e8e33 | 155 | wait(3); |
tony63 | 0:1886145e8e33 | 156 | |
tony63 | 0:1886145e8e33 | 157 | } |
tony63 | 0:1886145e8e33 | 158 | |
tony63 | 0:1886145e8e33 | 159 | } |
tony63 | 0:1886145e8e33 | 160 | //********************************************************* |
tony63 | 0:1886145e8e33 | 161 | void ch_dwn(){ |
tony63 | 0:1886145e8e33 | 162 | for(i=0;i<numb;i++){ |
tony63 | 0:1886145e8e33 | 163 | code[i]=ch_dwnHY[i]; |
tony63 | 0:1886145e8e33 | 164 | } |
tony63 | 0:1886145e8e33 | 165 | for(i=0;i<30;i++){ |
tony63 | 0:1886145e8e33 | 166 | sendcode(numb,code,cabeceraL, cabeceraH, Tdescanso, Tlow, Thigh); |
tony63 | 0:1886145e8e33 | 167 | wait(3); |
tony63 | 0:1886145e8e33 | 168 | |
tony63 | 0:1886145e8e33 | 169 | } |
tony63 | 0:1886145e8e33 | 170 | } |
tony63 | 0:1886145e8e33 | 171 | //****************************************************** |
tony63 | 0:1886145e8e33 | 172 | void mute(){ |
tony63 | 0:1886145e8e33 | 173 | for(i=0;i<numb;i++){ |
tony63 | 0:1886145e8e33 | 174 | code[i]=muteHY[i]; |
tony63 | 0:1886145e8e33 | 175 | } |
tony63 | 0:1886145e8e33 | 176 | sendcode(numb,code,cabeceraL, cabeceraH, Tdescanso, Tlow, Thigh); |
tony63 | 0:1886145e8e33 | 177 | wait(2); |
tony63 | 0:1886145e8e33 | 178 | } |
tony63 | 0:1886145e8e33 | 179 | //********************************************************** |
tony63 | 0:1886145e8e33 | 180 | void pwr(){ |
tony63 | 0:1886145e8e33 | 181 | for(i=0;i<numb;i++){ |
tony63 | 0:1886145e8e33 | 182 | code[i]=pwrHY[i]; |
tony63 | 0:1886145e8e33 | 183 | } |
tony63 | 0:1886145e8e33 | 184 | sendcode(numb,code,cabeceraL, cabeceraH, Tdescanso, Tlow, Thigh); |
tony63 | 0:1886145e8e33 | 185 | } |
tony63 | 0:1886145e8e33 | 186 | //**************************** |
tony63 | 0:1886145e8e33 | 187 | |
tony63 | 0:1886145e8e33 | 188 | void repeat(){ |
tony63 | 0:1886145e8e33 | 189 | wait_ms(42); |
tony63 | 0:1886145e8e33 | 190 | descanso(8800); |
tony63 | 0:1886145e8e33 | 191 | wait_us(2240); |
tony63 | 0:1886145e8e33 | 192 | descanso(560); |
tony63 | 0:1886145e8e33 | 193 | } |
tony63 | 0:1886145e8e33 | 194 | //************************************************ |