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
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);

View File

@ -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

View File

@ -10,42 +10,8 @@
//======================================================
// 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
#elif ARDUINO_AVR_UNO || ARDUINO_AVR_NANO
#ifdef ARDUINO_AVR_UNO || ARDUINO_AVR_NANO
//------------------------------------------------------
// Library Nessesary
@ -68,7 +34,7 @@
#define flushBluetooth while(isBluetooth) { Bluetooth.read(); }
// JSON Object & Memory
#define CAPACITY 100
#define CAPACITY 150
DynamicJsonDocument JSON(CAPACITY); // Building JSON Buffer
// LED Strip
@ -76,6 +42,13 @@
#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);
// 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
#define SENSOR_PIN A0 // IMPACT SENSOR
@ -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
@ -285,9 +264,12 @@
}
else
{
// Send Back A Signal
terminal(JSON_ERROR);
}
Bluetooth.flush();
// Clear Bluetooth Buffer
flushBluetooth;
}
}

View File

@ -8,11 +8,6 @@
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<NUM_PIXELS; i++)
{
@ -126,11 +96,6 @@
// Slightly different, this makes the rainbow equally distributed throughout
void LED_RAINBOW_CYCLE(uint8_t wait)
{
// Make Sure Of The Core
#ifdef ESP32
LED_BOOST_CHK();
#endif
// Loop Variables
uint16_t i, j;
@ -156,11 +121,6 @@
// The colours are a transition r - g - b - back to r.
uint32_t LED_COLOR_WHEEL(byte WHEELPos)
{
// Make Sure Of The Core
#ifdef ESP32
LED_BOOST_CHK();
#endif
// Wheel Sequance
WHEELPos = 255 - WHEELPos;
@ -183,11 +143,6 @@
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
for(int i=0; i<=255; i++)
{
@ -208,11 +163,6 @@
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
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)
{
// Make Sure Of The Core
#ifdef ESP32
LED_BOOST_CHK();
#endif
for(int i=0; i<Times; i++)
{
LED_FADEIN(R, G, B);
@ -310,11 +255,6 @@
void LED_BAHRAIN_FLAG()
{
// Make Sure Of The Core
#ifdef ESP32
LED_BOOST_CHK();
#endif
LED_SET_BRIGHTNESS(255);
LED_COLOR_WIPE(pixels.Color(255, 255, 255), 30); // White
delay(250);
@ -329,11 +269,6 @@
void LED_COLOMBIA_FLAG()
{
// Make Sure Of The Core
#ifdef ESP32
LED_BOOST_CHK();
#endif
LED_SET_BRIGHTNESS(255);
LED_COLOR_WIPE(pixels.Color(255, 255, 0), 30); // Yellow
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.