def device_class_init(cls, machine: MachineController): """Initialise lights. Args: machine: MachineController object """ cls.machine = machine cls.lights_to_fade = set() cls.lights_to_update = set() machine.validate_machine_config_section('matrix_light_settings') cls._updater_task = machine.clock.schedule_interval( cls.update_matrix_lights, 1 / machine.config['mpf']['default_matrix_light_hw_update_hz']) machine.mode_controller.register_stop_method(cls.mode_stop) machine.settings.add_setting( SettingEntry("brightness", "Brightness", 100, "brightness", 1.0, { 0.25: "25%", 0.5: "50%", 0.75: "75%", 1.0: "100% (default)" }))
def device_class_init(cls, machine: MachineController): """Initialise all LEDs. Args: machine: MachineController which is used """ cls.machine = machine cls.leds_to_fade = set() cls.leds_to_update = set() machine.validate_machine_config_section('led_settings') if machine.config['led_settings']['color_correction_profiles'] is None: machine.config['led_settings']['color_correction_profiles'] = ( dict()) # Generate and add color correction profiles to the machine machine.led_color_correction_profiles = dict() # Create the default color correction profile and add it to the machine default_profile = RGBColorCorrectionProfile.default() machine.led_color_correction_profiles['default'] = default_profile # Add any user-defined profiles specified in the machine config file for profile_name, profile_parameters in ( machine.config['led_settings'] ['color_correction_profiles'].items()): machine.config_validator.validate_config( 'color_correction_profile', machine.config['led_settings'] ['color_correction_profiles'][profile_name], profile_parameters) profile = RGBColorCorrectionProfile(profile_name) profile.generate_from_parameters( gamma=profile_parameters['gamma'], whitepoint=profile_parameters['whitepoint'], linear_slope=profile_parameters['linear_slope'], linear_cutoff=profile_parameters['linear_cutoff']) machine.led_color_correction_profiles[profile_name] = profile # schedule the single machine-wide update to write the current led of # each LED to the hardware cls._updater_task = machine.clock.schedule_interval( cls.update_leds, 1 / machine.config['mpf']['default_led_hw_update_hz']) machine.mode_controller.register_stop_method(cls.mode_stop) machine.settings.add_setting( SettingEntry("brightness", "Brightness", 100, "brightness", 1.0, { 0.25: "25%", 0.5: "50%", 0.75: "75%", 1.0: "100% (default)" }))