Beispiel #1
0
    def configure_light(self, number, subtype, platform_settings) -> LightPlatformInterface:
        """Configure light in platform."""
        if not self.net_connection:
            raise AssertionError('A request was made to configure a FAST Light, '
                                 'but no connection to a NET processor is '
                                 'available')
        if subtype == "gi":
            return FASTGIString(number, self.net_connection.send, self.machine,
                                int(1 / self.machine.config['mpf']['default_light_hw_update_hz'] * 1000))
        if subtype == "matrix":
            return FASTMatrixLight(number, self.net_connection.send, self.machine,
                                   int(1 / self.machine.config['mpf']['default_light_hw_update_hz'] * 1000), self)
        if not subtype or subtype == "led":
            if not self.flag_led_tick_registered:
                # Update leds every frame
                self._led_task = self.machine.clock.schedule_interval(
                    self.update_leds, 1 / self.machine.config['mpf']['default_light_hw_update_hz'])
                self.flag_led_tick_registered = True

            number_str, channel = number.split("-")
            if number_str not in self.fast_leds:
                self.fast_leds[number_str] = FASTDirectLED(
                    number_str, int(self.config['hardware_led_fade_time']))
            fast_led_channel = FASTDirectLEDChannel(self.fast_leds[number_str], channel)

            return fast_led_channel

        raise AssertionError("Unknown subtype {}".format(subtype))
Beispiel #2
0
    def configure_matrixlight(self, config: dict) -> FASTMatrixLight:
        """Configure a matrix light.

        Args:
            config: Matrix light config.

        Returns: Matrix light object.
        """
        if not self.net_connection:
            raise AssertionError('A request was made to configure a FAST '
                                 'matrix light, but no connection to a NET '
                                 'processor is available')

        if self.machine_type == 'wpc':  # translate number to FAST light num
            number = fast_defines.wpc_light_map.get(
                str(config['number']).upper())
        else:
            number = self.convert_number_from_config(config['number'])

        return FASTMatrixLight(number, self.net_connection.send)