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))
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
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))
def down_arm2(): pu.i2c_write(ADDRESS_PIC, com_and_data(COM_MOV_SERVO2, CON_UP)) pass
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
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
def up_arm2(): pu.i2c_write(ADDRESS_PIC, com_and_data(COM_MOV_SERVO2, CON_DOWN)) pass
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
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))
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]))
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]))
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))