libpruio  0.6.8
Fast and easy Digital/Analog Input/Output for Beaglebones
button.py
Go to the documentation of this file.
1 #!/usr/bin/python
2 
16 
17 from __future__ import print_function
18 from libpruio import *
19 
20 
21 PIN = P8_07
22 
23 
24 io = pruio_new(PRUIO_DEF_ACTIVE, 4, 0x98, 0)
25 try:
26 
27  IO = io.contents
28  if IO.Errr: raise AssertionError("pruio_new failed (%s)" % IO.Errr)
29  if pruio_config(io, 1, 0x1FE, 0, 4): # upload settings, start IO mode
30  raise AssertionError("config failed (%s)" % IO.Errr)
31  # IO mode is running, you can control digital output, read digital or analog input
32  print("Press <Crtl>-C to stop")
33  try:
34  while True:
35  print("\r%1X" % pruio_gpio_Value(io, PIN), end="");
36  print(end="\r") # next line
37  except KeyboardInterrupt:
38  print("") # clear terminal
39 finally:
40  pruio_destroy(io)
char * pruio_config(pruIo *Io, uint32 Samp, uint32 Mask, uint32 Tmr, uint16 Mds)
Wrapper function for PruIo::config().
uint32 pruio_gpio_Value(pruIo *Io, uint8 Ball)
Wrapper function for GpioUdt::Value().
pruIo * pruio_new(uint16 Act, uint8 Av, uint32 OpD, uint8 SaD)
Wrapper function for the constructor PruIo::PruIo().
void pruio_destroy(pruIo *Io)
Wrapper function for the destructor PruIo::~PruIo().