putting bac the led strip library

This commit is contained in:
Ghassan Yusuf 2020-03-22 00:58:38 +03:00
parent 9f86415b9a
commit 84539fecfc
3 changed files with 278 additions and 314 deletions

View File

@ -39,8 +39,15 @@
#include <Button.h> #include <Button.h>
#include <TimeTrigger.h> #include <TimeTrigger.h>
#include <ArduinoJson.h> #include <ArduinoJson.h>
#include <NeoPixelBus.h>
#include <BluetoothSerial.h> #include <BluetoothSerial.h>
#include <Adafruit_NeoPixel.h>
//======================================================
// OVER THE AIR PROGRAMMING
//======================================================
// #include <WiFi.h>
// #include <ESPmDNS.h>
// #include <WiFiUdp.h>
// #include <ArduinoOTA.h>
//====================================================== //======================================================
// PUBLIC VARIABLES // PUBLIC VARIABLES
//====================================================== //======================================================
@ -90,7 +97,7 @@
#define POWER_SETUP pinMode(POWER_PIN, OUTPUT) #define POWER_SETUP pinMode(POWER_PIN, OUTPUT)
#define POWER_OFF digitalWrite(POWER_PIN, LOW) #define POWER_OFF digitalWrite(POWER_PIN, LOW)
#define POWER_ON digitalWrite(POWER_PIN, HIGH) #define POWER_ON digitalWrite(POWER_PIN, HIGH)
TimeTrigger POWER_PRESS(4000); // The Interval In mSeconds TimeTrigger POWER_PRESS(4000); // The Interval In mSeconds
//------------------------------------------------------ //------------------------------------------------------
// Piezo Transducer // Piezo Transducer
//------------------------------------------------------ //------------------------------------------------------
@ -114,10 +121,12 @@
//------------------------------------------------------ //------------------------------------------------------
// Neo Pixel LED Strip // Neo Pixel LED Strip
//------------------------------------------------------ //------------------------------------------------------
#define PIXEL_COUNT 21 // make sure to set this to the number of pixels in your strip #ifdef __AVR__
#define PIXEL_PIN 26 // make sure to set this to the correct pin, ignored for Esp8266 #include <avr/power.h> // Required for 16 MHz Adafruit Trinket
// three element pixels, in different order and speeds #endif
NeoPixelBus<NeoGrbFeature, Neo800KbpsMethod> PIXEL_STRIP(PIXEL_COUNT, PIXEL_PIN); #define PIN 6 // On Trinket or Gemma, suggest changing this to 1
#define NUMPIXELS 16 // Number Of LED's
Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
//------------------------------------------------------ //------------------------------------------------------
// JSON Object & Memory // JSON Object & Memory
//------------------------------------------------------ //------------------------------------------------------
@ -158,11 +167,7 @@
POWER_SETUP; POWER_SETUP;
POWER_ON; POWER_ON;
// Turn On Booster // Charging Status Pin Setup
BOOST_SETUP;
BOOST_OFF;
// Charging Status Pin
STAT_SETUP; STAT_SETUP;
// I2C Module & OLED // I2C Module & OLED
@ -172,6 +177,13 @@
OLED_CLEAR(); OLED_CLEAR();
OLED_SHOW(); OLED_SHOW();
// IF Charger Connected Dont Allow Any One To Play
// Turn On Booster
BOOST_SETUP;
BOOST_ON;
// Start Buttons Function // Start Buttons Function
BTN_PREVIOUS.begin(); BTN_PREVIOUS.begin();
BTN_NEXT.begin(); BTN_NEXT.begin();

View File

