M1 updated UART communication.

This commit is contained in:
Vojtěch Pour 2022-12-19 16:06:50 +01:00
parent 9c8ec2f503
commit c324407db7

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");