sebhajek 2022-12-19 18:38:51 +01:00
commit f8f24240d8

View file

@ -15,8 +15,6 @@ const char* key2 = "brightness";
// UART communication variables
#define RX_PIN 19
#define TX_PIN 27
String stringReceived = "";
int valueReceived = 0;
// GUI variables
int brightnessValues[4] = {2500, 2750, 2900, 3150};
@ -114,18 +112,6 @@ void loop() {
}
M5.update();
// read value from UART
if(Serial2.available()){
char c = Serial2.read();
stringReceived += c;
if (stringReceived.length() == 1) {
valueReceived = stringReceived.toInt();
stringReceived = "";
} else {
stringReceived = "";
}
}
if (!SerialBT.isClosed() && SerialBT.connected()) {
if ((readOneByte() == 170) && readOneByte() == 170) {
@ -183,24 +169,13 @@ void loop() {
updateAttention();
// UART OUTPUT
switch (valueReceived) {
case 0:
break;
case 1:
Serial2.printf("%3d", attention);
break;
case 2:
Serial2.printf("%3d", attention);
break;
case 3:
Serial2.printf("%3d", poorQuality);
break;
case 4:
Serial2.printf("%+8d", raw);
break;
}
Serial2.printf("%3d", attention);
Serial2.printf("%3d", meditation);
Serial2.printf("%3d", poorQuality);
Serial2.printf("%+8d", raw);
// SERIAL OUTPUT
Serial.print("\n");
Serial.print("Attention: ");
Serial.print(attention);
Serial.print("\n");
@ -383,13 +358,12 @@ void drawBluetoothFailed() {
M5.lcd.fillRect(0, 185, 320, 240, (COLORS[COLOR_MODE] - 1) % 2);
M5.lcd.fillRect(0, 185, 320, 240, (COLORS[COLOR_MODE] - 1) % 2);
M5.Lcd.drawString("Bluetooth: disconnected", 20, 110, 4);
for (int i = 0; i < 4; i++) { // thicker line
M5.lcd.drawLine(240 + i, 55, 270 + i, 5, RED);
}
} else {
M5.Lcd.drawString("connecting failed", 50, 110, 4);
}
for (int i = 0; i < 4; i++) { // thicker line
M5.lcd.drawLine(240 + i, 55, 270 + i, 5, RED);
}
}
void bluetoothBlinking() {