basic parsing of data
This commit is contained in:
parent
71161ecde5
commit
275ea1330e
60
M2/M2.ino
60
M2/M2.ino
|
@ -139,15 +139,11 @@ void powerOffHandler(Event& e) {
|
||||||
|
|
||||||
void attentionHandler(Event& e) {
|
void attentionHandler(Event& e) {
|
||||||
M5.Axp.SetLDOEnable(3, true);
|
M5.Axp.SetLDOEnable(3, true);
|
||||||
delay(50);
|
delay(80);
|
||||||
M5.Axp.SetLDOEnable(3, false);
|
M5.Axp.SetLDOEnable(3, false);
|
||||||
if(DATA_MODE == ATTENTION){
|
if(DATA_MODE == ATTENTION){
|
||||||
Serial2.print("0");
|
|
||||||
DATA_MODE = STOP;
|
DATA_MODE = STOP;
|
||||||
Serial.println("Stopping");
|
|
||||||
}else{
|
}else{
|
||||||
delay(50);
|
|
||||||
Serial2.print("1");
|
|
||||||
DATA_MODE = ATTENTION;
|
DATA_MODE = ATTENTION;
|
||||||
Serial.println("in ATTENTION");
|
Serial.println("in ATTENTION");
|
||||||
}
|
}
|
||||||
|
@ -156,15 +152,11 @@ void attentionHandler(Event& e) {
|
||||||
|
|
||||||
void meditationHandler(Event& e) {
|
void meditationHandler(Event& e) {
|
||||||
M5.Axp.SetLDOEnable(3, true);
|
M5.Axp.SetLDOEnable(3, true);
|
||||||
delay(50);
|
delay(80);
|
||||||
M5.Axp.SetLDOEnable(3, false);
|
M5.Axp.SetLDOEnable(3, false);
|
||||||
if(DATA_MODE == MEDITATION){
|
if(DATA_MODE == MEDITATION){
|
||||||
Serial2.print("0");
|
|
||||||
DATA_MODE = STOP;
|
DATA_MODE = STOP;
|
||||||
Serial.println("Stopping");
|
|
||||||
}else{
|
}else{
|
||||||
delay(50);
|
|
||||||
Serial2.print("2");
|
|
||||||
DATA_MODE = MEDITATION;
|
DATA_MODE = MEDITATION;
|
||||||
Serial.println("in MEDITATION");
|
Serial.println("in MEDITATION");
|
||||||
}
|
}
|
||||||
|
@ -173,15 +165,11 @@ void meditationHandler(Event& e) {
|
||||||
|
|
||||||
void qualityHandler(Event& e) {
|
void qualityHandler(Event& e) {
|
||||||
M5.Axp.SetLDOEnable(3, true);
|
M5.Axp.SetLDOEnable(3, true);
|
||||||
delay(50);
|
delay(80);
|
||||||
M5.Axp.SetLDOEnable(3, false);
|
M5.Axp.SetLDOEnable(3, false);
|
||||||
if(DATA_MODE == QUALITY){
|
if(DATA_MODE == QUALITY){
|
||||||
Serial2.print("0");
|
|
||||||
DATA_MODE = STOP;
|
DATA_MODE = STOP;
|
||||||
Serial.println("Stopping");
|
|
||||||
}else{
|
}else{
|
||||||
delay(50);
|
|
||||||
Serial2.print("3");
|
|
||||||
DATA_MODE = QUALITY;
|
DATA_MODE = QUALITY;
|
||||||
Serial.println("in QUALITY");
|
Serial.println("in QUALITY");
|
||||||
}
|
}
|
||||||
|
@ -190,16 +178,13 @@ void qualityHandler(Event& e) {
|
||||||
|
|
||||||
void rawHandler(Event& e) {
|
void rawHandler(Event& e) {
|
||||||
M5.Axp.SetLDOEnable(3, true);
|
M5.Axp.SetLDOEnable(3, true);
|
||||||
delay(50);
|
delay(80);
|
||||||
M5.Axp.SetLDOEnable(3, false);
|
M5.Axp.SetLDOEnable(3, false);
|
||||||
if(DATA_MODE == RAW){
|
if(DATA_MODE == RAW){
|
||||||
Serial2.print("0");
|
|
||||||
DATA_MODE = STOP;
|
DATA_MODE = STOP;
|
||||||
Serial.println("Stopping");
|
|
||||||
}else{
|
}else{
|
||||||
delay(50);
|
|
||||||
Serial2.print("4");
|
|
||||||
DATA_MODE = RAW;
|
DATA_MODE = RAW;
|
||||||
|
Serial.println("in RAW");
|
||||||
}
|
}
|
||||||
drawGui(COLOR_MODE);
|
drawGui(COLOR_MODE);
|
||||||
}
|
}
|
||||||
|
@ -233,29 +218,24 @@ void writeScreenData(dataMode DATA_MODE, screenMode COLOR_MODE, int data){
|
||||||
|
|
||||||
String stringReceived = "";
|
String stringReceived = "";
|
||||||
int valueReceived = 0;
|
int valueReceived = 0;
|
||||||
|
int valuesReceived[4];
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
//M5.update();
|
M5.update();
|
||||||
if(Serial2.available()){
|
while(Serial2.available())
|
||||||
|
{
|
||||||
char c = Serial2.read();
|
char c = Serial2.read();
|
||||||
//Serial.print(c);
|
Serial.print(c);
|
||||||
|
Serial.println;
|
||||||
stringReceived += c;
|
stringReceived += c;
|
||||||
if (stringReceived.length() == 17) {
|
if (stringReceived.length() == 17) {
|
||||||
Serial.println("s:"+stringReceived);
|
Serial.println("s:"+stringReceived);
|
||||||
String rawData = stringReceived.substring(9);
|
valuesReceived[RAW] = {}stringReceived.substring(9);
|
||||||
/*int r = 8;
|
valuesReceived[QUALITY] = {}stringReceived.substring(6);
|
||||||
while (r < 17){
|
valuesReceived[MEDITATION] = {}stringReceived.substring(3);
|
||||||
rawData += stringReceived[r];
|
valuesReceived[ATTENTION] = {}stringReceived.substring(0);
|
||||||
r++;
|
Serial.printf("a:%3d m:%3d q:%3d r:%+8d\n",valuesReceived[ATTENTION],valueReceived[MEDITATION],valueReceived[QUALITY],valuesReceived[RAW]);
|
||||||
}*/
|
stringReceived = "";
|
||||||
Serial.println("r:" +rawData);
|
}
|
||||||
//valueReceived = stringReceived.toInt();
|
|
||||||
//Serial.println(valueReceived);
|
|
||||||
stringReceived = "";
|
|
||||||
//valueReceived= 0;
|
|
||||||
} else {
|
|
||||||
//stringReceived = "";
|
|
||||||
}
|
|
||||||
//writeScreenData(DATA_MODE, COLOR_MODE, valueReceived);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue