Skip to content
View in the app

A better way to browse. Learn more.

Learn more

how to do interrupt drive GPIO input in python?

Featured Replies

RPi has this interrupt driven GPIO input detection

GPIO.add_event_detect(pin_number, GPIO.BOTH, callback=callback_function)

 

 

Orange Pi has already this python GPIO function

https://github.com/duxingkei33/orangepi_PC_gpio_pyH3

 

But I see only gpio.input(pin_number) function for GPIO input detection

Anybody can answer whether possible to substitute RPi interrupt driven GPIO input detection?

Yes. use WiringOP from WereCatf https://github.com/WereCatf/WiringOP

 

example(from my :) )

void rpmInterrupt(void) {
          pulseCounter++;
}

....

void rpmFan(void) {
      pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
      wiringPiSetup () ;
      pinMode(PIN_RPM, INPUT);
      pullUpDnControl (PIN_RPM, PUD_UP) ;
      wiringPiISR (PIN_RPM, INT_EDGE_FALLING, &rpmInterrupt);
      while (1)  {
        rpm=(pulseCounter/HALL_PULSE)*60 ;
        pulseCounter = 0;
        delayMicroseconds ( 1000000 ); //cheÑk every 1 second
      }
}

It works. But this is C++

  • Author

Yes. use WiringOP from WereCatf https://github.com/WereCatf/WiringOP

 

example(from my :) )

void rpmInterrupt(void) {
          pulseCounter++;
}

....

void rpmFan(void) {
      pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
      wiringPiSetup () ;
      pinMode(PIN_RPM, INPUT);
      pullUpDnControl (PIN_RPM, PUD_UP) ;
      wiringPiISR (PIN_RPM, INT_EDGE_FALLING, &rpmInterrupt);
      while (1)  {
        rpm=(pulseCounter/HALL_PULSE)*60 ;
        pulseCounter = 0;
        delayMicroseconds ( 1000000 ); //cheÑk every 1 second
      }
}

It works. But this is C++

 

any python wrapper for this?

Guest
This topic is now closed to further replies.

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.