@ -1,295 +1,247 @@
////====================================================== //======================================================
//// NEO PIXEL LED STRIP // NEO PIXEL LED STRIP
////====================================================== //======================================================
//// PUBLIC DEFINITIONS // PUBLIC DEFINITIONS
////------------------------------------------------------ //------------------------------------------------------
// #define BETWEEN_FADE 15 #define BETWEEN_FADE 15
// #define FADE_RATE 15 #define FADE_RATE 15
// #define BLINK_RATE 250 #define BLINK_RATE 250
// #define ColorSaturation 128 #define ColorSaturation 128
////------------------------------------------------------ //------------------------------------------------------
//// PURE COLOR // Clearing The LED Strip
////------------------------------------------------------ //------------------------------------------------------
// RgbColor red(colorSaturation, 0, 0); void LED_CLEAR()
// RgbColor green(0, colorSaturation, 0); {
// RgbColor blue(0, 0, colorSaturation); // Clear The Strip Color
// RgbColor white(colorSaturation); PIXEL_STRIP.clear();
// RgbColor black(0);
////------------------------------------------------------ // Show On LED Strip
//// HSL COLOR LED_SHOW();
////------------------------------------------------------ }
// HslColor hslRed(red); //------------------------------------------------------
// HslColor hslGreen(green); // DISPLAY ON STRIP
// HslColor hslBlue(blue); //------------------------------------------------------
// HslColor hslWhite(white); void LED_SHOW()
// HslColor hslBlack(black); {
////------------------------------------------------------ // Pass It To The LED Strip
//// Clearing The LED Strip PIXEL_STRIP.show();
////------------------------------------------------------ }
// void LED_CLEAR() //------------------------------------------------------
// { // Set LED Brightness
// // Make Sure Boost Is On //------------------------------------------------------
// BOOST_ON; void LED_SET_BRIGHTNESS(uint8_t Value)
// {
// // Clear The Strip Color // Set The Brightness
// PIXEL_STRIP.clear(); PIXEL_STRIP.setBrightness(Value);
// }
// // Show On LED Strip //------------------------------------------------------
// LED_SHOW(); // Set LED Color
// } //------------------------------------------------------
////------------------------------------------------------ void LED_SET_COLOR(uint8_t R, uint8_t G, uint8_t B, uint8_t Intensity)
//// DISPLAY ON STRIP {
////------------------------------------------------------ // Set Intensity
// void LED_SHOW() LED_SET_BRIGHTNESS(Intensity);
// {
// // Make Sure Boost Is On // Loop
// BOOST_ON; for(int i=0; i<NUM_PIXELS; i++) {
// PIXEL_STRIP.setPixelColor(i, PIXEL_STRIP.Color(R, G, B));
// // Pass It To The LED Strip }
// PIXEL_STRIP.show();
// } // Show The Colors On LED Strip
////------------------------------------------------------ LED_SHOW();
//// Set LED Brightness }
////------------------------------------------------------ //------------------------------------------------------
// void LED_SET_BRIGHTNESS(uint8_t Value) // BLINK
// { //------------------------------------------------------
// // Make Sure Boost Is On void LED_BLINK(uint8_t R, uint8_t G, uint8_t B, int Times)
// BOOST_ON; {
// for(int i=0; i<Times; i++)
// // Set The Brightness {
// PIXEL_STRIP.setBrightness(Value); LED_SET_COLOR(R, G, B, 255);
// } delay(BLINK_RATE);
////------------------------------------------------------ LED_CLEAR();
//// Set LED Color delay(BLINK_RATE);
////------------------------------------------------------ }
// void LED_SET_COLOR(uint8_t R, uint8_t G, uint8_t B, uint8_t Intensity) }
// { //------------------------------------------------------
// // Make Sure Boost Is On // COLOR WHIPE
// BOOST_ON; //------------------------------------------------------
// // Fill the dots one after the other with a color
// // Set Intensity void LED_COLOR_WIPE(uint32_t c, uint8_t wait)
// LED_SET_BRIGHTNESS(Intensity); {
// // Work Loop
// // Loop for(uint16_t i=0; i<NUM_PIXELS; i++)
// for(int i=0; i<NUM_PIXELS; i++) { {
// PIXEL_STRIP.setPixelColor(i, PIXEL_STRIP.Color(R, G, B)); PIXEL_STRIP.setPixelColor(i, c);
// } LED_SHOW();
// delay(wait);
// // Show The Colors On LED Strip }
// LED_SHOW(); }
// } //------------------------------------------------------
////------------------------------------------------------ // END GAME LIGHTING SIGNAL
//// BLINK //------------------------------------------------------
////------------------------------------------------------ // Slightly different, this makes the rainbow equally distributed throughout
// void LED_BLINK(uint8_t R, uint8_t G, uint8_t B, int Times) void LED_RAINBOW_CYCLE(uint8_t wait)
// { {
// for(int i=0; i<Times; i++) // Loop Variables
// { uint16_t i, j;
// LED_SET_COLOR(R, G, B, 255);
// delay(BLINK_RATE); // The Loop
// LED_CLEAR(); for(j=0; j<256*5; j++)
// delay(BLINK_RATE); {
// } // 5 cycles of all colors on WHEEL
// } for(i=0; i< PIXEL_STRIP.numPixels(); i++)
////------------------------------------------------------ {
//// COLOR WHIPE PIXEL_STRIP.setPixelColor(i, LED_COLOR_WHEEL(((i * 256 / PIXEL_STRIP.numPixels()) + j) & 255));
////------------------------------------------------------ }
// // Fill the dots one after the other with a color
// void LED_COLOR_WIPE(uint32_t c, uint8_t wait) LED_SHOW();
// { delay(wait);
// // Make Sure Boost Is On }
// BOOST_ON; }
// //------------------------------------------------------
// // Work Loop // END GAME LIGHTING SIGNAL
// for(uint16_t i=0; i<NUM_PIXELS; i++) //------------------------------------------------------
// { // Input a value 0 to 255 to get a color value.
// PIXEL_STRIP.setPixelColor(i, c); // The colours are a transition r - g - b - back to r.
// LED_SHOW(); uint32_t LED_COLOR_WHEEL(byte WHEELPos)
// delay(wait); {
// } // Wheel Sequance
// } WHEELPos = 255 - WHEELPos;
////------------------------------------------------------
//// END GAME LIGHTING SIGNAL if(WHEELPos < 85)
////------------------------------------------------------ {
// // Slightly different, this makes the rainbow equally distributed throughout return PIXEL_STRIP.Color(255 - WHEELPos * 3, 0, WHEELPos * 3);
// void LED_RAINBOW_CYCLE(uint8_t wait) }
// { if(WHEELPos < 170)
// // Make Sure Boost Is On {
// BOOST_ON; WHEELPos -= 85;
// return PIXEL_STRIP.Color(0, WHEELPos * 3, 255 - WHEELPos * 3);
// // Loop Variables }
// uint16_t i, j; WHEELPos -= 170;
// return PIXEL_STRIP.Color(WHEELPos * 3, 255 - WHEELPos * 3, 0);
// // The Loop }
// for(j=0; j<256*5; j++) //------------------------------------------------------
// { // Set Color Fade In
// // 5 cycles of all colors on WHEEL //------------------------------------------------------
// for(i=0; i< PIXEL_STRIP.numPixels(); i++) void LED_FADEIN(uint8_t R, uint8_t G, uint8_t B)
// { {
// PIXEL_STRIP.setPixelColor(i, LED_COLOR_WHEEL(((i * 256 / PIXEL_STRIP.numPixels()) + j) & 255)); // Loop For Fade
// } for(int i=0; i<=255; i++)
// {
// LED_SHOW(); PIXEL_STRIP.setBrightness(i);
// delay(wait); for(int j=0; j<NUM_PIXELS; j++)
// } {
// } PIXEL_STRIP.setPixelColor(j, PIXEL_STRIP.Color(R, G, B));
////------------------------------------------------------ }
//// END GAME LIGHTING SIGNAL
////------------------------------------------------------ LED_SHOW();
// // Input a value 0 to 255 to get a color value. delay(4);
// // The colours are a transition r - g - b - back to r. }
// uint32_t LED_COLOR_WHEEL(byte WHEELPos) }
// { //------------------------------------------------------
// // Make Sure Boost Is On // Set Color Fade Out
// BOOST_ON; //------------------------------------------------------
// void LED_FADEOUT(uint8_t R, uint8_t G, uint8_t B)
// // Wheel Sequance {
// WHEELPos = 255 - WHEELPos; // Loop For Fade Out
// for(int i=255; i>=0; i--)
// if(WHEELPos < 85) {
// { PIXEL_STRIP.setBrightness(i);
// return PIXEL_STRIP.Color(255 - WHEELPos * 3, 0, WHEELPos * 3); for(int j=0; j<NUM_PIXELS; j++)
// } {
// if(WHEELPos < 170) PIXEL_STRIP.setPixelColor(j, PIXEL_STRIP.Color(R, G, B));
// { }
// WHEELPos -= 85;
// return PIXEL_STRIP.Color(0, WHEELPos * 3, 255 - WHEELPos * 3); LED_SHOW();
// } delay(4);
// WHEELPos -= 170; }
// return PIXEL_STRIP.Color(WHEELPos * 3, 255 - WHEELPos * 3, 0); }
// } //------------------------------------------------------
////------------------------------------------------------ // Set LED Color Cross Fade
//// Set Color Fade In //------------------------------------------------------
////------------------------------------------------------ void LED_CROSS_FADE(uint8_t R, uint8_t G, uint8_t B, unsigned int Times)
// void LED_FADEIN(uint8_t R, uint8_t G, uint8_t B) {
// { for(int i=0; i<Times; i++)
// // Make Sure Boost Is On {
// BOOST_ON; LED_FADEIN(R, G, B);
// LED_FADEOUT(R, G, B);
// // Loop For Fade delay(BETWEEN_FADE);
// for(int i=0; i<=255; i++) }
// { }
// PIXEL_STRIP.setBrightness(i); //------------------------------------------------------
// for(int j=0; j<NUM_PIXELS; j++) // REACTION GAME START LED SIGNAL
// { //------------------------------------------------------
// PIXEL_STRIP.setPixelColor(j, PIXEL_STRIP.Color(R, G, B)); void LED_SIGNAL_START()
// } {
// // Cross Fade White Color To Get ready 3 Times
// LED_SHOW(); LED_CROSS_FADE(255, 255, 255, 3);
// delay(4);
// } // Set Strip Color Green
// } LED_SET_COLOR(0, 255, 0, 255);
////------------------------------------------------------ }
//// Set Color Fade Out //------------------------------------------------------
////------------------------------------------------------ // REACTION GAME END SINGNAL LED SIGNAL
// void LED_FADEOUT(uint8_t R, uint8_t G, uint8_t B) //------------------------------------------------------
// { void LED_SIGNAL_END()
// // Make Sure Boost Is On {
// BOOST_ON; // Blink Red Twice
// LED_BLINK(255, 0, 0, 2);
// // Loop For Fade Out
// for(int i=255; i>=0; i--) // Fade The Red Color To Nothing
// { LED_FADEOUT(255, 0, 0);
// PIXEL_STRIP.setBrightness(i); }
// for(int j=0; j<NUM_PIXELS; j++) //------------------------------------------------------
// { // REACTION GAME START LED CELEBRATION
// PIXEL_STRIP.setPixelColor(j, PIXEL_STRIP.Color(R, G, B)); //------------------------------------------------------
// } void LED_SIGNAL_CELEBRATION()
// {
// LED_SHOW(); // Display Rainbow Twice
// delay(4); LED_RAINBOW_CYCLE(2);
// }
// } // Grean Light OUT
////------------------------------------------------------ LED_FADEOUT(0, 255, 0);
//// Set LED Color Cross Fade }
////------------------------------------------------------ //------------------------------------------------------
// void LED_CROSS_FADE(uint8_t R, uint8_t G, uint8_t B, unsigned int Times) // REACTION GAME RESET LED SIGNAL
// { //------------------------------------------------------
// // Make Sure Boost Is On void LED_SIGNAL_RESET()
// BOOST_ON; {
// // Light Bright Blue
// for(int i=0; i<Times; i++) LED_BLINK(0, 0, 255, 2);
// {
// LED_FADEIN(R, G, B); // Wait For 1/4 Second
// LED_FADEOUT(R, G, B); delay(250);
// delay(BETWEEN_FADE);
// } // Fade Out The Blue
// } LED_SET_COLOR(0, 255, 0, 255);
////------------------------------------------------------
//// REACTION GAME START LED SIGNAL // Set Strip Color Green
////------------------------------------------------------ LED_SET_COLOR(0, 255, 0, 255);
// void LED_SIGNAL_START() }
// { //------------------------------------------------------
// // Cross Fade White Color To Get ready 3 Times // DISPLAY BAHRAIN FLAG
// LED_CROSS_FADE(255, 255, 255, 3); //------------------------------------------------------
// void LED_BAHRAIN_FLAG()
// // Set Strip Color Green {
// LED_SET_COLOR(0, 255, 0, 255); LED_SET_BRIGHTNESS(255);
// } LED_COLOR_WIPE(PIXEL_STRIP.Color(255, 255, 255), 30); // White
////------------------------------------------------------ delay(250);
//// REACTION GAME END SINGNAL LED SIGNAL LED_COLOR_WIPE(PIXEL_STRIP.Color(255, 0, 0), 30); // Red
////------------------------------------------------------ delay(250);
// void LED_SIGNAL_END() LED_FADEOUT(255, 0, 0);
// { }
// // Blink Red Twice //------------------------------------------------------
// LED_BLINK(255, 0, 0, 2); // DISPLAY COLOMBIA FLAG
// //------------------------------------------------------
// // Fade The Red Color To Nothing void LED_COLOMBIA_FLAG()
// LED_FADEOUT(255, 0, 0); {
// } LED_SET_BRIGHTNESS(255);
////------------------------------------------------------ LED_COLOR_WIPE(PIXEL_STRIP.Color(255, 255, 0), 30); // Yellow
//// REACTION GAME START LED CELEBRATION delay(250);
////------------------------------------------------------ LED_COLOR_WIPE(PIXEL_STRIP.Color(0, 0, 255), 30); // Blue
// void LED_SIGNAL_CELEBRATION() delay(250);
// { LED_COLOR_WIPE(PIXEL_STRIP.Color(255, 0, 0), 30); // Red
// // Display Rainbow Twice delay(250);
// LED_RAINBOW_CYCLE(2); LED_FADEOUT(255, 0, 0);
// }
// // Grean Light OUT
// LED_FADEOUT(0, 255, 0);
// }
////------------------------------------------------------
//// REACTION GAME RESET LED SIGNAL
////------------------------------------------------------
// void LED_SIGNAL_RESET()
// {
// // Light Bright Blue
// LED_BLINK(0, 0, 255, 2);
//
// // Wait For 1/4 Second
// delay(250);
//
// // Fade Out The Blue
// LED_SET_COLOR(0, 255, 0, 255);
//
// // Set Strip Color Green
// LED_SET_COLOR(0, 255, 0, 255);
// }
////------------------------------------------------------
//// DISPLAY BAHRAIN FLAG
////------------------------------------------------------
// void LED_BAHRAIN_FLAG()
// {
// BOOST_ON;
// LED_SET_BRIGHTNESS(255);
// LED_COLOR_WIPE(PIXEL_STRIP.Color(255, 255, 255), 30); // White
// delay(250);
// LED_COLOR_WIPE(PIXEL_STRIP.Color(255, 0, 0), 30); // Red
// delay(250);
// LED_FADEOUT(255, 0, 0);
// }
////------------------------------------------------------
//// DISPLAY COLOMBIA FLAG
////------------------------------------------------------
// void LED_COLOMBIA_FLAG()
// {
// BOOST_ON;
// LED_SET_BRIGHTNESS(255);
// LED_COLOR_WIPE(PIXEL_STRIP.Color(255, 255, 0), 30); // Yellow
// delay(250);
// LED_COLOR_WIPE(PIXEL_STRIP.Color(0, 0, 255), 30); // Blue
// delay(250);
// LED_COLOR_WIPE(PIXEL_STRIP.Color(255, 0, 0), 30); // Red
// delay(250);
// LED_FADEOUT(255, 0, 0);
// }

