Simple single-color 8x8x8 LED Cube with AVRs
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777
  1. /*
  2. * main.c
  3. *
  4. * Copyright 2011 Thomas Buck <xythobuz@me.com>
  5. * Copyright 2011 Max Nuding <max.nuding@gmail.com>
  6. * Copyright 2011 Felix Bäder <baeder.felix@gmail.com>
  7. *
  8. * This file is part of LED-Cube.
  9. *
  10. * LED-Cube is free software: you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License as published by
  12. * the Free Software Foundation, either version 3 of the License, or
  13. * (at your option) any later version.
  14. *
  15. * LED-Cube is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with LED-Cube. If not, see <http://www.gnu.org/licenses/>.
  22. */
  23. #ifndef F_CPU
  24. #define F_CPU 16000000L
  25. #endif
  26. #define OK 0x42
  27. #define ERROR 0x23
  28. #include <avr/io.h>
  29. #include <util/delay.h>
  30. #include <avr/interrupt.h>
  31. #include <avr/pgmspace.h>
  32. #include <stdint.h>
  33. #include <stdlib.h>
  34. #include <avr/wdt.h>
  35. #include "serial.h"
  36. #include "cube.h"
  37. #include "time.h"
  38. #include "audio.h"
  39. #include "mem.h"
  40. #include "memLayer.h"
  41. #include "twi.h"
  42. #include "strings.h"
  43. #define NOERROR 0
  44. // Audio does not answer
  45. #define AUDIOERROR 1
  46. // Memory does not answer
  47. #define MEMORYERROR 2
  48. // Memory not writeable
  49. #define MEMORYWRITEERROR 4
  50. // x = errorcode, e = error definition, not NOERROR
  51. #define ISERROR(x, e) ((x) & (e))
  52. // Length of an idle animation frame, 24 -> 1 second
  53. #define IDLELENGTH 24
  54. void serialHandler(char c);
  55. void sendAudioData(void);
  56. void recieveAnimations(void);
  57. void transmitAnimations(void);
  58. uint8_t audioModeSelected(void);
  59. void setPixelBuffer(uint8_t x, uint8_t y, uint8_t z, uint8_t *buf);
  60. void setRow(uint8_t x, uint8_t z, uint8_t height, uint8_t *buf);
  61. void visualizeAudioData(uint8_t *audioData, uint8_t *imageData);
  62. #ifdef DEBUG
  63. void printErrors(uint8_t e);
  64. uint8_t selfTest(void);
  65. void printTime(void);
  66. #include "snake.c"
  67. #endif
  68. uint8_t shouldRestart = 0;
  69. uint8_t refreshAnimationCount = 1;
  70. uint8_t lastButtonState = 0;
  71. uint8_t mcusr_mirror;
  72. char buffer[11];
  73. uint8_t defaultImage[64] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
  74. 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
  75. 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
  76. 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
  77. 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
  78. 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
  79. 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
  80. 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
  81. uint8_t DebugDone = 0; // Bit 0: 10s int. count, Bit 1: switch idle display
  82. // Bit 2: state changed, disable idle
  83. int main(void) {
  84. uint8_t *audioData = NULL;
  85. uint8_t *imageData = NULL;
  86. uint8_t i, length = 0, lastMode;
  87. uint16_t count;
  88. uint64_t lastChecked;
  89. uint32_t temp;
  90. mcusr_mirror = MCUCSR;
  91. MCUCSR = 0;
  92. wdt_disable();
  93. initCube();
  94. serialInit(25, 8, NONE, 1);
  95. i2c_init();
  96. initSystemTimer();
  97. sei(); // Enable Interrupts
  98. wdt_enable(WDTO_500MS); // Enable watchdog reset after 500ms
  99. DDRA = 0xFF; // Latch Data Bus as Output
  100. DDRD = 0xFC; DDRB = 24; // Mosfets as Output
  101. DDRC = 0xFC; DDRB |= 6; // Latch Enable as Output
  102. DDRB &= ~(1 << PB0); // Pushbutton as Input
  103. setImage(defaultImage); // Display something
  104. #ifdef DEBUG
  105. // Kill animation counter in debug mode
  106. // => Don't preserve animations while power down
  107. setAnimationCount(0);
  108. i = selfTest();
  109. if (i) {
  110. serialWriteString(getString(1));
  111. serialWriteString(itoa(i, buffer, 2));
  112. serialWrite('\n');
  113. printErrors(i);
  114. }
  115. serialWriteString(getString(2));
  116. serialWriteString(getString(0));
  117. serialWriteString("Took ");
  118. serialWriteString(itoa(getSystemTime(), buffer, 10));
  119. serialWriteString(" ms!\n");
  120. if (mcusr_mirror & WDRF) {
  121. serialWriteString(getString(31));
  122. } else if (mcusr_mirror & BORF) {
  123. serialWriteString(getString(32));
  124. } else if (mcusr_mirror & EXTRF) {
  125. serialWriteString(getString(34));
  126. } else if (mcusr_mirror & JTRF) {
  127. serialWriteString(getString(35));
  128. } else if (mcusr_mirror & PORF) {
  129. serialWriteString(getString(36));
  130. } else {
  131. serialWriteString(getString(33));
  132. }
  133. #endif
  134. lastMode = audioModeSelected();
  135. lastChecked = getSystemTime();
  136. i = 0;
  137. count = getAnimationCount();
  138. while (1) {
  139. // Reset if requested
  140. if (!shouldRestart) {
  141. wdt_reset();
  142. }
  143. if(lastMode) {
  144. // Get Audio Data and visualize it
  145. if (isFinished()) {
  146. audioData = getAudioData();
  147. if (audioData != NULL) {
  148. imageData = (uint8_t *)malloc(64);
  149. if (imageData == NULL) {
  150. #ifdef DEBUG
  151. serialWriteString(getString(24));
  152. #endif
  153. while(1);
  154. }
  155. visualizeAudioData(audioData, imageData);
  156. setImage(imageData);
  157. free(imageData);
  158. }
  159. }
  160. } else {
  161. if (refreshAnimationCount) {
  162. // Get animation count stored in FRAM via TWI, if needed
  163. count = getAnimationCount();
  164. refreshAnimationCount = 0;
  165. i = 0;
  166. }
  167. if (count > 0) {
  168. if (isFinished() > length) {
  169. // Load next image
  170. if (i < (count - 1)) {
  171. i++;
  172. } else {
  173. i = 0;
  174. }
  175. imageData = getFrame(i);
  176. length = imageData[64];
  177. setImage(imageData);
  178. free(imageData);
  179. }
  180. } else {
  181. if (!(DebugDone & 4)) {
  182. if (isFinished() >= IDLELENGTH) {
  183. // Should happen every half second
  184. if (DebugDone & 2) {
  185. fillBuffer(0);
  186. DebugDone &= ~(2);
  187. } else {
  188. fillBuffer(0xFF);
  189. DebugDone |= 2;
  190. }
  191. }
  192. }
  193. }
  194. }
  195. if (serialHasChar()) {
  196. serialHandler((char)(serialGet()));
  197. }
  198. #ifdef DEBUG
  199. // Print frames per second
  200. if ((getSystemTime() >= 1000) && ((DebugDone & 1) == 0)) {
  201. temp = getTriggerCount();
  202. serialWriteString(ltoa(temp, buffer, 10));
  203. serialWriteString(getString(27));
  204. serialWriteString(ltoa((temp / 8), buffer, 10));
  205. serialWriteString(getString(28));
  206. DebugDone |= 1;
  207. }
  208. // Show how stable we are running :)
  209. if (((getSystemTime() % 60000) == 0) && (getSystemTime() > 0)) {
  210. serialWriteString(getString(37));
  211. printTime();
  212. }
  213. #endif
  214. if ((getSystemTime() - lastChecked) > 150) {
  215. lastMode = audioModeSelected();
  216. lastChecked = getSystemTime();
  217. }
  218. }
  219. close();
  220. return 0;
  221. }
  222. #ifdef DEBUG
  223. uint8_t selfTest(void) {
  224. uint8_t result = NOERROR;
  225. uint8_t *data = getAudioData();
  226. if (data == NULL) {
  227. result |= AUDIOERROR;
  228. } else {
  229. free(data);
  230. }
  231. data = memGetBytes(0, 1);
  232. if (data == NULL) {
  233. result |= MEMORYERROR;
  234. } else {
  235. free(data);
  236. }
  237. setGeneralPurposeByte(0, 0x42);
  238. if (getGeneralPurposeByte(0) != 0x42) {
  239. result |= MEMORYWRITEERROR;
  240. }
  241. return result;
  242. }
  243. void printErrors(uint8_t e) {
  244. if (ISERROR(e, AUDIOERROR)) {
  245. serialWriteString(getString(3));
  246. }
  247. if (ISERROR(e, MEMORYERROR)) {
  248. serialWriteString(getString(4));
  249. }
  250. if (ISERROR(e, MEMORYWRITEERROR)) {
  251. serialWriteString(getString(5));
  252. }
  253. }
  254. void randomAnimation(void) {
  255. uint8_t *b = (uint8_t *)malloc(64);
  256. uint8_t x, y, z;
  257. if (b == NULL) {
  258. serialWriteString(getString(24));
  259. return;
  260. }
  261. for (x = 0; x < 64; x++) {
  262. b[x] = 0;
  263. }
  264. while(1) {
  265. setImage(b);
  266. while(isFinished() == 0);
  267. x = rand() / 4096;
  268. y = rand() / 4096;
  269. z = rand() / 4096;
  270. b[x + (8 * y)] ^= (1 << z);
  271. if (serialHasChar()) {
  272. serialWriteString(getString(25));
  273. free(b);
  274. serialHandler(serialGet());
  275. return;
  276. }
  277. }
  278. free(b);
  279. }
  280. #endif
  281. void serialHandler(char c) {
  282. // Used letters:
  283. // a, c, d, e, g, i, n, q, r, s, t, v, x, y, 0, 1, 2
  284. uint8_t i, y, z;
  285. #ifdef DEBUG
  286. serialWrite(c);
  287. serialWriteString(": ");
  288. #endif
  289. switch(c) {
  290. case OK:
  291. serialWrite(OK);
  292. break;
  293. case 'h': case 'H': case '?':
  294. serialWriteString(getString(6));
  295. #ifdef DEBUG
  296. serialWriteString(getString(7));
  297. serialWriteString(getString(8));
  298. serialWriteString(getString(9));
  299. serialWriteString(getString(10));
  300. serialWriteString(getString(11));
  301. serialWriteString(getString(12));
  302. serialWriteString(getString(13));
  303. serialWriteString(getString(26));
  304. #endif
  305. break;
  306. case 'd': case 'D':
  307. clearMem();
  308. #ifndef DEBUG
  309. serialWrite(OK);
  310. #endif
  311. #ifdef DEBUG
  312. serialWriteString(getString(29));
  313. #endif
  314. break;
  315. #ifndef DEBUG
  316. case 'g': case 'G':
  317. transmitAnimations();
  318. break;
  319. case 's': case 'S':
  320. recieveAnimations();
  321. break;
  322. #endif
  323. case 'v': case 'V':
  324. serialWriteString(getString(0));
  325. break;
  326. #ifdef DEBUG
  327. case 'q': case 'Q':
  328. shouldRestart = 1;
  329. serialWriteString(getString(30));
  330. break;
  331. case 'r': case 'R':
  332. randomAnimation();
  333. break;
  334. case 't': case 'T':
  335. printTime();
  336. break;
  337. case 'a': case 'A':
  338. sendAudioData();
  339. break;
  340. case 'c': case 'C':
  341. serialWriteString(itoa(getAnimationCount(), buffer, 10));
  342. serialWriteString(getString(15));
  343. break;
  344. case 'x': case 'X':
  345. // Get byte, store as animation count
  346. serialWriteString(getString(16));
  347. while (!serialHasChar());
  348. c = serialGet();
  349. setAnimationCount(c);
  350. serialWriteString(itoa(c, buffer, 10));
  351. serialWriteString(getString(17));
  352. break;
  353. case 'y': case 'Y':
  354. setAnimationCount(0x2201);
  355. serialWriteString(getString(18));
  356. break;
  357. case 'e': case 'E':
  358. c = selfTest();
  359. serialWriteString(getString(19));
  360. serialWriteString(itoa(c, buffer, 2));
  361. serialWrite('\n');
  362. printErrors(c);
  363. break;
  364. case 'n': case 'N':
  365. snake();
  366. break;
  367. case '0':
  368. fillBuffer(0);
  369. DebugDone |= 4;
  370. break;
  371. case '1':
  372. fillBuffer(0xFF);
  373. DebugDone |= 4;
  374. break;
  375. case '2':
  376. DebugDone |= 4;
  377. fillBuffer(0);
  378. for (i = 0; i < 64; i++) {
  379. defaultImage[i] = 0;
  380. }
  381. while(1) {
  382. for (i = 0; i < 8; i++) {
  383. for (y = 0; y < 8; y++) {
  384. defaultImage[y + (i * 8)] = 0;
  385. for (z = 0; z < 8; z++) {
  386. defaultImage[y + (i * 8)] |= (1 << z);
  387. setImage(defaultImage);
  388. while (isFinished() == 0) {
  389. if (serialHasChar()) {
  390. goto killMeForIt; // Yes I know...
  391. // But I need to break out of 2 while Loops...
  392. }
  393. }
  394. }
  395. defaultImage[y + (i * 8)] = 0;
  396. }
  397. }
  398. }
  399. break;
  400. killMeForIt:
  401. serialGet();
  402. serialWriteString(getString(25));
  403. break;
  404. case 'I': case 'i':
  405. serialWriteString(ltoa(getTriggerCount(), buffer, 10));
  406. serialWrite('\n');
  407. break;
  408. #endif
  409. default:
  410. serialWrite(ERROR);
  411. break;
  412. }
  413. // c was used as temp var and does not contain the char anymore...!
  414. }
  415. #ifdef DEBUG
  416. void printTime(void) {
  417. serialWriteString(getString(14));
  418. serialWriteString(ltoa(getSystemTime(), buffer, 10));
  419. serialWriteString("ms");
  420. if (getSystemTime() > 60000) {
  421. serialWriteString(" (");
  422. serialWriteString(itoa(getSystemTime() / 60000, buffer, 10));
  423. serialWriteString(" min)");
  424. }
  425. if (getSystemTime() > 1000) {
  426. serialWriteString(" (");
  427. serialWriteString(itoa(getSystemTime() / 1000, buffer, 10));
  428. itoa(getSystemTime() % 1000, buffer, 10);
  429. if (buffer[0] != '\0')
  430. serialWrite('.');
  431. if (buffer[2] == '\0')
  432. serialWrite('0');
  433. if (buffer[1] == '\0')
  434. serialWrite('0');
  435. if (buffer[0] != '\0')
  436. serialWriteString(buffer);
  437. serialWriteString("s)\n");
  438. } else {
  439. serialWrite('\n');
  440. }
  441. }
  442. void sendAudioData(void) {
  443. uint8_t i;
  444. uint8_t *audioData = getAudioData();
  445. if (audioData == NULL) {
  446. serialWriteString(getString(21));
  447. } else {
  448. serialWriteString(getString(22));
  449. for (i = 0; i < 7; i++) {
  450. serialWrite(i + '0');
  451. serialWriteString(": ");
  452. itoa(audioData[i], buffer, 10);
  453. serialWriteString(buffer);
  454. serialWrite('\n');
  455. }
  456. }
  457. }
  458. #endif
  459. void recieveAnimations() {
  460. uint8_t animCount, a, frameCount, f, i;
  461. uint16_t completeCount = 0, character;
  462. uint8_t frame[65];
  463. serialWrite(OK); // We are ready...
  464. character = serialGet();
  465. while (character & 0xFF00) { // Wait for answer
  466. character = serialGet();
  467. }
  468. animCount = (uint8_t)(character & 0x00FF); // Got animation count
  469. serialWrite(OK);
  470. for (a = 0; a < animCount; a++) {
  471. character = serialGet();
  472. while (character & 0xFF00) { // Wait for answer
  473. character = serialGet();
  474. }
  475. frameCount = (uint8_t)(character & 0x00FF); // Got frame count
  476. serialWrite(OK);
  477. for (f = 0; f < frameCount; f++) {
  478. character = serialGet();
  479. while (character & 0xFF00) { // Wait for answer
  480. character = serialGet();
  481. }
  482. frame[64] = (uint8_t)(character & 0x00FF); // Got duration
  483. serialWrite(OK);
  484. for (i = 0; i < 64; i++) {
  485. character = serialGet();
  486. while (character & 0xFF00) { // Wait for answer
  487. character = serialGet();
  488. }
  489. frame[i] = (uint8_t)(character & 0x00FF); // Got data byte
  490. }
  491. serialWrite(OK);
  492. setFrame(completeCount++, frame);
  493. }
  494. }
  495. character = serialGet();
  496. while (character & 0xFF00) { // Wait for answer
  497. character = serialGet();
  498. }
  499. character = serialGet();
  500. while (character & 0xFF00) { // Wait for answer
  501. character = serialGet();
  502. }
  503. character = serialGet();
  504. while (character & 0xFF00) { // Wait for answer
  505. character = serialGet();
  506. }
  507. character = serialGet();
  508. while (character & 0xFF00) { // Wait for answer
  509. character = serialGet();
  510. }
  511. serialWrite(OK);
  512. setAnimationCount(completeCount);
  513. refreshAnimationCount = 1;
  514. }
  515. void transmitAnimations() {
  516. // We store no animation information in here
  517. // So we have to place all frames in one or more
  518. // animations... We need 8 animations max...
  519. uint8_t animationsToGo;
  520. uint16_t framesToGo = getAnimationCount();
  521. uint16_t character;
  522. uint8_t a;
  523. uint8_t f, fMax, i;
  524. uint8_t *frame;
  525. if ((framesToGo % 255) == 0) {
  526. animationsToGo = framesToGo / 255;
  527. } else {
  528. animationsToGo = (framesToGo / 255) + 1;
  529. }
  530. serialWrite(OK);
  531. serialWrite(animationsToGo);
  532. while ((character = serialGet()) & 0xFF00); // Wait for answer
  533. if ((character & 0x00FF) != OK) { // Error code recieved
  534. return;
  535. }
  536. for (a = 0; a < animationsToGo; a++) {
  537. if (framesToGo > 255) {
  538. fMax = 255;
  539. } else {
  540. fMax = framesToGo;
  541. }
  542. serialWrite(fMax); // Number of Frames in current animation
  543. while ((character = serialGet()) & 0xFF00); // Wait for answer
  544. if ((character & 0x00FF) != OK) { // Error code recieved
  545. return;
  546. }
  547. for (f = 0; f < fMax; f++) {
  548. frame = getFrame(f + (255 * a));
  549. serialWrite(frame[64]); // frame duration
  550. while ((character = serialGet()) & 0xFF00); // Wait for answer
  551. if ((character & 0x00FF) != OK) { // Error code recieved
  552. free(frame);
  553. return;
  554. }
  555. for (i = 0; i < 64; i++) {
  556. serialWrite(frame[i]);
  557. }
  558. while ((character = serialGet()) & 0xFF00); // Wait for answer
  559. if ((character & 0x00FF) != OK) { // Error code recieved
  560. free(frame);
  561. return;
  562. }
  563. free(frame);
  564. }
  565. framesToGo -= fMax;
  566. }
  567. serialWrite(OK);
  568. serialWrite(OK);
  569. serialWrite(OK);
  570. serialWrite(OK);
  571. while ((character = serialGet()) & 0xFF00); // Wait for answer
  572. // Error code ignored...
  573. }
  574. uint8_t audioModeSelected(void) {
  575. // Pushbutton: PB0, Low active
  576. if (!(PINB & (1 << PB0))) {
  577. // Button pushed
  578. if (lastButtonState == 0) {
  579. lastButtonState = 1;
  580. } else {
  581. lastButtonState = 0;
  582. }
  583. #ifdef DEBUG
  584. serialWriteString("New State (");
  585. serialWriteString(itoa(lastButtonState, buffer, 10));
  586. serialWriteString(")\n");
  587. #endif
  588. }
  589. return lastButtonState;
  590. }
  591. void setRow(uint8_t x, uint8_t z, uint8_t height, uint8_t *buf) {
  592. uint8_t i = 0;
  593. for (; i < height; i++) {
  594. setPixelBuffer(x, i, z, buf);
  595. }
  596. }
  597. void setPixelBuffer(uint8_t x, uint8_t y, uint8_t z, uint8_t *buf) {
  598. buf[(8 * z) + y] |= (1 << x);
  599. }
  600. void visualizeAudioData(uint8_t *audioData, uint8_t *imageData) {
  601. uint8_t i;
  602. for (i = 0; i < 64; i++) {
  603. imageData[i] = 0;
  604. }
  605. // 8 LEDs, Max Val 255:
  606. // 256 / 8 = 32 => Divide by 31 (FACTOR) to get num of leds to light
  607. // 255 / FACTOR = 8,...
  608. // 127 / FACTOR = 4,...
  609. #define FACTOR 31
  610. // Could not figure out a way to represent this easily in a loop
  611. // without using a shitload of 'if's...
  612. setRow(0, 0, (audioData[0] / FACTOR), imageData);
  613. setRow(0, 1, (audioData[0] / FACTOR), imageData);
  614. setRow(1, 0, (audioData[0] / FACTOR), imageData);
  615. setRow(0, 2, (audioData[1] / FACTOR), imageData);
  616. setRow(0, 3, (audioData[1] / FACTOR), imageData);
  617. setRow(1, 1, (audioData[1] / FACTOR), imageData);
  618. setRow(1, 2, (audioData[1] / FACTOR), imageData);
  619. setRow(2, 0, (audioData[1] / FACTOR), imageData);
  620. setRow(2, 1, (audioData[1] / FACTOR), imageData);
  621. setRow(0, 4, (audioData[2] / FACTOR), imageData);
  622. setRow(0, 5, (audioData[2] / FACTOR), imageData);
  623. setRow(1, 3, (audioData[2] / FACTOR), imageData);
  624. setRow(1, 4, (audioData[2] / FACTOR), imageData);
  625. setRow(2, 2, (audioData[2] / FACTOR), imageData);
  626. setRow(2, 3, (audioData[2] / FACTOR), imageData);
  627. setRow(3, 0, (audioData[2] / FACTOR), imageData);
  628. setRow(3, 1, (audioData[2] / FACTOR), imageData);
  629. setRow(3, 2, (audioData[2] / FACTOR), imageData);
  630. setRow(4, 0, (audioData[2] / FACTOR), imageData);
  631. setRow(4, 1, (audioData[2] / FACTOR), imageData);
  632. setRow(0, 6, (audioData[3] / FACTOR), imageData);
  633. setRow(0, 7, (audioData[3] / FACTOR), imageData);
  634. setRow(1, 5, (audioData[3] / FACTOR), imageData);
  635. setRow(1, 6, (audioData[3] / FACTOR), imageData);
  636. setRow(2, 4, (audioData[3] / FACTOR), imageData);
  637. setRow(2, 5, (audioData[3] / FACTOR), imageData);
  638. setRow(3, 3, (audioData[3] / FACTOR), imageData);
  639. setRow(3, 4, (audioData[3] / FACTOR), imageData);
  640. setRow(4, 2, (audioData[3] / FACTOR), imageData);
  641. setRow(4, 3, (audioData[3] / FACTOR), imageData);
  642. setRow(5, 0, (audioData[3] / FACTOR), imageData);
  643. setRow(5, 1, (audioData[3] / FACTOR), imageData);
  644. setRow(5, 2, (audioData[3] / FACTOR), imageData);
  645. setRow(6, 0, (audioData[3] / FACTOR), imageData);
  646. setRow(6, 1, (audioData[3] / FACTOR), imageData);
  647. setRow(1, 7, (audioData[4] / FACTOR), imageData);
  648. setRow(2, 6, (audioData[4] / FACTOR), imageData);
  649. setRow(2, 7, (audioData[4] / FACTOR), imageData);
  650. setRow(3, 5, (audioData[4] / FACTOR), imageData);
  651. setRow(3, 6, (audioData[4] / FACTOR), imageData);
  652. setRow(4, 4, (audioData[4] / FACTOR), imageData);
  653. setRow(4, 5, (audioData[4] / FACTOR), imageData);
  654. setRow(5, 3, (audioData[4] / FACTOR), imageData);
  655. setRow(5, 4, (audioData[4] / FACTOR), imageData);
  656. setRow(6, 2, (audioData[4] / FACTOR), imageData);
  657. setRow(6, 3, (audioData[4] / FACTOR), imageData);
  658. setRow(7, 0, (audioData[4] / FACTOR), imageData);
  659. setRow(7, 1, (audioData[4] / FACTOR), imageData);
  660. setRow(3, 7, (audioData[5] / FACTOR), imageData);
  661. setRow(4, 6, (audioData[5] / FACTOR), imageData);
  662. setRow(4, 7, (audioData[5] / FACTOR), imageData);
  663. setRow(5, 5, (audioData[5] / FACTOR), imageData);
  664. setRow(5, 6, (audioData[5] / FACTOR), imageData);
  665. setRow(6, 4, (audioData[5] / FACTOR), imageData);
  666. setRow(6, 5, (audioData[5] / FACTOR), imageData);
  667. setRow(7, 2, (audioData[5] / FACTOR), imageData);
  668. setRow(7, 3, (audioData[5] / FACTOR), imageData);
  669. setRow(7, 4, (audioData[5] / FACTOR), imageData);
  670. setRow(5, 7, (audioData[6] / FACTOR), imageData);
  671. setRow(6, 6, (audioData[6] / FACTOR), imageData);
  672. setRow(6, 7, (audioData[6] / FACTOR), imageData);
  673. setRow(7, 5, (audioData[6] / FACTOR), imageData);
  674. setRow(7, 6, (audioData[6] / FACTOR), imageData);
  675. setRow(7, 7, (audioData[6] / FACTOR), imageData);
  676. }