updating the repository

This commit is contained in:
Ghassan Yusuf 2020-05-25 14:02:42 +03:00
parent 3c3f3a4657
commit 7eac4601f4
10 changed files with 30 additions and 113 deletions

View File

@ -18,11 +18,11 @@
// Time Attack Game // Time Attack Game
else if(game == "ta") { else if(game == "ta") {
terminal(GM_TATTACK); terminal(GM_TATTACK);
game_reaction_bluetooth(settings); time_attack_bluetooth(settings);
return; return;
} }
// Time Attack Game // Time Reaction Game
else if(game == "ra") { else if(game == "ra") {
terminal(GM_REACTION); terminal(GM_REACTION);
game_reaction_bluetooth(settings); game_reaction_bluetooth(settings);

View File

@ -87,7 +87,7 @@
// PUBLIC VARIABLES // PUBLIC VARIABLES
uint16_t time = JSON["tm"]; // Time Window To JSON 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 uint16_t limit = JSON["lm"]; // Kick Target Limit
bool limitEnable = JSON["le"]; // Enable Kick Target Limit bool limitEnable = JSON["le"]; // Enable Kick Target Limit

View File

@ -10,42 +10,8 @@
//====================================================== //======================================================
// HARDWARE SETUP & SELECTION // HARDWARE SETUP & SELECTION
//====================================================== //======================================================
// Arduino MEGA
#ifdef ARDUINO_AVR_MEGA2560
//------------------------------------------------------
// Library Nessesary
#ifdef __AVR__
#include <avr/power.h>
#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 // Arduino Uno / Nano
#elif ARDUINO_AVR_UNO || ARDUINO_AVR_NANO #ifdef ARDUINO_AVR_UNO || ARDUINO_AVR_NANO
//------------------------------------------------------ //------------------------------------------------------
// Library Nessesary // Library Nessesary
@ -68,7 +34,7 @@
#define flushBluetooth while(isBluetooth) { Bluetooth.read(); } #define flushBluetooth while(isBluetooth) { Bluetooth.read(); }
// JSON Object & Memory // JSON Object & Memory
#define CAPACITY 100 #define CAPACITY 150
DynamicJsonDocument JSON(CAPACITY); // Building JSON Buffer DynamicJsonDocument JSON(CAPACITY); // Building JSON Buffer
// LED Strip // LED Strip
@ -76,6 +42,13 @@
#define NUM_PIXELS 14 // NUMBER OF LED'S IN NEO PIXEL STRIP #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 // Impact Detection
#define VTH 14 // THRESHOLD VOLTAGE FOR ZERO POSITIONNING KICKING POWER SENSOR #define VTH 14 // THRESHOLD VOLTAGE FOR ZERO POSITIONNING KICKING POWER SENSOR
#define SENSOR_PIN A0 // IMPACT SENSOR #define SENSOR_PIN A0 // IMPACT SENSOR
@ -154,6 +127,13 @@
#define BOOST_OFF digitalWrite(BOOST_PIN, LOW) #define BOOST_OFF digitalWrite(BOOST_PIN, LOW)
#define BOOST_STU digitalRead(BOOST_PIN) #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 // Battery Level Monitoring
#define BATTERY_PIN 35 #define BATTERY_PIN 35
#define BATTERY (float)(((analogRead(BATTERY_PIN) * (3.3 / 4096)) * 2) + 0.31) #define BATTERY (float)(((analogRead(BATTERY_PIN) * (3.3 / 4096)) * 2) + 0.31)
@ -182,9 +162,7 @@
#define POWERUP "{\"status\":\"POWER UP\"}" #define POWERUP "{\"status\":\"POWER UP\"}"
#define UNDERSTOOD "{\"status\":\"OK\"}" #define UNDERSTOOD "{\"status\":\"OK\"}"
#define JSON_ERROR "{\"status\":\"ERROR JSON\"}" #define JSON_ERROR "{\"status\":\"ERROR JSON\"}"
#define TARGET_MET "{\"status\":\"TARGET MEET\"}"
#define GAME_OVER "{\"status\":\"GAME OVER\"}" #define GAME_OVER "{\"status\":\"GAME OVER\"}"
#define TIME_OVER "{\"status\":\"TIME OVER\"}"
#define UNKNOWN_GAME "{\"status\":\"UNKNOWN GAME\"}" #define UNKNOWN_GAME "{\"status\":\"UNKNOWN GAME\"}"
// GAME NAMES // GAME NAMES
@ -198,7 +176,6 @@
#define CM_START "{\"cm\":\"START\"}" #define CM_START "{\"cm\":\"START\"}"
#define CM_RESET "{\"cm\":\"RESET\"}" #define CM_RESET "{\"cm\":\"RESET\"}"
#define CM_STOP "{\"cm\":\"STOP\"}" #define CM_STOP "{\"cm\":\"STOP\"}"
#define CM_EXIT "{\"cm\":\"EXIT\"}"
//====================================================== //======================================================
// READING IMPACT POWER FROM ANALOG PINS // READING IMPACT POWER FROM ANALOG PINS
@ -223,6 +200,8 @@
// Make Sure Of The Core // Make Sure Of The Core
#ifdef ESP32 #ifdef ESP32
Bluetooth.begin("KICKER"); // Bluetooth device name 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_SETUP; // Boost Pin Setup
BOOST_OFF; // Turn It Off BOOST_OFF; // Turn It Off
#else #else
@ -285,9 +264,12 @@
} }
else else
{ {
// Send Back A Signal
terminal(JSON_ERROR); terminal(JSON_ERROR);
} }
Bluetooth.flush();
// Clear Bluetooth Buffer
flushBluetooth;
} }
} }

