Advertisement
Guest User

Untitled

a guest
Jan 20th, 2020
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 55.10 KB | None | 0 0
  1. //**************************************************************************************************************************************************************************
  2. //******************************************************* Vu-Mètre Stéréo V2.0 64x32 RGB Matrix - Carte Mega (com15) *******************************************************
  3. //**************************************************************************************************************************************************************************
  4. #include <Adafruit_GFX.h> // Librairie pour la Gestion Graphique
  5. #include <RGBmatrixPanel.h> // Librairie pour la Gestion Graphique Spécifique à la Matrice Led RGB 64x32
  6.  
  7. #define audioInLeft A6 // Broche entrée audio casque gauche
  8. #define audioInRight A7 // Broche entrée audio casque doite
  9. #define BrocheBPMode 5 // Broche du bouton poussoir Mode
  10.  
  11. const int OE = 9; // Broches de la Matrice Led RGB 64x32
  12. const int LAT = 10;
  13. const int CLK = 11;
  14. const int A = A0;
  15. const int B = A1;
  16. const int C = A2;
  17. const int D = A3;
  18.  
  19. int val = 0; // Valeur lue sur l'entrée audio casque
  20.  
  21. int ModeCourant = 0; // Variable contenant le mode courant
  22. int lastModeCourant = -1; // Variable contenant le dernier mode courant
  23.  
  24. boolean LastetatBPMode = HIGH; // Dernier état courant de l'entrée du bouton poussoir BPMode
  25. boolean etatBPMode = HIGH; // Etat courant de l'entrée du bouton poussoir BPMode
  26.  
  27. int Amplitude [] = {0, 0}; // Tableau d'amplitudes mesurées sur l'entrée audio right et left
  28. int ylastAmplitude [] = {0, 0}; // Tableau des dernières valeurs du tableau d'amplitudes mesurées sur l'entrée audio right et left
  29. int yAmplitude [] = {0, 0}; // Tableau des ordonnées courantes d'une bande en fonction de l'amplitude
  30. int yPic [] = {0, 0}; // Tableau des ordonnées des Pics de chaque bande
  31. int yHautBande [] = {0, 0}; // Tableau des ordonnées du sommet de chaque bande selon le Mode d'affichage
  32. unsigned long t1tempoBande [] = {0, 0}; // Tableau des temporisations pour le delai avant la descente de la Bande
  33. unsigned long t1tempoPic [] = {0, 0}; // Tableau des temporisations pour le delai avant la descente du Pic
  34.  
  35. int TableauAmp [] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; // Tableau des amplitudes de gauche et de droite pour le mode défilement
  36. int TableauAmpLeft [] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; // Tableau des amplitudes de gauche pour les modes défilement
  37. int TableauAmpRight [] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; // Tableau des amplitudes de droite pour les modes défilement
  38. int hue = 0; // Variable contenant la couleur suivant le mode sélectionné
  39.  
  40. RGBmatrixPanel matrix(A, B, C, D, CLK, LAT, OE, false, 64); // Crée l'objet "matrix"
  41.  
  42. void setup()
  43. {
  44. Serial.begin(9600); // Démarre la communication avec la console
  45.  
  46. pinMode(audioInLeft, INPUT); // Configure les broches en entrées
  47. pinMode(audioInRight, INPUT);
  48. pinMode(BrocheBPMode, INPUT_PULLUP);
  49.  
  50. matrix.begin(); // Initialise l'objet "matrix"
  51. matrix.setTextWrap(false); // Désactive le saut de ligne de la Matrice Led
  52. matrix.setRotation(0); // Définit l'orientation de la matrice (Origine en bas à gauche)
  53. matrix.setTextSize(1); // Définit la taille du texte
  54. matrix.fillScreen(0); // Efface la Matrice Led
  55.  
  56. //**************************************************************************************************************************************************************************
  57. }
  58.  
  59. void loop()
  60. {
  61. //**************************************************************************************************************************************************************************
  62. etatBPMode = digitalRead(BrocheBPMode); // Lit l'état de BPMode
  63. if (etatBPMode != LastetatBPMode) // ************************************************************ // Si l'état de "BPMode" a changé
  64. {
  65. if (etatBPMode == LOW && LastetatBPMode == HIGH) // +++++++++++++++++++++++++++++++++++++++++++ // Si pression sur BPMode
  66. {
  67. ModeCourant++; // Change de mode
  68. if (ModeCourant > 10) {ModeCourant = 0;} // Borne le mode
  69. LastetatBPMode = etatBPMode; // Mémorise le dernier mode
  70. }
  71. else {LastetatBPMode = HIGH;} // Mémorise le dernier état du bouton poussoir "BPMode"
  72. }
  73.  
  74. //**************************************************************************************************************************************************************************
  75. if (ModeCourant == 0) // ************************************************************************ // Mode 0 sélectionné
  76. {
  77. if (lastModeCourant != ModeCourant) // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // Si le mode courant à changé
  78. {
  79. matrix.fillScreen(0); // Efface la matrice led
  80. FonctionAfficheFond();
  81. for (int i = 0; i <= 1; i++)
  82. {
  83. yAmplitude[i] = 0; // Réinitialisation des variables
  84. yPic[i] = 0;
  85. t1tempoBande[i] = 0;
  86. }
  87. lastModeCourant = ModeCourant; // Mémorise le dernier mode courant
  88. }
  89. FonctionMode0(); // Appelle la fonction d'affichage du mode 0
  90. }
  91. else if (ModeCourant == 1) // ******************************************************************* // Mode 1 sélectionné
  92. {
  93. if (lastModeCourant != ModeCourant) // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // Si le mode courant à changé
  94. {
  95. matrix.fillScreen(0); // Efface la matrice led
  96. FonctionAfficheFond();
  97. for (int i = 0; i <= 1; i++)
  98. {
  99. yAmplitude[i] = 0; // Réinitialisation des variables
  100. yPic[i] = 0;
  101. t1tempoBande[i] = 0;
  102. }
  103. lastModeCourant = ModeCourant; // Mémorise le dernier mode courant
  104. }
  105. FonctionMode1(); // Appelle la fonction d'affichage du mode 1
  106. }
  107. else if (ModeCourant == 2) // ******************************************************************* // Mode 2 sélectionné
  108. {
  109. if (lastModeCourant != ModeCourant) // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // Si le mode courant à changé
  110. {
  111. matrix.fillScreen(0); // Efface la matrice led
  112. FonctionAfficheFond();
  113. for (int i = 0; i <= 1; i++)
  114. {
  115. yAmplitude[i] = 0; // Réinitialisation des variables
  116. yPic[i] = 0;
  117. t1tempoBande[i] = 0;
  118. }
  119. lastModeCourant = ModeCourant; // Mémorise le dernier mode courant
  120. }
  121. FonctionMode2(); // Appelle la fonction d'affichage du mode 2
  122. }
  123. else if (ModeCourant == 3) // ******************************************************************* // Mode 3 sélectionné
  124. {
  125. if (lastModeCourant != ModeCourant) // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // Si le mode courant à changé
  126. {
  127. matrix.fillScreen(0); // Efface la matrice led
  128. FonctionAfficheFond();
  129. for (int i = 0; i <= 1; i++)
  130. {
  131. yAmplitude[i] = 0; // Réinitialisation des variables
  132. yPic[i] = 0;
  133. t1tempoBande[i] = 0;
  134. }
  135. lastModeCourant = ModeCourant; // Mémorise le dernier mode courant
  136. }
  137. FonctionMode3(); // Appelle la fonction d'affichage du mode 3
  138. }
  139. else if (ModeCourant == 4) // ******************************************************************* // Mode 4 sélectionné
  140. {
  141. if (lastModeCourant != ModeCourant) // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // Si le mode courant à changé
  142. {
  143. matrix.fillScreen(0); // Efface la matrice led
  144. FonctionAfficheFond();
  145. for (int i = 0; i <= 1; i++)
  146. {
  147. yAmplitude[i] = 0; // Réinitialisation des variables
  148. yPic[i] = 0;
  149. t1tempoBande[i] = 0;
  150. yHautBande[i] = 0;
  151. }
  152. lastModeCourant = ModeCourant; // Mémorise le dernier mode courant
  153. }
  154. FonctionMode4(); // Appelle la fonction d'affichage du mode 4
  155. }
  156. else if (ModeCourant == 5) // ******************************************************************* // Mode 5 sélectionné
  157. {
  158. if (lastModeCourant != ModeCourant) // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // Si le mode courant à changé
  159. {
  160. matrix.fillScreen(0); // Efface la matrice led
  161. FonctionAfficheFond();
  162. for (int i = 0; i <= 1; i++)
  163. {
  164. yAmplitude[i] = 0; // Réinitialisation des variables
  165. yPic[i] = 0;
  166. t1tempoBande[i] = 0;
  167. yHautBande[i] = 0;
  168. }
  169. lastModeCourant = ModeCourant; // Mémorise le dernier mode courant
  170. }
  171. FonctionMode5(); // Appelle la fonction d'affichage du mode 5
  172. }
  173. else if (ModeCourant == 6) // ******************************************************************* // Mode 6 sélectionné
  174. {
  175. if (lastModeCourant != ModeCourant) // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // Si le mode courant à changé
  176. {
  177. matrix.fillScreen(0); // Efface la matrice led
  178. FonctionAfficheFond();
  179. for (int i = 0; i <= 1; i++)
  180. {
  181. yAmplitude[i] = 0; // Réinitialisation des variables
  182. yPic[i] = 0;
  183. t1tempoBande[i] = 0;
  184. yHautBande[i] = 0;
  185. }
  186. lastModeCourant = ModeCourant; // Mémorise le dernier mode courant
  187. for (int y = 0; y <= 48; y++) // Affiche le fond vert, jaune et rouge des bandes
  188. {
  189. if (y <= 24)
  190. {
  191. matrix.drawFastVLine(y, 8, 4, matrix.Color333(0, 7, 0));
  192. matrix.drawFastVLine(y, 21, 4, matrix.Color333(0, 7, 0));
  193. }
  194. else if (y <= 38)
  195. {
  196. matrix.drawFastVLine(y, 8, 4, matrix.Color333(7, 7, 0));
  197. matrix.drawFastVLine(y, 21, 4, matrix.Color333(7, 7, 0));
  198. }
  199. else
  200. {
  201. matrix.drawFastVLine(y, 8, 4, matrix.Color333(7, 0, 0));
  202. matrix.drawFastVLine(y, 21, 4, matrix.Color333(7, 0, 0));
  203. }
  204. }
  205. }
  206. FonctionMode6(); // Appelle la fonction d'affichage du mode 6
  207. }
  208. else if (ModeCourant == 7) // ******************************************************************* // Mode 7 sélectionné
  209. {
  210. if (lastModeCourant != ModeCourant) // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // Si le mode courant à changé
  211. {
  212. matrix.fillScreen(0); // Efface la matrice led
  213. for (int i = 0; i <= 1; i++)
  214. {
  215. yAmplitude[i] = 0; // Réinitialisation des variables
  216. yPic[i] = 0;
  217. t1tempoBande[i] = 0;
  218. yHautBande[i] = 0;
  219. }
  220. lastModeCourant = ModeCourant; // Mémorise le dernier mode courant
  221. }
  222. FonctionMode7(); // Appelle la fonction d'affichage du mode 7
  223. }
  224. else if (ModeCourant == 8) // ******************************************************************* // Mode 8 sélectionné
  225. {
  226. if (lastModeCourant != ModeCourant) // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // Si le mode courant à changé
  227. {
  228. matrix.fillScreen(0); // Efface la matrice led
  229. for (int i = 0; i <= 1; i++)
  230. {
  231. yAmplitude[i] = 0; // Réinitialisation des variables
  232. yPic[i] = 0;
  233. t1tempoBande[i] = 0;
  234. yHautBande[i] = 0;
  235. }
  236. lastModeCourant = ModeCourant; // Mémorise le dernier mode courant
  237. }
  238. FonctionMode8(); // Appelle la fonction d'affichage du mode 8
  239. }
  240. else if (ModeCourant == 9) // ******************************************************************* // Mode 9 sélectionné
  241. {
  242. if (lastModeCourant != ModeCourant) // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // Si le mode courant à changé
  243. {
  244. matrix.fillScreen(0); // Efface la matrice led
  245. for (int i = 0; i <= 1; i++)
  246. {
  247. yAmplitude[i] = 0; // Réinitialisation des variables
  248. yPic[i] = 0;
  249. t1tempoBande[i] = 0;
  250. yHautBande[i] = 0;
  251. }
  252. lastModeCourant = ModeCourant; // Mémorise le dernier mode courant
  253. }
  254. FonctionMode9(); // Appelle la fonction d'affichage du mode 9
  255. }
  256. else if (ModeCourant == 10) // ****************************************************************** // Mode 10 sélectionné
  257. {
  258. if (lastModeCourant != ModeCourant) // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // Si le mode courant à changé
  259. {
  260. matrix.fillScreen(0); // Efface la matrice led
  261. for (int i = 0; i <= 1; i++)
  262. {
  263. yAmplitude[i] = 0; // Réinitialisation des variables
  264. yPic[i] = 0;
  265. t1tempoBande[i] = 0;
  266. yHautBande[i] = 0;
  267. }
  268. lastModeCourant = ModeCourant; // Mémorise le dernier mode courant
  269. }
  270. FonctionMode10(); // Appelle la fonction d'affichage du mode 10
  271. }
  272.  
  273. //**************************************************************************************************************************************************************************
  274. }
  275.  
  276. void FonctionMode0 ()
  277. {
  278. val = analogRead(audioInLeft); // Lit l'entrée audio de gauche (Sortie casque ampli)
  279. yAmplitude[0] = map(val,0, 150, 0, 48); // Convertit la valeur lue sur l'entrée audio en abscisse verticale sur la matrice led
  280.  
  281. val = analogRead(audioInRight); // Lit l'entrée audio de droite (Sortie casque ampli)
  282. yAmplitude[1] = map(val,0, 150, 0, 48); // Convertit la valeur lue sur l'entrée audio en abscisse verticale sur la matrice led
  283.  
  284. for (int col = 0; col <= 1; col++)
  285. {
  286. if (yAmplitude[col] > 48) {yAmplitude[col] = 48;} // Borne l'abscisse verticale sur la matrice led
  287.  
  288. if (yAmplitude[col] <= yPic[col] && millis() - t1tempoBande[col] > 20 && t1tempoBande[col] > 0) // Gestion de l'effacement descendant temporisé de la Bande ************
  289. {
  290. matrix.drawPixel(yPic[col], (8+col*13)+1, 0); matrix.drawPixel(yPic[col], (8+col*13)+2, 0); // Efface la led la plus haute de la bande
  291. yPic[col] = yPic[col] - 1; // Incrémente l'ordonnée de la led la plus haute de la bande
  292. if (yPic[col] < 0) {yPic[col] = 0; t1tempoBande[col] = 0;} // Réinitialisation de la temporisation de la descente de la bande
  293. else {t1tempoBande[col] = millis();} // Redémarre la temporisation de la descente de la bande
  294. }
  295.  
  296. if (yAmplitude[col] > yPic[col] || (yAmplitude[col] == 0 && yPic[col] == 0)) // Gestion de l'affichage montant des Bandes **********************************************
  297. {
  298. for (int y = yPic[col]; y <= yAmplitude[col]; y++) // Affiche les bandes en violet à partir de la dernière position
  299. {
  300. matrix.drawPixel(y, (8+col*13)+1, matrix.Color333(7, 0, 7)); matrix.drawPixel(y, (8+col*13)+2, matrix.Color333(7, 0, 7));
  301. }
  302.  
  303. yPic[col] = yAmplitude[col]; // Sauvegarde l'ordonnée du Pic de la bande courante
  304. t1tempoBande[col] = millis(); // Démarre la temporisation de la descente de la bande
  305. }
  306. }
  307. }
  308.  
  309. void FonctionMode1 ()
  310. {
  311. val = analogRead(audioInLeft); // Lit l'entrée audio de gauche (Sortie casque ampli)
  312. yAmplitude[0] = map(val,0, 150, 0, 48); // Convertit la valeur lue sur l'entrée audio en abscisse verticale sur la matrice led
  313.  
  314. val = analogRead(audioInRight); // Lit l'entrée audio de droite (Sortie casque ampli)
  315. yAmplitude[1] = map(val,0, 150, 0, 48); // Convertit la valeur lue sur l'entrée audio en abscisse verticale sur la matrice led
  316.  
  317. for (int col = 0; col <= 1; col++)
  318. {
  319. if (yAmplitude[col] > 48) {yAmplitude[col] = 48;} // Borne l'abscisse verticale sur la matrice led
  320.  
  321. if (yAmplitude[col] <= yPic[col] && millis() - t1tempoBande[col] > 20 && t1tempoBande[col] > 0) // Gestion de l'effacement descendant temporisé des Bandes *************
  322. {
  323. matrix.drawPixel(yPic[col], (8+col*13)+1, 0); matrix.drawPixel(yPic[col], (8+col*13)+2, 0); // Efface les led les plus hautes de la bande
  324. matrix.drawPixel(yPic[col], (8+col*13), 0); matrix.drawPixel(yPic[col], (8+col*13)+3, 0); // Efface les led les plus hautes de la bande
  325. yPic[col] = yPic[col] - 1; // Incrémente l'ordonnée de la led la plus haute de la bande
  326. if (yPic[col] < 0) {yPic[col] = 0; t1tempoBande[col] = 0;} // Réinitialisation de la temporisation de la descente de la bande
  327. else {t1tempoBande[col] = millis();} // Redémarre la temporisation de la descente de la bande
  328. }
  329.  
  330. if (yAmplitude[col] > yPic[col] || (yAmplitude[col] == 0 && yPic[col] == 0)) // Gestion de l'affichage montant des Bandes **********************************************
  331. {
  332. for (int y = yPic[col]; y <= yAmplitude[col]; y++) // Affiche les bandes en vert, jaune et rouge à partir de la dernière position
  333. {
  334. if (y <= 24)
  335. {
  336. matrix.drawFastVLine(y, (8+col*13), 4, matrix.Color333(0, 7, 0));
  337. }
  338. else if (y <= 38)
  339. {
  340. matrix.drawFastVLine(y, (8+col*13), 4, matrix.Color333(7, 7, 0));
  341. }
  342. else
  343. {
  344. matrix.drawFastVLine(y, (8+col*13), 4, matrix.Color333(7, 0, 0));
  345. }
  346. }
  347.  
  348. yPic[col] = yAmplitude[col]; // Sauvegarde l'ordonnée du Pic de la bande courante
  349. t1tempoBande[col] = millis(); // Démarre la temporisation de la descente de la bande
  350. }
  351. }
  352. }
  353.  
  354. void FonctionMode2 ()
  355. {
  356. val = analogRead(audioInLeft); // Lit l'entrée audio de gauche (Sortie casque ampli)
  357. yAmplitude[0] = map(val,0, 150, 0, 48); // Convertit la valeur lue sur l'entrée audio en abscisse verticale sur la matrice led
  358.  
  359. val = analogRead(audioInRight); // Lit l'entrée audio de droite (Sortie casque ampli)
  360. yAmplitude[1] = map(val,0, 150, 0, 48); // Convertit la valeur lue sur l'entrée audio en abscisse verticale sur la matrice led
  361.  
  362. for (int col = 0; col <= 1; col++)
  363. {
  364. if (yAmplitude[col] > 48) {yAmplitude[col] = 48;} // Borne l'abscisse verticale sur la matrice led
  365.  
  366. if (yAmplitude[col] > ylastAmplitude[col]) // Gestion de l'affichage montant de la Bande *******************************************************************************
  367. {
  368. if (ylastAmplitude[col] < 0) {ylastAmplitude[col] = 0;} // Réinitialise l'ordonnée du Pic de la bande courante
  369. for (int y = ylastAmplitude[col]; y <= yAmplitude[col]; y++) // Affiche la bande en orange
  370. {
  371. matrix.drawFastVLine(y, (8+col*13)+1, 2, matrix.ColorHSV(203, 255, 200, true));
  372. }
  373. ylastAmplitude[col] = yAmplitude[col]; // Sauvegarde l'ordonnée du Pic de la bande courante
  374. }
  375.  
  376. if (yAmplitude[col] < ylastAmplitude[col]) // Gestion de l'affichage descendant de la Bande ****************************************************************************
  377. {
  378. for (int y = ylastAmplitude[col]; y > yAmplitude[col]; y--) // Efface la bande
  379. {
  380. matrix.drawFastVLine(y, (8+col*13)+1, 2, 0);
  381. }
  382. ylastAmplitude[col] = yAmplitude[col]; // Sauvegarde l'ordonnée du Pic de la bande courante
  383. }
  384. }
  385. }
  386.  
  387. void FonctionMode3 ()
  388. {
  389. val = analogRead(audioInLeft); // Lit l'entrée audio de gauche (Sortie casque ampli)
  390. yAmplitude[0] = map(val,0, 150, 0, 48); // Convertit la valeur lue sur l'entrée audio en abscisse verticale sur la matrice led
  391.  
  392. val = analogRead(audioInRight); // Lit l'entrée audio de droite (Sortie casque ampli)
  393. yAmplitude[1] = map(val,0, 150, 0, 48); // Convertit la valeur lue sur l'entrée audio en abscisse verticale sur la matrice led
  394.  
  395. for (int col = 0; col <= 1; col++)
  396. {
  397. if (yAmplitude[col] > 48) {yAmplitude[col] = 48;} // Borne l'abscisse verticale sur la matrice led
  398.  
  399. if (yAmplitude[col] < yPic[col] && millis() - t1tempoBande[col] > 30 && t1tempoBande[col] > 0) // Gestion de d'affichage descendant temporisé du Point *****************
  400. {
  401. matrix.drawFastVLine(yPic[col], (8+col*13), 4, 0); // Efface le dernier point
  402. yPic[col] = yPic[col] - 1; // Incrémente l'ordonnée du dernier point
  403. if (yPic[col] < 0) {yPic[col] = 0; t1tempoBande[col] = 0; matrix.drawFastVLine(0, (8+col*13), 4, matrix.Color333(0, 0, 0));} // Réinitialise l'ordonnée du point et la temporisation
  404. else // Affiche le point courant et redémarre la temporisation
  405. {
  406. if (yPic[col] <= 24)
  407. {
  408. matrix.drawFastVLine(yPic[col], (8+col*13), 4, matrix.Color333(0, 7, 0));
  409. }
  410. else if (yPic[col] <= 38)
  411. {
  412. matrix.drawFastVLine(yPic[col], (8+col*13), 4, matrix.Color333(7, 7, 0));
  413. //matrix.drawFastVLine(yPic[col], 21, 4, matrix.Color333(7, 7, 0));
  414. }
  415. else
  416. {
  417. matrix.drawFastVLine(yPic[col], (8+col*13), 4, matrix.Color333(7, 0, 0));
  418. }
  419. t1tempoBande[col] = millis();
  420. }
  421. }
  422.  
  423. if (yAmplitude[col] > yPic[col]) // Gestion de l'affichage montant du Point ********************************************************************************************
  424. {
  425. matrix.drawFastVLine(yPic[col], (8+col*13), 4, 0); // Efface le dernier point // Affiche le point courant
  426. matrix.drawFastVLine(yAmplitude[col], (8+col*13), 4, matrix.Color333(7, 0, 0));
  427. yPic[col] = yAmplitude[col]; // Sauvegarde l'ordonnée du point courant
  428. t1tempoBande[col] = millis(); // Démarre la temporisation de la descente du point
  429. }
  430. }
  431. }
  432.  
  433. void FonctionMode4 ()
  434. {
  435. val = analogRead(audioInLeft); // Lit l'entrée audio de gauche (Sortie casque ampli)
  436. yAmplitude[0] = map(val,0, 150, 0, 48); // Convertit la valeur lue sur l'entrée audio en abscisse verticale sur la matrice led
  437.  
  438. val = analogRead(audioInRight); // Lit l'entrée audio de droite (Sortie casque ampli)
  439. yAmplitude[1] = map(val,0, 150, 0, 48); // Convertit la valeur lue sur l'entrée audio en abscisse verticale sur la matrice led
  440.  
  441. for (int col = 0; col <= 1; col++)
  442. {
  443. if (yAmplitude[col] > 48) {yAmplitude[col] = 48;} // Borne l'abscisse verticale sur la matrice led
  444.  
  445. if (millis() - t1tempoBande[col] > 20 && t1tempoBande[col] > 0) // Temporisation de la descente de la Bande ************************************************************
  446. {
  447. matrix.drawPixel(yHautBande[col], (8+col*13)+1, 0); // Efface la led la plus haute de la bande
  448. matrix.drawPixel(yHautBande[col], (8+col*13)+2, 0); // Efface la led la plus haute de la bande
  449. yHautBande[col] = yHautBande[col] - 1; // Incrémente l'ordonnée de la led la plus haute de la bande
  450. if (yHautBande[col] < 0) {yHautBande[col] = 0; t1tempoBande[col] = 0;} // Réinitialisation de la temporisation de la descente de la bande
  451. else {t1tempoBande[col] = millis();} // Redémarre la temporisation de la descente de la bande
  452. }
  453.  
  454. if (millis() - t1tempoPic[col] > 250 && t1tempoPic[col] > 0) // Temporisation avant l'affichage de la descente du Pic **************************************************
  455. {
  456. matrix.drawPixel(yPic[col], (8+col*13)+1, 0); // Efface l'ancienne position du Pic
  457. matrix.drawPixel(yPic[col], (8+col*13)+2, 0); // Efface l'ancienne position du Pic
  458. yPic[col] = yPic[col] - 1; // Incrémente l'ordonnée du Pic
  459. if (yPic[col] <= 0) {yPic[col] = 0; t1tempoPic[col] = 0;} // Désactive la gestion d'affichage du Pic
  460. else // Affiche la descente du Pic en rouge
  461. {
  462. if (yPic[col] > yHautBande[col])
  463. {
  464. matrix.drawPixel(yPic[col], (8+col*13)+1, matrix.Color333(7, 0, 0));
  465. matrix.drawPixel(yPic[col], (8+col*13)+2, matrix.Color333(7, 0, 0));
  466. delay(25);
  467. }
  468. else {t1tempoPic[col] = 0;}
  469. }
  470. }
  471.  
  472. if (yAmplitude[col] > yHautBande[col]) // Gestion de l'affichage montant de la Bande ***********************************************************************************
  473. {
  474. if (yAmplitude[col] < yPic[col]) // Affiche la bande uniquement
  475. {
  476. for (int y = yHautBande[col]; y < yAmplitude[col]; y++) // Affiche la bande en vert
  477. {
  478. matrix.drawPixel(y, (8+col*13)+1, matrix.Color333(0, 7, 0));
  479. matrix.drawPixel(y, (8+col*13)+2, matrix.Color333(0, 7, 0));
  480. }
  481. yHautBande[col] = yAmplitude[col] - 1; // Sauvegarde l'ordonnée de la bande courante
  482. t1tempoBande[col] = millis(); // Démarre la temporisation de la descente de la bande
  483. }
  484. else // Affiche la bande et le Pic rouge
  485. {
  486. for (int y = yHautBande[col]; y < yAmplitude[col]; y++) // Affiche la bande en vert
  487. {
  488. matrix.drawPixel(y, (8+col*13)+1, matrix.Color333(0, 7, 0));
  489. matrix.drawPixel(y, (8+col*13)+2, matrix.Color333(0, 7, 0));
  490. }
  491. matrix.drawPixel(yAmplitude[col], (8+col*13)+1, matrix.Color333(7, 0, 0)); // Affiche le Pic en rouge
  492. matrix.drawPixel(yAmplitude[col], (8+col*13)+2, matrix.Color333(7, 0, 0));
  493.  
  494. yHautBande[col] = yAmplitude[col] - 1; // Sauvegarde l'ordonnée de la bande courante
  495. t1tempoBande[col] = millis(); // Démarre la temporisation de la descente de la bande
  496. yPic[col] = yAmplitude[col]; // Sauvegarde l'ordonnée du Pic de la bande courante
  497. t1tempoPic[col] = millis(); // Démarre la temporisation de la descente du Pic
  498. }
  499. }
  500. }
  501. }
  502.  
  503. void FonctionMode5 ()
  504. {
  505. val = analogRead(audioInLeft); // Lit l'entrée audio de gauche (Sortie casque ampli)
  506. yAmplitude[0] = map(val,0, 150, 0, 48); // Convertit la valeur lue sur l'entrée audio en abscisse verticale sur la matrice led
  507.  
  508. val = analogRead(audioInRight); // Lit l'entrée audio de droite (Sortie casque ampli)
  509. yAmplitude[1] = map(val,0, 150, 0, 48); // Convertit la valeur lue sur l'entrée audio en abscisse verticale sur la matrice led
  510.  
  511. for (int col = 0; col <= 1; col++)
  512. {
  513. if (yAmplitude[col] > 48) {yAmplitude[col] = 48;} // Borne l'abscisse verticale sur la matrice led
  514.  
  515. if (millis() - t1tempoBande[col] > 20 && t1tempoBande[col] > 0) // Temporisation de la descente de la Bande ************************************************************
  516. {
  517. matrix.drawPixel(yHautBande[col], (8+col*13), 0); // Efface la led la plus haute de la bande
  518. matrix.drawPixel(yHautBande[col], (8+col*13)+1, 0); // Efface la led la plus haute de la bande
  519. matrix.drawPixel(yHautBande[col], (8+col*13)+2, 0); // Efface la led la plus haute de la bande
  520. matrix.drawPixel(yHautBande[col], (8+col*13)+3, 0); // Efface la led la plus haute de la bande
  521. yHautBande[col] = yHautBande[col] - 1; // Incrémente l'ordonnée de la led la plus haute de la bande
  522. if (yHautBande[col] < 0) {yHautBande[col] = 0; t1tempoBande[col] = 0;} // Réinitialisation de la temporisation de la descente de la bande
  523. else {t1tempoBande[col] = millis();} // Redémarre la temporisation de la descente de la bande
  524. }
  525.  
  526. if (millis() - t1tempoPic[col] > 250 && t1tempoPic[col] > 0) // Temporisation avant l'affichage de la descente du Pic **************************************************
  527. {
  528. matrix.drawPixel(yPic[col], (8+col*13), 0); // Efface l'ancienne position du Pic
  529. matrix.drawPixel(yPic[col], (8+col*13)+1, 0); // Efface l'ancienne position du Pic
  530. matrix.drawPixel(yPic[col], (8+col*13)+2, 0); // Efface l'ancienne position du Pic
  531. matrix.drawPixel(yPic[col], (8+col*13)+3, 0); // Efface l'ancienne position du Pic
  532. yPic[col] = yPic[col] - 1; // Incrémente l'ordonnée du Pic
  533. if (yPic[col] <= 0) {yPic[col] = 0; t1tempoPic[col] = 0;} // Désactive la gestion d'affichage du Pic
  534. else // Affiche la descente du Pic en rouge
  535. {
  536. if (yPic[col] > yHautBande[col])
  537. {
  538. matrix.drawPixel(yPic[col], (8+col*13), matrix.Color333(7, 0, 0));
  539. matrix.drawPixel(yPic[col], (8+col*13)+1, matrix.Color333(7, 0, 0));
  540. matrix.drawPixel(yPic[col], (8+col*13)+2, matrix.Color333(7, 0, 0));
  541. matrix.drawPixel(yPic[col], (8+col*13)+3, matrix.Color333(7, 0, 0));
  542. delay(30);
  543. }
  544. else {t1tempoPic[col] = 0;}
  545. }
  546. }
  547.  
  548. if (yAmplitude[col] > yHautBande[col]) // Gestion de l'affichage montant de la Bande ***********************************************************************************
  549. {
  550. if (yAmplitude[col] < yPic[col]) // Affiche la bande uniquement
  551. {
  552. for (int y = yHautBande[col]; y < yAmplitude[col]; y++) // Affiche la bande en vert
  553. {
  554. matrix.drawPixel(y, (8+col*13), matrix.Color333(7, 7, 7));
  555. matrix.drawPixel(y, (8+col*13)+1, matrix.Color333(7, 7, 7));
  556. matrix.drawPixel(y, (8+col*13)+2, matrix.Color333(7, 7, 7));
  557. matrix.drawPixel(y, (8+col*13)+3, matrix.Color333(7, 7, 7));
  558. }
  559. yHautBande[col] = yAmplitude[col] - 1; // Sauvegarde l'ordonnée de la bande courante
  560. t1tempoBande[col] = millis(); // Démarre la temporisation de la descente de la bande
  561. }
  562. else // Affiche la bande et le Pic rouge
  563. {
  564. for (int y = yHautBande[col]; y < yAmplitude[col]; y++) // Affiche la bande en vert
  565. {
  566. matrix.drawPixel(y, (8+col*13), matrix.Color333(7, 7, 7));
  567. matrix.drawPixel(y, (8+col*13)+1, matrix.Color333(7, 7, 7));
  568. matrix.drawPixel(y, (8+col*13)+2, matrix.Color333(7, 7, 7));
  569. matrix.drawPixel(y, (8+col*13)+3, matrix.Color333(7, 7, 7));
  570. }
  571. matrix.drawPixel(yAmplitude[col], (8+col*13), matrix.Color333(7, 0, 0)); // Affiche le Pic en rouge
  572. matrix.drawPixel(yAmplitude[col], (8+col*13)+1, matrix.Color333(7, 0, 0));
  573. matrix.drawPixel(yAmplitude[col], (8+col*13)+2, matrix.Color333(7, 0, 0));
  574. matrix.drawPixel(yAmplitude[col], (8+col*13)+3, matrix.Color333(7, 0, 0));
  575.  
  576. yHautBande[col] = yAmplitude[col] - 1; // Sauvegarde l'ordonnée de la bande courante
  577. t1tempoBande[col] = millis(); // Démarre la temporisation de la descente de la bande
  578. yPic[col] = yAmplitude[col]; // Sauvegarde l'ordonnée du Pic de la bande courante
  579. t1tempoPic[col] = millis(); // Démarre la temporisation de la descente du Pic
  580. }
  581. }
  582. }
  583. }
  584.  
  585. void FonctionMode6 ()
  586. {
  587. val = analogRead(audioInLeft); // Lit l'entrée audio de gauche (Sortie casque ampli)
  588. yAmplitude[0] = map(val,0, 150, 0, 48); // Convertit la valeur lue sur l'entrée audio en abscisse verticale sur la matrice led
  589.  
  590. val = analogRead(audioInRight); // Lit l'entrée audio de droite (Sortie casque ampli)
  591. yAmplitude[1] = map(val,0, 150, 0, 48); // Convertit la valeur lue sur l'entrée audio en abscisse verticale sur la matrice led
  592.  
  593. for (int col = 0; col <= 1; col++)
  594. {
  595. if (yAmplitude[col] > 48) {yAmplitude[col] = 48;} // Borne l'abscisse verticale sur la matrice led
  596.  
  597. if (yAmplitude[col] <= yPic[col] && millis() - t1tempoBande[col] > 20 && t1tempoBande[col] > 0) // Gestion de l'effacement descendant temporisé des Bandes **************
  598. {
  599. if (yPic[col] <= 24)
  600. {
  601. matrix.drawFastVLine(yPic[col], (8+col*13), 4, matrix.Color333(0, 7, 0));
  602. }
  603. else if (yPic[col] <= 38)
  604. {
  605. matrix.drawFastVLine(yPic[col], (8+col*13), 4, matrix.Color333(7, 7, 0));
  606. }
  607. else
  608. {
  609. matrix.drawFastVLine(yPic[col], (8+col*13), 4, matrix.Color333(7, 0, 0));
  610. }
  611. yPic[col] = yPic[col] - 1; // Incrémente l'ordonnée de la led la plus haute de la bande
  612. if (yPic[col] < 0) {yPic[col] = 0; t1tempoBande[col] = 0;} // Réinitialisation de la temporisation de la descente de la bande
  613. else {t1tempoBande[col] = millis();} // Redémarre la temporisation de la descente de la bande
  614. }
  615.  
  616. if (yAmplitude[col] > yPic[col] || (yAmplitude[col] == 0 && yPic[col] == 0)) // Gestion de l'affichage montant des Bandes ***********************************************
  617. {
  618. for (int y = yPic[col]; y <= yAmplitude[col]; y++) // Affiche les bandes en noir à partir de la dernière position
  619. {
  620. matrix.drawFastVLine(y, (8+col*13), 4, matrix.Color333(0, 0, 0));
  621. }
  622.  
  623. yPic[col] = yAmplitude[col]; // Sauvegarde l'ordonnée du Pic de la bande courante
  624. t1tempoBande[col] = millis(); // Démarre la temporisation de la descente de la bande
  625. }
  626. }
  627. }
  628.  
  629. void FonctionMode7 ()
  630. {
  631. val = analogRead(audioInLeft); // Lit l'entrée audio de gauche (Sortie casque ampli)
  632. yAmplitude[0] = map(val,0, 150, 0, 48); // Convertit la valeur lue sur l'entrée audio en abscisse verticale sur la matrice led
  633.  
  634. if (yAmplitude[0] > 48) {yAmplitude[0] = 48;} // Borne l'abscisse verticale sur la matrice led
  635.  
  636. for (int col = 15; col >= 1; col--) {TableauAmpLeft[col] = TableauAmpLeft[col-1];} // Décale les amplitudes de gauche dans le tableau "TableauAmpRight[]"
  637. TableauAmpLeft[0] = yAmplitude[0]; // Mémorise l'amplitude courante de droite dans la première case du tableau "TableauAmpRight[]"
  638.  
  639. matrix.drawFastHLine(0, 31, 48, 0);
  640. matrix.drawFastHLine(0, 31, TableauAmpLeft[0], matrix.ColorHSV(hue, 255, 255, true));
  641.  
  642. hue += 7;
  643. if(hue >= 1536) hue -= 1536;
  644. matrix.drawFastHLine(0, 29, 48, 0);
  645. matrix.drawFastHLine(0, 29, TableauAmpLeft[1], matrix.ColorHSV(hue, 255, 255, true));
  646.  
  647. hue += 7;
  648. if(hue >= 1536) hue -= 1536;
  649. matrix.drawFastHLine(0, 27, 48, 0);
  650. matrix.drawFastHLine(0, 27, TableauAmpLeft[2], matrix.ColorHSV(hue, 255, 255, true));
  651.  
  652. hue += 7;
  653. if(hue >= 1536) hue -= 1536;
  654. matrix.drawFastHLine(0, 25, 48, 0);
  655. matrix.drawFastHLine(0, 25, TableauAmpLeft[3], matrix.ColorHSV(hue, 255, 255, true));
  656.  
  657. hue += 7;
  658. if(hue >= 1536) hue -= 1536;
  659. matrix.drawFastHLine(0, 23, 48, 0);
  660. matrix.drawFastHLine(0, 23, TableauAmpLeft[4], matrix.ColorHSV(hue, 255, 255, true));
  661.  
  662. hue += 7;
  663. if(hue >= 1536) hue -= 1536;
  664. matrix.drawFastHLine(0, 21, 48, 0);
  665. matrix.drawFastHLine(0, 21, TableauAmpLeft[5], matrix.ColorHSV(hue, 255, 255, true));
  666.  
  667. hue += 7;
  668. if(hue >= 1536) hue -= 1536;
  669. matrix.drawFastHLine(0, 19, 48, 0);
  670. matrix.drawFastHLine(0, 19, TableauAmpLeft[6], matrix.ColorHSV(hue, 255, 255, true));
  671.  
  672. hue += 7;
  673. if(hue >= 1536) hue -= 1536;
  674. matrix.drawFastHLine(0, 17, 48, 0);
  675. matrix.drawFastHLine(0, 17, TableauAmpLeft[7], matrix.ColorHSV(hue, 255, 255, true));
  676.  
  677. hue += 7;
  678. if(hue >= 1536) hue -= 1536;
  679. matrix.drawFastHLine(0, 15, 48, 0);
  680. matrix.drawFastHLine(0, 15, TableauAmpLeft[8], matrix.ColorHSV(hue, 255, 255, true));
  681.  
  682. hue += 7;
  683. if(hue >= 1536) hue -= 1536;
  684. matrix.drawFastHLine(0, 13, 48, 0);
  685. matrix.drawFastHLine(0, 13, TableauAmpLeft[9], matrix.ColorHSV(hue, 255, 255, true));
  686.  
  687. hue += 7;
  688. if(hue >= 1536) hue -= 1536;
  689. matrix.drawFastHLine(0, 11, 48, 0);
  690. matrix.drawFastHLine(0, 11, TableauAmpLeft[10], matrix.ColorHSV(hue, 255, 255, true));
  691.  
  692. hue += 7;
  693. if(hue >= 1536) hue -= 1536;
  694. matrix.drawFastHLine(0, 9, 48, 0);
  695. matrix.drawFastHLine(0, 9, TableauAmpLeft[11], matrix.ColorHSV(hue, 255, 255, true));
  696.  
  697. hue += 7;
  698. if(hue >= 1536) hue -= 1536;
  699. matrix.drawFastHLine(0, 7, 48, 0);
  700. matrix.drawFastHLine(0, 7, TableauAmpLeft[12], matrix.ColorHSV(hue, 255, 255, true));
  701.  
  702. hue += 7;
  703. if(hue >= 1536) hue -= 1536;
  704. matrix.drawFastHLine(0, 5, 48, 0);
  705. matrix.drawFastHLine(0, 5, TableauAmpLeft[13], matrix.ColorHSV(hue, 255, 255, true));
  706.  
  707. hue += 7;
  708. if(hue >= 1536) hue -= 1536;
  709. matrix.drawFastHLine(0, 3, 48, 0);
  710. matrix.drawFastHLine(0, 3, TableauAmpLeft[14], matrix.ColorHSV(hue, 255, 255, true));
  711.  
  712. hue += 7;
  713. if(hue >= 1536) hue -= 1536;
  714. matrix.drawFastHLine(0, 1, 48, 0);
  715. matrix.drawFastHLine(0, 1, TableauAmpLeft[15], matrix.ColorHSV(hue, 255, 255, true));
  716. }
  717.  
  718. void FonctionMode8 ()
  719. {
  720. val = analogRead(audioInRight); // Lit l'entrée audio (Sortie casque ampli)
  721. yAmplitude[1] = map(val,0, 150, 0, 48); // Convertit la valeur lue sur l'entrée audio en abscisse verticale sur la matrice led
  722.  
  723. if (yAmplitude[1] > 48) {yAmplitude[1] = 48;} // Borne l'abscisse verticale sur la matrice led
  724.  
  725. for (int col = 15; col >= 1; col--) {TableauAmpRight[col] = TableauAmpRight[col-1];} // Décale les amplitudes de droite dans le tableau "TableauAmpRight[]"
  726. TableauAmpRight[0] = yAmplitude[1]; // Mémorise l'amplitude courante de droite dans la première case du tableau "TableauAmpRight[]"
  727.  
  728. matrix.drawFastHLine(0, 1, 48, 0);
  729. matrix.drawFastHLine(0, 1, TableauAmpRight[0], matrix.ColorHSV(hue, 255, 255, true));
  730.  
  731. hue += 7;
  732. if(hue >= 1536) hue -= 1536;
  733. matrix.drawFastHLine(0, 3, 48, 0);
  734. matrix.drawFastHLine(0, 3, TableauAmpRight[1], matrix.ColorHSV(hue, 255, 255, true));
  735.  
  736. hue += 7;
  737. if(hue >= 1536) hue -= 1536;
  738. matrix.drawFastHLine(0, 5, 48, 0);
  739. matrix.drawFastHLine(0, 5, TableauAmpRight[2], matrix.ColorHSV(hue, 255, 255, true));
  740.  
  741. hue += 7;
  742. if(hue >= 1536) hue -= 1536;
  743. matrix.drawFastHLine(0, 7, 48, 0);
  744. matrix.drawFastHLine(0, 7, TableauAmpRight[3], matrix.ColorHSV(hue, 255, 255, true));
  745.  
  746. hue += 7;
  747. if(hue >= 1536) hue -= 1536;
  748. matrix.drawFastHLine(0, 9, 48, 0);
  749. matrix.drawFastHLine(0, 9, TableauAmpRight[4], matrix.ColorHSV(hue, 255, 255, true));
  750.  
  751. hue += 7;
  752. if(hue >= 1536) hue -= 1536;
  753. matrix.drawFastHLine(0, 11, 48, 0);
  754. matrix.drawFastHLine(0, 11, TableauAmpRight[5], matrix.ColorHSV(hue, 255, 255, true));
  755.  
  756. hue += 7;
  757. if(hue >= 1536) hue -= 1536;
  758. matrix.drawFastHLine(0, 13, 48, 0);
  759. matrix.drawFastHLine(0, 13, TableauAmpRight[6], matrix.ColorHSV(hue, 255, 255, true));
  760.  
  761. hue += 7;
  762. if(hue >= 1536) hue -= 1536;
  763. matrix.drawFastHLine(0, 15, 48, 0);
  764. matrix.drawFastHLine(0, 15, TableauAmpRight[7], matrix.ColorHSV(hue, 255, 255, true));
  765.  
  766. hue += 7;
  767. if(hue >= 1536) hue -= 1536;
  768. matrix.drawFastHLine(0, 17, 48, 0);
  769. matrix.drawFastHLine(0, 17, TableauAmpRight[8], matrix.ColorHSV(hue, 255, 255, true));
  770.  
  771. hue += 7;
  772. if(hue >= 1536) hue -= 1536;
  773. matrix.drawFastHLine(0, 19, 48, 0);
  774. matrix.drawFastHLine(0, 19, TableauAmpRight[9], matrix.ColorHSV(hue, 255, 255, true));
  775.  
  776. hue += 7;
  777. if(hue >= 1536) hue -= 1536;
  778. matrix.drawFastHLine(0, 21, 48, 0);
  779. matrix.drawFastHLine(0, 21, TableauAmpRight[10], matrix.ColorHSV(hue, 255, 255, true));
  780.  
  781. hue += 7;
  782. if(hue >= 1536) hue -= 1536;
  783. matrix.drawFastHLine(0, 23, 48, 0);
  784. matrix.drawFastHLine(0, 23, TableauAmpRight[11], matrix.ColorHSV(hue, 255, 255, true));
  785.  
  786. hue += 7;
  787. if(hue >= 1536) hue -= 1536;
  788. matrix.drawFastHLine(0, 25, 48, 0);
  789. matrix.drawFastHLine(0, 25, TableauAmpRight[12], matrix.ColorHSV(hue, 255, 255, true));
  790.  
  791. hue += 7;
  792. if(hue >= 1536) hue -= 1536;
  793. matrix.drawFastHLine(0, 27, 48, 0);
  794. matrix.drawFastHLine(0, 27, TableauAmpRight[13], matrix.ColorHSV(hue, 255, 255, true));
  795.  
  796. hue += 7;
  797. if(hue >= 1536) hue -= 1536;
  798. matrix.drawFastHLine(0, 29, 48, 0);
  799. matrix.drawFastHLine(0, 29, TableauAmpRight[14], matrix.ColorHSV(hue, 255, 255, true));
  800.  
  801. hue += 7;
  802. if(hue >= 1536) hue -= 1536;
  803. matrix.drawFastHLine(0, 31, 48, 0);
  804. matrix.drawFastHLine(0, 31, TableauAmpRight[15], matrix.ColorHSV(hue, 255, 255, true));
  805. }
  806.  
  807. void FonctionMode9 ()
  808. {
  809. val = analogRead(audioInRight); // Lit l'entrée audio (Sortie casque ampli)
  810. yAmplitude[1] = map(val,0, 150, 0, 48); // Convertit la valeur lue sur l'entrée audio en abscisse verticale sur la matrice led
  811.  
  812. val = analogRead(audioInLeft); // Lit l'entrée audio (Sortie casque ampli)
  813. yAmplitude[0] = map(val,0, 150, 0, 48); // Convertit la valeur lue sur l'entrée audio en abscisse verticale sur la matrice led
  814.  
  815. if (yAmplitude[1] > 48) {yAmplitude[1] = 48;} // Borne l'abscisse verticale sur la matrice led
  816. if (yAmplitude[0] > 48) {yAmplitude[0] = 48;} // Borne l'abscisse verticale sur la matrice led
  817.  
  818. for (int col = 15; col >= 8; col--) {TableauAmp[col] = TableauAmp[col-1];}
  819. TableauAmp[8] = yAmplitude[1];
  820. for (int col = 8; col >= 1; col--) {TableauAmp[col] = TableauAmp[col-1];}
  821. TableauAmp[0] = yAmplitude[0];
  822.  
  823. matrix.drawFastHLine(0, 16, 48, 0);
  824. matrix.drawFastHLine(0, 16, TableauAmp[8], matrix.ColorHSV(hue, 255, 255, true));
  825. matrix.drawFastHLine(0, 15, 48, 0);
  826. matrix.drawFastHLine(0, 15, TableauAmp[0], matrix.ColorHSV(hue, 255, 255, true));
  827.  
  828. hue += 7;
  829. if(hue >= 1536) hue -= 1536;
  830. matrix.drawFastHLine(0, 18, 48, 0);
  831. matrix.drawFastHLine(0, 18, TableauAmp[9], matrix.ColorHSV(hue, 255, 255, true));
  832. matrix.drawFastHLine(0, 13, 48, 0);
  833. matrix.drawFastHLine(0, 13, TableauAmp[1], matrix.ColorHSV(hue, 255, 255, true));
  834.  
  835. hue += 7;
  836. if(hue >= 1536) hue -= 1536;
  837. matrix.drawFastHLine(0, 20, 48, 0);
  838. matrix.drawFastHLine(0, 20, TableauAmp[10], matrix.ColorHSV(hue, 255, 255, true));
  839. matrix.drawFastHLine(0, 11, 48, 0);
  840. matrix.drawFastHLine(0, 11, TableauAmp[2], matrix.ColorHSV(hue, 255, 255, true));
  841.  
  842. hue += 7;
  843. if(hue >= 1536) hue -= 1536;
  844. matrix.drawFastHLine(0, 22, 48, 0);
  845. matrix.drawFastHLine(0, 22, TableauAmp[11], matrix.ColorHSV(hue, 255, 255, true));
  846. matrix.drawFastHLine(0, 9, 48, 0);
  847. matrix.drawFastHLine(0, 9, TableauAmp[3], matrix.ColorHSV(hue, 255, 255, true));
  848.  
  849. hue += 7;
  850. if(hue >= 1536) hue -= 1536;
  851. matrix.drawFastHLine(0, 24, 48, 0);
  852. matrix.drawFastHLine(0, 24, TableauAmp[12], matrix.ColorHSV(hue, 255, 255, true));
  853. matrix.drawFastHLine(0, 7, 48, 0);
  854. matrix.drawFastHLine(0, 7, TableauAmp[4], matrix.ColorHSV(hue, 255, 255, true));
  855.  
  856. hue += 7;
  857. if(hue >= 1536) hue -= 1536;
  858. matrix.drawFastHLine(0, 26, 48, 0);
  859. matrix.drawFastHLine(0, 26, TableauAmp[13], matrix.ColorHSV(hue, 255, 255, true));
  860. matrix.drawFastHLine(0, 5, 48, 0);
  861. matrix.drawFastHLine(0, 5, TableauAmp[5], matrix.ColorHSV(hue, 255, 255, true));
  862.  
  863. hue += 7;
  864. if(hue >= 1536) hue -= 1536;
  865. matrix.drawFastHLine(0, 28, 48, 0);
  866. matrix.drawFastHLine(0, 28, TableauAmp[14], matrix.ColorHSV(hue, 255, 255, true));
  867. matrix.drawFastHLine(0, 3, 48, 0);
  868. matrix.drawFastHLine(0, 3, TableauAmp[6], matrix.ColorHSV(hue, 255, 255, true));
  869.  
  870. hue += 7;
  871. if(hue >= 1536) hue -= 1536;
  872. matrix.drawFastHLine(0, 30, 48, 0);
  873. matrix.drawFastHLine(0, 30, TableauAmp[15], matrix.ColorHSV(hue, 255, 255, true));
  874. matrix.drawFastHLine(0, 1, 48, 0);
  875. matrix.drawFastHLine(0, 1, TableauAmp[7], matrix.ColorHSV(hue, 255, 255, true));
  876. }
  877.  
  878. void FonctionMode10 ()
  879. {
  880. val = analogRead(audioInRight); // Lit l'entrée audio (Sortie casque ampli)
  881. yAmplitude[1] = map(val,0, 150, 0, 30); // Convertit la valeur lue sur l'entrée audio en abscisse verticale sur la matrice led
  882.  
  883. val = analogRead(audioInLeft); // Lit l'entrée audio (Sortie casque ampli)
  884. yAmplitude[0] = map(val,0, 150, 0, 30); // Convertit la valeur lue sur l'entrée audio en abscisse verticale sur la matrice led
  885.  
  886. if (yAmplitude[1] > 30) {yAmplitude[1] = 30;} // Borne l'abscisse verticale sur la matrice led
  887. if (yAmplitude[0] > 30) {yAmplitude[0] = 30;} // Borne l'abscisse verticale sur la matrice led
  888.  
  889. for (int col = 15; col >= 1; col--) {TableauAmpRight[col] = TableauAmpRight[col-1];} // Décale les amplitudes de droite dans le tableau "TableauAmpRight[]"
  890. TableauAmpRight[0] = yAmplitude[1]; // Mémorise l'amplitude courante de droite dans la première case du tableau "TableauAmpRight[]"
  891. for (int col = 15; col >= 1; col--) {TableauAmpLeft[col] = TableauAmpLeft[col-1];} // Décale les amplitudes de gauche dans le tableau "TableauAmpRight[]"
  892. TableauAmpLeft[0] = yAmplitude[0]; // Mémorise l'amplitude courante de droite dans la première case du tableau "TableauAmpRight[]"
  893.  
  894. matrix.drawFastHLine(32, 1, 30, 0); //matrix.Color333(7, 7, 7)
  895. matrix.drawFastHLine(32, 1, TableauAmpRight[0], matrix.ColorHSV(hue, 255, 255, true));
  896. matrix.drawFastHLine(31, 1, -30, 0);
  897. matrix.drawFastHLine(31, 1, -TableauAmpLeft[0], matrix.ColorHSV(hue, 255, 255, true));
  898.  
  899. hue += 7;
  900. if(hue >= 1536) hue -= 1536;
  901. matrix.drawFastHLine(32, 3, 30, 0);
  902. matrix.drawFastHLine(32, 3, TableauAmpRight[1], matrix.ColorHSV(hue, 255, 255, true));
  903. matrix.drawFastHLine(31, 3, -30, 0);
  904. matrix.drawFastHLine(31, 3, -TableauAmpLeft[1], matrix.ColorHSV(hue, 255, 255, true));
  905.  
  906. hue += 7;
  907. if(hue >= 1536) hue -= 1536;
  908. matrix.drawFastHLine(32, 5, 30, 0);
  909. matrix.drawFastHLine(32, 5, TableauAmpRight[2], matrix.ColorHSV(hue, 255, 255, true));
  910. matrix.drawFastHLine(31, 5, -30, 0);
  911. matrix.drawFastHLine(31, 5, -TableauAmpLeft[2], matrix.ColorHSV(hue, 255, 255, true));
  912.  
  913. hue += 7;
  914. if(hue >= 1536) hue -= 1536;
  915. matrix.drawFastHLine(32, 7, 30, 0);
  916. matrix.drawFastHLine(32, 7, TableauAmpRight[3], matrix.ColorHSV(hue, 255, 255, true));
  917. matrix.drawFastHLine(31, 7, -30, 0);
  918. matrix.drawFastHLine(31, 7, -TableauAmpLeft[3], matrix.ColorHSV(hue, 255, 255, true));
  919.  
  920. hue += 7;
  921. if(hue >= 1536) hue -= 1536;
  922. matrix.drawFastHLine(32, 9, 30, 0);
  923. matrix.drawFastHLine(32, 9, TableauAmpRight[4], matrix.ColorHSV(hue, 255, 255, true));
  924. matrix.drawFastHLine(31, 9, -30, 0);
  925. matrix.drawFastHLine(31, 9, -TableauAmpLeft[4], matrix.ColorHSV(hue, 255, 255, true));
  926.  
  927. hue += 7;
  928. if(hue >= 1536) hue -= 1536;
  929. matrix.drawFastHLine(32, 11, 30, 0);
  930. matrix.drawFastHLine(32, 11, TableauAmpRight[5], matrix.ColorHSV(hue, 255, 255, true));
  931. matrix.drawFastHLine(31, 11, -30, 0);
  932. matrix.drawFastHLine(31, 11, -TableauAmpLeft[5], matrix.ColorHSV(hue, 255, 255, true));
  933.  
  934. hue += 7;
  935. if(hue >= 1536) hue -= 1536;
  936. matrix.drawFastHLine(32, 13, 30, 0);
  937. matrix.drawFastHLine(32, 13, TableauAmpRight[6], matrix.ColorHSV(hue, 255, 255, true));
  938. matrix.drawFastHLine(31, 13, -30, 0);
  939. matrix.drawFastHLine(31, 13, -TableauAmpLeft[6], matrix.ColorHSV(hue, 255, 255, true));
  940.  
  941. hue += 7;
  942. if(hue >= 1536) hue -= 1536;
  943. matrix.drawFastHLine(32, 15, 30, 0);
  944. matrix.drawFastHLine(32, 15, TableauAmpRight[7], matrix.ColorHSV(hue, 255, 255, true));
  945. matrix.drawFastHLine(31, 15, -30, 0);
  946. matrix.drawFastHLine(31, 15, -TableauAmpLeft[7], matrix.ColorHSV(hue, 255, 255, true));
  947.  
  948. hue += 7;
  949. if(hue >= 1536) hue -= 1536;
  950. matrix.drawFastHLine(32, 17, 30, 0);
  951. matrix.drawFastHLine(32, 17, TableauAmpRight[8], matrix.ColorHSV(hue, 255, 255, true));
  952. matrix.drawFastHLine(31, 17, -30, 0);
  953. matrix.drawFastHLine(31, 17, -TableauAmpLeft[8], matrix.ColorHSV(hue, 255, 255, true));
  954.  
  955. hue += 7;
  956. if(hue >= 1536) hue -= 1536;
  957. matrix.drawFastHLine(32, 19, 30, 0);
  958. matrix.drawFastHLine(32, 19, TableauAmpRight[9], matrix.ColorHSV(hue, 255, 255, true));
  959. matrix.drawFastHLine(31, 19, -30, 0);
  960. matrix.drawFastHLine(31, 19, -TableauAmpLeft[9], matrix.ColorHSV(hue, 255, 255, true));
  961.  
  962. hue += 7;
  963. if(hue >= 1536) hue -= 1536;
  964. matrix.drawFastHLine(32, 21, 30, 0);
  965. matrix.drawFastHLine(32, 21, TableauAmpRight[10], matrix.ColorHSV(hue, 255, 255, true));
  966. matrix.drawFastHLine(31, 21, -30, 0);
  967. matrix.drawFastHLine(31, 21, -TableauAmpLeft[10], matrix.ColorHSV(hue, 255, 255, true));
  968.  
  969. hue += 7;
  970. if(hue >= 1536) hue -= 1536;
  971. matrix.drawFastHLine(32, 23, 30, 0);
  972. matrix.drawFastHLine(32, 23, TableauAmpRight[11], matrix.ColorHSV(hue, 255, 255, true));
  973. matrix.drawFastHLine(31, 23, -30, 0);
  974. matrix.drawFastHLine(31, 23, -TableauAmpLeft[11], matrix.ColorHSV(hue, 255, 255, true));
  975.  
  976. hue += 7;
  977. if(hue >= 1536) hue -= 1536;
  978. matrix.drawFastHLine(32, 25, 30, 0);
  979. matrix.drawFastHLine(32, 25, TableauAmpRight[12], matrix.ColorHSV(hue, 255, 255, true));
  980. matrix.drawFastHLine(31, 25, -30, 0);
  981. matrix.drawFastHLine(31, 25, -TableauAmpLeft[12], matrix.ColorHSV(hue, 255, 255, true));
  982.  
  983. hue += 7;
  984. if(hue >= 1536) hue -= 1536;
  985. matrix.drawFastHLine(32, 27, 30, 0);
  986. matrix.drawFastHLine(32, 27, TableauAmpRight[13], matrix.ColorHSV(hue, 255, 255, true));
  987. matrix.drawFastHLine(31, 27, -30, 0);
  988. matrix.drawFastHLine(31, 27, -TableauAmpLeft[13], matrix.ColorHSV(hue, 255, 255, true));
  989.  
  990. hue += 7;
  991. if(hue >= 1536) hue -= 1536;
  992. matrix.drawFastHLine(32, 29, 30, 0);
  993. matrix.drawFastHLine(32, 29, TableauAmpRight[14], matrix.ColorHSV(hue, 255, 255, true));
  994. matrix.drawFastHLine(31, 29, -30, 0);
  995. matrix.drawFastHLine(31, 29, -TableauAmpLeft[14], matrix.ColorHSV(hue, 255, 255, true));
  996.  
  997. hue += 7;
  998. if(hue >= 1536) hue -= 1536;
  999. matrix.drawFastHLine(32, 31, 30, 0);
  1000. matrix.drawFastHLine(32, 31, TableauAmpRight[15], matrix.ColorHSV(hue, 255, 255, true));
  1001. matrix.drawFastHLine(31, 31, -30, 0);
  1002. matrix.drawFastHLine(31, 31, -TableauAmpLeft[15], matrix.ColorHSV(hue, 255, 255, true));
  1003. }
  1004.  
  1005. void FonctionAfficheFond ()
  1006. {
  1007. matrix.drawFastHLine(0, 6, 50, matrix.Color333(0, 0, 7)); // Affiche le fond
  1008. matrix.drawFastHLine(0, 7, 25, matrix.Color333(0, 7, 0));
  1009. matrix.drawFastHLine(25, 7, 14, matrix.Color333(7, 7, 0));
  1010. matrix.drawFastHLine(39, 7, 10, matrix.Color333(7, 0, 0));
  1011. matrix.drawFastHLine(0, 12, 25, matrix.Color333(0, 7, 0));
  1012. matrix.drawFastHLine(25, 12, 14, matrix.Color333(7, 7, 0));
  1013. matrix.drawFastHLine(39, 12, 10, matrix.Color333(7, 0, 0));
  1014. matrix.drawFastHLine(0, 13, 50, matrix.Color333(0, 0, 7));
  1015. matrix.drawFastVLine(49, 5, 10, matrix.Color333(0, 0, 7));
  1016. matrix.drawFastVLine(50, 6, 8, matrix.Color333(0, 0, 7));
  1017. matrix.drawFastVLine(51, 7, 6, matrix.Color333(0, 0, 7));
  1018. matrix.drawFastVLine(52, 8, 4, matrix.Color333(0, 0, 7));
  1019. matrix.drawFastVLine(53, 9, 2, matrix.Color333(0, 0, 7));
  1020. matrix.drawPixel(39, 5, matrix.Color333(0, 0, 7));
  1021. matrix.drawPixel(39, 14, matrix.Color333(0, 0, 7));
  1022. matrix.drawPixel(25, 5, matrix.Color333(0, 0, 7));
  1023. matrix.drawPixel(25, 14, matrix.Color333(0, 0, 7));
  1024. matrix.drawPixel(0, 5, matrix.Color333(0, 0, 7));
  1025. matrix.drawPixel(0, 14, matrix.Color333(0, 0, 7));
  1026.  
  1027. matrix.drawFastHLine(0, 19, 50, matrix.Color333(0, 0, 7));
  1028. matrix.drawFastHLine(0, 20, 25, matrix.Color333(0, 7, 0));
  1029. matrix.drawFastHLine(25, 20, 14, matrix.Color333(7, 7, 0));
  1030. matrix.drawFastHLine(39, 20, 10, matrix.Color333(7, 0, 0));
  1031. matrix.drawFastHLine(0, 25, 25, matrix.Color333(0, 7, 0));
  1032. matrix.drawFastHLine(25, 25, 14, matrix.Color333(7, 7, 0));
  1033. matrix.drawFastHLine(39, 25, 10, matrix.Color333(7, 0, 0));
  1034. matrix.drawFastHLine(0, 26, 50, matrix.Color333(0, 0, 7));
  1035. matrix.drawFastVLine(49, 18, 10, matrix.Color333(0, 0, 7));
  1036. matrix.drawFastVLine(50, 19, 8, matrix.Color333(0, 0, 7));
  1037. matrix.drawFastVLine(51, 20, 6, matrix.Color333(0, 0, 7));
  1038. matrix.drawFastVLine(52, 21, 4, matrix.Color333(0, 0, 7));
  1039. matrix.drawFastVLine(53, 22, 2, matrix.Color333(0, 0, 7));
  1040. matrix.drawPixel(39, 18, matrix.Color333(0, 0, 7));
  1041. matrix.drawPixel(39, 27, matrix.Color333(0, 0, 7));
  1042. matrix.drawPixel(25, 18, matrix.Color333(0, 0, 7));
  1043. matrix.drawPixel(25, 27, matrix.Color333(0, 0, 7));
  1044. matrix.drawPixel(0, 18, matrix.Color333(0, 0, 7));
  1045. matrix.drawPixel(0, 27, matrix.Color333(0, 0, 7));
  1046. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement