Resume

Retro Time Machine

About

This is a dream project of mine. I love everything retro, and an interactive decoration like this is something I’ve always wanted.

It runs on a Raspberry Pi 3B+ with both RetroPie (for video games) and Ubuntu (for television) installed. To control everything using just a gamepad, I coded a Python-based interface that allows seamless switching between console emulation and simulated old television.

Despite many challenges, the toughest part was finding the right Jack-to-RCA cable to connect the TV—eventually, I had to solder my own.

Interface

The interface is minimalistic but functional, and I found it fitting for the theme.

First, I mapped all six buttons on my gamepad through trial and error to find the best layout, using the evdev library. The script then continuously checks for inputs in a loop.

Some parts of the script could be optimized further, ideally without relying so much on time and pyautogui, as seen in the power_tv() function, which is currently the main bottleneck. This is a temporary solution until I set up a local database for the simulated TV feature.


import pyautogui as gui
import os
import evdev
import webbrowser as web
import time

gui.FAILSAFE = False

X = 288
A = 289
B = 290
Y = 291
C = 296
S = 297

tv_era = False
tv_opt = False

def power_tv():
    time.sleep(1.5)
    gui.press('f11')
    time.sleep(7.5)
    gui.press('f')
    gui.press('space')
    gui.press('s')

def opts():
    os.system('clear')
    if tv_era:
        print("X - 2000s\nA - 90s\nB - 80s\nY - 70s")
    else:
        print("X - TV\nA - Games\nB - Music\nY - Shutdown")

gui.move(800,-400)
opts()
device = evdev.InputDevice('/dev/input/event0')
for event in device.read_loop():
    if event.type == evdev.ecodes.EV_KEY and event.value == 1:
        if event.code == X:
            if tv_opt:
                gui.press('up')
            elif tv_era:
                web.open("https://www.my00stv.com")
                tv_opt = True
                power_tv()
            else:
                tv_era = True
                opts()
        elif event.code == A:
            if tv_opt:
                pass
            elif tv_era:
                web.open("https://www.my90stv.com")
                tv_opt = True
                power_tv()
            else:
                os.system('reboot')
        elif event.code == B:
            if tv_opt:
                pass
            elif tv_era:
                web.open("https://www.my80stv.com")
                tv_opt = True
                power_tv()
            else:
                pass
        elif event.code == Y:
            if tv_opt:
                gui.press('down')
            elif tv_era:
                web.open("https://www.my70stv.com")
                tv_opt = True
                power_tv()
            else:
                os.system('sudo shutdown now')
        elif event.code == C:
            if tv_opt:
                tv_opt = False
                opts()
                gui.hotkey('alt','f4')
            elif tv_era:
                tv_era = False
                opts()
        elif event.code == S:
            if tv_opt:
                tv_opt = False
                tv_era = False
                opts()
                gui.hotkey('alt','f4')
            elif tv_era:
                tv_era = False
                opts()

I also coded a small shell code to launch the Python script on startup.

#!/bin/bash
xterm -hold -e "python3 /home/pi/Desktop/hello.py"
$SHELL