Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' into rpi_platform
- Loading branch information
Showing
52 changed files
with
2,245 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
from typing import TYPE_CHECKING | ||
|
||
from mpf.config_players.device_config_player import DeviceConfigPlayer | ||
|
||
if TYPE_CHECKING: | ||
from mpf.devices.hardware_sound_system import HardwareSoundSystem | ||
|
||
|
||
class HardwareSoundPlayer(DeviceConfigPlayer): | ||
|
||
"""Generates texts """ | ||
|
||
config_file_section = 'hardware_sound_player' | ||
show_section = 'hardware_sound_players' | ||
|
||
def play(self, settings, context, calling_context, priority=0, **kwargs): | ||
"""Show text on display""" | ||
del kwargs | ||
del context | ||
del calling_context | ||
|
||
for sound, s in settings.items(): | ||
sound_system = s['sound_system'] # type: HardwareSoundSystem | ||
|
||
if s['action'] == "stop": | ||
sound_system.stop_all_sounds() | ||
elif s['action'] == "play": | ||
sound_system.play(sound) | ||
else: | ||
raise AssertionError("Invalid action {}".format(s['action'])) | ||
|
||
def get_express_config(self, value): | ||
"""Parse express config.""" | ||
return dict(action=value) | ||
|
||
def get_string_config(self, string): | ||
"""Parse string config.""" | ||
if string == "stop": | ||
return {string: dict(action="stop")} | ||
else: | ||
return super().get_string_config(string) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
from mpf.core.delays import DelayManager | ||
|
||
from mpf.config_players.device_config_player import DeviceConfigPlayer | ||
|
||
|
||
class SegmentDisplayPlayer(DeviceConfigPlayer): | ||
|
||
"""Generates texts """ | ||
|
||
config_file_section = 'segment_display_player' | ||
show_section = 'segment_displays' | ||
machine_collection_name = 'segment_displays' | ||
|
||
def __init__(self, machine): | ||
"""Initialise SegmentDisplayPlayer.""" | ||
super().__init__(machine) | ||
self.delay = DelayManager(self.machine.delayRegistry) | ||
|
||
def play(self, settings, context, calling_context, priority=0, **kwargs): | ||
"""Show text on display""" | ||
del kwargs | ||
instance_dict = self._get_instance_dict(context) | ||
full_context = self._get_full_context(context) | ||
|
||
for display, s in settings.items(): | ||
action = s['action'] | ||
if not display in instance_dict: | ||
instance_dict[display] = {} | ||
|
||
key = full_context + "." + display.name | ||
|
||
if s['key']: | ||
key += s['key'] | ||
|
||
if action == "add": | ||
# in case it is already there | ||
self._remove(instance_dict=instance_dict, key=key, display=display) | ||
# add text | ||
display.add_text(s['text'], priority + s['priority'], key) | ||
|
||
if s['expire']: | ||
instance_dict[display][key] = self.delay.add(s['expire'], self._remove, | ||
instance_dict=instance_dict, | ||
key=key, | ||
display=display) | ||
else: | ||
instance_dict[display][key] = True | ||
elif action == "remove": | ||
self._remove(instance_dict=instance_dict, key=key, display=display) | ||
else: | ||
raise AssertionError("Invalid action {}".format(action)) | ||
|
||
def _remove(self, instance_dict, key, display): | ||
if key in instance_dict[display]: | ||
display.remove_text_by_key(key) | ||
if instance_dict[display][key] is not True: | ||
self.delay.remove(instance_dict[display][key]) | ||
del instance_dict[display][key] | ||
|
||
def clear_context(self, context): | ||
"""Remove all texts.""" | ||
full_context = self._get_full_context(context) | ||
instance_dict = self._get_instance_dict(context) | ||
for display, keys in instance_dict.items(): | ||
for key in dict(keys).keys(): | ||
self._remove(instance_dict=instance_dict, key=key, display=display) | ||
|
||
self._reset_instance_dict(context) | ||
|
||
def get_express_config(self, value): | ||
"""Parse express config.""" | ||
return dict(action="add", text=value) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.