From 63f13ff045862b46db63857b10b97418a786c6de Mon Sep 17 00:00:00 2001 From: Justin Revelstoke Date: Tue, 13 Feb 2024 12:31:40 -0800 Subject: [PATCH 01/14] Upgrade to python 3.11 --- button.py | 6 +++--- jeoparpy/game/__init__.py | 4 ++-- jeoparpy/game/gamedata.py | 4 ++-- jeoparpy/game/gamestate.py | 4 ++-- jeoparpy/main.py | 8 ++++---- jeoparpy/selectMenu.py | 6 +++--- jeoparpy/ui/__init__.py | 10 +++++----- jeoparpy/ui/audioplayer.py | 2 +- jeoparpy/ui/categoryscroll.py | 8 ++++---- jeoparpy/ui/congrats.py | 6 +++--- jeoparpy/ui/controller.py | 6 +++--- jeoparpy/ui/credits.py | 6 +++--- jeoparpy/ui/intro.py | 6 +++--- jeoparpy/ui/maingame/__init__.py | 8 ++++---- jeoparpy/ui/maingame/clue.py | 4 ++-- jeoparpy/ui/maingame/gameboard.py | 2 +- jeoparpy/ui/maingame/podiapanel.py | 4 ++-- jeoparpy/ui/maingame/podium.py | 4 ++-- requirements.txt | 6 ++++-- start.py | 2 +- 20 files changed, 54 insertions(+), 52 deletions(-) diff --git a/button.py b/button.py index 043d4e9..8bedf37 100644 --- a/button.py +++ b/button.py @@ -11,8 +11,8 @@ def __init__(self): #Setup pins and board gpio.setmode(gpio.BCM) gpio.setup(22, gpio.IN, pull_up_down=gpio.PUD_UP) - gpio.setup(4, gpio.IN, pull_up_down=gpio.PUD_UP) - gpio.setup(17, gpio.IN, pull_up_down=gpio.PUD_UP) + gpio.setup(4, gpio.IN, pull_up_down=gpio.PUD_UP) + gpio.setup(17, gpio.IN, pull_up_down=gpio.PUD_UP) #Put pins in variables self.center_button = 22 @@ -92,4 +92,4 @@ def check(self): while True: test.first = '' winner = test.poll() - print winner + print(winner) diff --git a/jeoparpy/game/__init__.py b/jeoparpy/game/__init__.py index 85bf85c..f66ed7b 100644 --- a/jeoparpy/game/__init__.py +++ b/jeoparpy/game/__init__.py @@ -15,5 +15,5 @@ See the "Customization" section of the README for details on how to alter the resource files from which the game data is built. """ -from gamedata import GameData -from gamestate import JeopGameState +from .gamedata import GameData +from .gamestate import JeopGameState diff --git a/jeoparpy/game/gamedata.py b/jeoparpy/game/gamedata.py index 3d0a689..e3f0a28 100644 --- a/jeoparpy/game/gamedata.py +++ b/jeoparpy/game/gamedata.py @@ -14,8 +14,8 @@ """ from sys import stderr -from constants import AMOUNTS_PATH, CATEGORIES_PATH, CLUES_PATH, PLAYERS_PATH -from jeopplayer import JeopPlayer +from .constants import AMOUNTS_PATH, CATEGORIES_PATH, CLUES_PATH, PLAYERS_PATH +from .jeopplayer import JeopPlayer from ..config import SUBTRACT_ON_INCORRECT from ..util import get_stripped_nonempty_file_lines, to_numeric diff --git a/jeoparpy/game/gamestate.py b/jeoparpy/game/gamestate.py index a6d3487..a104eac 100644 --- a/jeoparpy/game/gamestate.py +++ b/jeoparpy/game/gamestate.py @@ -104,7 +104,7 @@ def set(self, state, **kwargs): self.kwargs.update(kwargs) if DEBUG and self.kwargs: - print 'State args set: {0}'.format(self.kwargs) + print('State args set: {0}'.format(self.kwargs)) def _verify_transition(self, newState): """ @@ -145,7 +145,7 @@ def state(self, val): self.kwargs = {} if DEBUG: - print "State change: {0}".format(self) + print("State change: {0}".format(self)) class JeopGameState(GameState): """ diff --git a/jeoparpy/main.py b/jeoparpy/main.py index 94288e1..57d3cb7 100644 --- a/jeoparpy/main.py +++ b/jeoparpy/main.py @@ -23,10 +23,10 @@ import os import sys -from config import FPS_LIMIT, FULLSCREEN, SUBTRACT_ON_INCORRECT, SCREEN_SIZE -from constants import ANIMATIONEND, ANSWER_TIMEOUT, AUDIOEND, SKIP_INTRO_FLAG -from game import GameData, JeopGameState -from ui import Controller, do_congrats, do_credits, do_intro, do_scroll +from .config import FPS_LIMIT, FULLSCREEN, SUBTRACT_ON_INCORRECT, SCREEN_SIZE +from .constants import ANIMATIONEND, ANSWER_TIMEOUT, AUDIOEND, SKIP_INTRO_FLAG +from .game import GameData, JeopGameState +from .ui import Controller, do_congrats, do_credits, do_intro, do_scroll import button EVENTS_ALLOWED = (ANIMATIONEND, ANSWER_TIMEOUT, diff --git a/jeoparpy/selectMenu.py b/jeoparpy/selectMenu.py index 180f6d4..bfee40c 100644 --- a/jeoparpy/selectMenu.py +++ b/jeoparpy/selectMenu.py @@ -3,8 +3,8 @@ import pygame, sys, os from pygame.locals import * -from constants import ROOT_PATH -from config import DRIVE +from .constants import ROOT_PATH +from .config import DRIVE pygame.init() @@ -62,7 +62,7 @@ def get_options(self): if self.games > 4: self.games = 4 if self.games < 1: - print 'You must have a game in the /games directory!' + print('You must have a game in the /games directory!') pygame.quit() sys.exit() diff --git a/jeoparpy/ui/__init__.py b/jeoparpy/ui/__init__.py index 3af78b7..6aa59c6 100644 --- a/jeoparpy/ui/__init__.py +++ b/jeoparpy/ui/__init__.py @@ -16,8 +16,8 @@ CUSTOMIZATION: See instructions in config.py and resmaps.py. """ -from categoryscroll import do_scroll -from congrats import do_congrats -from controller import Controller -from credits import do_credits -from intro import do_intro +from .categoryscroll import do_scroll +from .congrats import do_congrats +from .controller import Controller +from .credits import do_credits +from .intro import do_intro diff --git a/jeoparpy/ui/audioplayer.py b/jeoparpy/ui/audioplayer.py index e182650..6ad82ec 100644 --- a/jeoparpy/ui/audioplayer.py +++ b/jeoparpy/ui/audioplayer.py @@ -1,6 +1,6 @@ import pygame -from resmaps import SOUNDS, CLUE_READS +from .resmaps import SOUNDS, CLUE_READS ############################################################################### class AudioPlayer(object): diff --git a/jeoparpy/ui/categoryscroll.py b/jeoparpy/ui/categoryscroll.py index 79a37b6..aaf4f56 100644 --- a/jeoparpy/ui/categoryscroll.py +++ b/jeoparpy/ui/categoryscroll.py @@ -20,10 +20,10 @@ import pygame -from config import CATEGORY_HOLD_TIME -from constants import JEOP_BLUE -from resmaps import FONTS -from util import (autofit_text, BorderedBox, draw_centered_textblock, +from .config import CATEGORY_HOLD_TIME +from .constants import JEOP_BLUE +from .resmaps import FONTS +from .util import (autofit_text, BorderedBox, draw_centered_textblock, get_anim_data, shadow_text) from ..config import FPS_LIMIT from ..util import chunker diff --git a/jeoparpy/ui/congrats.py b/jeoparpy/ui/congrats.py index af7ff89..ee55733 100644 --- a/jeoparpy/ui/congrats.py +++ b/jeoparpy/ui/congrats.py @@ -19,9 +19,9 @@ """ import pygame -from constants import JEOP_BLUE -from resmaps import FONTS -from util import scale +from .constants import JEOP_BLUE +from .resmaps import FONTS +from .util import scale def do_congrats(screen, clock, winners, audioPlayer): """ diff --git a/jeoparpy/ui/controller.py b/jeoparpy/ui/controller.py index 5578ac1..cd01a51 100644 --- a/jeoparpy/ui/controller.py +++ b/jeoparpy/ui/controller.py @@ -15,8 +15,8 @@ """ import pygame -from audioplayer import JeopAudioPlayer -from maingame import Clue, GameBoard, OpenClueAnimation, PodiaPanel +from .audioplayer import JeopAudioPlayer +from .maingame import Clue, GameBoard, OpenClueAnimation, PodiaPanel from ..config import DEBUG from ..constants import AUDIOEND @@ -68,7 +68,7 @@ def draw(self, screen): for sfc in self._sfcs: if sfc.dirty: if DEBUG: - print 'draw %s' % type(sfc).__name__ + print('draw %s' % type(sfc).__name__) if isinstance(sfc, pygame.sprite.Sprite): screen.blit(sfc.image, sfc.rect) diff --git a/jeoparpy/ui/credits.py b/jeoparpy/ui/credits.py index 80d13d7..0c56216 100644 --- a/jeoparpy/ui/credits.py +++ b/jeoparpy/ui/credits.py @@ -23,9 +23,9 @@ import pygame from pygame.locals import QUIT, KEYDOWN, K_q -from constants import JEOP_BLUE -from resmaps import FONTS, IMAGES -from util import get_anim_data, scale, shadow_text +from .constants import JEOP_BLUE +from .resmaps import FONTS, IMAGES +from .util import get_anim_data, scale, shadow_text ############################################################################### class CreditLine(pygame.sprite.DirtySprite): diff --git a/jeoparpy/ui/intro.py b/jeoparpy/ui/intro.py index a99dfb3..6f81d01 100644 --- a/jeoparpy/ui/intro.py +++ b/jeoparpy/ui/intro.py @@ -22,9 +22,9 @@ import pygame from pygame.locals import KEYDOWN, QUIT -from constants import JEOP_BLUE, RULES, SUBTITLE -from resmaps import FONTS, IMAGES -from util import (draw_centered_textblock, draw_textline, restrict_fontsize, +from .constants import JEOP_BLUE, RULES, SUBTITLE +from .resmaps import FONTS, IMAGES +from .util import (draw_centered_textblock, draw_textline, restrict_fontsize, scale, shadow_text, wait_for_keypress) ############################################################################### diff --git a/jeoparpy/ui/maingame/__init__.py b/jeoparpy/ui/maingame/__init__.py index 9c599eb..68878b4 100644 --- a/jeoparpy/ui/maingame/__init__.py +++ b/jeoparpy/ui/maingame/__init__.py @@ -6,7 +6,7 @@ JeoparPy, i.e. everything from when the main game board and podia appear until the game is over and the congratulations screen appears. """ -from clue import Clue -from clueanimation import OpenClueAnimation -from gameboard import GameBoard -from podiapanel import PodiaPanel +from .clue import Clue +from .clueanimation import OpenClueAnimation +from .gameboard import GameBoard +from .podiapanel import PodiaPanel diff --git a/jeoparpy/ui/maingame/clue.py b/jeoparpy/ui/maingame/clue.py index 99bd403..06f79d1 100644 --- a/jeoparpy/ui/maingame/clue.py +++ b/jeoparpy/ui/maingame/clue.py @@ -15,8 +15,8 @@ """ import pygame -from jeopgamesfc import JeopGameSurface -from util import Timer +from .jeopgamesfc import JeopGameSurface +from .util import Timer from ..constants import JEOP_BLUE from ..resmaps import FONTS, IMAGES from ..util import (autofit_text, draw_centered_textblock, draw_textblock, diff --git a/jeoparpy/ui/maingame/gameboard.py b/jeoparpy/ui/maingame/gameboard.py index 1f4240b..753a5de 100644 --- a/jeoparpy/ui/maingame/gameboard.py +++ b/jeoparpy/ui/maingame/gameboard.py @@ -17,7 +17,7 @@ import pygame -from jeopgamesfc import JeopGameSurface +from .jeopgamesfc import JeopGameSurface from ..constants import JEOP_BLUE from ..resmaps import FONTS from ..util import (autofit_text, BorderedBox, draw_centered_textblock, diff --git a/jeoparpy/ui/maingame/podiapanel.py b/jeoparpy/ui/maingame/podiapanel.py index e549cd7..8037522 100644 --- a/jeoparpy/ui/maingame/podiapanel.py +++ b/jeoparpy/ui/maingame/podiapanel.py @@ -16,8 +16,8 @@ """ import pygame -from jeopgamesfc import JeopGameSurface -from podium import Podium +from .jeopgamesfc import JeopGameSurface +from .podium import Podium from ..resmaps import FONTS, IMAGES diff --git a/jeoparpy/ui/maingame/podium.py b/jeoparpy/ui/maingame/podium.py index 9bb002f..ecc7d2f 100644 --- a/jeoparpy/ui/maingame/podium.py +++ b/jeoparpy/ui/maingame/podium.py @@ -16,8 +16,8 @@ """ import pygame -from jeopgamesfc import JeopGameSurface -from util import Timer +from .jeopgamesfc import JeopGameSurface +from .util import Timer from ..constants import JEOP_BLUE from ..resmaps import FONTS, IMAGES from ..util import (autofit_text, draw_centered_textblock, diff --git a/requirements.txt b/requirements.txt index 144b7b3..41d8040 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,4 @@ -pygame==2.0.3 -RPi.GPIO==0.7.1 \ No newline at end of file +pygame==2.5.2 +RPi.GPIO==0.7.1 +# GPIO Emulator +# RPi @ git+https://github.com/nosix/raspberry-gpio-emulator/@891462c30064141bca3e5d7aa7f4c46cca99a7eb \ No newline at end of file diff --git a/start.py b/start.py index 7aec6bb..fc82419 100644 --- a/start.py +++ b/start.py @@ -68,4 +68,4 @@ from jeoparpy.main import main main(*flags) - print config.DRIVE + print(config.DRIVE) From 10df684aab9a0601c000c5ae52e2dbc25d1f7fb8 Mon Sep 17 00:00:00 2001 From: Justin Revelstoke Date: Wed, 14 Feb 2024 17:05:56 -0800 Subject: [PATCH 02/14] Update dockerfile for the build pipeline --- Dockerfile | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index c84ebc8..9e380fd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,4 @@ -# The original project is very old and still uses Python 2.7.18 -# This needs to be updated to Python 3.8.5 or later after the project is updated -FROM python:2.7.18-buster +FROM python:3.11.8-bullseye # Set some basic image metadata LABEL org.opencontainers.image.description = "A Jeopardy game for the Raspberry Pi" From dd6b408d783457b26ceafcb3733c8c9991452697 Mon Sep 17 00:00:00 2001 From: Justin Revelstoke Date: Thu, 21 Mar 2024 01:06:50 +0000 Subject: [PATCH 03/14] python3.9 --- jeoparpy/game/gamedata.py | 6 +++--- jeoparpy/game/gamestate.py | 4 ++-- jeoparpy/ui/congrats.py | 2 +- jeoparpy/ui/credits.py | 2 +- jeoparpy/ui/intro.py | 2 +- jeoparpy/ui/maingame/clueanimation.py | 2 +- jeoparpy/ui/maingame/gameboard.py | 8 ++++---- jeoparpy/ui/maingame/podiapanel.py | 2 +- jeoparpy/ui/util.py | 4 ++-- 9 files changed, 16 insertions(+), 16 deletions(-) diff --git a/jeoparpy/game/gamedata.py b/jeoparpy/game/gamedata.py index e3f0a28..7caf7e3 100644 --- a/jeoparpy/game/gamedata.py +++ b/jeoparpy/game/gamedata.py @@ -122,7 +122,7 @@ def _build_players_from_file(self, path): elif len(playerNames) < 3: missing = 3 - len(playerNames) playerNames += tuple('Player ' + str(i + 2) - for i in xrange(missing)) + for i in range(missing)) return tuple(JeopPlayer(name) for name in playerNames) @@ -137,8 +137,8 @@ def _map_clues(self, clues, numCategories): ((Category 1 clues), (Category 2 clues), ...)) """ mapped = [] - numPerCat = len(clues) / numCategories - for c in xrange(numCategories): + numPerCat = int(len(clues) / numCategories) + for c in range(numCategories): start = c*numPerCat mapped.append(tuple(clues[start:start + numPerCat])) diff --git a/jeoparpy/game/gamestate.py b/jeoparpy/game/gamestate.py index a104eac..9df4fcb 100644 --- a/jeoparpy/game/gamestate.py +++ b/jeoparpy/game/gamestate.py @@ -134,7 +134,7 @@ def state(self, val): type(val).__name__), val) # Verify state within valid range of defined states - if val not in xrange(self._numStates): + if val not in range(self._numStates): raise StateSetError("Set of 'State' attempted with value " + "that has no assigned state.", val) @@ -265,4 +265,4 @@ def __str__(self): addendum = ' Previous state: {0}; Attempted state: {1}'.format( self.previous, self.attempted) - return self.msg + addendum \ No newline at end of file + return self.msg + addendum diff --git a/jeoparpy/ui/congrats.py b/jeoparpy/ui/congrats.py index ee55733..b58bc95 100644 --- a/jeoparpy/ui/congrats.py +++ b/jeoparpy/ui/congrats.py @@ -103,7 +103,7 @@ def _fade_in_sfc(screen, sfc, clock, time): fpsGoal = int(255.0 / time) # frames to draw / time to spend in secs sfc.fill(JEOP_BLUE) - for alpha in xrange(256): + for alpha in range(256): sfc.set_alpha(alpha) screen.blit(lastScreen, (0, 0)) screen.blit(sfc, (0, 0)) diff --git a/jeoparpy/ui/credits.py b/jeoparpy/ui/credits.py index 0c56216..a7bcc5d 100644 --- a/jeoparpy/ui/credits.py +++ b/jeoparpy/ui/credits.py @@ -281,7 +281,7 @@ def _scroll_credits(screen, scrRect, clock, lines, numFrames, step, fpsLimit): screen.fill(JEOP_BLUE) bg = screen.copy() - for frame in xrange(numFrames): + for frame in range(numFrames): lines.update(step, scrRect.h) lines.clear(screen, bg) lines.draw(screen) diff --git a/jeoparpy/ui/intro.py b/jeoparpy/ui/intro.py index 6f81d01..5600e5c 100644 --- a/jeoparpy/ui/intro.py +++ b/jeoparpy/ui/intro.py @@ -168,7 +168,7 @@ def _fade_in_title(screen, background, text, textRect, bannerColor, clock): fpsGoal = int(255 / 7.8) #frames to draw / time to spend in secs pygame.time.delay(2000) - for alpha in xrange(256): + for alpha in range(256): background.fill(bannerColor, textRect) text.set_alpha(alpha) background.blit(text, textRect) diff --git a/jeoparpy/ui/maingame/clueanimation.py b/jeoparpy/ui/maingame/clueanimation.py index bf9c58a..fd745c3 100644 --- a/jeoparpy/ui/maingame/clueanimation.py +++ b/jeoparpy/ui/maingame/clueanimation.py @@ -96,7 +96,7 @@ def _init_rects(self, clueCoords): self._startRect = self.rect.copy() self._moveAmts = tuple(self._endRect[i] - self.rect[i] - for i in xrange(4)) + for i in range(4)) def _is_animation_done(self): return self._frame == self._frameGoal diff --git a/jeoparpy/ui/maingame/gameboard.py b/jeoparpy/ui/maingame/gameboard.py index 753a5de..c9bbc37 100644 --- a/jeoparpy/ui/maingame/gameboard.py +++ b/jeoparpy/ui/maingame/gameboard.py @@ -63,8 +63,8 @@ def update(self, gameState, gameData): if gs.state == gs.BOARD_FILL: self._amtFont = pygame.font.Font(FONTS['amount'], self._scale(48)) - self._coordsStack = [(c, r) for c in xrange(len(self._boxes)) - for r in xrange(len(self._boxes[0]) - 1)] + self._coordsStack = [(c, r) for c in range(len(self._boxes)) + for r in range(len(self._boxes[0]) - 1)] shuffle(self._coordsStack) elif gs.state == gs.WAIT_BOARD_FILL: @@ -128,7 +128,7 @@ def _init_boxes(self, nCols, nRows): (borderW, borderW, catBottomBorder, borderW), (0, 0, 0)) - for col in xrange(nCols): + for col in range(nCols): colBoxes = [] if col == nCols - 1: @@ -142,7 +142,7 @@ def _init_boxes(self, nCols, nRows): catBox.rect.topleft = (boxW*col, 0) colBoxes.append(catBox.copy()) - for row in xrange(1, nRows): + for row in range(1, nRows): clueBox.rect.topleft = (boxW*col, boxH*row) colBoxes.append(clueBox.copy()) diff --git a/jeoparpy/ui/maingame/podiapanel.py b/jeoparpy/ui/maingame/podiapanel.py index 8037522..67ed18f 100644 --- a/jeoparpy/ui/maingame/podiapanel.py +++ b/jeoparpy/ui/maingame/podiapanel.py @@ -85,7 +85,7 @@ def _init_podia(self, gameData, scalar): fonts = (('team1', 42), ('team2', 33), ('team3', 40)) fonts = tuple((FONTS[n], s) for n,s in fonts) - for i in xrange(3): + for i in range(3): p = Podium(i, img, scalar, gameData.players[i].name, fonts[i], nameBounds, podia) diff --git a/jeoparpy/ui/util.py b/jeoparpy/ui/util.py index 832e5e1..8f99812 100644 --- a/jeoparpy/ui/util.py +++ b/jeoparpy/ui/util.py @@ -201,7 +201,7 @@ def get_size_textblock(lines, font, spacing): blockW = 0 blockH = 0 - if isinstance(lines, basestring): + if isinstance(lines, str): lines = [lines] for line in lines: @@ -332,7 +332,7 @@ def borderWidths(self, val): val = 4*[val] try: - for i in xrange(4): + for i in range(4): ws.append(to_numeric(val[i])) except IndexError: raise BorderError("'borderW' contains ") From c059cd093ec3c2f645e5b7142f6e6600a4ff0c38 Mon Sep 17 00:00:00 2001 From: Justin Revelstoke Date: Thu, 21 Mar 2024 02:32:11 +0000 Subject: [PATCH 04/14] pygame downgrade --- requirements.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index 41d8040..911ebab 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -pygame==2.5.2 +pygame==1.9.6 RPi.GPIO==0.7.1 # GPIO Emulator -# RPi @ git+https://github.com/nosix/raspberry-gpio-emulator/@891462c30064141bca3e5d7aa7f4c46cca99a7eb \ No newline at end of file +# RPi @ git+https://github.com/nosix/raspberry-gpio-emulator/@891462c30064141bca3e5d7aa7f4c46cca99a7eb From 0a4587f4b91a53fbd5458f4921e1bda6becd0932 Mon Sep 17 00:00:00 2001 From: Justin Revelstoke Date: Thu, 21 Mar 2024 02:44:25 +0000 Subject: [PATCH 05/14] button fix --- button.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/button.py b/button.py index 8bedf37..e6ddf0b 100644 --- a/button.py +++ b/button.py @@ -10,9 +10,9 @@ def __init__(self): #Setup pins and board gpio.setmode(gpio.BCM) - gpio.setup(22, gpio.IN, pull_up_down=gpio.PUD_UP) - gpio.setup(4, gpio.IN, pull_up_down=gpio.PUD_UP) - gpio.setup(17, gpio.IN, pull_up_down=gpio.PUD_UP) + gpio.setup(22, gpio.IN, pull_up_down=gpio.PUD_DOWN) + gpio.setup(4, gpio.IN, pull_up_down=gpio.PUD_DOWN) + gpio.setup(17, gpio.IN, pull_up_down=gpio.PUD_DOWN) #Put pins in variables self.center_button = 22 @@ -50,7 +50,7 @@ def check(self): center_input = gpio.input(self.center_button) left_input = gpio.input(self.left_button) right_input = gpio.input(self.right_button) - if center_input == True: + if center_input == gpio.HIGH: if self.center_press > 0: if self.DEBUG: print('ADMIN: Console button 2 has been pressed') @@ -62,7 +62,7 @@ def check(self): self.center_press += 1 #Right buttons stuff - if right_input == True: + if right_input == gpio.HIGH: if self.right_press > 0: if self.DEBUG: print('ADMIN: Console button 3 has been pressed') @@ -74,7 +74,7 @@ def check(self): self.right_press += 1 #Left button stuff - if left_input == True: + if left_input == gpio.HIGH: if self.left_press > 0: if self.DEBUG: print('ADMIN: Console button 1 has been pressed') From ba840dc1a54f2806709481d94f521ad139c395bc Mon Sep 17 00:00:00 2001 From: Garth Johnson Date: Wed, 27 Mar 2024 19:55:18 -0700 Subject: [PATCH 06/14] added for SDL compat --- Dockerfile | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 9e380fd..17d6b4f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,6 +8,12 @@ LABEL org.opencontainers.image.licenses=GPL3 # Set the working directory for installations WORKDIR /app +# Install OS packages +RUN apt update && apt install -y libsdl2-dev libsdl2-2.0-0 \ + libjpeg-dev libwebp-dev libtiff5-dev libsdl2-image-dev libsdl2-image-2.0-0 \ + libmikmod-dev libfishsound1-dev libsmpeg-dev liboggz2-dev libflac-dev libfluidsynth-dev libsdl2-mixer-dev libsdl2-mixer-2.0-0 \ + libfreetype6-dev libsdl2-ttf-dev libsdl2-ttf-2.0-0 + # Add our python requirements file to the working directory ADD requirements.txt . @@ -27,4 +33,4 @@ ADD ./ . # ADD ????? # Set default command to run the start.py file -CMD ["/usr/local/bin/python", "start.py"] \ No newline at end of file +CMD ["/usr/local/bin/python", "start.py"] From fba4fd904ef780f2fe3988e2fb034917901c9fe7 Mon Sep 17 00:00:00 2001 From: Garth Johnson Date: Thu, 28 Mar 2024 21:32:16 -0700 Subject: [PATCH 07/14] Removed version (no longer used) added default DISPLAY value --- docker-compose.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 0707952..2e7f7af 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,4 +1,4 @@ -version: '3.8' + services: # Building and testing environment @@ -14,7 +14,7 @@ services: - ${PWD}:/app - /tmp/.X11-unix:/tmp/.X11-unix environment: - - DISPLAY=$DISPLAY + - DISPLAY=${DISPLAY:-:0} privileged: true app: @@ -24,6 +24,6 @@ services: volumes: - /tmp/.X11-unix:/tmp/.X11-unix environment: - - DISPLAY=$DISPLAY + - DISPLAY=${DISPLAY:-:0} privileged: true From 3b7f448edfbb71535a569d6443af2f258a395337 Mon Sep 17 00:00:00 2001 From: Garth Johnson Date: Thu, 28 Mar 2024 21:33:22 -0700 Subject: [PATCH 08/14] reflowed apt installs and added libpng-dev --- Dockerfile | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 17d6b4f..3aface1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,9 +9,12 @@ LABEL org.opencontainers.image.licenses=GPL3 WORKDIR /app # Install OS packages -RUN apt update && apt install -y libsdl2-dev libsdl2-2.0-0 \ - libjpeg-dev libwebp-dev libtiff5-dev libsdl2-image-dev libsdl2-image-2.0-0 \ - libmikmod-dev libfishsound1-dev libsmpeg-dev liboggz2-dev libflac-dev libfluidsynth-dev libsdl2-mixer-dev libsdl2-mixer-2.0-0 \ +RUN apt update && apt install -y \ + libsdl2-dev libsdl2-2.0-0 \ + libjpeg-dev libpng-dev libwebp-dev libtiff-dev \ + libsdl2-image-dev libsdl2-image-2.0-0 \ + libmikmod-dev libfishsound1-dev libsmpeg-dev liboggz2-dev \ + libflac-dev libfluidsynth-dev libsdl2-mixer-dev libsdl2-mixer-2.0-0 \ libfreetype6-dev libsdl2-ttf-dev libsdl2-ttf-2.0-0 # Add our python requirements file to the working directory From a3177440a39cce1dae64bea54d0ea1f66ef47444 Mon Sep 17 00:00:00 2001 From: Garth Johnson Date: Thu, 28 Mar 2024 21:34:37 -0700 Subject: [PATCH 09/14] changed pygame version to 2.5.2 --- requirements.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 911ebab..ddc8549 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,5 @@ -pygame==1.9.6 +#pygame==1.9.6 +pygame==2.5.2 RPi.GPIO==0.7.1 # GPIO Emulator # RPi @ git+https://github.com/nosix/raspberry-gpio-emulator/@891462c30064141bca3e5d7aa7f4c46cca99a7eb From 1d231ff5fb1caf30cace2986727eabb80781168c Mon Sep 17 00:00:00 2001 From: Garth Johnson Date: Thu, 28 Mar 2024 22:16:32 -0700 Subject: [PATCH 10/14] Added profile for build --- README.md | 10 ++++++++++ docker-compose.yml | 2 ++ 2 files changed, 12 insertions(+) diff --git a/README.md b/README.md index 7df23a4..75f7097 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,10 @@ Play Jeopardy on your Raspberry Pi How to get Jeopardy running on your Raspberry Pi +- install docker +- create a copy of the `docker-compose.yml` file +- run `docker compose up` + ### Hardware Follow these instructions:
@@ -16,6 +20,12 @@ http://hackaday.io/project/3721/instructions Follow these instructions:
http://hackaday.io/project/3721-game-show-emulator/log/12365 +## Building + +To build the container image localy: + + docker compose --profile build build + ## Notes This software is designed to be used with the Raspberry Pi. If you would like to run Jeopardy on a Windows or Ubuntu please use Adam Beagle's jeoparpy software. diff --git a/docker-compose.yml b/docker-compose.yml index 2e7f7af..1710713 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -16,6 +16,8 @@ services: environment: - DISPLAY=${DISPLAY:-:0} privileged: true + profiles: + - build app: image: ghcr.io/btc-raspberrypiclub/jeopardy:latest From 6c95d70548724b47f25ba02d48b398738108e565 Mon Sep 17 00:00:00 2001 From: Garth Johnson Date: Thu, 28 Mar 2024 23:00:39 -0700 Subject: [PATCH 11/14] added venv dir python --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 7bf1e89..d02dd17 100644 --- a/.gitignore +++ b/.gitignore @@ -130,6 +130,7 @@ celerybeat.pid # Environments .env .venv +python env/ venv/ ENV/ @@ -169,4 +170,4 @@ cython_debug/ # Project specific -jeoparpy/dir.txt \ No newline at end of file +jeoparpy/dir.txt From ad41fc94d69c3f1b36b2a872ca7775d31801493e Mon Sep 17 00:00:00 2001 From: Garth Johnson Date: Thu, 28 Mar 2024 23:01:09 -0700 Subject: [PATCH 12/14] commented out the local dir mapping --- docker-compose.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 1710713..64226d8 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -11,7 +11,7 @@ services: tty: true command: ["/bin/bash"] volumes: - - ${PWD}:/app + #- ${PWD}:/app - /tmp/.X11-unix:/tmp/.X11-unix environment: - DISPLAY=${DISPLAY:-:0} @@ -27,5 +27,6 @@ services: - /tmp/.X11-unix:/tmp/.X11-unix environment: - DISPLAY=${DISPLAY:-:0} + - PW_AUDIO_MODULE=pipewire privileged: true From 809bd73842cd77c274038c28e118823d56edb9ba Mon Sep 17 00:00:00 2001 From: Garth Johnson Date: Thu, 28 Mar 2024 23:01:43 -0700 Subject: [PATCH 13/14] added pipewire for compatibility with default on current raspbian --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 3aface1..21f594a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,7 +15,7 @@ RUN apt update && apt install -y \ libsdl2-image-dev libsdl2-image-2.0-0 \ libmikmod-dev libfishsound1-dev libsmpeg-dev liboggz2-dev \ libflac-dev libfluidsynth-dev libsdl2-mixer-dev libsdl2-mixer-2.0-0 \ - libfreetype6-dev libsdl2-ttf-dev libsdl2-ttf-2.0-0 + libfreetype6-dev libsdl2-ttf-dev libsdl2-ttf-2.0-0 pipewire # Add our python requirements file to the working directory ADD requirements.txt . From c088f6b818d05e00b7df2f56c4166db60996494a Mon Sep 17 00:00:00 2001 From: Garth Johnson Date: Thu, 28 Mar 2024 23:56:26 -0700 Subject: [PATCH 14/14] Update requirements.txt --- requirements.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index ddc8549..eeb23b6 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,3 @@ -#pygame==1.9.6 pygame==2.5.2 RPi.GPIO==0.7.1 # GPIO Emulator