bidirectionnal communication, first milestone reached

This commit is contained in:
phyto
2019-05-14 15:46:49 +02:00
parent 565c70b54f
commit 6d597e59e8
5 changed files with 69 additions and 42 deletions

View File

@@ -10,8 +10,6 @@
#define DEBUG 0
/* -------------------------------------------------- */
/* some interesting macros */
#define prt(a) Serial.print(a)
#define prtln(a) Serial.println(a)
/* -------------------------------------------------- */
char waitkey(char echo)
@@ -78,7 +76,7 @@ static void clihelp()
prtln("r\tread config");
prtln("w\twrite config");
prtln("T\ttest relay");
prtln("0/1\tcontrole frigo");
prtln("+/-\tcontrole frigo");
prtln("h\thexdump config");
}
/* --------------------------------------------------------------- */
@@ -148,7 +146,7 @@ do {
prt("$ ");
ret = readline(line,TLINE);
#if DEBUG > 1
hexdump((unsigned char *)line, ret);
prt("readline -> "); hexdump((unsigned char *)line, ret);
#endif
key = *(sptr = strtok(line, " "));

View File

@@ -10,6 +10,9 @@
#define RELAIS_FRIGO 42
#define RELAIS_VENTILO 40
#define prt(a) Serial.print(a)
#define prtln(a) Serial.println(a)
typedef struct {
unsigned short magic;
@@ -73,9 +76,7 @@ void updatevalues(short *ptr)
delay(50);
}
}
for (foo=0; foo<NBVAL; foo++) { ptr[foo] /= NB_PASSE; }
digitalWrite(LED_BUILTIN, LOW);
}
/* -------------------------------------------------- */
@@ -125,13 +126,13 @@ void loop() {
controle_frigo(0);
break;
default:
Serial.print("M bad control code");
prtln("M bad control code");
break;
}
}
delay(DELAI);
/* ETERNEL LOOP HERE */
/* ETERNAL LOOP END HERE */
}
/* -------------------------------------------------- */

View File

@@ -27,7 +27,7 @@ prtln(">>> read config");
magic = 0;
EEPROM.get(0, magic);
prt("magic is "); prtln(magic);
prt("M magic is "); prtln(magic);
if (0xfde9 != magic) return -1;
EEPROM.get(0, *where);
return -2;
@@ -61,7 +61,7 @@ prtln("");
prt("Delay : "); prtln(what->delai);
prt("Temp mini : "); prtln(what->temp_mini);
prt("Temp maxi : "); prtln(what->temp_maxi);
prt("Control : "); prtln(what->control);
return -1;
}
/* --------------------------------------------------------------- */