26 from libpruio
import *
37 io =
pruio_new(PRUIO_DEF_ACTIVE, 4, 0x98, 0)
48 if (Rot & 1): move.pos &= 7
51 if move.pos == 1:
PIN_OUT(1,0,0,0)
52 elif move.pos == 2:
PIN_OUT(1,1,0,0)
53 elif move.pos == 3:
PIN_OUT(0,1,0,0)
54 elif move.pos == 4:
PIN_OUT(0,1,1,0)
55 elif move.pos == 5:
PIN_OUT(0,0,1,0)
56 elif move.pos == 6:
PIN_OUT(0,0,1,1)
57 elif move.pos == 7:
PIN_OUT(0,0,0,1)
65 if IO.Errr:
raise AssertionError(
"pruio_new failed (%s)" % IO.Errr)
70 raise AssertionError(
"config failed (%s)" % IO.Errr)
73 stdscr.addstr(0,0,
"Controls: (other keys quit, 1 and 3 only when Direction = 0)\n")
74 stdscr.addstr(1,0,
" 8 = faster\n")
75 stdscr.addstr(2,0,
" 4 = rotate CW 5 = stop, hold position 6 = rotate CCW\n")
76 stdscr.addstr(3,0,
" 1 = single step CW 2 = slower 3 = single step CCW\n")
77 stdscr.addstr(4,0,
" 0 = stop, power off\n\n")
78 stdscr.addstr(6,0,
" Pins Dir Sleep")
81 stdscr.addstr(7,10,
"{:2d} {:3d}".format(d, w))
84 stdscr.addstr(7,0,
"{:1d}-{:1d}-{:1d}-{:1d}".format(
98 elif c == ord(
'4'): d = -1
99 elif c == ord(
'7'): d = -2
100 elif c == ord(
'9'): d = 2
101 elif c == ord(
'6'): d = 1
102 elif c == ord(
'0'): d = 0;
PIN_OUT(0,0,0,0)
103 elif c == ord(
'5'): d = 0;
move(d)
109 stdscr.addstr(7,10,
"{:2d} {:3d}".format(d, w))
114 if __name__ ==
"__main__":
115 curses.wrapper(stepper)
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().
char * pruio_gpio_setValue(pruIo *Io, uint8 Ball, uint8 Modus)
Wrapper function for GpioUdt::setValue().
#define PIN_OUT(a, b, c, d)
Set values of all four output pins.
void move(pruIo *Io, int Rot)
Make the motor move the next step.