diff --git a/.gitignore b/.gitignore index ed8ebf5..934eb76 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ -__pycache__ \ No newline at end of file +__pycache__ +.vscode +*.csv \ No newline at end of file diff --git a/Host/DataFile.py b/Host/DataFile.py index 6288972..37b5464 100644 --- a/Host/DataFile.py +++ b/Host/DataFile.py @@ -3,19 +3,18 @@ class DataFile: def __init__(self): - base_path = os.path.dirname(__file__) - self.File = None - self.File = open( base_path + "/data/data.csv", "a+") + self.BasePath = os.path.dirname(__file__) def __del__(self): - if self.File != None: - self.File.flush() - self.File.close() + self.Close() def Write(self, data): + if self.File == None: + self.Open() + if len(data) >= 6: for i in range(6): if i > 0: self.File.write("\t") @@ -24,4 +23,16 @@ def Write(self, data): self.File.write("\n") + def Open(self): + self.File = None + self.File = open(self.BasePath + "/data/data.csv", "a+") + + + def Close(self): + if self.File != None: + self.File.flush() + self.File.close() + + self.File = None + \ No newline at end of file diff --git a/Host/SensorChart.py b/Host/SensorChart.py index 425c742..89c7d1a 100644 --- a/Host/SensorChart.py +++ b/Host/SensorChart.py @@ -1,3 +1,5 @@ + + from OpenGL import GLUT, GLU, GL AxisColor = [[1, 0, 0], [0, 1, 0], [0, 0, 1]] diff --git a/Host/SensorProcess.py b/Host/SensorProcess.py index d6c2922..18288ff 100644 --- a/Host/SensorProcess.py +++ b/Host/SensorProcess.py @@ -1,3 +1,5 @@ +## + from asyncio.windows_events import NULL import socket from PerformanceCounter import PerformanceCounter @@ -41,6 +43,7 @@ def Recv(self): except socket.timeout: raw_data = [] + self.DataFile.Close() except Exception as e: raw_data = [] diff --git a/Host/tinyml.ipynb b/Host/tinyml.ipynb index 864eb1d..3b76ae1 100644 --- a/Host/tinyml.ipynb +++ b/Host/tinyml.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "code", - "execution_count": 15, + "execution_count": 1, "id": "5b90960c", "metadata": {}, "outputs": [], @@ -256,8 +256,11 @@ } ], "metadata": { + "interpreter": { + "hash": "065a7fd65857af9b0d7d7760ab62099efda22ea2fccd7cdd83105fb1a789eaf5" + }, "kernelspec": { - "display_name": "Python 3 (ipykernel)", + "display_name": "Python 3.7.13 64-bit ('tinyml': conda)", "language": "python", "name": "python3" }, @@ -271,7 +274,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.7.11" + "version": "3.7.13" } }, "nbformat": 4, diff --git a/predict_gesture/predict_gesture.ino b/predict_gesture/predict_gesture.ino index ecb58b9..b1405df 100644 --- a/predict_gesture/predict_gesture.ino +++ b/predict_gesture/predict_gesture.ino @@ -20,7 +20,7 @@ const int BUTTOM_PIN = 4; -const char* AP_SSID = "iCheng-choy"; +const char* AP_SSID = "iCheng"; const char* AP_PWD = "nopassword"; const char* GESTURES[] = {