8000 Using PulseIn to detect pin interrupts · Issue #1072 · adafruit/circuitpython · GitHub
[go: up one dir, main page]

Skip to content
Using PulseIn to detect pin interrupts #1072
Closed
@notro

Description

@notro

I'm trying to emulate an MCP23008 (I2C I/O Expander) and for that I need pin interrupts.

pulseio.PulseIn almost gives me what I need.
All I need to know is:

  • has an interrupt happened since last time I checked
  • what's the current pin value.

These are the problems I face with PulseIn:

  • I don't get access to the very first edge, so I loose the first interrupt.
  • If the pin is active on init I loose another edge due to idle_state
  • In case of jitter, the pulse buffer is easily overrun. I will know that there was an interrupt, but I don't know the current pin value so I have to check with DigitalInOut. This means that I loose out on the next edge.

Adding an edge counter to PulseIn would solve these problems (counter will be cleared on read).
It would also be nice to have a PulseIn.pinvalue or something.

Or would it be better to just implement proper pin interrupts?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0