Simple single-color 8x8x8 LED Cube with AVRs
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

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