added flask

master
q3k 2012-11-11 13:14:50 +01:00
parent a562781ab7
commit 213b8f01eb
3 changed files with 19 additions and 4 deletions

View File

@ -16,15 +16,18 @@ class CannonController :
ports = glob.glob("/dev/ttyACM*")
if(len(ports) == 1):
self.ser = serial.Serial(ports[0], 115200, timeout=1)
try:
self.ser = serial.Serial(ports[0], 115200, timeout=1)
except serial.SerialException:
raise Exception("Could not open serial connction (busy?)")
self.connected_to_serial = True
else:
self.ser = False
self.connected_to_serial = False
if len(ports) > 1 :
raise "To many devices to handle"
raise Exception("To many devices to handle")
elif len(ports) == 0 :
print "No device is connected"
print Exception("No device is connected")
def set_position(self, point):
self.position = point

Binary file not shown.

View File

@ -6,10 +6,14 @@ Created on Nov 10, 2012
import random, pygame, sys
import flask
import threading
from pygame.locals import *
from Cannon import CannonController
from Cannon import Gunpoint
app = flask.Flask(__name__)
app.debug = True
pygame.init()
def main():
@ -174,4 +178,12 @@ class Screen:
if __name__ == '__main__':
main()
t = threading.Thread(target=main)
def flask_runner():
app.run(use_reloader=False)
t2 = threading.Thread(target=flask_runner)
print "Starting pygame..."
t.start()
print "Starting flask..."
t2.start()