selftest.ino 14 KB

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