selftest.ino 13 KB

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