From 443d8961ae632271717d9e0e0147351da66d2bb1 Mon Sep 17 00:00:00 2001 From: Joey Babcock Date: Fri, 30 Dec 2016 14:23:54 -0800 Subject: [PATCH] make "if" statement instead of just ifdef --- .../ws2812_controller/ws2812_controller.ino | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/arduino/ws2812_controller/ws2812_controller.ino b/arduino/ws2812_controller/ws2812_controller.ino index 5ba1603..e209da2 100644 --- a/arduino/ws2812_controller/ws2812_controller.ino +++ b/arduino/ws2812_controller/ws2812_controller.ino @@ -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 + } }