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;
}
Beispiel #2
0
inline long ReadWlanInterruptPin(void)
{
  /* Return the status of WIFI_IRQ pin */

   return kl_gpioread(GPIO_WIFI_IRQ);
}