Browse Source

added selfTest function for testing board and removed some garbage from html.h

master
parent
commit
c4a6768576
  1. 8
      src/html.h
  2. 16
      src/main.cpp

8
src/html.h

@ -59,8 +59,8 @@ const char html_begin[] PROGMEM = R"(
var context = c.getContext("2d"); var context = c.getContext("2d");
var maxX = 400, maxY = 200; var maxX = 400, maxY = 200;
var biasX = 20, biasY = 20; var biasX = 20, biasY = 20;
var curVoltage = 20; var maxVoltage = 20;
var freq = 16; var freq = 4/4;
function iY(y) { function iY(y) {
return maxY + biasY - y; return maxY + biasY - y;
} }
@ -71,7 +71,7 @@ const char html_begin[] PROGMEM = R"(
context.lineTo(20, iY(i)); context.lineTo(20, iY(i));
context.lineTo(15, iY(i)); context.lineTo(15, iY(i));
context.moveTo(20, 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.fillText(textY.toFixed(1), 0, iY(i-2.5));
} }
context.moveTo(20, iY(0)); context.moveTo(20, iY(0));
@ -100,8 +100,6 @@ const char html_begin[] PROGMEM = R"(
for (i = 1; i < 200; i++) { for (i = 1; i < 200; i++) {
context.lineTo(i*2 + biasX, data.data[i] + biasY); context.lineTo(i*2 + biasX, data.data[i] + biasY);
} }
voltage = data.data[199]*(-0.1)+20;
context.fillText(voltage + " V", 200,20);
context.stroke(); context.stroke();
}; };
function calibrateDevice() { function calibrateDevice() {

16
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) void setup(void)
@ -157,6 +170,7 @@ void setup(void)
webSocket.onEvent(webSocketEvent); webSocket.onEvent(webSocketEvent);
pinMode(A0, INPUT); pinMode(A0, INPUT);
pinMode(D0, OUTPUT); //selftest pin
} }
void loop(void) void loop(void)
@ -168,6 +182,8 @@ void loop(void)
updateSensors(); updateSensors();
sendDataToSocket(); sendDataToSocket();
selfTest();
updateCpuTime(1); updateCpuTime(1);
printCpuLoad(); printCpuLoad();
} }
Loading…
Cancel
Save