initial commit
This commit is contained in:
commit
4a7d153391
2 changed files with 658 additions and 0 deletions
200
lean.cpp
Normal file
200
lean.cpp
Normal file
|
@ -0,0 +1,200 @@
|
|||
#include <FastLED.h>
|
||||
|
||||
|
||||
//fastled
|
||||
#define NUM_LEDS 132 //7 * 9 * 2 + 2*3(points)
|
||||
#define DATA_PIN 3
|
||||
CRGB leds[NUM_LEDS]; // Define the array of leds
|
||||
|
||||
|
||||
void setup()
|
||||
{
|
||||
//Serial
|
||||
Serial.begin(9600);
|
||||
|
||||
//FASTLED
|
||||
FastLED.addLeds<WS2811, DATA_PIN, GRB>(leds, NUM_LEDS);
|
||||
|
||||
//char test[10] = "000000019";
|
||||
//sevensegment(test, 1, false);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void sevensegment(char displayText[9], short displayColor, bool displayPoints) //2 strings
|
||||
{
|
||||
|
||||
Serial.println("Entrée dans sevensegment");
|
||||
|
||||
//transformer la matrice de caracteres en une matrice de numéros
|
||||
//avec
|
||||
//char 0 = 0
|
||||
//char 1 = 1
|
||||
//etc
|
||||
//char - = 10
|
||||
int displayNumCode[9];
|
||||
|
||||
for(int i=0; i<9; i++)
|
||||
{
|
||||
switch (displayText[i])
|
||||
{
|
||||
case '0':
|
||||
displayNumCode[i] = 0;
|
||||
break;
|
||||
case '1':
|
||||
displayNumCode[i] = 1;
|
||||
break;
|
||||
case '2':
|
||||
displayNumCode[i] = 2;
|
||||
break;
|
||||
case '3':
|
||||
displayNumCode[i] = 3;
|
||||
break;
|
||||
case '4':
|
||||
displayNumCode[i] = 4;
|
||||
break;
|
||||
case '5':
|
||||
displayNumCode[i] = 5;
|
||||
break;
|
||||
case '6':
|
||||
displayNumCode[i] = 6;
|
||||
break;
|
||||
case '7':
|
||||
displayNumCode[i] = 7;
|
||||
break;
|
||||
case '8':
|
||||
displayNumCode[i] = 8;
|
||||
break;
|
||||
case '9':
|
||||
displayNumCode[i] = 9;
|
||||
break;
|
||||
case '-':
|
||||
displayNumCode[i] = 10; // -
|
||||
break;
|
||||
case ' ':
|
||||
displayNumCode[i] = 11; // " "
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//afficher l'array displayNumCode
|
||||
for(int i=0; i<9; i++)
|
||||
{
|
||||
Serial.print(displayNumCode[i]);
|
||||
Serial.print(",");
|
||||
}
|
||||
Serial.println("");
|
||||
|
||||
|
||||
|
||||
//quels segments allumer pour chaque caractere
|
||||
// 2
|
||||
// ___
|
||||
// 3| |1
|
||||
// |_4_|
|
||||
// 7| |5
|
||||
// |___|
|
||||
// 6
|
||||
|
||||
// à revoir
|
||||
short matrixsevenseg[12][7] = //12 charactères, 012345679-" ", 7 seg
|
||||
// 1 2 3 4 5 6 7
|
||||
{ {1,1,1,0,1,1,1}, //char 0
|
||||
{0,0,1,0,0,0,1}, //char 1
|
||||
{1,1,0,1,0,1,1}, //char 2
|
||||
{0,1,1,1,0,1,1}, //char 3
|
||||
{0,0,1,1,1,0,1}, //char 4
|
||||
{0,1,1,1,1,1,0}, //char 5
|
||||
{1,1,1,1,1,1,0}, //char 6
|
||||
{0,0,1,0,0,1,1}, //char 7
|
||||
{1,1,1,1,1,1,1}, //char 8
|
||||
{0,1,1,1,1,1,1}, //char 9
|
||||
{0,0,0,1,0,0,0}, //char -
|
||||
{0,0,0,0,0,0,0} //char " " (space)
|
||||
};
|
||||
|
||||
Serial.println("Déclaré la matrice des segments 'matrixsevenseg' ");
|
||||
//afficher les caracteres individuels
|
||||
|
||||
for(int i=0; i<9; i++) //chaque caractère
|
||||
{
|
||||
Serial.print("on entre dans le caractère n°");
|
||||
Serial.println(i);
|
||||
for(int j = 0; j<7; j++) //chaque segment
|
||||
{
|
||||
Serial.print("on entre dans le segments n°");
|
||||
Serial.println(j);
|
||||
if(matrixsevenseg[displayNumCode[i]][j] == 1)
|
||||
{
|
||||
for(short k; k<2; k++) // les 2 leds du segemnt
|
||||
{
|
||||
if(displayColor == 0) //rouge
|
||||
{
|
||||
leds[(i+1)*7 +(j+1)*2 + k] = CRGB::Red;
|
||||
}
|
||||
else if(displayColor == 1) //rose
|
||||
{
|
||||
leds[(i+1)*7 +(j+1)*2 + k] = CRGB::Pink;
|
||||
}
|
||||
else if(displayColor == 2) //jaune
|
||||
{
|
||||
leds[(i+1)*7 +(j+1)*2 + k] = CRGB::Yellow;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for(int i=0; i<140; i++
|
||||
{
|
||||
Serial.println(leds[i]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//points
|
||||
|
||||
if(displayPoints == false)
|
||||
{
|
||||
//éteindre les points
|
||||
for(int m=125; m<=131; m++)
|
||||
{
|
||||
leds[m] = CRGB::Black;
|
||||
}
|
||||
}
|
||||
else if(displayPoints)
|
||||
{
|
||||
//allumer les points
|
||||
for(int m=379; m<=396; m++)
|
||||
{
|
||||
leds[m] = CRGB::Red; //adapter les points à la couleur de displaycolor
|
||||
}
|
||||
}
|
||||
|
||||
FastLED.show();
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
|
||||
|
||||
|
||||
leds[19] = CRGB::Green;
|
||||
|
||||
|
||||
FastLED.show();
|
||||
|
||||
char message[9] = "000000019";
|
||||
sevensegment(message, 0, true);
|
||||
delay(10000);
|
||||
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue