From c4a6768576e05ccfdd4c6e7728bd65a251dc11b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9D=D0=B8=D0=BA=D0=B8=D1=82=D0=B0=20=D0=A0=D0=BE=D0=BC?= =?UTF-8?q?=D0=B0=D0=BD=D0=B5=D0=BD=D0=BA=D0=BE?= Date: Sun, 29 Apr 2018 11:14:59 +0300 Subject: [PATCH] added selfTest function for testing board and removed some garbage from html.h --- src/html.h | 8 +++----- src/main.cpp | 16 ++++++++++++++++ 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/html.h b/src/html.h index d664827..15b6fff 100644 --- a/src/html.h +++ b/src/html.h @@ -59,8 +59,8 @@ const char html_begin[] PROGMEM = R"( var context = c.getContext("2d"); var maxX = 400, maxY = 200; var biasX = 20, biasY = 20; - var curVoltage = 20; - var freq = 16; + var maxVoltage = 20; + var freq = 4/4; function iY(y) { return maxY + biasY - y; } @@ -71,7 +71,7 @@ const char html_begin[] PROGMEM = R"( context.lineTo(20, iY(i)); context.lineTo(15, iY(i)); context.moveTo(20, iY(i)); - textY = i/200*curVoltage; + textY = i/200*maxVoltage; context.fillText(textY.toFixed(1), 0, iY(i-2.5)); } context.moveTo(20, iY(0)); @@ -100,8 +100,6 @@ const char html_begin[] PROGMEM = R"( for (i = 1; i < 200; i++) { context.lineTo(i*2 + biasX, data.data[i] + biasY); } - voltage = data.data[199]*(-0.1)+20; - context.fillText(voltage + " V", 200,20); context.stroke(); }; function calibrateDevice() { diff --git a/src/main.cpp b/src/main.cpp index db6cfe7..fec68b8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -131,6 +131,19 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t length } } +void selfTest(){ + if (millis() - lastTest > 19) { + if (!testState) { + digitalWrite(D0, HIGH); + testState = true; + } else { + digitalWrite(D0, LOW); + testState = false; + } + lastTest = millis(); + } +} + void setup(void) @@ -157,6 +170,7 @@ void setup(void) webSocket.onEvent(webSocketEvent); pinMode(A0, INPUT); + pinMode(D0, OUTPUT); //selftest pin } void loop(void) @@ -168,6 +182,8 @@ void loop(void) updateSensors(); sendDataToSocket(); + selfTest(); + updateCpuTime(1); printCpuLoad(); } \ No newline at end of file