View File

@ -8,19 +8,19 @@ TAKEONE Kicker, Hi-tech state of the art equipment, that will encourage you to b
Kicking target is originally used in TaeKwonDo martial arts for light training where its meant to increase your focus, timing and speed training, how ever this target was a dead piece it was just a target for striking without any intelligence. it could not tell anything about the striker not measure the capabilities. Kicking target is originally used in TaeKwonDo martial arts for light training where its meant to increase your focus, timing and speed training, how ever this target was a dead piece it was just a target for striking without any intelligence. it could not tell anything about the striker not measure the capabilities.
## The Science Behind The Kicker ## The Science Behind The Kicker
The science behind the kicker, is the basic understanding of martial arts training terminology and converting them to algorithms. Its based on registering the strikes magnitude and register their timestamp. This will open opportunities to calculate and measure the athletes capabilities and skills, not to mention that it can keep track of their progress. with the addition of an RGB interactive element it expands the possibilities to be able to measure skills that are related to your brain activity like reflex time, decision making and much more.
### Key Components
## Key Components ##### Strike Sensing
### Strike Sensing
Strikes are sensed with vibration sensor it gives an alternating voltage when struck and the amplitude increases proportionally with the force of the strike. how ever we don't measure the force of the strike accurately, so we give it a threshold in case this threshold is crossed that is considers a valid strike. Strikes are sensed with vibration sensor it gives an alternating voltage when struck and the amplitude increases proportionally with the force of the strike. how ever we don't measure the force of the strike accurately, so we give it a threshold in case this threshold is crossed that is considers a valid strike.
### Interactive Indication ##### Interactive Indication
Interactive indication is important so that user could understand the signals and knows what's going on. we use addressable RGB Neo Pixel Strip, to light up the strip with different patterns to signal the user to interact with the device. Interactive indication is important so that user could understand the signals and knows what's going on. we use addressable RGB Neo Pixel Strip, to light up the strip with different patterns to signal the user to interact with the device.
### Device Controller ##### Device Controller
in order to do accurate timing and measuring of the event of the games and the capabilities of the athletes who are using the device, we need and powerful brain that's is accurate and reliable with expandable memory wireless connectivity and can run a display and manage power consumption intelligently and keep the battery in safe conditions that will expand its life span. that brain is TAKEONE Board (ESP32 Weroom) in order to do accurate timing and measuring of the event of the games and the capabilities of the athletes who are using the device, we need and powerful brain that's is accurate and reliable with expandable memory wireless connectivity and can run a display and manage power consumption intelligently and keep the battery in safe conditions that will expand its life span. that brain is [TAKEONE Board (ESP32)](https://github.com/GhassanYusuf/takeone-esp32-board)
# Circuit Diagram ##### Circuit Diagram
![](./Pictures/schematicv2.png) ![](./Pictures/schematicv2.png)