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