Go to the documentation of this file.00001
00002
00003 import time
00004 import curses
00005 import atexit
00006 import sys
00007
00008 import pigpio
00009
00010 GPIOS=32
00011
00012 MODES=["INPUT", "OUTPUT", "ALT5", "ALT4", "ALT0", "ALT1", "ALT2", "ALT3"]
00013
00014 def cleanup():
00015 curses.nocbreak()
00016 curses.echo()
00017 curses.endwin()
00018 pi.stop()
00019
00020 pi = pigpio.pi()
00021 if not pi.connected:
00022 sys.exit(1)
00023
00024 stdscr = curses.initscr()
00025 curses.noecho()
00026 curses.cbreak()
00027
00028 atexit.register(cleanup)
00029
00030 cb = []
00031
00032 for g in range(GPIOS):
00033 cb.append(pi.callback(g, pigpio.EITHER_EDGE))
00034
00035
00036
00037 cb[28].cancel()
00038
00039 stdscr.nodelay(1)
00040
00041 stdscr.addstr(0, 23, "Status of gpios 0-31", curses.A_REVERSE)
00042
00043 while True:
00044
00045 for g in range(GPIOS):
00046 tally = cb[g].tally()
00047 mode = pi.get_mode(g)
00048
00049 col = (g // 11) * 25
00050 row = (g % 11) + 2
00051
00052 stdscr.addstr(row, col, "{:2}".format(g), curses.A_BOLD)
00053
00054 stdscr.addstr(
00055 "={} {:>6}: {:<10}".format(pi.read(g), MODES[mode], tally))
00056
00057 stdscr.refresh()
00058
00059 time.sleep(0.1)
00060
00061 c = stdscr.getch()
00062
00063 if c != curses.ERR:
00064 break
00065