Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
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
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@
.project
.pydevproject
.settings
lib
radio
lib
33 changes: 33 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
pypboy
======

Remember that one Python Pip-Boy 3000 project? Neither do we!<br>
Python/Pygame interface, emulating that of the Pipboy-3000.<br>
Uses OSM for map data and has been partially tailored to respond to physical switches over Raspberry Pi's GPIO<br>

## Features

Work with Screen TFT 2.8" Capacitive of Adafruit<br>

## Autors

* By Sabas of The Inventor's House Hackerspace

* By grieve work original<br>

## Special Thanks

Ruiz Brothers for the mention in [Adafruit](https://learn.adafruit.com/raspberry-pi-pipboy-3000/overview)

## License
MIT

##Contributions

Contribuyendo a este programa se da la bienvenida con gusto.<br>

Contributing to this software is warmly welcomed. You can do this basically by [forking](https://help.github.com/articles/fork-a-repo), committing modifications and then [pulling requests](https://help.github.com/articles/using-pull-requests) (follow the links above for operating guide). Adding change log and your contact into file header is encouraged.<br>

Thanks for your contribution.

Enjoy!
33 changes: 17 additions & 16 deletions config.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import pygame

WIDTH = 480
HEIGHT = 360
WIDTH = 320
HEIGHT = 240

# OUTPUT_WIDTH = 480
# OUTPUT_HEIGHT = 360
# OUTPUT_WIDTH = 320
# OUTPUT_HEIGHT = 240

MAP_FOCUS = (-5.9347681, 54.5889076)
#MAP_FOCUS = (-5.9347681, 54.5889076)
MAP_FOCUS = (-102.3016145, 21.8841274)

EVENTS = {
'SONG_END': pygame.USEREVENT + 1
Expand All @@ -25,18 +26,18 @@
pygame.K_DOWN: "dial_down"
}

# Using GPIO.BOARD as mode
# Using GPIO.BCM as mode
GPIO_ACTIONS = {
22: "module_stats",
24: "module_items",
26: "module_data",
13: "knob_1",
11: "knob_2",
7: "knob_3",
5: "knob_4",
3: "knob_5",
# 8: "dial_up",
# 7: "dial_down"
4: "module_stats", #GPIO 4
14: "module_items", #GPIO 14
15: "module_data", #GPIO 15
17: "knob_1", #GPIO 17
18: "knob_2", #GPIO 18
7: "knob_3", #GPIO 7
22: "knob_4", #GPIO 22
23: "knob_5", #GPIO 27
# 31: "dial_up", #GPIO 23
27: "dial_down" #GPIO 7
}


Expand Down
2 changes: 1 addition & 1 deletion game/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def __init__(self, title, width, height, *args, **kwargs):
self.window = pygame.display.set_mode((width, height))
self.screen = pygame.display.get_surface()
pygame.display.set_caption(title)
pygame.mouse.set_visible(False)
pygame.mouse.set_visible(True)

self.groups = []
self.root_children = EntityGroup()
Expand Down
17 changes: 13 additions & 4 deletions game/radio.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from random import randint
import copy
import game.globals as globals
+import mutagen.oggvorbis


class Radio(game.Entity):
Expand Down Expand Up @@ -68,18 +69,26 @@ def render(self, *args, **kwargs):
self.osc.update(start*50,f,p)
if self.osc:
self.blit(self.osc.screen, (550, 150))

metadata = mutagen.File(filename, easy = True)

selectFont = pygame.font.Font('monofonto.ttf', 24)
basicFont = pygame.font.Font('monofonto.ttf', 22)
text = selectFont.render(" - Random Play Radio ", True, (105, 251, 187), (0, 0, 0))
self.blit(text, (75, 75))

text = selectFont.render(game.Entity.name, True, (105, 251, 187), (0, 0, 0))

#text = selectFont.render(" - Random Play Radio ", True, (105, 251, 187), (0, 0, 0))

self.blit(text, (75, 75))
text = basicFont.render(" 'r' selects a random song ", True, (105, 251, 187), (0, 0, 0))
self.blit(text, (75, 100))
text = basicFont.render(" 'p' to play 's' to stop ", True, (105, 251, 187), (0, 0, 0))
self.blit(text, (75, 120))

if self.filename:
text = selectFont.render(u" %s " % self.filename[self.filename.rfind(os.sep)+1:], True, (105, 251, 187), (0, 0, 0))
text = selectFont.render(" %s " % metadata["ARTIST"] + ' - ' + metadata["TITLE"], True, (105, 251, 187), (0, 0, 0))

#text = selectFont.render(u" %s " % self.filename[self.filename.rfind(os.sep)+1:], True, (105, 251, 187), (0, 0, 0))
self.blit(text, (75, 200))

super(Radio, self).update(*args, **kwargs)
Expand All @@ -93,7 +102,7 @@ def __init__(self):
self.embedded = False

def open(self, screen=None):
# Open window
# Open window
pygame.init()
if screen:
'''Embedded'''
Expand Down
28 changes: 18 additions & 10 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,30 @@
import pygame
import config
import os

# Init framebuffer/touchscreen environment variables
os.putenv('SDL_VIDEODRIVER', 'fbcon')
os.putenv('SDL_FBDEV' , '/dev/fb1')
os.putenv('SDL_MOUSEDRV' , 'TSLIB')
os.putenv('SDL_MOUSEDEV' , '/dev/input/touchscreen')

try:
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BOARD)
config.GPIO_AVAILABLE = True
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
config.GPIO_AVAILABLE = True
except Exception, e:
print "GPIO UNAVAILABLE (%s)" % e
config.GPIO_AVAILABLE = False
print "GPIO UNAVAILABLE (%s)" % e
config.GPIO_AVAILABLE = False

from pypboy.core import Pypboy

try:
pygame.mixer.init(44100, -16, 2, 2048)
config.SOUND_ENABLED = True
pygame.mixer.init(44100, -16, 2, 2048)
config.SOUND_ENABLED = True
except:
config.SOUND_ENABLED = False
config.SOUND_ENABLED = False

if __name__ == "__main__":
boy = Pypboy('Pip-Boy 3000', config.WIDTH, config.HEIGHT)
boy.run()
boy = Pypboy('Pip-Boy 3000', config.WIDTH, config.HEIGHT)
print "RUN"
boy.run()
2 changes: 1 addition & 1 deletion pypboy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def __init__(self, boy, *args, **kwargs):
for mod in self.submodules:
self.footer.menu.append(mod.label)
self.footer.selected = self.footer.menu[0]
self.footer.position = (0, config.HEIGHT - 80)
self.footer.position = (0, config.HEIGHT - 53) #80
self.add(self.footer)

self.switch_submodule(0)
Expand Down
2 changes: 1 addition & 1 deletion pypboy/modules/data/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
class Module(BaseModule):

label = "DATA"
GPIO_LED_ID = 23
GPIO_LED_ID = 28 #GPIO 23 #23

def __init__(self, *args, **kwargs):
self.submodules = [
Expand Down
2 changes: 1 addition & 1 deletion pypboy/modules/items/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
class Module(BaseModule):

label = "ITEMS"
GPIO_LED_ID = 21
GPIO_LED_ID = 29 #GPIO27 #21

def __init__(self, *args, **kwargs):
self.submodules = [
Expand Down
2 changes: 1 addition & 1 deletion pypboy/modules/stats/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
class Module(BaseModule):

label = "STATS"
GPIO_LED_ID = 19
GPIO_LED_ID = 30 #GPIO 22 #19

def __init__(self, *args, **kwargs):
self.submodules = [
Expand Down
Binary file added sounds/radio/gnr/8bits.mp3
Binary file not shown.