make "if" statement instead of just ifdef

This commit is contained in:
Joey Babcock 2016-12-30 14:23:54 -08:00 committed by GitHub
parent 35d1ab23de
commit 443d8961ae
1 changed files with 12 additions and 9 deletions

View File

@ -48,10 +48,11 @@ void setup() {
}
uint8_t N = 0;
#ifdef PRINT_FPS
int fpsCounter = 0;
int secondTimer = 0;
#endif
if(PRINT_FPS == 1)
{
int fpsCounter = 0;
int secondTimer = 0;
}
void loop() {
// Read data over socket
int packetSize = port.parsePacket();
@ -66,12 +67,14 @@ void loop() {
pixels[N].B = (uint8_t)packetBuffer[i+3];
}
ledstrip.show(pixels);
Serial.print("*");
#ifdef PRINT_FPS
if(PRINT_FPS == 1)
{
Serial.print("*");
fpsCounter++;
#endif
}
}
#ifdef PRINT_FPS
if(PRINT_FPS == 1){
if(millis() - secondTimer >= 1000)
{
secondTimer = millis();
@ -79,5 +82,5 @@ void loop() {
Serial.printf("FPS: %d\n", fpsCounter);
fpsCounter = 0;
}
#endif
}
}