diff --git a/firmware/kicker/game_selector.ino b/firmware/kicker/game_selector.ino index 5a9f5d4..5a8452e 100644 --- a/firmware/kicker/game_selector.ino +++ b/firmware/kicker/game_selector.ino @@ -18,11 +18,11 @@ // Time Attack Game else if(game == "ta") { terminal(GM_TATTACK); - game_reaction_bluetooth(settings); + time_attack_bluetooth(settings); return; } - // Time Attack Game + // Time Reaction Game else if(game == "ra") { terminal(GM_REACTION); game_reaction_bluetooth(settings); diff --git a/firmware/kicker/game_time_attack.ino b/firmware/kicker/game_time_attack.ino index 606a917..67ea5aa 100644 --- a/firmware/kicker/game_time_attack.ino +++ b/firmware/kicker/game_time_attack.ino @@ -87,7 +87,7 @@ // PUBLIC VARIABLES uint16_t time = JSON["tm"]; // Time Window To JSON - uint16_t timer = time; + uint16_t timer = time; // Time uint16_t limit = JSON["lm"]; // Kick Target Limit bool limitEnable = JSON["le"]; // Enable Kick Target Limit diff --git a/firmware/kicker/KICKER_V1.ino b/firmware/kicker/kicker.ino similarity index 81% rename from firmware/kicker/KICKER_V1.ino rename to firmware/kicker/kicker.ino index c9d4052..efd4eeb 100644 --- a/firmware/kicker/KICKER_V1.ino +++ b/firmware/kicker/kicker.ino @@ -10,42 +10,8 @@ //====================================================== // HARDWARE SETUP & SELECTION //====================================================== - // Arduino MEGA - #ifdef ARDUINO_AVR_MEGA2560 -//------------------------------------------------------ - - // Library Nessesary - #ifdef __AVR__ - #include - #endif - - // Serial Terminal - #define Terminal Serial // SERIAL PORT USED AS TERMINAL WINDO FOR DEBUG - #define isTerminal Terminal.available() // Terminal Serial Buffer Available - #define flushTerminal while(isTerminal) { Terminal.read(); } - - // Bluetooth Terminal - #define Bluetooth Serial1 // We will Connect The HC-05 To Hardware Serial1 In Arduino Mega - #define isBluetooth Bluetooth.available() // Bluetooth Serial Buffer Available - #define flushBluetooth while(isBluetooth) { Bluetooth.read(); } - - // JSON Object & Memory - #define CAPACITY 100 - DynamicJsonDocument JSON(CAPACITY); // Building JSON Buffer - - // LED Strip - #define LED_STRIP 53 // LED STRIP PIN NUMBER - #define NUM_PIXELS 14 // NUMBER OF LED'S IN NEO PIXEL STRIP - Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUM_PIXELS, LED_STRIP, NEO_GRB + NEO_KHZ800); - - // Impact Detection - #define VTH 14 // THRESHOLD VOLTAGE FOR ZERO POSITIONNING KICKING POWER SENSOR - #define SENSOR_PIN A0 // IMPACT SENSOR - #define RANDOM_SOURCE A7 // RANDOM NUMBER GENERATOR SOURCE - -//------------------------------------------------------ // Arduino Uno / Nano - #elif ARDUINO_AVR_UNO || ARDUINO_AVR_NANO + #ifdef ARDUINO_AVR_UNO || ARDUINO_AVR_NANO //------------------------------------------------------ // Library Nessesary @@ -68,13 +34,20 @@ #define flushBluetooth while(isBluetooth) { Bluetooth.read(); } // JSON Object & Memory - #define CAPACITY 100 + #define CAPACITY 150 DynamicJsonDocument JSON(CAPACITY); // Building JSON Buffer // LED Strip #define LED_STRIP 2 // LED STRIP PIN NUMBER #define NUM_PIXELS 14 // NUMBER OF LED'S IN NEO PIXEL STRIP - Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUM_PIXELS, LED_STRIP, NEO_GRB + NEO_KHZ800); + Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUM_PIXELS, LED_STRIP, NEO_GRB + NEO_KHZ800); + + // Power Holding Pin + #define POWER_PIN 13 + #define POWER_SETUP pinMode(POWER_PIN, OUTPUT) + #define POWER_ON digitalWrite(POWER_PIN, HIGH) + #define POWER_OFF digitalWrite(POWER_PIN, LOW) + #define POWER_STU digitalRead(POWER_PIN) // Impact Detection #define VTH 14 // THRESHOLD VOLTAGE FOR ZERO POSITIONNING KICKING POWER SENSOR @@ -128,7 +101,7 @@ DynamicJsonDocument JSON(CAPACITY); // Building JSON Buffer // LED Strip - #define LED_STRIP 33 // LED STRIP PIN NUMBER + #define LED_STRIP 33 // LED STRIP PIN NUMBER #define NUM_PIXELS 14 // NUMBER OF LED'S IN NEO PIXEL STRIP Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUM_PIXELS, LED_STRIP, NEO_GRB + NEO_KHZ800); @@ -154,6 +127,13 @@ #define BOOST_OFF digitalWrite(BOOST_PIN, LOW) #define BOOST_STU digitalRead(BOOST_PIN) + // Power Holding Pin + #define POWER_PIN 13 + #define POWER_SETUP pinMode(POWER_PIN, OUTPUT) + #define POWER_ON digitalWrite(POWER_PIN, HIGH) + #define POWER_OFF digitalWrite(POWER_PIN, LOW) + #define POWER_STU digitalRead(POWER_PIN) + // Battery Level Monitoring #define BATTERY_PIN 35 #define BATTERY (float)(((analogRead(BATTERY_PIN) * (3.3 / 4096)) * 2) + 0.31) @@ -182,9 +162,7 @@ #define POWERUP "{\"status\":\"POWER UP\"}" #define UNDERSTOOD "{\"status\":\"OK\"}" #define JSON_ERROR "{\"status\":\"ERROR JSON\"}" - #define TARGET_MET "{\"status\":\"TARGET MEET\"}" #define GAME_OVER "{\"status\":\"GAME OVER\"}" - #define TIME_OVER "{\"status\":\"TIME OVER\"}" #define UNKNOWN_GAME "{\"status\":\"UNKNOWN GAME\"}" // GAME NAMES @@ -198,7 +176,6 @@ #define CM_START "{\"cm\":\"START\"}" #define CM_RESET "{\"cm\":\"RESET\"}" #define CM_STOP "{\"cm\":\"STOP\"}" - #define CM_EXIT "{\"cm\":\"EXIT\"}" //====================================================== // READING IMPACT POWER FROM ANALOG PINS @@ -223,6 +200,8 @@ // Make Sure Of The Core #ifdef ESP32 Bluetooth.begin("KICKER"); // Bluetooth device name + POWER_SETUP; // Boost Pin Setup + POWER_ON; // Turn Power On - And Keep On BOOST_SETUP; // Boost Pin Setup BOOST_OFF; // Turn It Off #else @@ -274,7 +253,7 @@ dualcomm(UNDERSTOOD); // Reading Game Name & Settings - String game = JSON["gm"]; + String game = JSON["gm"]; String settings = JSON["set"]; // Clearing JSON Buffer @@ -285,9 +264,12 @@ } else { + // Send Back A Signal terminal(JSON_ERROR); } - Bluetooth.flush(); + + // Clear Bluetooth Buffer + flushBluetooth; } } diff --git a/firmware/kicker/neo_pixel.ino b/firmware/kicker/neo_pixel.ino index 3b777ba..0164455 100644 --- a/firmware/kicker/neo_pixel.ino +++ b/firmware/kicker/neo_pixel.ino @@ -7,12 +7,7 @@ //------------------------------------------------------ void LED_CLEAR() - { - // Make Sure Of The Core - #ifdef ESP32 - LED_BOOST_CHK(); - #endif - + { // Clear The Strip Color pixels.clear(); @@ -23,11 +18,6 @@ // Show On LED Strip LED_SHOW(); - - // Make Sure Of The Core - #ifdef ESP32 - BOOST_OFF; - #endif } //------------------------------------------------------ @@ -36,11 +26,6 @@ void LED_SHOW() { - // Make Sure Of The Core - #ifdef ESP32 - LED_BOOST_CHK(); - #endif - // Pass It To The LED Strip pixels.show(); } @@ -51,11 +36,6 @@ void LED_SET_BRIGHTNESS(uint8_t Value) { - // Make Sure Of The Core - #ifdef ESP32 - LED_BOOST_CHK(); - #endif - // Set The Brightness pixels.setBrightness(Value); } @@ -66,11 +46,6 @@ void LED_SET_COLOR(uint8_t R, uint8_t G, uint8_t B, uint8_t Intensity) { - // Make Sure Of The Core - #ifdef ESP32 - LED_BOOST_CHK(); - #endif - // Set Intensity LED_SET_BRIGHTNESS(Intensity); @@ -105,11 +80,6 @@ // Fill the dots one after the other with a color void LED_COLOR_WIPE(uint32_t c, uint8_t wait) { - // Make Sure Of The Core - #ifdef ESP32 - LED_BOOST_CHK(); - #endif - // Work Loop for(uint16_t i=0; i=0; i--) { @@ -232,12 +182,7 @@ //------------------------------------------------------ void LED_CROSS_FADE(uint8_t R, uint8_t G, uint8_t B, unsigned int Times) - { - // Make Sure Of The Core - #ifdef ESP32 - LED_BOOST_CHK(); - #endif - + { for(int i=0; i