Management, update arduino, add initial webapp
This commit is contained in:
parent
b6f4601972
commit
fd6f26f202
@ -188,23 +188,18 @@ if (win){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void logTasks(){
|
void logTasks(){
|
||||||
LogSerial.print("tasks: ");
|
CommandSerial.print("TASKS:");
|
||||||
for(int i=0; i<N_TASKS; i++){
|
for(int i=0; i<N_TASKS; i++){
|
||||||
LogSerial.print(i+1);
|
CommandSerial.print(taskLifetimes[i]);
|
||||||
LogSerial.print(": ");
|
if (i < N_TASKS-1) CommandSerial.print(",");
|
||||||
LogSerial.print(taskLifetimes[i]);
|
|
||||||
LogSerial.print("\t\t");
|
|
||||||
|
|
||||||
CommandSerial.print(i);
|
|
||||||
CommandSerial.print(":");
|
|
||||||
if(taskLifetimes[i]) CommandSerial.print(("y")); else CommandSerial.print(("n"));
|
|
||||||
CommandSerial.print("#");
|
|
||||||
}
|
}
|
||||||
LogSerial.println();
|
|
||||||
CommandSerial.println();
|
CommandSerial.println();
|
||||||
}
|
}
|
||||||
|
|
||||||
void setSlide(int n){
|
void setSlide(int n){
|
||||||
|
CommandSerial.print("SLIDE:");
|
||||||
|
CommandSerial.println(n);
|
||||||
|
|
||||||
switch(n){
|
switch(n){
|
||||||
case 1:
|
case 1:
|
||||||
log("signalling slide 1.");
|
log("signalling slide 1.");
|
||||||
@ -484,7 +479,7 @@ void setup() {
|
|||||||
// set the digital pin as output:
|
// set the digital pin as output:
|
||||||
pinMode(13, OUTPUT);
|
pinMode(13, OUTPUT);
|
||||||
LogSerial.begin(115200);
|
LogSerial.begin(115200);
|
||||||
CommandSerial.begin(9600);
|
CommandSerial.begin(115200);
|
||||||
setupPins();
|
setupPins();
|
||||||
keypad.addEventListener(keypadEvent);
|
keypad.addEventListener(keypadEvent);
|
||||||
prevKnobInput = map(analogRead(pin_knob), 0, 1024, 0, 10);
|
prevKnobInput = map(analogRead(pin_knob), 0, 1024, 0, 10);
|
||||||
|
3
raspi/mgmt/autostart
Normal file
3
raspi/mgmt/autostart
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
@xset s noblank
|
||||||
|
@xset s off
|
||||||
|
@xset -dpms
|
7
raspi/mgmt/playbook.yml
Normal file
7
raspi/mgmt/playbook.yml
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
- hosts: raspi
|
||||||
|
become: True
|
||||||
|
become_user: root
|
||||||
|
tasks:
|
||||||
|
- copy: src=autostart dest=/home/pi/.config/lxsession/LXDE-pi/autostart
|
||||||
|
- copy: src=sejf.desktop dest=/etc/xdg/autostart
|
||||||
|
- apt: name=python-flask state=present
|
7
raspi/mgmt/sejf.desktop
Executable file
7
raspi/mgmt/sejf.desktop
Executable file
@ -0,0 +1,7 @@
|
|||||||
|
[Desktop Entry]
|
||||||
|
Type=Application
|
||||||
|
Name=sejf
|
||||||
|
NoDisplay=true
|
||||||
|
Exec=python /home/pi/sejf/raspi/pySejf.py
|
||||||
|
Terminal=true
|
||||||
|
NotShowIn=GNOME;KDE;XFCE;
|
@ -2,8 +2,10 @@
|
|||||||
import os
|
import os
|
||||||
os.chdir(os.path.dirname(os.path.realpath(__file__)))
|
os.chdir(os.path.dirname(os.path.realpath(__file__)))
|
||||||
|
|
||||||
import subprocess
|
import serial
|
||||||
subprocess.call('(date; pwd) >> /tmp/log', shell=True)
|
import webapp
|
||||||
|
|
||||||
|
webapp.init(serial.Serial('/dev/ttyUSB0', 115200))
|
||||||
|
|
||||||
import random, math, pygame
|
import random, math, pygame
|
||||||
from pygame.locals import *
|
from pygame.locals import *
|
||||||
@ -176,6 +178,7 @@ def waitForEvents():
|
|||||||
global slide
|
global slide
|
||||||
print("waiting for events")
|
print("waiting for events")
|
||||||
while 1:
|
while 1:
|
||||||
|
time.sleep(0.01)
|
||||||
if GPIO.input(PIN_SET1) == 0 and slide != SLIDE_KEY:
|
if GPIO.input(PIN_SET1) == 0 and slide != SLIDE_KEY:
|
||||||
print "Ardu said go to key slide"
|
print "Ardu said go to key slide"
|
||||||
slide = SLIDE_KEY
|
slide = SLIDE_KEY
|
||||||
|
19
raspi/templates/index.html
Normal file
19
raspi/templates/index.html
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
<html>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<th>Włącz</th>
|
||||||
|
{% for n in range(10) %}
|
||||||
|
<td><a href="/set/{{ n }}">{{ n + 1 }}</a></td>
|
||||||
|
{% endfor %}
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th>Wyłącz</th>
|
||||||
|
{% for n in range(10) %}
|
||||||
|
<td><a href="/clear/{{ n }}">{{ n + 1 }}</a></td>
|
||||||
|
{% endfor %}
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</body>
|
||||||
|
</html>
|
28
raspi/webapp.py
Normal file
28
raspi/webapp.py
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
import flask
|
||||||
|
import string
|
||||||
|
import threading
|
||||||
|
|
||||||
|
app = flask.Flask(__name__)
|
||||||
|
|
||||||
|
@app.route('/set/<int:task>')
|
||||||
|
def set_task(task):
|
||||||
|
app.port.write(string.uppercase[task])
|
||||||
|
return flask.redirect('/')
|
||||||
|
|
||||||
|
@app.route('/clear/<int:task>')
|
||||||
|
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()
|
Loading…
x
Reference in New Issue
Block a user