git diff
This commit is contained in:
parent
0a83be585a
commit
cce90eb60e
@ -7,7 +7,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#define DEBUG 1
|
||||
#define DEBUG 0
|
||||
/* -------------------------------------------------- */
|
||||
/* some interesting macros */
|
||||
#define prt(a) Serial.print(a)
|
||||
@ -70,13 +70,23 @@ prtln("");
|
||||
static void clihelp()
|
||||
{
|
||||
prtln("x\texit cli");
|
||||
prtln("I\tinit storage");
|
||||
prtln("I\tinit storage"); /* dangerous !!! */
|
||||
prtln("s d N\tset delay");
|
||||
prtln("s l N\tset lo temp");
|
||||
prtln("s h N\tset hi temp");
|
||||
prtln("d\tdisplay config");
|
||||
prtln("r\tread config");
|
||||
prtln("w\twrite config");
|
||||
prtln("H\thexdump config");
|
||||
prtln("h\thexdump config");
|
||||
}
|
||||
/* --------------------------------------------------------------- */
|
||||
void setvalue(char *cmdline)
|
||||
{
|
||||
hexdump(cmdline, 10);
|
||||
|
||||
}
|
||||
/* --------------------------------------------------------------- */
|
||||
|
||||
void phytocli(void)
|
||||
{
|
||||
char flag_exit = 0;
|
||||
@ -99,11 +109,11 @@ do {
|
||||
switch(key) {
|
||||
case 'x': flag_exit=1; break;
|
||||
case '?': clihelp(); break;
|
||||
case 'I': init_storage(); break;
|
||||
case 'I': init_storage(¶metres); break;
|
||||
case 'd': display_config(¶metres); break;
|
||||
case 'r': read_config(0, ¶metres); break;
|
||||
case 'w': write_config(0, ¶metres); break;
|
||||
case 'H': hexdump((unsigned char *)¶metres,
|
||||
case 'h': hexdump((unsigned char *)¶metres,
|
||||
sizeof(Global)); break;
|
||||
|
||||
default: prtln("gni ?"); break;
|
||||
|
@ -11,6 +11,9 @@ typedef struct {
|
||||
unsigned short magic;
|
||||
char tag[4];
|
||||
short delai;
|
||||
short temp_maxi;
|
||||
short temp_mini;
|
||||
short control;
|
||||
} Global;
|
||||
|
||||
Global parametres;
|
||||
@ -21,16 +24,13 @@ void setup() {
|
||||
pinMode(LED_BUILTIN, OUTPUT);
|
||||
|
||||
Serial.print("\n");
|
||||
|
||||
phytocli(); /* XXX */
|
||||
|
||||
/* XXX */
|
||||
/* changing the voltage reference of the ADC
|
||||
* greatly increase the prcision on the limited
|
||||
* range of our temperatures.
|
||||
*/
|
||||
analogReference(INTERNAL1V1); // Pour Arduino Mega2560
|
||||
Serial.print("\n\n");
|
||||
Serial.print("\n");
|
||||
delay(1000);
|
||||
Serial.print("M running now\n");
|
||||
|
||||
|
@ -1,40 +1,45 @@
|
||||
/* --------------------------------------------------------------- */
|
||||
#include <EEPROM.h>
|
||||
/* --------------------------------------------------------------- */
|
||||
short init_storage(void)
|
||||
short init_storage(Global *what)
|
||||
{
|
||||
short foo;
|
||||
|
||||
Serial.println(__func__);
|
||||
|
||||
Serial.print("eeprom length: ");
|
||||
Serial.println(EEPROM.length());
|
||||
Serial.print("global length: ");
|
||||
Serial.println(sizeof(Global));
|
||||
|
||||
memset(what, 0, sizeof(Global));
|
||||
what->magic = 0xfde9;
|
||||
EEPROM.put(0, *what);
|
||||
|
||||
return 0;
|
||||
}
|
||||
/* --------------------------------------------------------------- */
|
||||
short read_config(short num, Global *where)
|
||||
{
|
||||
unsigned short magic;
|
||||
|
||||
#if DEBUG
|
||||
prtln(">>> read config");
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
return -1;
|
||||
magic = 0;
|
||||
prt("magic is "); prtln(magic);
|
||||
EEPROM.get(0, magic);
|
||||
prt("magic is "); prtln(magic);
|
||||
if (0xfde9 != magic) return -1;
|
||||
EEPROM.get(0, *where);
|
||||
return -2;
|
||||
}
|
||||
/* --------------------------------------------------------------- */
|
||||
short write_config(short num, Global *from)
|
||||
{
|
||||
#if DEBUG
|
||||
prtln(">>> write config");
|
||||
#endif
|
||||
|
||||
from->magic = 0xfde9;
|
||||
memcpy(from->tag, "aaaa", 4);
|
||||
|
||||
|
||||
|
||||
return -1;
|
||||
}
|
||||
/* --------------------------------------------------------------- */
|
||||
@ -53,6 +58,8 @@ for (foo=0; foo<4; foo++) {
|
||||
}
|
||||
prtln("");
|
||||
prt("Delay : "); prtln(what->delai);
|
||||
prt("Temp mini : "); prtln(what->temp_mini);
|
||||
prt("Temp maxi : "); prtln(what->temp_maxi);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user