void setup() { DDRD |= 0b01000000; // ������� ��������� PORTD &= 0b10111111; // ������� ��������� DDRD |= 0b00100000; // ����� ������� PORTD &= 0b11011111; // ����� ������� DDRD |= 0b00010000; // ��������� �� PORTD &= 0b11101111; // ��������� �� DDRD &= 0b11111011; // ������ PORTD |= 0b00000100; // ������ enableIROut(56); enableIRIn(); //���������� ��� ���� ISCxx //����������� �� ������������ INT0 �� ������� ������ MCUCR &= ~( (1<<ISC11)|(1<<ISC10)|(1<<ISC01)|(1<<ISC00) ); //��������� ������� ���������� INT0 GICR |= (1<<INT0); //���������� ���� ����������� ���������� ���������� PT_INIT(&ptIRReceive); PT_INIT(&ptWaitForTrigger); PT_INIT(&ptExplode); PT_INIT(&ptFinder); set_sleep_mode(SLEEP_MODE_PWR_DOWN); }
void IRSendRev::Init(int revPin) { irparams.recvpin = revPin; enableIRIn(); // Start the receiver delay(20); Clear(); }
int IRrecvSF::getIRRemoteCode() { if (!isEnabledIRIn()) enableIRIn(); decode_resultsSF results; int result = 0; //##Se determinó que devolver 0 en vez de -1 cuando no recibe nada coherente, es mejor //para algunas actividades, como la música con el control remoto (sobre todo cuando se //trabaja con chicos). Es por esto que abajo se devuelve 10 cuando se detecta un 0. //##Implementar... if (decode(&results)) { int count = results.rawlen; if (results.decode_type == RC5) //By now, only supports RC5 Format. { char command[10];// = results.value; ultoa(results.value,command,16); if ( (strcmp(command, "0") == 0) || (strcmp(command, "800") == 0)) //##Ver si el cero es correcto. result = 10; //See note above. else if ( (strcmp(command, "1") == 0) || (strcmp(command, "801") == 0)) result = 1; else if ( (strcmp(command, "2") == 0) || (strcmp(command, "802") == 0)) result = 2; else if ( (strcmp(command, "3") == 0) || (strcmp(command, "803") == 0)) result = 3; else if ((strcmp(command, "4") == 0) || (strcmp(command, "804") == 0)) result = 4; else if ( (strcmp(command, "5") == 0) || (strcmp(command, "805") == 0)) result = 5; else if ((strcmp(command, "6") == 0) || (strcmp(command, "806") == 0)) result = 6; else if ( (strcmp(command, "7") == 0) || (strcmp(command, "807") == 0)) result = 7; else if ((strcmp(command, "8") == 0) || (strcmp(command, "808") == 0)) result = 8; else if ( (strcmp(command, "9") == 0) || (strcmp(command, "809") == 0)) result = 9; // if ((strcmp(command, "80c") == 0) || (strcmp(command, "c") == 0)) // //Remote control's POWER button: By now do nothing. // return 10; } resume(); // Receive the next value } //disableIRIn(); return result; //##Invalid code... See if in the future there will be a constant defined in Minibloq. }
void sendNEC(unsigned long data) { // handle turning on an approximation of our colour, // as RGB PWM is off during IR sending. // TODO enableIROut(); // put timer into send mode mark(NEC_HDR_MARK); space(NEC_HDR_SPACE); for (uint8_t i = 0; i < 32; i++) { if (data & 1) { mark(NEC_BIT_MARK); space(NEC_ONE_SPACE); } else { mark(NEC_BIT_MARK); space(NEC_ZERO_SPACE); } data >>= 1; } mark(NEC_BIT_MARK); space(0); enableIRIn(); // switch back to recv mode }
void loop() { // If button pressed, send the code. int buttonState = kl_gpioread(BUTTON_PIN); if (lastButtonState == HIGH && buttonState == LOW) { printf("Released\n"); enableIRIn(); // Re-enable receiver } if (buttonState) { printf("Pressed, sending\n"); kl_gpiowrite(STATUS_PIN, HIGH); sendCode(lastButtonState == buttonState); kl_gpiowrite(STATUS_PIN, LOW); usleep(50000); // Wait a bit between retransmissions } else if (decode(&results)) { kl_gpiowrite(STATUS_PIN, HIGH); storeCode(&results); resume(); // resume receiver kl_gpiowrite(STATUS_PIN, LOW); } lastButtonState = buttonState; }
int main(void) { wiringPiSetup(); char key[100]; int fvalue[100]; int lcd1,value,temp=0,i; FILE *fd = NULL,*fd2 = NULL; fd = fopen("../config.txt","r"); printf("what"); fd2 = fopen("/home/pi/.config/pianobar/ctl","w"); printf("file ready"); //lcd1=lcdInit(2,16,8,11,10,14,13,12,3,2,0,7,9); //enableIRIn(4); //lcdPosition(lcd1,0,0); //lcdPuts(lcd1,"learning process"); //lcdPosition(lcd1,0,1); //lcdPuts(lcd1,"press anykey"); FILE *fr; /* declare the file pointer */ int n; char line[80]; char tmp[1]; int num; fr = fopen ("test.txt", "r"); /* open the file for reading */ while(fgets(line, 80, fr) != NULL) { sscanf (line, "%s", tmp); key[temp]=tmp; fgets(line, 80, fr); sscanf (line, "%d", &num); fvalue[temp]=num; temp++;} fclose(fr); enableIRIn(4); //while(1) { // if(decode()) // {resume();if(get_result!=-1) break;} //} //delay(7000); //while(fscanf(fd, "%s", key) != EOF) { // int temp=1; //lcdPosition(lcd1,0,0); //lcdPrintf(lcd1,"keyyyyy"); //lcdPosition(lcd1,0,1); //lcdPrintf(lcd1,"press for learn "); while(1) { //printf("wtf"); if(decode()){ for(i=0;i<temp;i++) { if(fvalue[i]==get_result()) { tmpkey[1]=key[i]; fprintf(fd2,"%s",tmpkey[1]);// >> /home/pi/.config/pianobar/ctl; }} //fprintf(fd2, "%d %s\n",get_result(),key); //lcdPosition(lcd1,0,0); //lcdPrintf(lcd1,"complete wait for next key"); //delay(1500); resume(); //temp=0; } //else if(decode())resume(); }}//return 0; }
/*US*/ void IRrecv::branch(){ enableIRIn(); m_lifeLongPush=200; // Durée de vie minimale d'un appui long m_dateLongPush=0; }