Last active
August 20, 2021 06:24
-
-
Save simonjenny/0f04b3e826ac1d245173213de92de7d5 to your computer and use it in GitHub Desktop.
Commodore C64 Style Dashboard
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
# Download c64 Font : https://www.ffonts.net/Pet-Me-64.font | |
# Install Efa : https://simonjenny.dev/efa | |
# STATION="Allschwil, zum Sporn" python c64.py | |
import time, os, pygame, subprocess | |
from datetime import datetime | |
STATION = os.getenv('STATION', 'Basel, Marktplatz') | |
FOREGROUND = (62,50,162)#(64, 50, 133) | |
BACKGROUND = (124,113,218)#(120, 106, 189) | |
pygame.init() | |
pygame.mouse.set_visible(False) | |
X = 800 | |
Y = 480 | |
C = 0 | |
size = (X, Y) | |
display_surface = pygame.display.set_mode(size) | |
def alter(): | |
while True: | |
yield FOREGROUND | |
yield BACKGROUND | |
alt = alter() | |
def printLine(display, fontsize, text, position): | |
font = pygame.font.Font("PetMe64.ttf",fontsize) | |
line = font.render(text, True, BACKGROUND, FOREGROUND) | |
lineRect = line.get_rect() | |
lineRect.center = position | |
display.blit(line, lineRect) | |
p = subprocess.Popen("efa --notfancy -s %s 2>&1 | head -n 5" % STATION, shell=True, \ | |
stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()[0] | |
while True: | |
R = 60 | |
display_surface.fill(BACKGROUND) | |
display_surface.fill(FOREGROUND, pygame.Rect(40,40,720,400)) | |
C=C+1 | |
if(C == 60): | |
p = subprocess.Popen("efa --notfancy -s %s 2>&1 | head -n 5" % STATION, shell=True, \ | |
stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()[0] | |
C = 0 | |
printLine(display_surface, 15, "**** COMMODORE 64 BASIC V2 ****", (X // 2, R)) | |
R += 20 | |
printLine(display_surface, 15, "64K RAM SYSTEM 38911 BASIC BYTES FREE", (X // 2, R)) | |
printLine(display_surface, 60, datetime.now().strftime('%H:%M'), ( X // 2 , 320 )) | |
R += 20 | |
for line in p.split("\n"): | |
R += 22 | |
printLine(display_surface, 18, line.replace('ü','ue').replace('ä','ae').replace('ö','oe'), (X // 2, R)) | |
R += 160 | |
printLine(display_surface, 15, "READY.", (85, R)) | |
R += 10 | |
display_surface.fill(alt.next(), pygame.Rect(41,R,10,20)) | |
for event in pygame.event.get() : | |
if event.type == pygame.QUIT : | |
pygame.quit() | |
quit() | |
pygame.display.update() | |
time.sleep(1) |
Author
simonjenny
commented
Jan 15, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment