add event to calendar, only import GPIO if necessary

This commit is contained in:
ohsqueezy 2022-11-30 20:16:12 -05:00
parent 51165f5af9
commit e0b4ed0251
4 changed files with 42 additions and 5 deletions

1
.gitignore vendored
View File

@ -15,3 +15,4 @@ lib/python3.9/
pyvenv.cfg
lib/python*
stat/
www/scrapeboard_new.gif

24
NS.py
View File

@ -31,7 +31,6 @@ from pygame.draw import aalines, lines
from pygame.gfxdraw import aapolygon, arc, polygon, aaellipse, ellipse, filled_ellipse, filled_circle
from pygame.locals import *
import gpio
from lib.pgfw.pgfw.Game import Game
from lib.pgfw.pgfw.GameChild import GameChild
from lib.pgfw.pgfw.Sprite import Sprite, RainbowSprite, BlinkingSprite
@ -239,6 +238,8 @@ class NS(Game, Animation):
# init Pi
if self.pi_enabled():
import gpio
# Initialize GPIO interface
gpio.initialize_gpio()
@ -1045,12 +1046,25 @@ class Logo(Sprite):
class Title(Animation):
"""
Handles displaying and drawing the title screen.
Handles displaying and drawing the title screen. It draws the high scores, creates and updates an attract mode video pop-up, tracks
the player's moves and checks if they are doing the start game pattern, and updates the background logo and giant Tony sprite.
Notes
-----
* It should be directed to draw scores when a new score is added (and only then), and it will store the score surfaces and only blit
them once when activated (unless the scores are updated). This way it only blits that section of the screen once.
"""
# Sequence of moves the player must do to start the game
UNLOCK_MOVES = NS.NW, NS.N, NS.NE, NS.S
def __init__(self, parent):
"""
Create an object for the attract mode video pop-up.
@param parent GameChild object that will connect this GameChild object to the overall tree and root Game object
"""
Animation.__init__(self, parent)
ds = self.get_display_surface()
dsr = ds.get_rect()
@ -1062,12 +1076,18 @@ class Title(Animation):
self.score_sprites = []
def reset(self):
"""
Set the unlock progress back to zero. Start glowing the first move in the unlock pattern. Halt all animations. Unhide video.
"""
self.unlock_index = 0
self.get_game().platform.set_glowing(self.get_game().platform.get_buttons_from_edges([self.UNLOCK_MOVES[0]]))
self.halt()
self.show_video()
def activate(self):
"""
Activate platform, Tony, and player objects as well. Start playing the BGM.
"""
self.active = True
platform = self.get_game().platform
platform.activate()

6
config
View File

@ -22,7 +22,7 @@ data-exclude = local/, *.pyc, .git*, README, build/, dist/, *.egg-info, *.py, MA
[display]
caption = Scrapeboard
show-framerate = yes
show-framerate = yes
dimensions = 800, 450
fullscreen = no
attract-gif-alpha = 1.0
@ -60,9 +60,9 @@ volume = 1.0
[input]
buffer = 0
arduino-port = /dev/ttyACM0
serial = no
serial = no
pi = no
confirm-quit = no
confirm-quit = no
[time]
timer-max-time = 10000

View File

@ -302,6 +302,8 @@
<img src="www/ad_description_transparent_3.png" />
</div>
<!-- CALENDAR -->
<style>
/* landscape */
@media (min-width: 800px)
@ -386,6 +388,20 @@
</div>
</div>
<div class="date current">
<div class="day-of-week">
Mon
</div>
<div class="day">
Dec. 5
</div>
<div class="year">
2022
</div>
<div class="location">
<a href="https://wonderville.nyc">Wonderville, NYC</a>
</div>
</div>
<div class="date past">
<div class="day-of-week">
Sat
</div>