Python-Steuerprogramm für Eigenbau-LED-Matrix
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

70 lines
1.9 KiB

#!/usr/bin/python
from MCP23S17 import *
from lightChip import *
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
class HTTPServ(BaseHTTPRequestHandler):
def do_GET(self):
try:
self.send_response(200)
self.send_header('Content-Type','text/html')
self.end_headers()
parts = self.path.split('/',2)
chanel=int(parts[1])
prec=int(parts[2])
self.wfile.write('<html>');
self.wfile.write('<head><title></title><style>*{ background-color: #000; color: #fff; } td{ text-align: center; border: 1px solid #222; border-radius: 5px; padding: 5px; } table{ border-spacing: 10px 0; width: 100%; height: 100%}</style></head>');
self.wfile.write('<body>')
self.wfile.write('<table>');
self.wfile.write("<tr>\n");
self.wfile.write("</tr>\n");
for dim in range(0,11):
self.wfile.write("<tr>\n");
for col in range(0,8):
self.wfile.write('<td onclick="window.location=\'../../{}/{}\';">{}/{}</td>'.format(col,dim,(1+col),dim))
self.wfile.write("</tr>\n");
self.wfile.write('</table>');
self.wfile.write('</body>')
self.wfile.write('</html>');
chip.state[chanel]=prec
return
except IOError:
self.send_error(404,'Not found')
if __name__ == "__main__":
GPIO.cleanup()
GPIO.setmode(GPIO.BOARD);
GPIO.setwarnings(True);
CS=13
CLK=11
MOSI=7
MISO=5
CS=16
CLK=12
MOSI=10
MISO=8
print "configuring line pins."
GPIO.setup(CLK, GPIO.OUT)
GPIO.setup(MOSI, GPIO.OUT)
GPIO.setup(MISO, GPIO.IN)
GPIO.setup(CS, GPIO.OUT)
print "initializing line level."
GPIO.output(CS, GPIO.HIGH);
GPIO.output(CLK, GPIO.LOW);
chip = lightChip(0,CS, CLK, MISO, MOSI)
try:
server = HTTPServer(('',80), HTTPServ)
print 'started server'
server.serve_forever()
except KeyboardInterrupt:
server.socket.close()
GPIO.cleanup()