View File

@ -8,11 +8,6 @@
void LED_CLEAR() void LED_CLEAR()
{ {
// Make Sure Of The Core
#ifdef ESP32
LED_BOOST_CHK();
#endif
// Clear The Strip Color // Clear The Strip Color
pixels.clear(); pixels.clear();
@ -23,11 +18,6 @@
// Show On LED Strip // Show On LED Strip
LED_SHOW(); LED_SHOW();
// Make Sure Of The Core
#ifdef ESP32
BOOST_OFF;
#endif
} }
//------------------------------------------------------ //------------------------------------------------------
@ -36,11 +26,6 @@
void LED_SHOW() void LED_SHOW()
{ {
// Make Sure Of The Core
#ifdef ESP32
LED_BOOST_CHK();
#endif
// Pass It To The LED Strip // Pass It To The LED Strip
pixels.show(); pixels.show();
} }
@ -51,11 +36,6 @@
void LED_SET_BRIGHTNESS(uint8_t Value) void LED_SET_BRIGHTNESS(uint8_t Value)
{ {
// Make Sure Of The Core
#ifdef ESP32
LED_BOOST_CHK();
#endif
// Set The Brightness // Set The Brightness
pixels.setBrightness(Value); pixels.setBrightness(Value);
} }
@ -66,11 +46,6 @@
void LED_SET_COLOR(uint8_t R, uint8_t G, uint8_t B, uint8_t Intensity) 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 // Set Intensity
LED_SET_BRIGHTNESS(Intensity); LED_SET_BRIGHTNESS(Intensity);
@ -105,11 +80,6 @@
// Fill the dots one after the other with a color // Fill the dots one after the other with a color
void LED_COLOR_WIPE(uint32_t c, uint8_t wait) void LED_COLOR_WIPE(uint32_t c, uint8_t wait)
{ {
// Make Sure Of The Core
#ifdef ESP32
LED_BOOST_CHK();
#endif
// Work Loop // Work Loop
for(uint16_t i=0; i<NUM_PIXELS; i++) for(uint16_t i=0; i<NUM_PIXELS; i++)
{ {
@ -126,11 +96,6 @@
// Slightly different, this makes the rainbow equally distributed throughout // Slightly different, this makes the rainbow equally distributed throughout
void LED_RAINBOW_CYCLE(uint8_t wait) void LED_RAINBOW_CYCLE(uint8_t wait)
{ {
// Make Sure Of The Core
#ifdef ESP32
LED_BOOST_CHK();
#endif
// Loop Variables // Loop Variables
uint16_t i, j; uint16_t i, j;
@ -156,11 +121,6 @@
// The colours are a transition r - g - b - back to r. // The colours are a transition r - g - b - back to r.
uint32_t LED_COLOR_WHEEL(byte WHEELPos) uint32_t LED_COLOR_WHEEL(byte WHEELPos)
{ {
// Make Sure Of The Core
#ifdef ESP32
LED_BOOST_CHK();
#endif
// Wheel Sequance // Wheel Sequance
WHEELPos = 255 - WHEELPos; WHEELPos = 255 - WHEELPos;
@ -183,11 +143,6 @@
void LED_FADEIN(uint8_t R, uint8_t G, uint8_t B) void LED_FADEIN(uint8_t R, uint8_t G, uint8_t B)
{ {
// Make Sure Of The Core
#ifdef ESP32
LED_BOOST_CHK();
#endif
// Loop For Fade // Loop For Fade
for(int i=0; i<=255; i++) for(int i=0; i<=255; i++)
{ {
@ -208,11 +163,6 @@
void LED_FADEOUT(uint8_t R, uint8_t G, uint8_t B) void LED_FADEOUT(uint8_t R, uint8_t G, uint8_t B)
{ {
// Make Sure Of The Core
#ifdef ESP32
LED_BOOST_CHK();
#endif
// Loop For Fade Out // Loop For Fade Out
for(int i=255; i>=0; i--) for(int i=255; i>=0; i--)
{ {
@ -233,11 +183,6 @@
void LED_CROSS_FADE(uint8_t R, uint8_t G, uint8_t B, unsigned int Times) 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<Times; i++) for(int i=0; i<Times; i++)
{ {
LED_FADEIN(R, G, B); LED_FADEIN(R, G, B);
@ -310,11 +255,6 @@
void LED_BAHRAIN_FLAG() void LED_BAHRAIN_FLAG()
{ {
// Make Sure Of The Core
#ifdef ESP32
LED_BOOST_CHK();
#endif
LED_SET_BRIGHTNESS(255); LED_SET_BRIGHTNESS(255);
LED_COLOR_WIPE(pixels.Color(255, 255, 255), 30); // White LED_COLOR_WIPE(pixels.Color(255, 255, 255), 30); // White
delay(250); delay(250);
@ -329,11 +269,6 @@
void LED_COLOMBIA_FLAG() void LED_COLOMBIA_FLAG()
{ {
// Make Sure Of The Core
#ifdef ESP32
LED_BOOST_CHK();
#endif
LED_SET_BRIGHTNESS(255); LED_SET_BRIGHTNESS(255);
LED_COLOR_WIPE(pixels.Color(255, 255, 0), 30); // Yellow LED_COLOR_WIPE(pixels.Color(255, 255, 0), 30); // Yellow
delay(250); delay(250);

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.