From fd6f26f2020a8c4fa535e6e74f106a05ec77001a Mon Sep 17 00:00:00 2001 From: Piotr Dobrowolski Date: Sat, 9 Sep 2017 23:44:49 +0200 Subject: [PATCH] Management, update arduino, add initial webapp --- arduino/src/main.ino | 19 +++++++------------ raspi/mgmt/autostart | 3 +++ raspi/mgmt/playbook.yml | 7 +++++++ raspi/mgmt/sejf.desktop | 7 +++++++ raspi/pySejf.py | 7 +++++-- raspi/templates/index.html | 19 +++++++++++++++++++ raspi/webapp.py | 28 ++++++++++++++++++++++++++++ 7 files changed, 76 insertions(+), 14 deletions(-) create mode 100644 raspi/mgmt/autostart create mode 100644 raspi/mgmt/playbook.yml create mode 100755 raspi/mgmt/sejf.desktop create mode 100644 raspi/templates/index.html create mode 100644 raspi/webapp.py diff --git a/arduino/src/main.ino b/arduino/src/main.ino index 8cf208a..7f369d5 100644 --- a/arduino/src/main.ino +++ b/arduino/src/main.ino @@ -188,23 +188,18 @@ if (win){ } void logTasks(){ - LogSerial.print("tasks: "); + CommandSerial.print("TASKS:"); for(int i=0; i> /tmp/log', shell=True) +import serial +import webapp + +webapp.init(serial.Serial('/dev/ttyUSB0', 115200)) import random, math, pygame from pygame.locals import * @@ -176,6 +178,7 @@ def waitForEvents(): global slide print("waiting for events") while 1: + time.sleep(0.01) if GPIO.input(PIN_SET1) == 0 and slide != SLIDE_KEY: print "Ardu said go to key slide" slide = SLIDE_KEY diff --git a/raspi/templates/index.html b/raspi/templates/index.html new file mode 100644 index 0000000..2872457 --- /dev/null +++ b/raspi/templates/index.html @@ -0,0 +1,19 @@ + + + + + + +{% for n in range(10) %} + +{% endfor %} + + + +{% for n in range(10) %} + +{% endfor %} + +
Włącz{{ n + 1 }}
Wyłącz{{ n + 1 }}
+ + diff --git a/raspi/webapp.py b/raspi/webapp.py new file mode 100644 index 0000000..52d186d --- /dev/null +++ b/raspi/webapp.py @@ -0,0 +1,28 @@ +import flask +import string +import threading + +app = flask.Flask(__name__) + +@app.route('/set/') +def set_task(task): + app.port.write(string.uppercase[task]) + return flask.redirect('/') + +@app.route('/clear/') +def clear_task(task): + app.port.write(string.lowercase[task]) + return flask.redirect('/') + +@app.route('/') +def index(): + return flask.render_template('index.html') + +def init(ser): + app.port = ser + + app.th = threading.Thread(target=app.run, kwargs={ + 'host': '0.0.0.0' + }) + app.th.daemon = True + app.th.start()