Coder Social home page Coder Social logo

pimamemanager's Introduction

Pi Mame Manager

TLDR;

A Perl script for Raspbian OS to help facilitate the use of a Raspberry Pi as a replica arcade cabinet.

This was built for my replica Track & Field cocktail project, which you can read more about at http://www.classicarcadeprojects.com.

More Details

The Problem

The problem is Raspberry Pis need to be powered down properly to avoid corrupting the file system. A fair number of arcade machines were designed to operate just by pulling the plug so it's difficult to simulate this functionality with a Raspberry Pi.

The Solution

Using a USB power brick (like you'd use as backup power for your cell phone) combined with an ethernet switch, and this script, we can create a makeshift Uninterruptible Power Supply (UPS).

The script is responsible for detecting the power state and launching or killing Mame as appropriate.

To achieve this, the script watches connectivity of the Raspberry Pi's ethernet port. When power is dropped, the ethernet switch will lose power and the script will detect the lost of network connectivity on the ethernet port.

The script will stop Mame from running when the power fails. It will also track the amount of downtime and compare that against the expected battery life for the backup battery. If the threshold of the backup battery is exceeded the script will shutdown the Pi.

How To Use

Clone or copy the script to your computer, grant executable access (chmod +x pi-mame-manager.pl) and then run from the terminal to get started ./pi-mame-manager.pl.

There are some global variables defined at the beginning of the code which you will need to modify based on your needs: your path to Mame, the name of your Mame executable, the game you want to run, etc.

The script runs in a loop, so you can execute it in the background. It is designed to be launched at start up, but it would not be difficult to modify to run as a daemon or cron task.

Credit

This project is based on the Raspberry Pi UPS project by Mathias Kunter.

pimamemanager's People

Contributors

stilgarisca avatar

Watchers

 avatar

pimamemanager's Issues

Script should track battery life remaining

Currently, the script assumes that when the powered off state begins the battery will be fully charged. It should be possible to estimate and track how much battery charge exists at any given time and adjust the time before true shutdown appropriately.

Flexible sleep interval

The amount of time the script sleeps is currently fixed.
It might make more sense for the sleep interval to differ if the game is powered on/off in a way that could improve performance or battery run time.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.