Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- uint16_t RECV_PIN = D7;
- IRrecv irrecv(RECV_PIN);
- decode_results results;
- unsigned long cod;
- unsigned int canguru;
- unsigned int fimDeCode;
- unsigned int addr = 0;
- bool tigre;
- bool grava = false;
- bool inicio1 = 1;
- int pulga = 0;
- int addrControl ;
- int displayRC;
- //-------------------------------------------
- void verifica()
- {
- grava = true;
- int EEPROM_Old;
- // Serial.println(addr);
- {
- for (int EEPROMaddr = pulga * 0x64 ; EEPROMaddr <= addr;) // Busca todos enderecos
- {
- EEPROM.get(EEPROMaddr, EEPROM_Old);
- if (EEPROM_Old == cod)
- {
- Serial.println(" <-- Já tem este code gravado");
- grava = false;
- }
- EEPROMaddr = EEPROMaddr + 4;
- }
- }
- }
- //---------------------------------------
- void guardaRC_Code()
- {
- Serial.println("Aperte uma tecla do RC");
- tigre = 0;
- while (tigre == 0)
- {
- yield();
- if (irrecv.decode(&results))
- {
- cod = results.value;
- tigre = 1;
- irrecv.resume(); // Receive the next value
- }
- }
- Serial.print(" Lido " ); Serial.print(cod, HEX);
- verifica();
- if ( grava == true)
- {
- EEPROM.put(addr, cod);
- Serial.println(" ");
- Serial.print("cod "); Serial.print(cod, HEX); Serial.print(" salvo em ");
- Serial.println(addr);
- Serial.println(" ");
- EEPROM.put(addr + 4, 0xDAD0DAD0);
- EEPROM.commit();
- // EEPROM.get(addr, canguru);
- addr = addr + 4;
- }
- Serial.println("Digite um valor na serial");
- }
- //--------------------------------------------------------
- void selectRC()
- {
- while (inicio1 == 1)
- {
- yield();
- if (Serial.available() > 0)
- {
- pulga = Serial.read();
- pulga = pulga & 0x0F;
- Serial.println(" ");
- Serial.print("RC "); Serial.print(pulga, DEC); Serial.print(" selecionado,");
- addr = pulga * 0x64;
- Serial.print(" iniciando no end. "); Serial.println(pulga * 0x64, DEC);
- Serial.println(" ");
- inicio1 = 0;
- addrControl = addr;
- }
- }
- }
- //--------------------------------------------------------
- void listaRC()
- {
- addr = pulga * 0x64;
- while ((displayRC != 0xDAD0DAD0) & (displayRC != 0xFFFFFFFF))
- {
- yield();
- EEPROM.get(addr, displayRC);
- Serial.print(addr);
- Serial.print(" : ");
- Serial.println(displayRC, HEX);
- addr = addr + 4;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement