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:
Profouzors (LE) 2022-11-04 11:05:51 +01:00
parent 79ab9547ff
commit 98eeb45fbb
2 changed files with 39 additions and 43 deletions

View File

@ -8,10 +8,17 @@
; Please visit documentation for the other options and examples ; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html ; https://docs.platformio.org/page/projectconf.html
[env:pro8MHzatmega328] [env:ProMini8MHz]
platform = atmelavr platform = atmelavr
board = pro8MHzatmega328 board = pro8MHzatmega328
framework = arduino framework = arduino
lib_deps = lib_deps =
adafruit/Adafruit NeoPixel@^1.10.6 adafruit/Adafruit NeoPixel@^1.10.6
featherfly/SoftwareSerial@^1.0 featherfly/SoftwareSerial@^1.0
[env:NanoRouge]
platform = atmelavr
board = nanoatmega168
framework = arduino
lib_deps =
adafruit/Adafruit NeoPixel@^1.10.6
featherfly/SoftwareSerial@^1.0

View File

@ -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); Adafruit_NeoPixel CUIZZPixel(CUIZZ_NB_LED,CUIZZ_PIN_LED,NEO_GRB + NEO_KHZ800);
// Calcul Couleur RGB sur 1 Byte // Calcul Couleur RGB sur 1 Byte
void CUIZZ_Color_C2B(byte IDColor, byte nRed, byte nGreen, byte nBlue){ void CUIZZ_Color_C2B(byte IDColor, byte* nRed, byte* nGreen, byte* nBlue){
nRed = (IDColor >> 5) * 32; if(IDColor == 255){
nGreen = ((IDColor & 28) >> 2) * 32; *nRed = 255;
nBlue = (IDColor & 3) * 64; *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){ 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 //Envoi simple Message
@ -48,41 +55,19 @@ void CUIZZ_UpdateLED(unsigned long nDelay = 1){
byte CUIZZPixel_G[8]; byte CUIZZPixel_G[8];
byte CUIZZPixel_B[8]; byte CUIZZPixel_B[8];
byte nRouge, nVert, nBleu;
// OFF // OFF
CUIZZPixel.clear(); CUIZZPixel.clear();
switch (CUIZZ_GameMode) switch (CUIZZ_GameMode)
{ {
case 0: // Game Mode - Attente Initialisation case 0: // Game Mode - Attente Initialisation
if(CUIZZ_Score < 20 ){ for (byte i = 0; i < 8; i++)
// LED en ROUGE {
for (byte i = 0; i < 8; i++) CUIZZ_Color_C2B((CUIZZ_Score+i+1),&nRouge,&nVert,&nBleu);
{ CUIZZPixel_R[i] = nRouge;
CUIZZPixel_R[i] = 255; CUIZZPixel_G[i] = nVert;
CUIZZPixel_G[i] = 0; CUIZZPixel_B[i] = nBleu;
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;
}
}
} }
break; break;
@ -165,19 +150,23 @@ void setup() {
// INIT Pin Buzzer // INIT Pin Buzzer
pinMode(CUIZZ_PIN_Buzzer,INPUT_PULLUP); 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 // Attente MASTER
while(CUIZZ_GameMode == 0){ while(CUIZZ_GameMode == 0){
CUIZZ_GetMessage(); CUIZZ_GetMessage();
if(CUIZZ_Score > 60){ if(CUIZZ_Score > 247){
CUIZZ_Score = 0; CUIZZ_Score = 0;
} }
CUIZZ_Score++; if(CUIZZ_GameState > 11){
CUIZZ_UpdateLED(50); 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);
} }
} }