pythonwiringpi

Least CPU intense call in python to use in while loop


I'm currently using wiringpi to control the GPIO ports of a mcp23017 expansion board for my Raspberry Pi. One of the GPIOs should be used as an input and wait for a INT_EDGE_FALLING event. Wiringpi itself supports an interrupt mode but for whatever reason supports this only up to pin number 63 - mine is pin 70.

So I'm stuck with somthing like this:

wiringpi.pinMode(70,0)
wiringpi.pullUpDnControl(70,2)
while wiringpi.digitalRead(70) == 1:
    print "not pressed"

This loop causes a CPU usage of about 6% - is there any way to reduce this? Which is the least cpu intense command to use within the while loop?


Solution

  • You can use the pass statement to do nothing.

    while wiringpi.digitalRead(70) == 1:
        pass