Jump to content

how to do interrupt drive GPIO input in python?


dony71

Recommended Posts

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?

Link to comment
Share on other sites

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++

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines