20 from libpruio
import *
35 io =
pruio_new(PRUIO_DEF_ACTIVE, 4, 0x98, 0)
38 if IO.Errr:
raise AssertionError(
"pruio_new failed (%s)" % IO.Errr)
40 raise AssertionError(
"failed setting input @P_IN (%s)" % IO.Errr)
46 raise AssertionError(
"failed setting output @POUT (%s)" % IO.Errr)
49 raise AssertionError(
"config failed (%s)" % IO.Errr)
51 form =
"Frequency: %10.2f , Duty: %2.8f"
52 stdscr.addstr(0,0,
"--> " + form % (f0.value, d0.value));
55 raise AssertionError(
"failed reading input @P_IN (%s)" % IO.Errr)
56 stdscr.addstr(1,4, form % (f1.value, d1.value))
59 if c == ord(
'-'): f0.value = 0.5
60 elif c == ord(
'+'): f0.value = 1000000.
62 if f0.value > 5.5: f0.value -= 5.
65 if f0.value < 999995.: f0.value += 5.
66 else: f0.value = 1000000.
68 if f0.value < 500000.: f0.value *= 2
69 else: f0.value = 1000000.
71 if f0.value > 1.: f0.value /= 2
73 elif c == ord(
'0'): d0.value = 0.0
74 elif c == ord(
'1'): d0.value = 0.1
75 elif c == ord(
'2'): d0.value = 0.2
76 elif c == ord(
'3'): d0.value = 0.3
77 elif c == ord(
'4'): d0.value = 0.4
78 elif c == ord(
'5'): d0.value = 0.5
79 elif c == ord(
'6'): d0.value = 0.6
80 elif c == ord(
'7'): d0.value = 0.7
81 elif c == ord(
'8'): d0.value = 0.8
82 elif c == ord(
'9'): d0.value = 0.9
83 elif c == ord(
','): d0.value = 1.
84 elif c == ord(
'.'): d0.value = 1.
87 raise AssertionError(
"failed setting PWM output (%s)" % IO.Errr)
88 stdscr.addstr(0,4, form % (f0.value, d0.value))
92 if __name__ ==
"__main__":
93 curses.wrapper(pwm_cap)
char * pruio_config(pruIo *Io, uint32 Samp, uint32 Mask, uint32 Tmr, uint16 Mds)
Wrapper function for PruIo::config().
char * pruio_cap_Value(pruIo *Io, uint8 Ball, float_t *Hz, float_t *Du)
Wrapper function for CapMod::Value().
char * pruio_pwm_setValue(pruIo *Io, uint8 Ball, float_t Hz, float_t Du)
Wrapper function for PwmMod::setValue().
pruIo * pruio_new(uint16 Act, uint8 Av, uint32 OpD, uint8 SaD)
Wrapper function for the constructor PruIo::PruIo().
char * pruio_cap_config(pruIo *Io, uint8 Ball, float_t FLow)
Wrapper function for CapMod::config().
void pruio_destroy(pruIo *Io)
Wrapper function for the destructor PruIo::~PruIo().