diff --git a/.vscode/ipch/2b4ff356d5e809d2/mmap_address.bin b/.vscode/ipch/2b4ff356d5e809d2/mmap_address.bin new file mode 100644 index 0000000..862b842 Binary files /dev/null and b/.vscode/ipch/2b4ff356d5e809d2/mmap_address.bin differ diff --git a/config.py b/config.py new file mode 100644 index 0000000..e4d63eb --- /dev/null +++ b/config.py @@ -0,0 +1,77 @@ +""" Override config values from config_base using this file """ +from config_base import * + + +""" Configure the plugin set """ + +# -- Enable camera, replays and video motiondetector +#plugins.update(set(['replay', 'camera', 'motiondetector'])) +#camera_preview = "-p 0,0,128,72" + +# -- Modify this to tune your camera settings - see raspivid --help for more info +#camera_extra_params = "--ev 7" +#draw_bg_with_dispmanx = False + +blank_console = False + +# -- Enable league sync with server +#plugins.add('league_sync') + +# -- Enable Youtube video upload +#plugins.add('upload') + +# -- Enable hipchat bot +#plugins.add('hipbot') + +# -- Enable Arduino serial input and led output +#plugins.add('io_serial') + +# -- Enable auto-TV standby +#plugins.add('standby') + +# -- Enable IO using Raspberry Pi. Change pin numbers according to your setup. +# -- PWM output for the IR led is BCM18 (hardware PWM pin) +plugins.add('io_raspberry') +io_raspberry_pins = { + "irbarrier_team_black": 8, # Physical pin 8 + "irbarrier_team_yellow": 26, # Physical pin 26 + "yellow_plus" : 10, # Physical pin 10 + "yellow_minus": 16, # Physical pin 16 + "black_plus": 3, # Physical pin 3 + "black_minus": 22, # Physical pin 22 + "ok_button": 24, # Physical pin 24 +} + +# -- Modify clock format: see strftime +#clock_format = "%-I:%M %p" # 12 hour format + +""" Configure team names and colors """ +team_names = {"yellow": "bleus", "black": "rouges"} +team_colors = {"yellow": (0.1, 0.1, 0.4), "black": (0.7, 0, 0)} + +# game modes: tuples of (winning score, timeout in minutes) +game_modes = [(None, None), (5, None), (7, None), (10, None), (3, 120)] + +# Customize winner strings +winner_strings = ["Victoire des {}!","Des kings les {}!","Les {} déchirent!","Trop forts les {}!","Faites place aux {}!","You rock !!!"] + +""" Configure paths """ + +# -- replay path +replay_save_path = "./replay" +replay_fps = 25 +save_replays = True + +# -- or the location of the file_handler +#log["handlers"]["file_handler"]["filename"] = "" + + +""" Override tokens for plugins """ + +#hipchat_token = 'your_token' +#hipchat_room = 'your_room_id' + +league_url = 'http://localhost:4567/api' +league_apikey = 'API_KEY_HERE' + +#slack_webhook = 'https://hooks.slack.com/services/BLAW/BLAW' diff --git a/config.py.sample b/config.py.sample index 9df88fb..f57506a 100755 --- a/config.py.sample +++ b/config.py.sample @@ -45,6 +45,9 @@ from config_base import * #team_names = {"yellow": "blue", "black": "red"} #team_colors = {"yellow": (0.1, 0.1, 0.4), "black": (0.7, 0, 0)} +# Customize winner strings +#winner_strings = ["{} wins!","You rock, {}!"] + """ Configure paths """ # -- replay path diff --git a/config_base.py b/config_base.py index cb8c651..7bbd11b 100644 --- a/config_base.py +++ b/config_base.py @@ -24,7 +24,12 @@ # game modes: tuples of (winning score, timeout in minutes) game_modes = [(None, None), (3, None), (5, None), (3, 120)] +# Winner strings +winner_strings = ["{} wins!","You rock, {}!"] + replay_path = '/dev/shm/replay' +save_replays = False +replay_save_path = "./replay" replay_fps = 25 ignore_recent_chunks = 1 short_chunks = 10 diff --git a/doc/HWSetup.md b/doc/HWSetup.md index cd82369..efa8212 100644 --- a/doc/HWSetup.md +++ b/doc/HWSetup.md @@ -88,9 +88,11 @@ You can also run the whole setup without an Arduino and use the RaspberryPI to g You only have to connect everything directly to the RaspberryPi GPIO and enable the io_raspberry plugin (see config.py.sample for config options). Verify the pin numbers in the config, and you're good to go! -For now you'll need to run with sudo to give access to the GPIO pins. + Thanks to Adam Bartha for this! +![schematic](foos_RPi_only_schema.png) + ## BOM * [Raspberry Pi2](https://www.raspberrypi.org/products/raspberry-pi-2-model-b/) diff --git a/doc/foos_RPi_only.fzz b/doc/foos_RPi_only.fzz new file mode 100644 index 0000000..ce3156f Binary files /dev/null and b/doc/foos_RPi_only.fzz differ diff --git a/doc/foos_RPi_only_schema.png b/doc/foos_RPi_only_schema.png new file mode 100644 index 0000000..babb249 Binary files /dev/null and b/doc/foos_RPi_only_schema.png differ diff --git a/foos/ui/ui.py b/foos/ui/ui.py index 5a0566e..1e4cabc 100755 --- a/foos/ui/ui.py +++ b/foos/ui/ui.py @@ -180,23 +180,28 @@ def __init__(self, shader, teams=["yellow", "black"]): duration = 5 drop_duration = 0.2 self.shapes = {} - for team in teams: - s = FixedOutlineString(font, "{} wins!".format(utils.teamName(team).capitalize()), outline_size=2, font_size=180, shader=shader) - s = Move(Disappear(s.sprite, duration=duration), duration=drop_duration) - self.shapes[team] = s + for i, team in enumerate(teams): + self.shapes[team] = [] + for j, winnerString in enumerate(config.winner_strings): + s = FixedOutlineString(font, winnerString.format(utils.teamName(team).capitalize()), outline_size=2, font_size=180, shader=shader) + s = Move(Disappear(s.sprite, duration=duration), duration=drop_duration) + self.shapes[team].append(s) def draw(self): for team, s in self.shapes.items(): - s.draw() + for shape in s: + shape.draw() def show_winner(self, team): for t, s in self.shapes.items(): if team == t: - s.position(0, 650, 40) - s.moveTo((0, 330, 40), (1, 1, 1)) - s.show() + shape = random.choice(s) + shape.position(0, 650, 40) + shape.moveTo((0, 330, 40), (1, 1, 1)) + shape.show() else: - s.hide() + for shape in s: + shape.hide() class Gui(): diff --git a/plugins/replay.py b/plugins/replay.py index 075b2c7..58faa54 100644 --- a/plugins/replay.py +++ b/plugins/replay.py @@ -4,6 +4,7 @@ from foos.process import call_and_log from foos.platform import is_pi +from shutil import copyfile class Plugin: def __init__(self, bus): @@ -18,6 +19,14 @@ def replay(self, replay_type, trigger, extra={}): call_and_log(["video/generate-replay.sh", config.replay_path, str(config.ignore_recent_chunks), str(config.long_chunks), str(config.short_chunks)]) + + # If we want to keep replays, make a copy of the files with a timestamp. + if config.save_replays == True: + copyfile(os.path.join(config.replay_save_path, "replay_short.h264"), + os.path.join(config.replay_save_path, "{}_replay_short.h264".format(int(time.time())))) + copyfile(os.path.join(config.replay_save_path, "replay_long.h264"), + os.path.join(config.replay_save_path, "{}_replay_long.h264".format(int(time.time())))) + self.bus.notify('replay_start', extra) if is_pi(): call_and_log(["video/replay.sh", os.path.join(config.replay_path, "replay_{}.h264".format(replay_type)), str(config.replay_fps)])