예제 #1
0
while c != 'q' and c != 'Q':
    t0 = time.time()
    r0 = m0.get_radians()
    c = getch()
    t1 = time.time()
    r1 = m0.get_radians()
    print("{0}, {1}".format(voltage, (r1 - r0)/(t1 - t0)))
    if ord(c) == 27:
        c = getch()
        if ord(c) == 91:
            c = getch()
            if ord(c) in key_map.keys():
                print(key_map[ord(c)])
                if key_map[ord(c)] == 'up':
                    voltage += voltage_step
                elif key_map[ord(c)] == 'down':
                    voltage -= voltage_step
    elif ord(c) == 32:
        pass
    else:
        print(ord(c))
    if voltage > 100:
        volate = 100
    if voltage < -100:
        voltage = -100
    m0.get_radians()
    m0.set_voltage(voltage)

m0.set_encoder(0)
m0.close()