예제 #1
0
 def reset(self):
     """Reset all lights to off
     """
     internal.sendMidiMessage(0xBF, 0x00, 0x00)
     internal.debugLog("Sent lighting reset signal", internal.consts.DEBUG.LIGHTING_RESET)
     internal.window.resetAnimationTick()
     self.__init__()
    def getType(self):
        """Returns string detailing type and ID of event

        Returns:
            str: Type and ID of event info
        """
        a = ""
        b = ""
        if self.type is eventconsts.TYPE_UNRECOGNISED:
            a = "Unrecognised"
        elif self.type is eventconsts.TYPE_SYSEX_EVENT:
            a = "Sysex"
        elif self.type is eventconsts.TYPE_NOTE:
            a = "Note"
            b = utils.GetNoteName(self.note) + " (Ch. " + str(
                self.channel) + ')'
        elif self.type is eventconsts.TYPE_SYSTEM_MSG:
            a = "System"
            b = self.getID_System()
        elif self.type is eventconsts.TYPE_INCONTROL:
            a = "InControl"
            b = self.getID_InControl()
        elif self.type is eventconsts.TYPE_TRANSPORT:
            a = "Transport"
            b = self.getID_Transport()
        elif self.type is eventconsts.TYPE_KNOB or self.type is eventconsts.TYPE_BASIC_KNOB:
            a = "Knob"
            b = self.getID_Knobs()
        elif self.type is eventconsts.TYPE_FADER or self.type is eventconsts.TYPE_BASIC_FADER:
            a = "Fader"
            b = self.getID_Fader()
        elif self.type is eventconsts.TYPE_FADER_BUTTON or self.type is eventconsts.TYPE_BASIC_FADER_BUTTON:
            a = "Fader Button"
            b = self.getID_FaderButton()
        elif self.type is eventconsts.TYPE_PAD:
            a = "Pad"
            b = self.getID_Pads()
        elif self.type is eventconsts.TYPE_BASIC_PAD:
            a = "Pad (Basic)"
            b = self.getID_Pads()
        elif self.type is eventconsts.TYPE_BASIC_EVENT:
            a = "Basic Event"
            b = self.getID_Basic()
        elif self.type is eventconsts.TYPE_INTERNAL_EVENT:
            a = "Internal event"
        else:
            internal.debugLog("Bad event type")
            a = "ERROR!!!"
        a = internal.getTab(a)
        return a + b
    def appendAction(self,
                     act,
                     silent=False,
                     handle_type=internal.consts.EVENT_NO_HANDLE):
        """Appends an action to the current event processor

        Args:
            act (str): The action taken
            silent (bool, optional): Whether the action should be set as a hint message. Defaults to False.
            handled (int, optional): How the action handled/ignored the event. Defaults to internal.consts.EVENT_NO_HANDLE.
        """

        # Add some random processor if a processor doesn't exist for some reason
        if len(self.eventProcessors) == 0:
            self.addProcessor("NoProcessor")
            internal.debugLog(
                "Added NoProcessor Processor",
                internal.consts.DEBUG.WARNING_DEPRECIATED_FEATURE)
        # Append the action
        self.eventProcessors[len(self.eventProcessors) - 1].appendAction(
            act, silent, handle_type)
    def flush(self):
        """Log all actions taken, and set a hint message if applicable
        """
        # Log all actions taken
        for x in range(len(self.eventProcessors)):
            internal.debugLog(self.eventProcessors[x].getString(),
                              internal.consts.DEBUG.EVENT_ACTIONS)

        # Get hint message to set (ignores silent messages)
        hint_msg = ""
        for x in range(len(self.eventProcessors)):
            cur_msg = self.eventProcessors[x].getHintMsg()

            # Might want to fix this some time, some handler modules append this manually
            if cur_msg != "" and cur_msg != "[Did not handle]":
                hint_msg = cur_msg

        if hint_msg != "":
            # Sometimes this fails...
            try:
                ui.setHintMsg(hint_msg)
            except:
                pass
        self.eventProcessors.clear()
 def printOutput(self):
     """Prints actions taken whilst handling event
     """
     if internal.consts.DEBUG.PRINT_INTERNAL_EVENTS in config.CONSOLE_DEBUG_MODE or self.type != eventconsts.TYPE_INTERNAL_EVENT:
         internal.debugLog("", internal.consts.DEBUG.EVENT_ACTIONS)
         self.actions.flush()
         if self.handled:
             internal.debugLog("[Event was handled]",
                               internal.consts.DEBUG.EVENT_ACTIONS)
         else:
             internal.debugLog("[Event wasn't handled]",
                               internal.consts.DEBUG.EVENT_ACTIONS)
