Talk Sketch: Pointless Blinking: Evolution¶
gpiod
Intro¶
gpiod
basics,Box
Show center on/off
Quickly explain
request_lines()
(request.set_value()
vs.request.set_values()
)Show
blink.glt2024.box
Use
Box.matrix
insert
snippets/blink
, and use it
asyncio
Intro¶
threading
insert
snippets/threads
strace -f ...
⟶ PIDsComplain about threads
Change to
asyncio
strace -f ...
again ⟶ no PIDs
And blink
?¶
Explain
on
⟶asyncio.create_future()
sleep
Combine through
any
⟶launch_isolated
forever
andsequence
⟶blink
forever(
sequence(
any(
on(box.matrix.get(2,2)),
sleep(0.5),
),
sleep(0.5),
)
)
Pull in snippet
blueprints/snippet-nice-pattern
gpiod
, And Interrupts¶
blink.base.sleep
: timer eventOther events? ⟶ interrupt on GPIO line
Show
blueprints/gpiod-interrupts.py
Discuss edges, timestamps, bouncing
FALLING
,debounce_period
Transform into generator,
events()
Nice, Pythonic!
gpiod
, Interrupts, and asyncio
¶
async def main()
; simply iterate overevents()
⟶ works
Second button, 19? Hm, tasks.
Wrap
events()
iteration inprint_events()
Make
print_events()
async
In
main()
, create two tasks aroundprint_events()
⟶ one works, the other not
We block! Aha, async
all over
Question: how make
events()
async? asynchronous generator?Future, loops, blah
And blink
?¶
Show
wait_button
back in
blink-demo.py
, replacesleep(3)
withwait_button()
textual
¶
Python 3.12 Installation (for TaskGroup
)¶
$ sudo apt install libssl-dev libreadline-dev libffi-dev libsystemd-dev python3-dev
$ wget https://www.python.org/ftp/python/3.12.2/Python-3.12.2.tar.xz
$ tar xf Python-3.12.2.tar.xz
$ cd Python-3.12.2/
$ ./configure --prefix=$HOME/Python-3.12.2-Install --with-readline
$ make
$ make install