Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .vscode/ipch/2b4ff356d5e809d2/mmap_address.bin
Binary file not shown.
77 changes: 77 additions & 0 deletions config.py
Original file line number Diff line number Diff line change
@@ -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"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't add your config to the repo (same goes for the .vscode files)


# -- 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'
3 changes: 3 additions & 0 deletions config.py.sample
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions config_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion doc/HWSetup.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/)
Expand Down
Binary file added doc/foos_RPi_only.fzz
Binary file not shown.
Binary file added doc/foos_RPi_only_schema.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 14 additions & 9 deletions foos/ui/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
9 changes: 9 additions & 0 deletions plugins/replay.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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)])
Expand Down