Checking a bit sequence

  • I'm working with SX1509 peripheral.


    Based on this value '00000000 00000110' from 0x18+0x19 I know that pin 01 and pin 02 caused an interrupt. Now I need to read IO state for pin 01 and pin 02.

    Below code works, but can you suggest improvements?

    def digitalReadFromInterrupt(self,interruptSource):
            readResults = []
            for i in range(15,0,-1):
                if interruptSource & (1<<i):
            return readResults

Log in to reply

Pycom on Twitter