예제 #6
0
    def setPadColour(self, x, y, colour, state = lightingconsts.MODE_DEFAULT, override = False):
        """Set the colour of a pad

        Args:
            x (int): X coordinate
            y (int): Y coordinate
            colour (int): Colour option
            state (int, optional): Light mode. Defaults to lightingconsts.MODE_DEFAULT.
            override (bool, optional): Whether the event should be sent regardless of the 
                current state of that pad. Defaults to False.
        """
        if internal.window.getAbsoluteTick() % config.LIGHTS_FULL_REDRAW_FREQUENCY == 0:
            full_redraw = True
        else:
            full_redraw = False
            
        
        # Handle light offs
        if colour == 0 and state == lightingconsts.MODE_DEFAULT:
            state = lightingconsts.MODE_OFF

        # Set legacy state
        elif state == lightingconsts.MODE_DEFAULT:
            state = lightingconsts.MODE_ON

        if state == lightingconsts.MODE_OFF:
            colour = 0

        # Check if pad is already in that state - don't bother with event if so
        if self.PadColours[x][y] == colour and self.PadStates[x][y] == state and not override and not full_redraw:
            return

        # Set state variables
        self.PadColours[x][y] = colour
        self.PadStates[x][y] = state

        status_a = 0x9
        status_b = 0xF

        if state == lightingconsts.MODE_OFF:
            status_a = 0x8

        elif state == lightingconsts.MODE_PULSE:
            status_b = 0x2

        elif state > 0:
            status_b = 0xF

        # Round pads in basic mode
        if x == 8 and not internal.extendedMode.query(eventconsts.INCONTROL_PADS):
            status_a = 0xB

        # Calculate Status
        status = (status_a << 4) + status_b

        if internal.extendedMode.query(eventconsts.INCONTROL_PADS): 
            internal.sendMidiMessage(status, eventconsts.Pads[x][y], colour)
            internal.debugLog("Sent lighting command [" + str(x) + ", " + str(y) + "] (InControl Enabled)", internal.consts.DEBUG.LIGHTING_MESSAGE)
            
        else: 
            internal.sendMidiMessage(status, processorhelpers.convertPadMapping(eventconsts.Pads[x][y]), colour)
            internal.debugLog("Sent lighting command [" + str(x) + ", " + str(y) + "] (InControl Disabled)", internal.consts.DEBUG.LIGHTING_MESSAGE)
        
        if state > 0: # Send extra event to trigger flashing
            status_b = 0x1
            status = (status_a << 4) + status_b

            if internal.extendedMode.query(eventconsts.INCONTROL_PADS): 
                
                internal.sendMidiMessage(status, eventconsts.Pads[x][y], state)
                internal.debugLog("Sent light flash command [" + str(x) + ", " + str(y) + "] (InControl Enabled)", internal.consts.DEBUG.LIGHTING_MESSAGE)
                
            else: 
                internal.sendMidiMessage(status, processorhelpers.convertPadMapping(eventconsts.Pads[x][y]), state)
                internal.debugLog("Sent light flash command [" + str(x) + ", " + str(y) + "] (InControl Disabled)", internal.consts.DEBUG.LIGHTING_MESSAGE)
 def printInfo(self):
     """Prints string info about event
     """
     internal.debugLog(self.getInfo(), internal.consts.DEBUG.EVENT_DATA)
def onInit():
    internal.debugLog("Running on 61-key model",
                      internal.consts.DEBUG.DEVICE_TYPE)