teste de publish

Dependencies:   DS1820 HighSpeedAnalogIn devices mbed

Committer:
brunofgc
Date:
Mon Jan 29 14:22:38 2018 +0000
Revision:
20:da1b8d80ba00
Parent:
7:ae9c47f62946
Child:
21:b9315cdd9275
Versao com ir modificado e travando ao iniciar; 29/01/2018;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
brunofgc 0:1c0a769988ee 1 #include "IRPack.h"
brunofgc 0:1c0a769988ee 2 //bool dataIn[maxBytesMsg*8];
brunofgc 0:1c0a769988ee 3 uint16_t bits[maxBitsMsg*2][2];
brunofgc 5:7801f913384e 4 int indexIr=0,botao;
brunofgc 0:1c0a769988ee 5 int startBitAlto=0, startBitBaixo=0, bitBaixo[maxBitsMsg], bitAlto[maxBitsMsg], i;
brunofgc 0:1c0a769988ee 6 //unsigned char byte=0,msg[maxBytesMsg],msgBytes=0;
brunofgc 0:1c0a769988ee 7
brunofgc 0:1c0a769988ee 8 Timer IrTmr;
brunofgc 0:1c0a769988ee 9 Timer IrDetect;
brunofgc 0:1c0a769988ee 10 bool irInAntes=1;
brunofgc 0:1c0a769988ee 11 CircularBuffer bufIROut(maxBitsMsg*2*4);
brunofgc 0:1c0a769988ee 12
brunofgc 0:1c0a769988ee 13 //PwmOut IrOut(P1_18);
brunofgc 0:1c0a769988ee 14 DigitalIn IrIn(P1_24); //Não utilizado na placa
brunofgc 0:1c0a769988ee 15
brunofgc 0:1c0a769988ee 16 int round(float in){
brunofgc 0:1c0a769988ee 17 int x = floor(in);
brunofgc 0:1c0a769988ee 18 float y = in-x;
brunofgc 0:1c0a769988ee 19 if(y>=0.5){
brunofgc 0:1c0a769988ee 20 x++;
brunofgc 0:1c0a769988ee 21 }
brunofgc 0:1c0a769988ee 22 return x;
brunofgc 0:1c0a769988ee 23 }
brunofgc 0:1c0a769988ee 24
brunofgc 0:1c0a769988ee 25 uint16_t pulseDuration_us(bool high,DigitalIn pin,unsigned long int timeout){
brunofgc 20:da1b8d80ba00 26 //unsigned long int durationBefore, duration;
brunofgc 20:da1b8d80ba00 27 unsigned long int duration;
brunofgc 20:da1b8d80ba00 28 //IrTmr.reset();
brunofgc 20:da1b8d80ba00 29 //IrTmr.start();
brunofgc 20:da1b8d80ba00 30
brunofgc 20:da1b8d80ba00 31 //durationBefore = us_ticker_read();
brunofgc 20:da1b8d80ba00 32 duration=0;
brunofgc 0:1c0a769988ee 33 do{
brunofgc 20:da1b8d80ba00 34 duration++;
brunofgc 20:da1b8d80ba00 35 wait_us(1);
brunofgc 0:1c0a769988ee 36 }while((duration < timeout) && (pin==high));
brunofgc 0:1c0a769988ee 37
brunofgc 0:1c0a769988ee 38
brunofgc 20:da1b8d80ba00 39 //IrTmr.stop();
brunofgc 0:1c0a769988ee 40 if(duration < timeout){
brunofgc 0:1c0a769988ee 41 return duration;
brunofgc 0:1c0a769988ee 42 }
brunofgc 0:1c0a769988ee 43 else{
brunofgc 0:1c0a769988ee 44 return 65535;
brunofgc 0:1c0a769988ee 45 }
brunofgc 0:1c0a769988ee 46 }
brunofgc 0:1c0a769988ee 47
brunofgc 0:1c0a769988ee 48
brunofgc 0:1c0a769988ee 49
brunofgc 6:d4ebbaaba295 50 void enviaComandoIR(uint8_t freq,uint8_t port){
brunofgc 0:1c0a769988ee 51 float sd1Duty = SD1.read();
brunofgc 0:1c0a769988ee 52 float sd2Duty = SD2.read();
brunofgc 0:1c0a769988ee 53 float sd3Duty = SD3.read();
brunofgc 0:1c0a769988ee 54 float sd4Duty = SD4.read();
brunofgc 0:1c0a769988ee 55 float sd5Duty = SD5.read();
brunofgc 5:7801f913384e 56 float sd6Duty = SD6.read();
brunofgc 20:da1b8d80ba00 57 unsigned long int duration;
brunofgc 5:7801f913384e 58 float frequencia = freq*1000.0;
brunofgc 6:d4ebbaaba295 59 float periodo = 1000000.0/frequencia;
brunofgc 20:da1b8d80ba00 60
brunofgc 6:d4ebbaaba295 61 PwmOut *SD;
brunofgc 0:1c0a769988ee 62 switch(port){
brunofgc 0:1c0a769988ee 63 case 0:
brunofgc 0:1c0a769988ee 64 SD = &SD1;
brunofgc 0:1c0a769988ee 65 break;
brunofgc 0:1c0a769988ee 66 case 1:
brunofgc 0:1c0a769988ee 67 SD = &SD2;
brunofgc 0:1c0a769988ee 68 break;
brunofgc 0:1c0a769988ee 69 case 2:
brunofgc 0:1c0a769988ee 70 SD = &SD3;
brunofgc 0:1c0a769988ee 71 break;
brunofgc 0:1c0a769988ee 72 case 3:
brunofgc 0:1c0a769988ee 73 SD = &SD4;
brunofgc 0:1c0a769988ee 74 break;
brunofgc 0:1c0a769988ee 75 case 4:
brunofgc 0:1c0a769988ee 76 SD = &SD5;
brunofgc 0:1c0a769988ee 77 break;
brunofgc 0:1c0a769988ee 78 case 5:
brunofgc 0:1c0a769988ee 79 SD = &SD6;
brunofgc 0:1c0a769988ee 80 break;
brunofgc 0:1c0a769988ee 81 }
brunofgc 0:1c0a769988ee 82
brunofgc 0:1c0a769988ee 83 SD1.write(0.0f);
brunofgc 0:1c0a769988ee 84 SD2.write(0.0f);
brunofgc 0:1c0a769988ee 85 SD3.write(0.0f);
brunofgc 0:1c0a769988ee 86 SD4.write(0.0f);
brunofgc 0:1c0a769988ee 87 SD5.write(0.0f);
brunofgc 0:1c0a769988ee 88 SD6.write(0.0f);
brunofgc 0:1c0a769988ee 89
brunofgc 6:d4ebbaaba295 90 //pc.printf("Enviando o pacote IR na porta %lu com periodo %f e frequencia %f.\r\n",port,periodo,frequencia);
brunofgc 5:7801f913384e 91
brunofgc 5:7801f913384e 92 //SD->period(1.0/(freq*1000.0));
brunofgc 6:d4ebbaaba295 93 SD->period_us(periodo);
brunofgc 5:7801f913384e 94
brunofgc 5:7801f913384e 95 pc.printf("Iniciando o envio IR.\r\n");
brunofgc 5:7801f913384e 96
brunofgc 6:d4ebbaaba295 97 /*SD->write(0.5);
brunofgc 0:1c0a769988ee 98 if(startBitAlto!=65535){wait_us(startBitAlto);}
brunofgc 0:1c0a769988ee 99 SD->write(0.0);
brunofgc 6:d4ebbaaba295 100 if(startBitBaixo!=65535){wait_us(startBitBaixo);}*/
brunofgc 20:da1b8d80ba00 101
brunofgc 20:da1b8d80ba00 102 /*for(i=0;i<indexIr;i++){
brunofgc 20:da1b8d80ba00 103 SD->write(0.5);
brunofgc 20:da1b8d80ba00 104 if(bitAlto[i]!=65535){
brunofgc 20:da1b8d80ba00 105 duration = us_ticker_read();
brunofgc 20:da1b8d80ba00 106 while((us_ticker_read()-duration)<bits[i][0]);
brunofgc 20:da1b8d80ba00 107 }
brunofgc 20:da1b8d80ba00 108 SD->write(0.0);
brunofgc 20:da1b8d80ba00 109 if(bitBaixo[i]!=65535){
brunofgc 20:da1b8d80ba00 110 duration = us_ticker_read();
brunofgc 20:da1b8d80ba00 111 while((us_ticker_read()-duration)<bits[i][1]);
brunofgc 20:da1b8d80ba00 112 }
brunofgc 20:da1b8d80ba00 113 }*/
brunofgc 20:da1b8d80ba00 114
brunofgc 5:7801f913384e 115 for(i=0;i<indexIr;i++){
brunofgc 0:1c0a769988ee 116 SD->write(0.5);
brunofgc 20:da1b8d80ba00 117 if(bitAlto[i]!=65535){
brunofgc 20:da1b8d80ba00 118 wait_us(bits[i][0]);
brunofgc 20:da1b8d80ba00 119 }
brunofgc 0:1c0a769988ee 120 SD->write(0.0);
brunofgc 20:da1b8d80ba00 121 if(bitBaixo[i]!=65535){
brunofgc 20:da1b8d80ba00 122 wait_us(bits[i][1]);
brunofgc 20:da1b8d80ba00 123 }
brunofgc 20:da1b8d80ba00 124 }
brunofgc 6:d4ebbaaba295 125
brunofgc 5:7801f913384e 126 pc.printf("Finalizado o envio IR.\r\n");
brunofgc 0:1c0a769988ee 127 SD1.period_us(pwmPeriod);
brunofgc 0:1c0a769988ee 128 SD1.write(sd1Duty);
brunofgc 0:1c0a769988ee 129 SD2.write(sd2Duty);
brunofgc 0:1c0a769988ee 130 SD3.write(sd3Duty);
brunofgc 0:1c0a769988ee 131 SD4.write(sd4Duty);
brunofgc 0:1c0a769988ee 132 SD5.write(sd5Duty);
brunofgc 6:d4ebbaaba295 133 SD6.write(sd6Duty);
brunofgc 6:d4ebbaaba295 134
brunofgc 0:1c0a769988ee 135 }
brunofgc 0:1c0a769988ee 136
brunofgc 0:1c0a769988ee 137
brunofgc 5:7801f913384e 138 /*static const long hextable[] = {
brunofgc 0:1c0a769988ee 139 [0 ... 255] = -1, // bit aligned access into this table is considerably
brunofgc 0:1c0a769988ee 140 ['0'] = 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, // faster for most modern processors,
brunofgc 0:1c0a769988ee 141 ['A'] = 10, 11, 12, 13, 14, 15, // for the space conscious, reduce to
brunofgc 0:1c0a769988ee 142 ['a'] = 10, 11, 12, 13, 14, 15 // signed char.
brunofgc 5:7801f913384e 143 };*/
brunofgc 5:7801f913384e 144
brunofgc 5:7801f913384e 145 uint8_t hextable(char c){
brunofgc 5:7801f913384e 146 uint8_t ret=0;
brunofgc 5:7801f913384e 147 if(c>='a'){
brunofgc 5:7801f913384e 148 ret = c-87;
brunofgc 5:7801f913384e 149 }else if(c>='A'){
brunofgc 5:7801f913384e 150 ret = c-55;
brunofgc 5:7801f913384e 151 }else{
brunofgc 5:7801f913384e 152 ret = c-48;
brunofgc 5:7801f913384e 153 }
brunofgc 5:7801f913384e 154 return ret;
brunofgc 5:7801f913384e 155 }
brunofgc 0:1c0a769988ee 156
brunofgc 0:1c0a769988ee 157 uint16_t hexdec(char *hex,uint16_t tam) {
brunofgc 0:1c0a769988ee 158 uint16_t ret = 0;
brunofgc 7:ae9c47f62946 159 //uint8_t auxHex=0;
brunofgc 5:7801f913384e 160 uint16_t i;
brunofgc 0:1c0a769988ee 161 for(i=0;i<tam;i++){
brunofgc 5:7801f913384e 162 //ret += hextable[hex[i]] << (i*4);
brunofgc 5:7801f913384e 163 ret += hextable(hex[i]) << (i*4);
brunofgc 5:7801f913384e 164 //pc.printf("%c",hex[i]);
brunofgc 5:7801f913384e 165 }
brunofgc 5:7801f913384e 166 //pc.printf("\r\n");
brunofgc 0:1c0a769988ee 167 return ret;
brunofgc 0:1c0a769988ee 168 }
brunofgc 0:1c0a769988ee 169
brunofgc 0:1c0a769988ee 170
brunofgc 5:7801f913384e 171 void deserializaPacoteIR(char *strIr){
brunofgc 5:7801f913384e 172 uint16_t len;
brunofgc 0:1c0a769988ee 173 uint16_t i;
brunofgc 5:7801f913384e 174
brunofgc 5:7801f913384e 175 len = strlen(strIr);
brunofgc 0:1c0a769988ee 176 len = len/4; //Separando de quatro em quatro pra formar um uint16_t
brunofgc 7:ae9c47f62946 177
brunofgc 0:1c0a769988ee 178 for(i=0;i<len;i++){
brunofgc 5:7801f913384e 179 bits[i/2][(i%2)]=hexdec(strIr,4);
brunofgc 5:7801f913384e 180 strIr = strIr+4;
brunofgc 5:7801f913384e 181 }
brunofgc 7:ae9c47f62946 182 indexIr = len/2;
brunofgc 0:1c0a769988ee 183 }
brunofgc 0:1c0a769988ee 184
brunofgc 0:1c0a769988ee 185 void serializaPacoteIR(uint8_t connectionID){
brunofgc 2:55b7b466e742 186 char aux[50];
brunofgc 0:1c0a769988ee 187 uint32_t length;
brunofgc 0:1c0a769988ee 188 char *ptr;
brunofgc 0:1c0a769988ee 189 uint16_t i;
brunofgc 0:1c0a769988ee 190 union{
brunofgc 0:1c0a769988ee 191 char c[2];
brunofgc 0:1c0a769988ee 192 uint16_t v;
brunofgc 0:1c0a769988ee 193 }u;
brunofgc 2:55b7b466e742 194 sdCardBuf.del();
brunofgc 5:7801f913384e 195 for(i=0;i<indexIr;i++){
brunofgc 0:1c0a769988ee 196 u.v = bits[i][0];
brunofgc 0:1c0a769988ee 197 sprintf(aux,"%01X%01X%01X%01X"
brunofgc 0:1c0a769988ee 198 ,u.c[0]&0xF
brunofgc 0:1c0a769988ee 199 ,u.c[0]>>4
brunofgc 0:1c0a769988ee 200 ,u.c[1]&0xF
brunofgc 0:1c0a769988ee 201 ,u.c[1]>>4
brunofgc 0:1c0a769988ee 202 );
brunofgc 0:1c0a769988ee 203 sdCardBuf.fill(aux,strlen(aux));
brunofgc 0:1c0a769988ee 204
brunofgc 0:1c0a769988ee 205 u.v = bits[i][1];
brunofgc 0:1c0a769988ee 206 sprintf(aux,"%01X%01X%01X%01X"
brunofgc 0:1c0a769988ee 207 ,u.c[0]&0xF
brunofgc 0:1c0a769988ee 208 ,u.c[0]>>4
brunofgc 0:1c0a769988ee 209 ,u.c[1]&0xF
brunofgc 0:1c0a769988ee 210 ,u.c[1]>>4
brunofgc 0:1c0a769988ee 211 );
brunofgc 0:1c0a769988ee 212 sdCardBuf.fill(aux,strlen(aux));
brunofgc 0:1c0a769988ee 213 }
brunofgc 0:1c0a769988ee 214 length = sdCardBuf.getLength();
brunofgc 0:1c0a769988ee 215 ptr = sdCardBuf.get();
brunofgc 0:1c0a769988ee 216 modemCom::cipSend(connID,ptr,length);
brunofgc 2:55b7b466e742 217 //pc.printf("Conteudo de sdCardBuf <%s>.\r\n",ptr);
brunofgc 0:1c0a769988ee 218 }
brunofgc 0:1c0a769988ee 219
brunofgc 0:1c0a769988ee 220 bool detectaIRIn(){
brunofgc 0:1c0a769988ee 221 bool detectado=0;
brunofgc 0:1c0a769988ee 222 if((irInAntes!=IrIn) && (!IrIn)){
brunofgc 0:1c0a769988ee 223 bits[0][0] = pulseDuration_us(0,IrIn,10000);
brunofgc 0:1c0a769988ee 224 bits[0][1] = pulseDuration_us(1,IrIn,10000);
brunofgc 20:da1b8d80ba00 225 if((bits[0][0]>100)&&(bits[0][1]>100)){
brunofgc 5:7801f913384e 226 indexIr = 1;
brunofgc 0:1c0a769988ee 227 do{
brunofgc 5:7801f913384e 228 bits[indexIr][0] = pulseDuration_us(0,IrIn,10000);
brunofgc 5:7801f913384e 229 bits[indexIr][1] = pulseDuration_us(1,IrIn,10000);
brunofgc 5:7801f913384e 230 indexIr++;
brunofgc 0:1c0a769988ee 231
brunofgc 5:7801f913384e 232 }while((bits[indexIr-1][0]!=65535)&&(bits[indexIr-1][1]!=65535));
brunofgc 0:1c0a769988ee 233 detectado=1;
brunofgc 0:1c0a769988ee 234 }
brunofgc 0:1c0a769988ee 235 }
brunofgc 0:1c0a769988ee 236 irInAntes = IrIn;
brunofgc 7:ae9c47f62946 237 ledUsoGeral = !IrIn;
brunofgc 0:1c0a769988ee 238 return detectado;
brunofgc 0:1c0a769988ee 239 }
brunofgc 0:1c0a769988ee 240
brunofgc 0:1c0a769988ee 241 void pesquisaIRIn(){
brunofgc 0:1c0a769988ee 242 if((irInAntes!=IrIn) && (!IrIn)){
brunofgc 0:1c0a769988ee 243 startBitAlto = pulseDuration_us(0,IrIn,10000);
brunofgc 0:1c0a769988ee 244 startBitBaixo = pulseDuration_us(1,IrIn,10000);
brunofgc 0:1c0a769988ee 245 if((startBitAlto>1000)&&(startBitBaixo>1000)){
brunofgc 5:7801f913384e 246 indexIr = 0;
brunofgc 0:1c0a769988ee 247 do{
brunofgc 5:7801f913384e 248 bitAlto[indexIr] = pulseDuration_us(0,IrIn,10000);
brunofgc 5:7801f913384e 249 bitBaixo[indexIr] = pulseDuration_us(1,IrIn,10000);
brunofgc 5:7801f913384e 250 //dataIn[indexIr] = (bitBaixo[indexIr] > 1000);
brunofgc 5:7801f913384e 251 indexIr++;
brunofgc 0:1c0a769988ee 252
brunofgc 5:7801f913384e 253 }while((bitAlto[indexIr-1]!=(-1))&&(bitBaixo[indexIr-1]!=(-1)));
brunofgc 0:1c0a769988ee 254
brunofgc 5:7801f913384e 255 pc.printf("Capturado um quadro com %lu bits. sbH %ld, sbL %ld <",indexIr,startBitAlto, startBitBaixo);
brunofgc 5:7801f913384e 256 for(i=0;i<(indexIr);i++){
brunofgc 0:1c0a769988ee 257 pc.printf("[H%ld L%ld] ",bitAlto[i],bitBaixo[i]);
brunofgc 0:1c0a769988ee 258 }
brunofgc 0:1c0a769988ee 259 pc.printf(">.\n\n");
brunofgc 0:1c0a769988ee 260
brunofgc 5:7801f913384e 261 /*pc.printf("%lu bits 0b",indexIr);
brunofgc 5:7801f913384e 262 for(i=0;i<indexIr;i++){
brunofgc 0:1c0a769988ee 263 pc.printf("%u",dataIn[i]);
brunofgc 0:1c0a769988ee 264 }
brunofgc 0:1c0a769988ee 265 pc.printf("\n\n");*/
brunofgc 0:1c0a769988ee 266
brunofgc 0:1c0a769988ee 267 /*//Montando os bytes;
brunofgc 0:1c0a769988ee 268 byte=0;
brunofgc 0:1c0a769988ee 269 msgBytes=0;
brunofgc 5:7801f913384e 270 for(i=0;i<=indexIr;i++){
brunofgc 0:1c0a769988ee 271 if((i!=0)&&((i%8) == 0)){
brunofgc 0:1c0a769988ee 272 msg[msgBytes]=byte;
brunofgc 0:1c0a769988ee 273 msgBytes++;
brunofgc 0:1c0a769988ee 274 byte=0;
brunofgc 0:1c0a769988ee 275 }
brunofgc 0:1c0a769988ee 276 byte+= dataIn[i]<<(i%8);
brunofgc 0:1c0a769988ee 277
brunofgc 0:1c0a769988ee 278 }
brunofgc 0:1c0a769988ee 279
brunofgc 0:1c0a769988ee 280 //Exibindo pacote
brunofgc 0:1c0a769988ee 281 pc.printf("Resultado 0x");
brunofgc 0:1c0a769988ee 282 for(i=0;i<msgBytes;i++){
brunofgc 0:1c0a769988ee 283 pc.printf("%02X",msg[i]);
brunofgc 0:1c0a769988ee 284 }
brunofgc 0:1c0a769988ee 285 pc.printf("\n\n");
brunofgc 0:1c0a769988ee 286
brunofgc 0:1c0a769988ee 287 //Atuando nos leds
brunofgc 0:1c0a769988ee 288 botao=0;
brunofgc 0:1c0a769988ee 289 for(i=0;i<msgBytes;i++){
brunofgc 0:1c0a769988ee 290 botao+=msg[i]<<(8*i);
brunofgc 0:1c0a769988ee 291
brunofgc 0:1c0a769988ee 292 }
brunofgc 0:1c0a769988ee 293 //pc.printf("Botao pressionado %X\n",botao);
brunofgc 0:1c0a769988ee 294 switch(botao){
brunofgc 0:1c0a769988ee 295 case 0xfb040707: //1
brunofgc 0:1c0a769988ee 296 led2=1;
brunofgc 0:1c0a769988ee 297 break;
brunofgc 0:1c0a769988ee 298 case 0xfa050707: //2
brunofgc 0:1c0a769988ee 299 led3=1;
brunofgc 0:1c0a769988ee 300 break;
brunofgc 0:1c0a769988ee 301 case 0xf9060707: //3
brunofgc 0:1c0a769988ee 302 led4=1;
brunofgc 0:1c0a769988ee 303 break;
brunofgc 0:1c0a769988ee 304 case 0xf7080707: //4
brunofgc 0:1c0a769988ee 305 led2=0;
brunofgc 0:1c0a769988ee 306 break;
brunofgc 0:1c0a769988ee 307 case 0xf6090707: //5
brunofgc 0:1c0a769988ee 308 led3=0;
brunofgc 0:1c0a769988ee 309 break;
brunofgc 0:1c0a769988ee 310 case 0xf50a0707: //6
brunofgc 0:1c0a769988ee 311 led4=0;
brunofgc 0:1c0a769988ee 312 break;
brunofgc 0:1c0a769988ee 313 }*/
brunofgc 0:1c0a769988ee 314 //descritorPacoteIR(int startBitAlto, int startBitBaixo, int *bitAlto, int *bitBaixo, int numBits)
brunofgc 5:7801f913384e 315 //descritorPacoteIR(startBitAlto,startBitBaixo,bitAlto,bitBaixo,indexIr);
brunofgc 0:1c0a769988ee 316 }
brunofgc 0:1c0a769988ee 317 }
brunofgc 0:1c0a769988ee 318 irInAntes = IrIn;
brunofgc 7:ae9c47f62946 319 ledUsoGeral = !IrIn;
brunofgc 0:1c0a769988ee 320 }
brunofgc 0:1c0a769988ee 321
brunofgc 0:1c0a769988ee 322 /*
brunofgc 0:1c0a769988ee 323
brunofgc 0:1c0a769988ee 324 float razaoBit(int iH, int iL){
brunofgc 0:1c0a769988ee 325 float H=(float)iH,L=(float)iL;
brunofgc 0:1c0a769988ee 326 float razao = L/H;
brunofgc 0:1c0a769988ee 327
brunofgc 0:1c0a769988ee 328 if(razao>=1){
brunofgc 0:1c0a769988ee 329 return (float) round(razao);
brunofgc 0:1c0a769988ee 330 }else if(razao>=0.5){
brunofgc 0:1c0a769988ee 331 return 0.5;
brunofgc 0:1c0a769988ee 332 }else if(razao>=0.25){
brunofgc 0:1c0a769988ee 333 return 0.25;
brunofgc 0:1c0a769988ee 334 }else if(razao>=0.125){
brunofgc 0:1c0a769988ee 335 return 0.125;
brunofgc 0:1c0a769988ee 336 }else{
brunofgc 0:1c0a769988ee 337 return -1;
brunofgc 0:1c0a769988ee 338 }
brunofgc 0:1c0a769988ee 339
brunofgc 0:1c0a769988ee 340 }
brunofgc 0:1c0a769988ee 341
brunofgc 0:1c0a769988ee 342 void descritorPacoteIR(int startBitAlto, int startBitBaixo, int *bitAlto, int *bitBaixo, int numBits){
brunofgc 0:1c0a769988ee 343 unsigned int razao_maiorQue4=0;
brunofgc 0:1c0a769988ee 344 unsigned int razao_4=0;
brunofgc 0:1c0a769988ee 345 unsigned int razao_3=0;
brunofgc 0:1c0a769988ee 346 unsigned int razao_2=0;
brunofgc 0:1c0a769988ee 347 unsigned int razao_1=0;
brunofgc 0:1c0a769988ee 348 unsigned int razao_0_5=0;
brunofgc 0:1c0a769988ee 349 unsigned int razao_0_25=0;
brunofgc 0:1c0a769988ee 350 unsigned int razao_0_125=0;
brunofgc 0:1c0a769988ee 351 unsigned int razao_menorQue_0_125=0;
brunofgc 0:1c0a769988ee 352
brunofgc 0:1c0a769988ee 353 //Indice 0 ALto, 1 Baixo;
brunofgc 0:1c0a769988ee 354 unsigned long int bitRazao_maiorQue4[2]= {0,0};
brunofgc 0:1c0a769988ee 355 unsigned long int bitRazao_4[2]= {0,0};
brunofgc 0:1c0a769988ee 356 unsigned long int bitRazao_3[2]= {0,0};
brunofgc 0:1c0a769988ee 357 unsigned long int bitRazao_2[2]= {0,0};
brunofgc 0:1c0a769988ee 358 unsigned long int bitRazao_1[2]= {0,0};
brunofgc 0:1c0a769988ee 359 unsigned long int bitRazao_0_5[2]= {0,0};
brunofgc 0:1c0a769988ee 360 unsigned long int bitRazao_0_25[2]= {0,0};
brunofgc 0:1c0a769988ee 361 unsigned long int bitRazao_0_125[2]= {0,0};
brunofgc 0:1c0a769988ee 362 unsigned long int bitRazao_menorQue_0_125[2]= {0,0};
brunofgc 0:1c0a769988ee 363
brunofgc 0:1c0a769988ee 364 unsigned long int indiceMaiorNEventos[2] = {0,0};
brunofgc 0:1c0a769988ee 365 unsigned long int indiceSegundoMaiorNEventos[2] = {0,0};
brunofgc 0:1c0a769988ee 366
brunofgc 0:1c0a769988ee 367
brunofgc 0:1c0a769988ee 368
brunofgc 0:1c0a769988ee 369 unsigned int bitAlto_H=0;
brunofgc 0:1c0a769988ee 370 unsigned int bitAlto_L=0;
brunofgc 0:1c0a769988ee 371 unsigned int bitBaixo_H=0;
brunofgc 0:1c0a769988ee 372 unsigned int bitBaixo_L=0;
brunofgc 0:1c0a769988ee 373
brunofgc 0:1c0a769988ee 374 unsigned int stopBitAlto = bitAlto[numBits-1];
brunofgc 0:1c0a769988ee 375
brunofgc 0:1c0a769988ee 376 int i;
brunofgc 0:1c0a769988ee 377
brunofgc 0:1c0a769988ee 378 //printf("startBitAlto %d, startBitBaixo %d, stopBitAlto %d, stopBitBaixo %d numBits %d\n",startBitAlto,startBitBaixo,bitAlto[numBits-1],bitBaixo[numBits-1],numBits);
brunofgc 0:1c0a769988ee 379
brunofgc 0:1c0a769988ee 380 //Despresando o stopBit pois esse já sabemos como faz
brunofgc 0:1c0a769988ee 381 for(i=0;i<numBits-1;i++){
brunofgc 0:1c0a769988ee 382 //printf("Razao entre [L %05d e H %05d]=%1.2f\n",bitBaixo[i],bitAlto[i],razaoBit(bitAlto[i],bitBaixo[i]));
brunofgc 0:1c0a769988ee 383 //Detecção de padroes
brunofgc 0:1c0a769988ee 384 if(razaoBit(bitAlto[i],bitBaixo[i])>=4){
brunofgc 0:1c0a769988ee 385 razao_maiorQue4++;
brunofgc 0:1c0a769988ee 386 bitRazao_maiorQue4[0]+= bitAlto[i];
brunofgc 0:1c0a769988ee 387 bitRazao_maiorQue4[1]+=bitBaixo[i];
brunofgc 0:1c0a769988ee 388
brunofgc 0:1c0a769988ee 389 }else if(razaoBit(bitAlto[i],bitBaixo[i])==4){
brunofgc 0:1c0a769988ee 390 razao_4++;
brunofgc 0:1c0a769988ee 391 bitRazao_4[0]+= bitAlto[i];
brunofgc 0:1c0a769988ee 392 bitRazao_4[1]+=bitBaixo[i];
brunofgc 0:1c0a769988ee 393 }else if(razaoBit(bitAlto[i],bitBaixo[i])==3){
brunofgc 0:1c0a769988ee 394 razao_3++;
brunofgc 0:1c0a769988ee 395 bitRazao_3[0]+= bitAlto[i];
brunofgc 0:1c0a769988ee 396 bitRazao_3[1]+=bitBaixo[i];
brunofgc 0:1c0a769988ee 397 }else if(razaoBit(bitAlto[i],bitBaixo[i])==2){
brunofgc 0:1c0a769988ee 398 razao_2++;
brunofgc 0:1c0a769988ee 399 bitRazao_2[0]+= bitAlto[i];
brunofgc 0:1c0a769988ee 400 bitRazao_2[1]+=bitBaixo[i];
brunofgc 0:1c0a769988ee 401 }else if(razaoBit(bitAlto[i],bitBaixo[i])==1){
brunofgc 0:1c0a769988ee 402 razao_1++;
brunofgc 0:1c0a769988ee 403 bitRazao_1[0]+= bitAlto[i];
brunofgc 0:1c0a769988ee 404 bitRazao_1[1]+=bitBaixo[i];
brunofgc 0:1c0a769988ee 405 }else if(razaoBit(bitAlto[i],bitBaixo[i])==0.5){
brunofgc 0:1c0a769988ee 406 razao_0_5++;
brunofgc 0:1c0a769988ee 407 bitRazao_0_5[0]+= bitAlto[i];
brunofgc 0:1c0a769988ee 408 bitRazao_0_5[1]+=bitBaixo[i];
brunofgc 0:1c0a769988ee 409 }else if(razaoBit(bitAlto[i],bitBaixo[i])==0.25){
brunofgc 0:1c0a769988ee 410 razao_0_25++;
brunofgc 0:1c0a769988ee 411 bitRazao_0_25[0]+= bitAlto[i];
brunofgc 0:1c0a769988ee 412 bitRazao_0_25[1]+=bitBaixo[i];
brunofgc 0:1c0a769988ee 413 }else if(razaoBit(bitAlto[i],bitBaixo[i])==0.125){
brunofgc 0:1c0a769988ee 414 razao_0_125++;
brunofgc 0:1c0a769988ee 415 bitRazao_0_125[0]+= bitAlto[i];
brunofgc 0:1c0a769988ee 416 bitRazao_0_125[1]+=bitBaixo[i];
brunofgc 0:1c0a769988ee 417 }else {
brunofgc 0:1c0a769988ee 418 razao_menorQue_0_125++;
brunofgc 0:1c0a769988ee 419 bitRazao_menorQue_0_125[0]+= bitAlto[i];
brunofgc 0:1c0a769988ee 420 bitRazao_menorQue_0_125[1]+=bitBaixo[i];
brunofgc 0:1c0a769988ee 421 }
brunofgc 0:1c0a769988ee 422
brunofgc 0:1c0a769988ee 423 }
brunofgc 0:1c0a769988ee 424 printf("Razoes <0.125 = %d\n 0.125 = %d\n 0.25 = %d\n 0.5 = %d\n 1 = %d\n 2 = %d\n 3 = %d\n 4 = %d\n maior que 4 = %d\n"
brunofgc 0:1c0a769988ee 425 ,razao_menorQue_0_125
brunofgc 0:1c0a769988ee 426 ,razao_0_125
brunofgc 0:1c0a769988ee 427 ,razao_0_25
brunofgc 0:1c0a769988ee 428 ,razao_0_5
brunofgc 0:1c0a769988ee 429 ,razao_1
brunofgc 0:1c0a769988ee 430 ,razao_2
brunofgc 0:1c0a769988ee 431 ,razao_3
brunofgc 0:1c0a769988ee 432 ,razao_4
brunofgc 0:1c0a769988ee 433 ,razao_maiorQue4
brunofgc 0:1c0a769988ee 434 );
brunofgc 0:1c0a769988ee 435
brunofgc 0:1c0a769988ee 436 //Buscando os dois maiores em numero de eventos por Indice;
brunofgc 0:1c0a769988ee 437 //Buscando o primeiro
brunofgc 0:1c0a769988ee 438 for(i=0;i<9;i++){
brunofgc 0:1c0a769988ee 439 //Buscando nos indices maior numero eventos
brunofgc 0:1c0a769988ee 440 switch(i){
brunofgc 0:1c0a769988ee 441 case 0:
brunofgc 0:1c0a769988ee 442 if(razao_maiorQue4>indiceMaiorNEventos[0]){
brunofgc 0:1c0a769988ee 443 indiceMaiorNEventos[0] = razao_maiorQue4;
brunofgc 0:1c0a769988ee 444 indiceMaiorNEventos[1] = i;
brunofgc 0:1c0a769988ee 445 }
brunofgc 0:1c0a769988ee 446 break;
brunofgc 0:1c0a769988ee 447
brunofgc 0:1c0a769988ee 448 case 1:
brunofgc 0:1c0a769988ee 449 if(razao_4>indiceMaiorNEventos[0]){
brunofgc 0:1c0a769988ee 450 indiceMaiorNEventos[0] = razao_4;
brunofgc 0:1c0a769988ee 451 indiceMaiorNEventos[1] = i;
brunofgc 0:1c0a769988ee 452 }
brunofgc 0:1c0a769988ee 453 break;
brunofgc 0:1c0a769988ee 454 case 2:
brunofgc 0:1c0a769988ee 455 if(razao_3>indiceMaiorNEventos[0]){
brunofgc 0:1c0a769988ee 456 indiceMaiorNEventos[0] = razao_3;
brunofgc 0:1c0a769988ee 457 indiceMaiorNEventos[1] = i;
brunofgc 0:1c0a769988ee 458 }
brunofgc 0:1c0a769988ee 459 break;
brunofgc 0:1c0a769988ee 460 case 3:
brunofgc 0:1c0a769988ee 461 if(razao_2>indiceMaiorNEventos[0]){
brunofgc 0:1c0a769988ee 462 indiceMaiorNEventos[0] = razao_2;
brunofgc 0:1c0a769988ee 463 indiceMaiorNEventos[1] = i;
brunofgc 0:1c0a769988ee 464 }
brunofgc 0:1c0a769988ee 465 break;
brunofgc 0:1c0a769988ee 466 case 4:
brunofgc 0:1c0a769988ee 467 if(razao_1>indiceMaiorNEventos[0]){
brunofgc 0:1c0a769988ee 468 indiceMaiorNEventos[0] = razao_1;
brunofgc 0:1c0a769988ee 469 indiceMaiorNEventos[1] = i;
brunofgc 0:1c0a769988ee 470 }
brunofgc 0:1c0a769988ee 471 break;
brunofgc 0:1c0a769988ee 472 case 5:
brunofgc 0:1c0a769988ee 473 if(razao_0_5>indiceMaiorNEventos[0]){
brunofgc 0:1c0a769988ee 474 indiceMaiorNEventos[0] = razao_0_5;
brunofgc 0:1c0a769988ee 475 indiceMaiorNEventos[1] = i;
brunofgc 0:1c0a769988ee 476 }
brunofgc 0:1c0a769988ee 477 break;
brunofgc 0:1c0a769988ee 478 case 6:
brunofgc 0:1c0a769988ee 479 if(razao_0_25>indiceMaiorNEventos[0]){
brunofgc 0:1c0a769988ee 480 indiceMaiorNEventos[0] = razao_0_25;
brunofgc 0:1c0a769988ee 481 indiceMaiorNEventos[1] = i;
brunofgc 0:1c0a769988ee 482 }
brunofgc 0:1c0a769988ee 483 break;
brunofgc 0:1c0a769988ee 484 case 7:
brunofgc 0:1c0a769988ee 485 if(razao_0_125>indiceMaiorNEventos[0]){
brunofgc 0:1c0a769988ee 486 indiceMaiorNEventos[0] = razao_0_125;
brunofgc 0:1c0a769988ee 487 indiceMaiorNEventos[1] = i;
brunofgc 0:1c0a769988ee 488 }
brunofgc 0:1c0a769988ee 489 break;
brunofgc 0:1c0a769988ee 490 case 8:
brunofgc 0:1c0a769988ee 491 if(razao_menorQue_0_125>indiceMaiorNEventos[0]){
brunofgc 0:1c0a769988ee 492 indiceMaiorNEventos[0] = razao_menorQue_0_125;
brunofgc 0:1c0a769988ee 493 indiceMaiorNEventos[1] = i;
brunofgc 0:1c0a769988ee 494 }
brunofgc 0:1c0a769988ee 495 break;
brunofgc 0:1c0a769988ee 496
brunofgc 0:1c0a769988ee 497 }
brunofgc 0:1c0a769988ee 498 }
brunofgc 0:1c0a769988ee 499
brunofgc 0:1c0a769988ee 500 //Buscando o segundo
brunofgc 0:1c0a769988ee 501 //Buscando o primeiro
brunofgc 0:1c0a769988ee 502 for(i=0;i<9;i++){
brunofgc 0:1c0a769988ee 503 //Buscando nos indices maior numero eventos
brunofgc 0:1c0a769988ee 504 if(i!=indiceMaiorNEventos[1]){
brunofgc 0:1c0a769988ee 505 switch(i){
brunofgc 0:1c0a769988ee 506 case 0:
brunofgc 0:1c0a769988ee 507 if(razao_maiorQue4>indiceSegundoMaiorNEventos[0]){
brunofgc 0:1c0a769988ee 508 indiceSegundoMaiorNEventos[0] = razao_maiorQue4;
brunofgc 0:1c0a769988ee 509 indiceSegundoMaiorNEventos[1] = i;
brunofgc 0:1c0a769988ee 510 }
brunofgc 0:1c0a769988ee 511 break;
brunofgc 0:1c0a769988ee 512
brunofgc 0:1c0a769988ee 513 case 1:
brunofgc 0:1c0a769988ee 514 if(razao_4>indiceSegundoMaiorNEventos[0]){
brunofgc 0:1c0a769988ee 515 indiceSegundoMaiorNEventos[0] = razao_4;
brunofgc 0:1c0a769988ee 516 indiceSegundoMaiorNEventos[1] = i;
brunofgc 0:1c0a769988ee 517 }
brunofgc 0:1c0a769988ee 518 break;
brunofgc 0:1c0a769988ee 519 case 2:
brunofgc 0:1c0a769988ee 520 if(razao_3>indiceSegundoMaiorNEventos[0]){
brunofgc 0:1c0a769988ee 521 indiceSegundoMaiorNEventos[0] = razao_3;
brunofgc 0:1c0a769988ee 522 indiceSegundoMaiorNEventos[1] = i;
brunofgc 0:1c0a769988ee 523 }
brunofgc 0:1c0a769988ee 524 break;
brunofgc 0:1c0a769988ee 525 case 3:
brunofgc 0:1c0a769988ee 526 if(razao_2>indiceSegundoMaiorNEventos[0]){
brunofgc 0:1c0a769988ee 527 indiceSegundoMaiorNEventos[0] = razao_2;
brunofgc 0:1c0a769988ee 528 indiceSegundoMaiorNEventos[1] = i;
brunofgc 0:1c0a769988ee 529 }
brunofgc 0:1c0a769988ee 530 break;
brunofgc 0:1c0a769988ee 531 case 4:
brunofgc 0:1c0a769988ee 532 if(razao_1>indiceSegundoMaiorNEventos[0]){
brunofgc 0:1c0a769988ee 533 indiceSegundoMaiorNEventos[0] = razao_1;
brunofgc 0:1c0a769988ee 534 indiceSegundoMaiorNEventos[1] = i;
brunofgc 0:1c0a769988ee 535 }
brunofgc 0:1c0a769988ee 536 break;
brunofgc 0:1c0a769988ee 537 case 5:
brunofgc 0:1c0a769988ee 538 if(razao_0_5>indiceSegundoMaiorNEventos[0]){
brunofgc 0:1c0a769988ee 539 indiceSegundoMaiorNEventos[0] = razao_0_5;
brunofgc 0:1c0a769988ee 540 indiceSegundoMaiorNEventos[1] = i;
brunofgc 0:1c0a769988ee 541 }
brunofgc 0:1c0a769988ee 542 break;
brunofgc 0:1c0a769988ee 543 case 6:
brunofgc 0:1c0a769988ee 544 if(razao_0_25>indiceSegundoMaiorNEventos[0]){
brunofgc 0:1c0a769988ee 545 indiceSegundoMaiorNEventos[0] = razao_0_25;
brunofgc 0:1c0a769988ee 546 indiceSegundoMaiorNEventos[1] = i;
brunofgc 0:1c0a769988ee 547 }
brunofgc 0:1c0a769988ee 548 break;
brunofgc 0:1c0a769988ee 549 case 7:
brunofgc 0:1c0a769988ee 550 if(razao_0_125>indiceSegundoMaiorNEventos[0]){
brunofgc 0:1c0a769988ee 551 indiceSegundoMaiorNEventos[0] = razao_0_125;
brunofgc 0:1c0a769988ee 552 indiceSegundoMaiorNEventos[1] = i;
brunofgc 0:1c0a769988ee 553 }
brunofgc 0:1c0a769988ee 554 break;
brunofgc 0:1c0a769988ee 555 case 8:
brunofgc 0:1c0a769988ee 556 if(razao_menorQue_0_125>indiceSegundoMaiorNEventos[0]){
brunofgc 0:1c0a769988ee 557 indiceSegundoMaiorNEventos[0] = razao_menorQue_0_125;
brunofgc 0:1c0a769988ee 558 indiceSegundoMaiorNEventos[1] = i;
brunofgc 0:1c0a769988ee 559 }
brunofgc 0:1c0a769988ee 560 break;
brunofgc 0:1c0a769988ee 561
brunofgc 0:1c0a769988ee 562 }
brunofgc 0:1c0a769988ee 563 }
brunofgc 0:1c0a769988ee 564 }
brunofgc 0:1c0a769988ee 565
brunofgc 0:1c0a769988ee 566
brunofgc 0:1c0a769988ee 567 //printf("Indice de maior aparecimento foi o de %d.\nIndice de segundo maior aparecimento foi o de %d.\n",indiceMaiorNEventos[1],indiceSegundoMaiorNEventos[1]);
brunofgc 0:1c0a769988ee 568
brunofgc 0:1c0a769988ee 569 //Calculando bitAlto
brunofgc 0:1c0a769988ee 570 switch(indiceMaiorNEventos[1]){
brunofgc 0:1c0a769988ee 571 case 0:
brunofgc 0:1c0a769988ee 572 bitAlto_H = round(bitRazao_maiorQue4[0]/indiceMaiorNEventos[0]);
brunofgc 0:1c0a769988ee 573 bitAlto_L = round(bitRazao_maiorQue4[1]/indiceMaiorNEventos[0]);
brunofgc 0:1c0a769988ee 574 break;
brunofgc 0:1c0a769988ee 575 case 1:
brunofgc 0:1c0a769988ee 576 bitAlto_H = round(bitRazao_4[0]/indiceMaiorNEventos[0]);
brunofgc 0:1c0a769988ee 577 bitAlto_L = round(bitRazao_4[1]/indiceMaiorNEventos[0]);
brunofgc 0:1c0a769988ee 578 break;
brunofgc 0:1c0a769988ee 579 case 2:
brunofgc 0:1c0a769988ee 580 bitAlto_H = round(bitRazao_3[0]/indiceMaiorNEventos[0]);
brunofgc 0:1c0a769988ee 581 bitAlto_L = round(bitRazao_3[1]/indiceMaiorNEventos[0]);
brunofgc 0:1c0a769988ee 582 break;
brunofgc 0:1c0a769988ee 583 case 3:
brunofgc 0:1c0a769988ee 584 bitAlto_H = round(bitRazao_2[0]/indiceMaiorNEventos[0]);
brunofgc 0:1c0a769988ee 585 bitAlto_L = round(bitRazao_2[1]/indiceMaiorNEventos[0]);
brunofgc 0:1c0a769988ee 586 break;
brunofgc 0:1c0a769988ee 587 case 4:
brunofgc 0:1c0a769988ee 588 bitAlto_H = round(bitRazao_1[0]/indiceMaiorNEventos[0]);
brunofgc 0:1c0a769988ee 589 bitAlto_L = round(bitRazao_1[1]/indiceMaiorNEventos[0]);
brunofgc 0:1c0a769988ee 590 break;
brunofgc 0:1c0a769988ee 591 case 5:
brunofgc 0:1c0a769988ee 592 bitAlto_H = round(bitRazao_0_5[0]/indiceMaiorNEventos[0]);
brunofgc 0:1c0a769988ee 593 bitAlto_L = round(bitRazao_0_5[1]/indiceMaiorNEventos[0]);
brunofgc 0:1c0a769988ee 594 break;
brunofgc 0:1c0a769988ee 595 case 6:
brunofgc 0:1c0a769988ee 596 bitAlto_H = round(bitRazao_0_25[0]/indiceMaiorNEventos[0]);
brunofgc 0:1c0a769988ee 597 bitAlto_L = round(bitRazao_0_25[1]/indiceMaiorNEventos[0]);
brunofgc 0:1c0a769988ee 598 break;
brunofgc 0:1c0a769988ee 599 case 7:
brunofgc 0:1c0a769988ee 600 bitAlto_H = round(bitRazao_0_125[0]/indiceMaiorNEventos[0]);
brunofgc 0:1c0a769988ee 601 bitAlto_L = round(bitRazao_0_125[1]/indiceMaiorNEventos[0]);
brunofgc 0:1c0a769988ee 602 break;
brunofgc 0:1c0a769988ee 603 case 8:
brunofgc 0:1c0a769988ee 604 bitAlto_H = round(bitRazao_menorQue_0_125[0]/indiceMaiorNEventos[0]);
brunofgc 0:1c0a769988ee 605 bitAlto_L = round(bitRazao_menorQue_0_125[1]/indiceMaiorNEventos[0]);
brunofgc 0:1c0a769988ee 606 break;
brunofgc 0:1c0a769988ee 607 }
brunofgc 0:1c0a769988ee 608
brunofgc 0:1c0a769988ee 609 //Calculando bitBaixo
brunofgc 0:1c0a769988ee 610 switch(indiceSegundoMaiorNEventos[1]){
brunofgc 0:1c0a769988ee 611 case 0:
brunofgc 0:1c0a769988ee 612 bitBaixo_H = round(bitRazao_maiorQue4[0]/indiceSegundoMaiorNEventos[0]);
brunofgc 0:1c0a769988ee 613 bitBaixo_L = round(bitRazao_maiorQue4[1]/indiceSegundoMaiorNEventos[0]);
brunofgc 0:1c0a769988ee 614 break;
brunofgc 0:1c0a769988ee 615 case 1:
brunofgc 0:1c0a769988ee 616 bitBaixo_H = round(bitRazao_4[0]/indiceSegundoMaiorNEventos[0]);
brunofgc 0:1c0a769988ee 617 bitBaixo_L = round(bitRazao_4[1]/indiceSegundoMaiorNEventos[0]);
brunofgc 0:1c0a769988ee 618 break;
brunofgc 0:1c0a769988ee 619 case 2:
brunofgc 0:1c0a769988ee 620 bitBaixo_H = round(bitRazao_3[0]/indiceSegundoMaiorNEventos[0]);
brunofgc 0:1c0a769988ee 621 bitBaixo_L = round(bitRazao_3[1]/indiceSegundoMaiorNEventos[0]);
brunofgc 0:1c0a769988ee 622 break;
brunofgc 0:1c0a769988ee 623 case 3:
brunofgc 0:1c0a769988ee 624 bitBaixo_H = round(bitRazao_2[0]/indiceSegundoMaiorNEventos[0]);
brunofgc 0:1c0a769988ee 625 bitBaixo_L = round(bitRazao_2[1]/indiceSegundoMaiorNEventos[0]);
brunofgc 0:1c0a769988ee 626 break;
brunofgc 0:1c0a769988ee 627 case 4:
brunofgc 0:1c0a769988ee 628 bitBaixo_H = round(bitRazao_1[0]/indiceSegundoMaiorNEventos[0]);
brunofgc 0:1c0a769988ee 629 bitBaixo_L = round(bitRazao_1[1]/indiceSegundoMaiorNEventos[0]);
brunofgc 0:1c0a769988ee 630 break;
brunofgc 0:1c0a769988ee 631 case 5:
brunofgc 0:1c0a769988ee 632 bitBaixo_H = round(bitRazao_0_5[0]/indiceSegundoMaiorNEventos[0]);
brunofgc 0:1c0a769988ee 633 bitBaixo_L = round(bitRazao_0_5[1]/indiceSegundoMaiorNEventos[0]);
brunofgc 0:1c0a769988ee 634 break;
brunofgc 0:1c0a769988ee 635 case 6:
brunofgc 0:1c0a769988ee 636 bitBaixo_H = round(bitRazao_0_25[0]/indiceSegundoMaiorNEventos[0]);
brunofgc 0:1c0a769988ee 637 bitBaixo_L = round(bitRazao_0_25[1]/indiceSegundoMaiorNEventos[0]);
brunofgc 0:1c0a769988ee 638 break;
brunofgc 0:1c0a769988ee 639 case 7:
brunofgc 0:1c0a769988ee 640 bitBaixo_H = round(bitRazao_0_125[0]/indiceSegundoMaiorNEventos[0]);
brunofgc 0:1c0a769988ee 641 bitBaixo_L = round(bitRazao_0_125[1]/indiceSegundoMaiorNEventos[0]);
brunofgc 0:1c0a769988ee 642 break;
brunofgc 0:1c0a769988ee 643 case 8:
brunofgc 0:1c0a769988ee 644 bitBaixo_H = round(bitRazao_menorQue_0_125[0]/indiceSegundoMaiorNEventos[0]);
brunofgc 0:1c0a769988ee 645 bitBaixo_L = round(bitRazao_menorQue_0_125[1]/indiceSegundoMaiorNEventos[0]);
brunofgc 0:1c0a769988ee 646 break;
brunofgc 0:1c0a769988ee 647 }
brunofgc 0:1c0a769988ee 648
brunofgc 0:1c0a769988ee 649 printf("\n\nFinalmente.\n");
brunofgc 0:1c0a769988ee 650 printf("startBitAlto = %ld, startBitBaixo = %ld\n", startBitAlto,startBitBaixo);
brunofgc 0:1c0a769988ee 651 printf("bitAlto_H = %ld bitAlto_l = %ld\n",bitAlto_H,bitAlto_L);
brunofgc 0:1c0a769988ee 652 printf("bitBaixo_H = %ld bitBaixo_l = %ld\n",bitBaixo_H,bitBaixo_L);
brunofgc 0:1c0a769988ee 653 printf("stopBitAlto = %ld\n",stopBitAlto);
brunofgc 0:1c0a769988ee 654
brunofgc 0:1c0a769988ee 655 return;
brunofgc 0:1c0a769988ee 656 }*/