selftest.ino 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694
  1. #include <EEPROM.h>
  2. #include <SPI.h>
  3. #include <GD2.h>
  4. #define GD3 ft8xx_model
  5. #define UART_SPEED 115200
  6. #include "selftest_assets.h"
  7. #define SCREEN_ADDR 0x30000UL
  8. byte x, y;
  9. static void log(const char*s)
  10. {
  11. while (*s) {
  12. char c = *s++;
  13. #ifndef RASPBERRY_PI
  14. Serial.write(c);
  15. #endif
  16. if (c == '\n') {
  17. x = 0;
  18. y++;
  19. } else {
  20. uint32_t dst = SCREEN_ADDR + (((x + (y * 48)) << 1));
  21. GD.wr16(dst, 0x0f00 | c);
  22. x++;
  23. }
  24. };
  25. }
  26. void setup()
  27. {
  28. Serial.begin(UART_SPEED);
  29. Serial.println("---- GAMEDUINO 2 SELFTEST ----");
  30. }
  31. static void ramp(int y, uint32_t color)
  32. {
  33. GD.ScissorSize(400, 8);
  34. GD.ScissorXY(40, y);
  35. GD.cmd_gradient(40, 0, 0x000000, 440, 0, color);
  36. }
  37. void testcard(int pass, const char *message)
  38. {
  39. // GD.ClearColorRGB(0x204060);
  40. GD.get_inputs();
  41. GD.Clear();
  42. GD.cmd_text(240, 12, 28, OPT_CENTER,
  43. GD3 ? "Gameduino3 Self test" :
  44. "Gameduino2 Self test");
  45. int y;
  46. y = 50;
  47. GD.Begin(POINTS);
  48. for (int i = 0; i < 6; i++) {
  49. byte l = 4 << i;
  50. GD.PointSize(280);
  51. GD.ColorRGB(0xffffff);
  52. GD.Vertex2ii(68 * (i + 1), y, 0, 0);
  53. GD.PointSize(240);
  54. GD.ColorRGB(l, l, l);
  55. GD.Vertex2ii(68 * (i + 1), y, 0, 0);
  56. }
  57. y += 30;
  58. ramp(y, 0xff0000); y += 12;
  59. ramp(y, 0x00ff00); y += 12;
  60. ramp(y, 0x0000ff); y += 12;
  61. ramp(y, 0xffffff); y += 12;
  62. GD.RestoreContext();
  63. // GD.Begin(BITMAPS);
  64. // GD.Vertex2ii(0, 272 - (8 * 16), 1, 0);
  65. // GD.Vertex2ii(480 - LENA_WIDTH, 272 - LENA_WIDTH, 0, 0);
  66. if (pass == -1)
  67. GD.ColorRGB(0x808000);
  68. else
  69. GD.ColorRGB(pass ? 0x40ff40 : 0xff4040);
  70. GD.cmd_text(120, 180, 31, OPT_CENTERY, message);
  71. GD.ColorRGB(0xffffff);
  72. GD.Begin(LINES);
  73. GD.Vertex2f(PIXELS(GD.inputs.x), PIXELS(0));
  74. GD.Vertex2f(PIXELS(GD.inputs.x), PIXELS(GD.h));
  75. GD.Vertex2f(PIXELS(0), PIXELS(GD.inputs.y));
  76. GD.Vertex2f(PIXELS(GD.w), PIXELS(GD.inputs.y));
  77. GD.swap();
  78. GD.finish();
  79. }
  80. #define SCREENTEST(NAME) \
  81. do { \
  82. Serial.println(#NAME); \
  83. testcard(-1, #NAME); \
  84. r = test_##NAME(); \
  85. const char* msg = r ? (#NAME ": pass") : (#NAME ": FAIL"); \
  86. Serial.println(msg); \
  87. testcard(r, msg); \
  88. while (!r) ; \
  89. } while (0)
  90. int test_ident()
  91. {
  92. byte id = GD.rd(REG_ID);
  93. if (id != 0x7c) {
  94. Serial.println(id, HEX);
  95. return 0;
  96. }
  97. return 1;
  98. }
  99. int test_clock()
  100. {
  101. int SPEEDUP = 8;
  102. GD.rd32(REG_CLOCK); // warm-up
  103. delay(10);
  104. long t1 = GD.rd32(REG_CLOCK);
  105. delay(1000 / SPEEDUP);
  106. long t2 = GD.rd32(REG_CLOCK);
  107. float measured = float(t2 - t1);
  108. // measured should be 48e6, within 2%
  109. float expected = (GD3 ? 60e6 : 48e6) / SPEEDUP;
  110. Serial.println(measured, DEC);
  111. Serial.println(expected, DEC);
  112. float diff = measured - expected;
  113. float percent = fabs(100 * (diff / expected));
  114. return percent < 5.0;
  115. }
  116. int test_tune()
  117. {
  118. GD.tune();
  119. return 1;
  120. }
  121. static byte test_RAM(void)
  122. {
  123. uint32_t a;
  124. for (a = 0; a < 0x40000U; a += 947)
  125. GD.wr(a, a);
  126. for (a = 0; a < 0x40000U; a += 947)
  127. if (GD.rd(a) != (a & 0xff))
  128. return 0;
  129. return 1;
  130. }
  131. static byte test_PWM(void)
  132. {
  133. for (int i = 128; i >= 0; i--) {
  134. GD.wr(REG_PWM_DUTY, i);
  135. delay(2);
  136. }
  137. GD.wr(REG_PWM_DUTY, 128);
  138. return 1;
  139. }
  140. static byte test_storage(void)
  141. {
  142. GD.storage();
  143. return test_ident();
  144. }
  145. static byte test_SDcard(void)
  146. {
  147. for (byte i = 0; i < 2; i++) {
  148. GD.safeload("selftest.gd2");
  149. uint32_t pcrc = GD.cmd_memcrc(0, ASSETS_END);
  150. GD.finish();
  151. uint32_t crc = GD.rd32(pcrc);
  152. if (crc != KITTEN_CRC)
  153. return 0;
  154. }
  155. return 1;
  156. }
  157. static int collect(int &rx, int &ry, int &rz)
  158. {
  159. uint16_t ax = 0, ay = 0, az = 0;
  160. for (byte i = 32; i; i--) {
  161. int x = analogRead(A2);
  162. int y = analogRead(A1);
  163. int z = analogRead(A0);
  164. ax += x;
  165. ay += y;
  166. az += z;
  167. }
  168. rx = ax >> 5;
  169. ry = ay >> 5;
  170. rz = az >> 5;
  171. }
  172. static byte test_accel2(void)
  173. {
  174. while (1) {
  175. GD.finish();
  176. if ((millis() % 2000) < 1000)
  177. GD.wr(REG_GPIO, 0x80);
  178. else
  179. GD.wr(REG_GPIO, 0x81);
  180. int x, y, z;
  181. collect(x, y, z);
  182. GD.Clear();
  183. GD.cmd_number(0, 40, 26, 3, x);
  184. GD.cmd_slider(50, 40, 400, 10, 0, x, 512);
  185. GD.cmd_number(0, 70, 26, 3, y);
  186. GD.cmd_slider(50, 70, 400, 10, 0, y, 512);
  187. GD.cmd_number(0, 100, 26, 3, GD.rd(REG_GPIO));
  188. GD.cmd_slider(50, 100, 400, 10, 0, z, 512);
  189. GD.swap();
  190. }
  191. return 1;
  192. }
  193. static byte test_accel(void)
  194. {
  195. int x0, y0, z0;
  196. int x1, y1, z1;
  197. GD.wr(REG_GPIO, 0x80);
  198. collect(x0, y0, z0);
  199. delay(100);
  200. GD.wr(REG_GPIO, 0x81);
  201. delay(100);
  202. collect(x1, y1, z1);
  203. Serial.print(x0); Serial.print(" "); Serial.print(y0); Serial.print(" "); Serial.println(z0);
  204. Serial.print(x1); Serial.print(" "); Serial.print(y1); Serial.print(" "); Serial.println(z1);
  205. // if ((x0 > x1) || (y0 > y1) || (z0 > z1)) return 0;
  206. int d;
  207. d = abs(x0 - x1);
  208. if ((d < 30) || (120 < d))
  209. return 0;
  210. d = abs(y0 - y1);
  211. if ((d < 30) || (120 < d))
  212. return 0;
  213. d = abs(z0 - z1);
  214. if ((d < 50) || (200 < d))
  215. return 0;
  216. z0 %= 37;
  217. while (z0--)
  218. GD.random();
  219. return 1;
  220. }
  221. static void play(uint16_t n)
  222. {
  223. GD.wr16(REG_SOUND, n);
  224. GD.wr(REG_PLAY, 1);
  225. }
  226. static void play_wait(uint16_t n)
  227. {
  228. play(n);
  229. while (GD.rd(REG_PLAY))
  230. ;
  231. }
  232. static byte test_touch(void)
  233. {
  234. if (!GD3) {
  235. GD.Clear();
  236. GD.cmd_text(240, 100, 30, OPT_CENTERX, "please tap on the dot");
  237. GD.self_calibrate();
  238. // write the new calibration back to EEPROM
  239. #if !defined(RASPBERRY_PI) && !defined(__DUE__)
  240. for (int i = 0; i < 24; i++)
  241. EEPROM.write(1 + i, GD.rd(REG_TOUCH_TRANSFORM_A + i));
  242. #endif
  243. }
  244. byte hit = 0;
  245. while (hit != 0x0f) {
  246. GD.finish();
  247. byte tag = GD.rd(REG_TOUCH_TAG);
  248. if ((1 <= tag) && (tag <= 4)) {
  249. play(0x50);
  250. hit |= (1 << (tag - 1));
  251. }
  252. if (tag == 77)
  253. return 0;
  254. GD.ClearTag(77);
  255. GD.Clear();
  256. GD.PointSize(20 * 16);
  257. GD.Begin(POINTS);
  258. for (byte i = 1; i <= 4; i++) {
  259. if (hit & (1 << (i - 1))) {
  260. GD.ColorRGB(0x00ff00);
  261. GD.Tag(0xff);
  262. } else {
  263. GD.ColorRGB(0x808080);
  264. GD.Tag(i);
  265. }
  266. switch (i) {
  267. case 1: GD.Vertex2ii(20, 20, 0, 0); break;
  268. case 2: GD.Vertex2ii(460, 20, 0, 0); break;
  269. case 3: GD.Vertex2ii(20, 250, 0, 0); break;
  270. case 4: GD.Vertex2ii(460, 250, 0, 0); break;
  271. }
  272. }
  273. GD.random(); // scramble PRN state for later
  274. GD.swap();
  275. }
  276. return 1;
  277. }
  278. static const PROGMEM uint32_t digits[11] = {
  279. DIGIT_0,
  280. DIGIT_1,
  281. DIGIT_2,
  282. DIGIT_3,
  283. DIGIT_4,
  284. DIGIT_5,
  285. DIGIT_6,
  286. DIGIT_7,
  287. DIGIT_8,
  288. DIGIT_9,
  289. DIGIT_9 + DIGIT_9_LENGTH
  290. };
  291. static void saydigit(byte n)
  292. {
  293. GD.wr32(REG_PLAYBACK_FREQ, 8000);
  294. GD.wr32(REG_PLAYBACK_FORMAT, ADPCM_SAMPLES);
  295. uint32_t dstart = pgm_read_dword(digits + n);
  296. uint32_t dend = pgm_read_dword(digits + n + 1);
  297. GD.wr32(REG_PLAYBACK_START, dstart);
  298. GD.wr32(REG_PLAYBACK_LENGTH, dend - dstart);
  299. GD.wr(REG_PLAYBACK_PLAY, 1);
  300. }
  301. static void blank(int n)
  302. {
  303. for (int i = 0; i < n; i++) {
  304. GD.get_inputs();
  305. GD.cmd_gradient(0, 0, 0xb0b0a0, 0, 272, 0x404040);
  306. GD.swap();
  307. }
  308. }
  309. static byte getkey()
  310. {
  311. byte prev_tag;
  312. do {
  313. prev_tag = GD.inputs.tag;
  314. GD.get_inputs();
  315. if (GD.inputs.x & 1)
  316. GD.random();
  317. GD.cmd_gradient(0, 0, 0xb0b0a0, 0, 272, 0x404040);
  318. for (int i = 0; i < 9; i++) {
  319. byte digit = i + 1;
  320. int x = 120 + 80 * (i % 3);
  321. int y = 20 + 80 * (i / 3);
  322. GD.Tag(digit);
  323. char msg[2] = { '0' + digit, 0 };
  324. GD.cmd_fgcolor((digit == GD.inputs.tag) ? 0xc08000 : 0x003870);
  325. GD.cmd_button(x, y, 70, 70, 31, 0, msg);
  326. }
  327. GD.swap();
  328. } while (!((GD.inputs.tag == 0) && (1 <= prev_tag) && (prev_tag <= 9)));
  329. return prev_tag;
  330. }
  331. static byte test_audio(void)
  332. {
  333. // Stir up the PRN
  334. for (int i = micros() % 97; i; i--)
  335. GD.random();
  336. blank(20);
  337. for (int i = 0; i < 3; i++) {
  338. byte d = 1 + GD.random(9);
  339. saydigit(d);
  340. blank(12);
  341. if (getkey() != d)
  342. return 0;
  343. }
  344. return 1;
  345. }
  346. static struct {
  347. byte t, note;
  348. } pacman[] = {
  349. { 0, 71 },
  350. { 2, 83 },
  351. { 4, 78 },
  352. { 6, 75 },
  353. { 8, 83 },
  354. { 9, 78 },
  355. { 12, 75 },
  356. { 16, 72 },
  357. { 18, 84 },
  358. { 20, 79 },
  359. { 22, 76 },
  360. { 24, 84 },
  361. { 25, 79 },
  362. { 28, 76 },
  363. { 32, 71 },
  364. { 34, 83 },
  365. { 36, 78 },
  366. { 38, 75 },
  367. { 40, 83 },
  368. { 41, 78 },
  369. { 44, 75 },
  370. { 48, 75 },
  371. { 49, 76 },
  372. { 50, 77 },
  373. { 52, 77 },
  374. { 53, 78 },
  375. { 54, 79 },
  376. { 56, 79 },
  377. { 57, 80 },
  378. { 58, 81 },
  379. { 60, 83 },
  380. { 255, 255 }
  381. };
  382. static const uint8_t GD3_43__init[128] = {
  383. 255, 255, 1, 1, 26, 255, 255, 255, 12, 32, 48, 0, 4, 0, 0, 0, 0, 135,
  384. 147, 3, 26, 255, 255, 255, 80, 33, 48, 0, 24, 0, 0, 0, 46, 46, 46, 46,
  385. 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46,
  386. 46, 46, 46, 34, 255, 255, 255, 88, 32, 48, 0, 120, 156, 99, 100, 96,
  387. 96, 216, 198, 200, 192, 0, 68, 12, 204, 12, 16, 26, 132, 217, 128, 24,
  388. 0, 17, 207, 0, 197, 0, 0, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255,
  389. 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0,
  390. 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255
  391. };
  392. static const uint8_t GD3_7__init[128] = {
  393. 255, 255, 1, 1, 26, 255, 255, 255, 12, 32, 48, 0, 4, 0, 0, 0, 0, 39,
  394. 134, 3, 26, 255, 255, 255, 80, 33, 48, 0, 24, 0, 0, 0, 46, 46, 46, 46,
  395. 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46,
  396. 46, 46, 46, 34, 255, 255, 255, 44, 32, 48, 0, 120, 156, 59, 201, 204,
  397. 192, 16, 193, 192, 192, 160, 0, 164, 65, 192, 0, 136, 89, 152, 128,
  398. 124, 32, 253, 128, 17, 34, 6, 149, 98, 0, 113, 183, 49, 66, 104, 100,
  399. 49, 160, 114, 6, 0, 164, 38, 3, 65, 0, 0, 0, 0, 255, 255, 255, 0, 255,
  400. 255, 255, 0, 255, 255, 255, 0, 255, 255, 255
  401. };
  402. static const uint8_t GD3_VGA__init[128] = {
  403. 255, 255, 1, 2, 26, 255, 255, 255, 12, 32, 48, 0, 4, 0, 0, 0, 64, 210,
  404. 223, 3, 26, 255, 255, 255, 148, 32, 48, 0, 4, 0, 0, 0, 16, 0, 0, 0,
  405. 34, 255, 255, 255, 44, 32, 48, 0, 120, 156, 115, 96, 101, 96, 208, 96,
  406. 100, 96, 96, 96, 97, 0, 131, 14, 32, 86, 99, 102, 96, 80, 6, 113, 152,
  407. 33, 98, 108, 12, 248, 1, 72, 59, 0, 77, 136, 1, 81, 0, 0, 0, 255, 255,
  408. 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255,
  409. 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0,
  410. 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255
  411. };
  412. #define FREQUENCY_OFFSET 16
  413. #define CALIBRATION_OFFSET 32
  414. uint8_t gpio, gpio_dir;
  415. void set_SDA(byte n)
  416. {
  417. GD.wr(REG_GPIO_DIR, gpio_dir | (0x03 - n)); // Drive SCL, SDA low
  418. }
  419. void set_SCL(byte n)
  420. {
  421. GD.wr(REG_GPIO, gpio | (n << 1));
  422. }
  423. int get_SDA(void)
  424. {
  425. return GD.rd(REG_GPIO) & 1;
  426. }
  427. void i2c_start(void)
  428. {
  429. set_SDA(1);
  430. set_SCL(1);
  431. set_SDA(0);
  432. set_SCL(0);
  433. }
  434. void i2c_stop(void)
  435. {
  436. set_SDA(0);
  437. set_SCL(1);
  438. set_SDA(1);
  439. set_SCL(1);
  440. }
  441. int i2c_rx1()
  442. {
  443. set_SDA(1);
  444. set_SCL(1);
  445. byte r = get_SDA();
  446. set_SCL(0);
  447. return r;
  448. }
  449. void i2c_tx1(byte b)
  450. {
  451. set_SDA(b);
  452. set_SCL(1);
  453. set_SCL(0);
  454. }
  455. int i2c_tx(byte x)
  456. {
  457. for (int i = 7; i >= 0; i--)
  458. i2c_tx1(1 & (x >> i));
  459. return i2c_rx1();
  460. }
  461. int i2c_rx(int nak)
  462. {
  463. byte r = 0;
  464. for (byte i = 0; i < 8; i++)
  465. r = (r << 1) | i2c_rx1();
  466. i2c_tx1(nak);
  467. return r;
  468. }
  469. void i2c_begin(void)
  470. {
  471. gpio = GD.rd(REG_GPIO) & ~3;
  472. gpio_dir = GD.rd(REG_GPIO_DIR) & ~3;
  473. // 2-wire software reset
  474. i2c_start();
  475. i2c_rx(1);
  476. i2c_start();
  477. i2c_stop();
  478. }
  479. #define ADDR 0xa0
  480. void ram_write(const uint8_t *v)
  481. {
  482. for (byte i = 0; i < 128; i += 8) {
  483. i2c_start();
  484. i2c_tx(ADDR);
  485. i2c_tx(i);
  486. for (byte j = 0; j < 8; j++)
  487. i2c_tx(*v++);
  488. i2c_stop();
  489. delay(6);
  490. }
  491. }
  492. byte ram_read(byte a)
  493. {
  494. i2c_start();
  495. i2c_tx(ADDR);
  496. i2c_tx(a);
  497. i2c_start();
  498. i2c_tx(ADDR | 1);
  499. byte r = i2c_rx(1);
  500. i2c_stop();
  501. return r;
  502. }
  503. void ramdump(void)
  504. {
  505. for (int i = 0; i < 128; i++) {
  506. byte v = ram_read(i);
  507. Serial.print(i, HEX);
  508. Serial.print(" ");
  509. Serial.println(v, HEX);
  510. }
  511. }
  512. void ram_get(byte *v)
  513. {
  514. i2c_start();
  515. i2c_tx(ADDR);
  516. i2c_tx(0);
  517. i2c_start();
  518. i2c_tx(ADDR | 1);
  519. for (int i = 0; i < 128; i++) {
  520. *v++ = i2c_rx(i == 127);
  521. // Serial.println(v[-1], DEC);
  522. }
  523. i2c_stop();
  524. }
  525. static void load_flash()
  526. {
  527. GD.begin(0);
  528. if (GD3) {
  529. uint8_t stage[128];
  530. memcpy(stage, GD3_43__init, 128);
  531. i2c_begin();
  532. GD.Clear();
  533. GD.cmd_text(240, 100, 30, OPT_CENTERX, "please tap on the dot");
  534. GD.self_calibrate();
  535. GD.finish();
  536. for (int i = 0; i < 24; i++)
  537. stage[CALIBRATION_OFFSET + i] = GD.rd(REG_TOUCH_TRANSFORM_A + i);
  538. ram_write(stage);
  539. byte b[128];
  540. ram_get(b);
  541. Serial.print("compare ");
  542. int diff = memcmp(stage, b, 128);
  543. if (diff != 0) {
  544. GD.Clear();
  545. GD.cmd_text(240, 100, 30, OPT_CENTERX, "FLASH fault");
  546. GD.swap();
  547. for (;;);
  548. }
  549. Serial.println(diff);
  550. }
  551. }
  552. void loop()
  553. {
  554. if (EEPROM.read(0) == 0x7c)
  555. EEPROM.write(0, 0xff);
  556. load_flash();
  557. GD.begin(0);
  558. x = y = 0;
  559. testcard(1, "Starting tests");
  560. GD.finish();
  561. Serial.println("Starting self-test");
  562. byte r, pass = 1;
  563. {
  564. SCREENTEST(ident);
  565. if (!GD3)
  566. SCREENTEST(tune);
  567. SCREENTEST(clock);
  568. SCREENTEST(RAM);
  569. SCREENTEST(PWM);
  570. SCREENTEST(storage);
  571. SCREENTEST(SDcard);
  572. if (0)
  573. SCREENTEST(accel);
  574. if (1) {
  575. SCREENTEST(touch);
  576. SCREENTEST(audio);
  577. }
  578. {
  579. int i = 0, t = 0;
  580. for (;;) {
  581. testcard(1, "* ALL PASS *");
  582. if (t == 4 * pacman[i].t)
  583. GD.play(HARP, pacman[i++].note - 12);
  584. if (++t == 256) {
  585. t = 0;
  586. i = 0;
  587. }
  588. }
  589. }
  590. }
  591. if (pass) {
  592. char msg[60];
  593. log("All tests passed\n");
  594. long seconds = millis() / 1000;
  595. int minutes = seconds / 60;
  596. sprintf(msg, "%d minutes", minutes);
  597. log(msg);
  598. } else {
  599. for (;;)
  600. ;
  601. }
  602. delay(5000);
  603. }