Exemple #1
0
def back():
    pu.i2c_write(ADDRESS_PIC, com_and_data(COM_SET_MORTOR1_DIR, CON_DOWN))
    pu.i2c_write(ADDRESS_PIC, com_and_data(COM_SET_MORTOR2_DIR, CON_DOWN))
Exemple #2
0
def init_pysical_status():
    pu.i2c_write(ADDRESS_PIC,
                 com_and_data(COM_SET_SERVO1_MAX, CON_DS939MG_MAX_ANGLE))
    pu.i2c_write(ADDRESS_PIC,
                 com_and_data(COM_SET_SERVO2_MAX, CON_DS939MG_MAX_ANGLE))
    pu.i2c_write(ADDRESS_PIC,
                 com_and_data(COM_SET_SERVO1_MIN, CON_DS939MG_MIN_ANGLE))
    pu.i2c_write(ADDRESS_PIC,
                 com_and_data(COM_SET_SERVO2_MIN, CON_DS939MG_MIN_ANGLE))
    pu.i2c_write(ADDRESS_PIC,
                 com_and_data(COM_SET_SERVO1_POW, CON_DS939MG_POWER_MODERATE))
    pu.i2c_write(ADDRESS_PIC,
                 com_and_data(COM_SET_SERVO2_POW, CON_DS939MG_POWER_MODERATE))

    global current_gear
    #current_gear = CON_POWER_STEP / 2
    current_gear = CON_POWER_STEP - 1
    pu.i2c_write(
        ADDRESS_PIC,
        com_and_data(COM_SET_MORTOR_POW, CON_MORTOR_POWERS[current_gear]))

    #init arm
    pu.i2c_write(ADDRESS_PIC, com_and_data(COM_MOV_SERVO1, CON_DOWN))
    pu.i2c_write(ADDRESS_PIC, com_and_data(COM_MOV_SERVO2, CON_DOWN))
    time.sleep(3)
    pass
Exemple #3
0
def forward():
    pu.i2c_write(ADDRESS_PIC, com_and_data(COM_SET_MORTOR1_DIR, CON_UP))
    pu.i2c_write(ADDRESS_PIC, com_and_data(COM_SET_MORTOR2_DIR, CON_UP))
Exemple #4
0
def down_arm2():
    pu.i2c_write(ADDRESS_PIC, com_and_data(COM_MOV_SERVO2, CON_UP))
    pass
Exemple #5
0
def stop_arm2():
    pu.i2c_write(ADDRESS_PIC, com_and_data(COM_MOV_SERVO2, CON_MIDDLE))
    pu.i2c_write(ADDRESS_PIC, com_and_data(COM_MOV_SERVO2, CON_MIDDLE))
    pu.i2c_write(ADDRESS_PIC, com_and_data(COM_MOV_SERVO2, CON_MIDDLE))
    pass
Exemple #6
0
def down_arm1():
    pu.i2c_write(ADDRESS_PIC, com_and_data(COM_MOV_SERVO1, CON_DOWN))
    pu.i2c_write(ADDRESS_PIC, com_and_data(COM_MOV_SERVO2, CON_DOWN))
    pass
Exemple #7
0
def up_arm2():
    pu.i2c_write(ADDRESS_PIC, com_and_data(COM_MOV_SERVO2, CON_DOWN))
    pass
Exemple #8
0
def up_arm1():
    pu.i2c_write(ADDRESS_PIC, com_and_data(COM_MOV_SERVO1, CON_UP))
    pu.i2c_write(ADDRESS_PIC, com_and_data(COM_MOV_SERVO2, CON_UP))
    pass
Exemple #9
0
def stop():
    pu.i2c_write(ADDRESS_PIC, com_and_data(COM_SET_MORTOR1_DIR, CON_MIDDLE))
    pu.i2c_write(ADDRESS_PIC, com_and_data(COM_SET_MORTOR2_DIR, CON_MIDDLE))
Exemple #10
0
def speed_down():
    global current_gear
    current_gear = max(0, current_gear - 1)
    pu.i2c_write(
        ADDRESS_PIC,
        com_and_data(COM_SET_MORTOR_POW, CON_MORTOR_POWERS[current_gear]))
Exemple #11
0
def speed_up():
    global current_gear
    current_gear = min(CON_POWER_STEP - 1, current_gear + 1)
    pu.i2c_write(
        ADDRESS_PIC,
        com_and_data(COM_SET_MORTOR_POW, CON_MORTOR_POWERS[current_gear]))
Exemple #12
0
def left_turn():
    pu.i2c_write(ADDRESS_PIC, com_and_data(COM_SET_MORTOR1_DIR, CON_UP))
    pu.i2c_write(ADDRESS_PIC, com_and_data(COM_SET_MORTOR2_DIR, CON_DOWN))