This wiki has been archived and made read-only.
For up-to-date information about TkkrLab and it's projects please visit our main website at tkkrlab.nl.

1943 Arcadekast

From

Jump to: navigation, search

Aim: To tweet a highscore on twitter when this is broken.


Avr 1943 arcade.jpg

What is needed

  • Hardware
    • a fairly hefty ATMega644P
    • ENC28J60 for the ethernet connection
  • Software
    • Ethersex framework for connection to internet
    • ecmds to send commands form HTTP to the AVR
    • z80interface: hardware driver to make the AVR aware of the Z80
    • arcade1943: do the magic as finding the highscore and store in EEPROM
    • python script and libraries to read the highschore by ecmds interface and tweet it.


AVR interface

For all the details of the hardware and AVR software look at Sprite_TM Twitter1943 own project page.

Available AVR commands

When the arcade start up its joining the #tkkrlab irc channel. In irc you can give the following commands to the arcade:

  • '!1943_readhs' : give the higscore as in the arcade.
  • '!1943_msg time message' put a message on display for 'time' seconds
  • '!ip' : give the current ip of arcade

You can also execute an ecmd over http: do a GET on http://ip.of.the.machine/ecmd?the_command


Twitter interface

The arcade have a simple ethernet interface where the highscore can be read. This python script is reading the highscore every 15 seconds and check with previous score and twitter the new highscore if one is broken.

Do the steps of twitter API to get the autorisation codes. (4 codes in total)

get the python packages oauth2 and python-twitter

build and install these

copy/create the script below

/*
import twitter
import sys
import time
import datetime
import urllib
 
twit = twitter.Api(consumer_key='customer_ley',
consumer_secret='secret_key', access_token_key='token_key', access_token_secret='token_secret_key')
 
 
oldscore = []
wait = 300
 
def check( tempoldscore ):
        newscore = []
        try:
                filehandle = urllib.urlopen('http://ip.of.the.machine/ecmd?1943_readhs')
        except IOError:
                print "Arcade kast niet gevonden"
                wait = 15
        else:
                if filehandle.getcode() <>200:
                        print 'Error HTTGET Code ' 
                        print filehandle.getcode()
                else:
                        for lines in filehandle.readlines():
                                element = lines.split(' ')
                                element[1] = element[1].strip('\n')
                                newscore.append(element)
                                filehandle.close()
                wait = 15
 
        # if script is run first time
        if len(tempoldscore) == 0:
                tempoldscore = list(newscore)
 
        element = 0
        for i in newscore:
                if ((i <> tempoldscore[element]) and (i[1]<>'') and (i[1]<>'0') and (i[1]<>'000') ):
                        now = datetime.datetime.now()
                        timestamp = now.strftime("%d-%m-%Y %H:%M")
                        text =  i[1] + ' has broken the high score on 1943 arcade with '+ i[0] + ' on ' + timestamp
                        tempoldscore = list(newscore)           
                        status = twit.PostUpdate(text)
                        break
                element +=1
        return tempoldscore
 
 
#main program
while True:
        oldscore = check( oldscore )
        time.sleep(wait)
Put some text on the arcade

More info


This project has been build by

  • Sprite_TM (all harware and AVR stuff)
  • Zeno (twitter script)