diff --git a/.gitignore b/.gitignore index d17d8f5a..4487e678 100644 --- a/.gitignore +++ b/.gitignore @@ -2,5 +2,4 @@ .project .pydevproject .settings -lib -radio \ No newline at end of file +lib \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 00000000..53738447 --- /dev/null +++ b/README.md @@ -0,0 +1,33 @@ +pypboy +====== + +Remember that one Python Pip-Boy 3000 project? Neither do we!
+Python/Pygame interface, emulating that of the Pipboy-3000.
+Uses OSM for map data and has been partially tailored to respond to physical switches over Raspberry Pi's GPIO
+ +## Features + +Work with Screen TFT 2.8" Capacitive of Adafruit
+ +## Autors + +* By Sabas of The Inventor's House Hackerspace + +* By grieve work original
+ +## 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.
+ +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.
+ +Thanks for your contribution. + +Enjoy! diff --git a/config.py b/config.py index 30c70cff..8bb4ea36 100644 --- a/config.py +++ b/config.py @@ -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 @@ -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 } diff --git a/game/core.py b/game/core.py index 84db5abf..8e7ca616 100644 --- a/game/core.py +++ b/game/core.py @@ -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() diff --git a/game/radio.py b/game/radio.py index 41d8e52c..31ec46f9 100644 --- a/game/radio.py +++ b/game/radio.py @@ -11,6 +11,7 @@ from random import randint import copy import game.globals as globals ++import mutagen.oggvorbis class Radio(game.Entity): @@ -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) @@ -93,7 +102,7 @@ def __init__(self): self.embedded = False def open(self, screen=None): - # Open window + # Open window pygame.init() if screen: '''Embedded''' diff --git a/main.py b/main.py index b999192e..89feae18 100644 --- a/main.py +++ b/main.py @@ -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() diff --git a/pypboy/__init__.py b/pypboy/__init__.py index 528963ed..307b718a 100644 --- a/pypboy/__init__.py +++ b/pypboy/__init__.py @@ -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) diff --git a/pypboy/modules/data/__init__.py b/pypboy/modules/data/__init__.py index 52290fbc..b27d5304 100644 --- a/pypboy/modules/data/__init__.py +++ b/pypboy/modules/data/__init__.py @@ -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 = [ diff --git a/pypboy/modules/items/__init__.py b/pypboy/modules/items/__init__.py index 18811651..2c3d4149 100644 --- a/pypboy/modules/items/__init__.py +++ b/pypboy/modules/items/__init__.py @@ -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 = [ diff --git a/pypboy/modules/stats/__init__.py b/pypboy/modules/stats/__init__.py index 4a779156..41e5dd0e 100644 --- a/pypboy/modules/stats/__init__.py +++ b/pypboy/modules/stats/__init__.py @@ -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 = [ diff --git a/sounds/radio/gnr/8bits.mp3 b/sounds/radio/gnr/8bits.mp3 new file mode 100644 index 00000000..3ebe3ec1 Binary files /dev/null and b/sounds/radio/gnr/8bits.mp3 differ