Esempio n. 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))
Esempio n. 2
0
    def configure_gi(self, config: dict) -> FASTGIString:
        """Configure a GI.

        Args:
            config: GI config.

        Returns: GI object.
        """
        # TODO: Add support for driver-based GI strings

        if not self.net_connection:
            raise AssertionError('A request was made to configure a FAST GI, '
                                 'but no connection to a NET processor is '
                                 'available')

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

        return FASTGIString(number, self.net_connection.send)