char* model = "MoDeL"; char* ip_remote = "IpHoSt"; char* rec = "ReC"; uint8_t modelCount =0; uint8_t ipCount =0; uint8_t recCount =0; boolean ok_model = false; boolean ok_ip = false; boolean ok_rec = false; uint8_t pos_mod_x=0; uint8_t pos_mod_y=0; uint8_t pos_ip=0; void test_model(char inByte) { if ((inByte == model[modelCount])&&(!ok_model)) { modelCount++; if (modelCount==strlen(model)) { modelCount=0; ok_model=true; } } else if (ok_model) save_model(inByte); else modelCount=0; } void test_rec(char inByte) { if ((inByte == rec[recCount])&&(!ok_rec)) { recCount++; if (recCount==strlen(rec)) { recCount=0; ok_rec=true; } } else if (ok_rec) mod_rec(inByte); else recCount=0; } void test_ip(char inByte) { if ((inByte == ip_remote[ipCount])&&(!ok_ip)) { ipCount++; if (ipCount==strlen(ip_remote)) { ipCount=0; ok_ip=true; } } else if (ok_ip) save_ip(inByte); else ipCount=0; } void save_model(byte inByte) { unsigned int temp_address; temp_address = EEI2C_ADDR_MODELS + 80*system_num_models; if (inByte=='/') { if(pos_mod_y>0) { writeEEPROM(eeprom, temp_address + pos_mod_x + (pos_mod_y - 1)*16 , 0x0D); /*Serial.print((char)readEEPROM(eeprom, temp_address + pos_mem_x + (pos_mem_y - 1)*16));*/ } pos_mod_x=0; pos_mod_y++; } else { if ((pos_mod_x<16)&&(pos_mod_y<6)) { if (pos_mod_y<2) { writeEEPROM(eeprom, temp_address + pos_mod_x + (pos_mod_y - 1)*16 , inByte); //Serial.print((char)readEEPROM(eeprom, temp_address + pos_mod_x + (pos_mod_y - 1)*16)); pos_mod_x++; } else { byte temp=0x00; if (byte_count==1) temp=readEEPROM(eeprom, temp_address + pos_mod_x + (pos_mod_y - 1)*16); if ((inByte>=0x30)&&(inByte<=0x39)) temp=(temp<<4) + (inByte - 0x30); else if ((inByte>=0x41)&&(inByte<=0x46)) temp=(temp<<4) + (inByte - 0x37); writeEEPROM(eeprom, temp_address + pos_mod_x + (pos_mod_y - 1)*16 , temp); byte_count++; if (byte_count==2) { pos_mod_x++; byte_count=0; } //Serial.print((byte)readEEPROM(eeprom, temp_address + pos_mod_x + (pos_mod_y - 1)*16), HEX); } } else if (pos_mod_y>5) { ok_model=false; pos_mod_y = 0; system_num_models++; writeEEPROM(eeprom, EEI2C_ADDR_system_num_models + 1, highByte(system_num_models)); writeEEPROM(eeprom, EEI2C_ADDR_system_num_models, lowByte(system_num_models)); } } } void save_ip(byte inByte) { if (inByte=='/') { if(pos_ip>0) { writeEEPROM(eeprom, EEI2C_ADDR_HOST + pos_ip - 1, 0x00); ip_host[pos_ip - 1] = 0x00; ok_ip=false; pos_ip = 0; software_Reset(); } else pos_ip=1; } else { if (pos_ip<17) { writeEEPROM(eeprom, EEI2C_ADDR_HOST + pos_ip - 1 , inByte); ip_host[pos_ip - 1] = inByte; pos_ip++; } } } void mod_rec(byte inByte) { } void video_rec() { timecode++; frame++; if (frame>sistema) {frame=0; timeseconds++; } if (timeseconds==timeseconds_next) { timeseconds_next = timeseconds + 1; if (timeseconds==(timetotalvideo-1)) {if(!frec) lanc.println();} else if (timeseconds==(timetotalvideo)) { start_video=false; lcd.shiftWrite(red, HIGH); lcd.shiftWrite(green, HIGH); digitalWrite(aud,LOW); lcd.shiftWrite(lamp,LOW); if (system_useSpeaker) digitalWrite(PINS_BUZZER,LOW); if(!frec) { if (system_mode)lanc.println(lancstop,HEX); else irsend.sendNEC(remotestop, 32); } } else if ((timeseconds==(timeant-1))&&(system_mode))lanc.println(); //Un segundo antes de mandar el comando lanc, mando un enter else if (timeseconds==timeant) { if (frec) { lcd.shiftWrite(red, LOW); lcd.shiftWrite(green, HIGH); if(system_mode) lanc.println(lancrec,HEX); else irsend.sendNEC(remoterec, 32); } else { lcd.shiftWrite(red, HIGH); lcd.shiftWrite(green, LOW); if (system_mode)lanc.println(lancstop,HEX); else irsend.sendNEC(remotestop, 32); } } else if (timeseconds==(timeant+1)) { timeant = timeant + (timepausevideo*(!frec) + timerecvideo*frec); frec=!frec; if(!frec) { frames_ant=timecode; morse_count++; bit_count = 0; } } } if ((!frec)&&(bit_count<16)&&((timecode-frames_ant)==1)) { frames_ant=timecode; uint16_t temp = (MORSE[morse_count]>>(15-bit_count))&0x0001; digitalWrite(aud,temp); lcd.shiftWrite(lamp,temp); if (system_useSpeaker)digitalWrite(PINS_BUZZER,temp); bit_count++; } }