Пример #1
0
def playback_instruction(pin_type, pin_index, value):
    if pin_type == "d":
        # print "DIGITAL,  PIN_INDEX: ", pin_index, "VALUE: ", value
        mctransmitter.tx_digital(pin_index, value)
    elif pin_type == "a":
        # print "ANALOG,  PIN_INDEX: ", pin_index, "VALUE: ", value
        mctransmitter.tx_analog(pin_index, value)
Пример #2
0
 def update(self, button_type, button_index, button_value):
     if (button_type == global_data.TYPE_BUTTON):
         if (button_index == global_data.BUTTON_X):
             mctransmitter.tx_digital(0, button_value)
         elif (button_index == global_data.BUTTON_Y):
             mctransmitter.tx_digital(1, button_value)
         elif ((button_index == global_data.BUTTON_A) and button_value):
             mctransmitter.tx_digital(0, not global_data.digital_0_sent)
         elif ((button_index == global_data.BUTTON_B) and button_value):
             mctransmitter.tx_digital(1, not global_data.digital_1_sent)
     elif (button_type == global_data.TYPE_AXIS):
         if (button_index == global_data.AXIS_LEFT_TRIGGER):
             tx_value = 127 - (button_value / 2)
             mctransmitter.tx_analog(0, tx_value)
         if (button_index == global_data.AXIS_RIGHT_TRIGGER):
             tx_value = 127
             if (button_value > 0.0):
                 tx_value = 128 + (button_value / 2)
             mctransmitter.tx_analog(0, tx_value)
Пример #3
0
            control_mode = (control_mode + 1) % 3
            input_value = 0
            input_state = False


        # LEFT COLUMN
        elif (control_mode == CONTROL_MANUAL):
            if (event.type == pygame.KEYDOWN):
                if ((event.key == KEY_UP) and motorstate[current_motor] == 0):
                    current_motor = (current_motor - 1) % NUM_MOTORS
                elif ((event.key == KEY_DOWN) and motorstate[current_motor] == 0):
                    current_motor = (current_motor + 1) % NUM_MOTORS
                elif (event.key == KEY_LEFT):
                    if (motorstate[current_motor] == 0):
                        motorstate[current_motor] = 1
                        mctransmitter.tx_analog(current_motor, 1)
                elif (event.key == KEY_RIGHT):
                    if (motorstate[current_motor] == 0):
                        motorstate[current_motor] = 2
                        mctransmitter.tx_analog(current_motor, 2)
            elif (event.type == pygame.KEYUP):
                if ((event.key == KEY_LEFT) or (event.key == KEY_RIGHT)):
                    motorstate[current_motor] = 0
                    mctransmitter.tx_analog(current_motor, 0)


        # MIDDLE COLUMN
        elif (control_mode == CONTROL_TRANSMIT):
            if event.type == pygame.KEYDOWN:

                if (event.key == KEY_TRANSFER):
Пример #4
0
import mctransmitter
mctransmitter.initialize()

mctransmitter.tx_analog(0,0)
mctransmitter.tx_analog(1,0)
mctransmitter.tx_digital(0,0)
mctransmitter.tx_digital(1,0)