Séquence Initialisation + Debug sur NanoRed
Création d'un second environnement pour debug sur Arduino Nano Red (Mega168P 16Mhz)
This commit is contained in:
parent
79ab9547ff
commit
98eeb45fbb
|
@ -8,10 +8,17 @@
|
|||
; Please visit documentation for the other options and examples
|
||||
; https://docs.platformio.org/page/projectconf.html
|
||||
|
||||
[env:pro8MHzatmega328]
|
||||
[env:ProMini8MHz]
|
||||
platform = atmelavr
|
||||
board = pro8MHzatmega328
|
||||
framework = arduino
|
||||
lib_deps =
|
||||
adafruit/Adafruit NeoPixel@^1.10.6
|
||||
featherfly/SoftwareSerial@^1.0
|
||||
[env:NanoRouge]
|
||||
platform = atmelavr
|
||||
board = nanoatmega168
|
||||
framework = arduino
|
||||
lib_deps =
|
||||
adafruit/Adafruit NeoPixel@^1.10.6
|
||||
featherfly/SoftwareSerial@^1.0
|
73
src/main.cpp
73
src/main.cpp
|
@ -17,14 +17,21 @@ SoftwareSerial HC12(CUIZZ_SERIAL_TX,CUIZZ_SERIAL_RX);
|
|||
Adafruit_NeoPixel CUIZZPixel(CUIZZ_NB_LED,CUIZZ_PIN_LED,NEO_GRB + NEO_KHZ800);
|
||||
|
||||
// Calcul Couleur RGB sur 1 Byte
|
||||
void CUIZZ_Color_C2B(byte IDColor, byte nRed, byte nGreen, byte nBlue){
|
||||
nRed = (IDColor >> 5) * 32;
|
||||
nGreen = ((IDColor & 28) >> 2) * 32;
|
||||
nBlue = (IDColor & 3) * 64;
|
||||
void CUIZZ_Color_C2B(byte IDColor, byte* nRed, byte* nGreen, byte* nBlue){
|
||||
if(IDColor == 255){
|
||||
*nRed = 255;
|
||||
*nGreen = 255;
|
||||
*nBlue = 255;
|
||||
}
|
||||
else{
|
||||
*nRed = ((IDColor >> 5) * 32);
|
||||
*nGreen = ((IDColor & 28) >> 2) * 32;
|
||||
*nBlue = (IDColor & 3) * 64;
|
||||
}
|
||||
}
|
||||
|
||||
byte CUIZZ_Color_B2C(byte nRed, byte nGreen, byte nBlue){
|
||||
return ((nRed << 5) | (nGreen << 2) | nBlue);
|
||||
return (((nRed/32) << 5) | ((nGreen/32) << 2) | nBlue/64);
|
||||
}
|
||||
|
||||
//Envoi simple Message
|
||||
|
@ -48,41 +55,19 @@ void CUIZZ_UpdateLED(unsigned long nDelay = 1){
|
|||
byte CUIZZPixel_G[8];
|
||||
byte CUIZZPixel_B[8];
|
||||
|
||||
byte nRouge, nVert, nBleu;
|
||||
// OFF
|
||||
CUIZZPixel.clear();
|
||||
|
||||
switch (CUIZZ_GameMode)
|
||||
{
|
||||
case 0: // Game Mode - Attente Initialisation
|
||||
if(CUIZZ_Score < 20 ){
|
||||
// LED en ROUGE
|
||||
for (byte i = 0; i < 8; i++)
|
||||
{
|
||||
CUIZZPixel_R[i] = 255;
|
||||
CUIZZPixel_G[i] = 0;
|
||||
CUIZZPixel_B[i] = 0;
|
||||
}
|
||||
|
||||
}
|
||||
else{
|
||||
if(CUIZZ_Score < 40 ){
|
||||
// LED en VERT
|
||||
for (byte i = 0; i < 8; i++)
|
||||
{
|
||||
CUIZZPixel_R[i] = 0;
|
||||
CUIZZPixel_G[i] = 255;
|
||||
CUIZZPixel_B[i] = 0;
|
||||
}
|
||||
}
|
||||
else{
|
||||
// LED en Bleu
|
||||
for (byte i = 0; i < 8; i++)
|
||||
{
|
||||
CUIZZPixel_R[i] = 0;
|
||||
CUIZZPixel_G[i] = 0;
|
||||
CUIZZPixel_B[i] = 255;
|
||||
}
|
||||
}
|
||||
for (byte i = 0; i < 8; i++)
|
||||
{
|
||||
CUIZZ_Color_C2B((CUIZZ_Score+i+1),&nRouge,&nVert,&nBleu);
|
||||
CUIZZPixel_R[i] = nRouge;
|
||||
CUIZZPixel_G[i] = nVert;
|
||||
CUIZZPixel_B[i] = nBleu;
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -165,19 +150,23 @@ void setup() {
|
|||
// INIT Pin Buzzer
|
||||
pinMode(CUIZZ_PIN_Buzzer,INPUT_PULLUP);
|
||||
|
||||
if(CUIZZ_PIN_Buzzer == 2 || CUIZZ_PIN_Buzzer == 3)
|
||||
{
|
||||
attachInterrupt(digitalPinToInterrupt(CUIZZ_PIN_Buzzer),CUIZZ_Buzzer,CHANGE);
|
||||
}
|
||||
|
||||
// Attente MASTER
|
||||
while(CUIZZ_GameMode == 0){
|
||||
CUIZZ_GetMessage();
|
||||
if(CUIZZ_Score > 60){
|
||||
if(CUIZZ_Score > 247){
|
||||
CUIZZ_Score = 0;
|
||||
}
|
||||
CUIZZ_Score++;
|
||||
CUIZZ_UpdateLED(50);
|
||||
if(CUIZZ_GameState > 11){
|
||||
CUIZZ_Score++;
|
||||
CUIZZ_GameState = 0;
|
||||
}
|
||||
else{CUIZZ_GameState++;}
|
||||
CUIZZ_UpdateLED(20);
|
||||
}
|
||||
|
||||
if(CUIZZ_PIN_Buzzer == 2 || CUIZZ_PIN_Buzzer == 3)
|
||||
{
|
||||
attachInterrupt(digitalPinToInterrupt(CUIZZ_PIN_Buzzer),CUIZZ_Buzzer,CHANGE);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue