Added debugging and loop
This commit is contained in:
parent
53bbff3217
commit
8880502576
@ -3,6 +3,7 @@
|
||||
from flask import Flask, request
|
||||
import threading
|
||||
import serial
|
||||
import time
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
@ -17,6 +18,8 @@ def update():
|
||||
with globals()['lock']:
|
||||
globals()['data'] = grid_string
|
||||
|
||||
print("data updated to: " + grid_string)
|
||||
|
||||
return grid_string
|
||||
|
||||
def prepare_grid(grid):
|
||||
@ -35,10 +38,12 @@ def prepare_grid(grid):
|
||||
|
||||
def serial_func():
|
||||
with serial.Serial('/dev/ttyACM0', 9600, timeout=1) as ser:
|
||||
with globals()['lock']:
|
||||
if globals()['data'] != '':
|
||||
serial.write(bytes(globals()['data'], 'ascii'))
|
||||
globals()['data'] = ''
|
||||
while True:
|
||||
with globals()['lock']:
|
||||
if globals()['data'] != '':
|
||||
serial.write(bytes(globals()['data'], 'ascii'))
|
||||
globals()['data'] = ''
|
||||
time.sleep(0.1)
|
||||
|
||||
serial_thread = threading.Thread(target=serial_func)
|
||||
serial_thread.start()
|
||||
|
Loading…
Reference in New Issue
Block a user