/* * Phytotron * configuration par la console */ /* -------------------------------------------------- */ #include #include #define DEBUG 1 /* -------------------------------------------------- */ /* some interesting macros */ #define prt(a) Serial.print(a) #define prtln(a) Serial.println(a) /* -------------------------------------------------- */ char waitkey(char echo) { char key; while (!Serial.available()); key = Serial.read(); if (echo) Serial.write(key); return key; } /* -------------------------------------------------- */ short readline(char *where, short sz) { char key; short count = 0; for(;;) { /* check for end of buffer */ if (count==sz) { where[count] = '\0'; return -1; } key = waitkey(1); #if DEBUG > 1 prtln((int)key); #endif if ((0x08==key) && count) { /* we have got a backspace */ count--; where[count] = '\0'; #if DEBUG prt("< "); prtln(count); #endif continue; } if ('\r' == key) { prt('\n'); where[count] = '\0'; return count; } where[count++] = key; } /* NOTREACHED */ } /* --------------------------------------------------------------- */ void hexdump(unsigned char *ptr, short nbre) { short foo; for (foo=0; foo