{"action":"opened","issue":{"url":"https://api.github.com/repos/derekstavis/python-sysfs-gpio/issues/17","repository_url":"https://api.github.com/repos/derekstavis/python-sysfs-gpio","labels_url":"https://api.github.com/repos/derekstavis/python-sysfs-gpio/issues/17/labels{/name}","comments_url":"https://api.github.com/repos/derekstavis/python-sysfs-gpio/issues/17/comments","events_url":"https://api.github.com/repos/derekstavis/python-sysfs-gpio/issues/17/events","html_url":"https://github.com/derekstavis/python-sysfs-gpio/issues/17","id":223156062,"number":17,"title":"Question:  Example Usage with While Loop","user":{"login":"dhildreth","id":1189273,"avatar_url":"https://avatars0.githubusercontent.com/u/1189273?v=3","gravatar_id":"","url":"https://api.github.com/users/dhildreth","html_url":"https://github.com/dhildreth","followers_url":"https://api.github.com/users/dhildreth/followers","following_url":"https://api.github.com/users/dhildreth/following{/other_user}","gists_url":"https://api.github.com/users/dhildreth/gists{/gist_id}","starred_url":"https://api.github.com/users/dhildreth/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dhildreth/subscriptions","organizations_url":"https://api.github.com/users/dhildreth/orgs","repos_url":"https://api.github.com/users/dhildreth/repos","events_url":"https://api.github.com/users/dhildreth/events{/privacy}","received_events_url":"https://api.github.com/users/dhildreth/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-04-20T18:22:59Z","updated_at":"2017-04-20T18:22:59Z","closed_at":null,"body":"I'm attempting to use this excellent library in a project where I'm attempting to turn on an LED when an interrupt is triggered, but I have a feeling I'm missing something basic.  This is the first time I've heard of Twisted Reactor, so I'm wondering if that has something to do with my misunderstanding of what I thought was relatively straightforward. \r\n\r\nI have a while loop which reads a light sensor every second.  The light sensor (I2C device) is programmed to trigger an interrupt when the value reads below a certain threshold.  I have the interrupt pin of the sensor connected to GPIO 65 of my SBC.  I then have an LED hooked up to GPIO 64 of my SBC.  Something like this:\r\n\r\n    import time\r\n    from twisted.internet import reactor\r\n    from sysfs.gpio import Controller, OUTPUT, INPUT, RISING\r\n\r\n    Controller.available_pins = [64, 65]\r\n    led_en = Controller.alloc_pin(64, OUTPUT)\r\n\r\n    def pin_changed(pin, state):\r\n        print(\"Pin changed to %d state\" % state)\r\n        if state:\r\n            led_en.set()   # Sets pin to high logic level\r\n        else:\r\n            led_en.reset()\r\n\r\n    intt = Controller.alloc_pin(65, INPUT, pin_changed, RISING)\r\n\r\n    reactor.run()\r\n\r\n    while True:\r\n\r\n        # Enable sensor light interrupts\r\n        # Read and store sensor light value via I2C\r\n        # Print sensor light value to console for debugging\r\n        print(\"Testing!\")\r\n        sleep(.5)\r\n\r\nAnyways, so I'm expecting my while loop to execute, but it never does.  Instead, I get \"Pin changed to 0 state\", from the `pin_changed()` callback and then nothing!\r\n\r\n    $ sudo python test-gpio-interrupt.py \r\n    SysfsGPIO: alloc_pin(64, out, None, None, 0)\r\n    SysfsGPIO: alloc_pin(65, in, <function pin_changed at 0x76468830>, rising, 0)\r\n    Pin changed to 0 state\r\n\r\nI then have to Ctrl + C to end the process.\r\n\r\nI would've expected the code in the while loop to execute.  I must be having a lapse of common sense and I'm hoping you can help.\r\n"}}
{"actor":{"display_login":"dhildreth"}}