Skip to content

Commit

Permalink
Adafruit Pixie support and automatic sleep mode entry, other see desc…
Browse files Browse the repository at this point in the history
…ription below

Buttons.cpp: prepare for COLOR Profiles, added lines for Adafruit Pixies support (ADF_PIXIE_BLADE)

Config_HW.h:
- added compile directive for ADF_PIXIE_BLADE (Adafruit Pixie)
- added dummy NUMPIXELS define for led strings and star led setups to enable compilation wo/errors

Config_SW.h:
- definition SLEEPYTIME compile define statement
- prepare swicth between GRAVITY_COLOR and COLOR_PROFILES to change blade colors in Config Menu

Light.cpp/.h:
- mainly support code for ADF_PIXIE_BLADE
- fixed smooth blade ramp for LED_STAR setup, now ignition and retractions have a very smooth brightness Ramp

FX-SaberOS.ino:
sleep mode changes:
- automatic entry into sleep mode after SLEEPYTIME sent in idle mode
- accent led switch off in sleep mode
- ADF_PIXIE_BLADE support, needed to make a switch between 2 DFPlayer libraries to enable using SoftwareSerial

Known issues:
- ADF_PIXIE_BLADE cannot be made to flicker properly, current code simply keeps the blade static
  • Loading branch information
Protonerd authored Dec 8, 2017
1 parent 9a42f9a commit c947d73
Show file tree
Hide file tree
Showing 8 changed files with 963 additions and 219 deletions.
14 changes: 10 additions & 4 deletions Buttons.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ extern uint8_t ledPins[];
extern cRGB currentColor;
//extern uint8_t currentColor[4]; //0:Red 1:Green 2:Blue 3:ColorID
#endif
#if defined PIXELBLADE
#if defined PIXELBLADE or defined ADF_PIXIE_BLADE
extern uint8_t ledPins[];
extern cRGB color;
extern cRGB currentColor;
Expand Down Expand Up @@ -105,10 +105,13 @@ void ConfigMenuButtonEventHandler(bool SaturateColor, ButtonActionEnum ButtonAct
//Serial.print("soundfont "); Serial.print(storage.soundFont); Serial.print(" Offset: ");Serial.println(soundFont.getMenu((storage.soundFont)*NR_FILE_SF));
delay(150);
}
#if defined(PIXELBLADE) or defined(STAR_LED)
#if defined PIXELBLADE or defined STAR_LED or defined ADF_PIXIE_BLADE
else if (ConfigModeSubStates==CS_MAINCOLOR) {
//confParseValue(storage.sndProfile[storage.soundFont].mainColor, 0, 100 - 1, 1);
ColorMixing(storage.sndProfile[storage.soundFont].mainColor,modification,MAX_BRIGHTNESS, SaturateColor);
#ifdef GRAVITY_COLOR
ColorMixing(storage.sndProfile[storage.soundFont].mainColor,modification,MAX_BRIGHTNESS, SaturateColor);
#else if COLOR_PROFILE

#endif
storage.sndProfile[storage.soundFont].mainColor.r=currentColor.r;
storage.sndProfile[storage.soundFont].mainColor.g=currentColor.g;
storage.sndProfile[storage.soundFont].mainColor.b=currentColor.b;
Expand Down Expand Up @@ -140,6 +143,9 @@ void ConfigMenuButtonEventHandler(bool SaturateColor, ButtonActionEnum ButtonAct
#ifdef STAR_LED
confParseValue(storage.sndProfile[storage.soundFont].flickerType, 0, 2, 1*incrementSign); // max number of flicker types for STAR_LED currently 3
#endif
#ifdef ADF_PIXIE_BLADE
confParseValue(storage.sndProfile[storage.soundFont].flickerType, 0, 0, 1*incrementSign); // max number of flicker types for Adafruit Pixie currently 1
#endif
#ifdef PIXELBLADE
confParseValue(storage.sndProfile[storage.soundFont].flickerType, 0, 4, 1*incrementSign); // max number of flicker types for PIXELBLADE currently 5
#endif
Expand Down
4 changes: 2 additions & 2 deletions ConfigMenu.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ enum ActionModeSubStatesEnum {AS_HUM, AS_IGNITION, AS_RETRACTION, AS_BLADELOCKUP
#if defined LEDSTRINGS
enum ConfigModeSubStatesEnum {CS_SOUNDFONT, CS_FLICKERTYPE, CS_SLEEPINIT, CS_LASTMEMBER, CS_VOLUME, CS_POWERONOFFTYPE, CS_SWINGSENSITIVITY, CS_MAINCOLOR, CS_CLASHCOLOR, CS_BLASTCOLOR, CS_BATTERYLEVEL, CS_STORAGEACCESS, CS_UARTMODE}; // never delete CS_LASTMEMBER!!! Needed to calculate number of elements in the enum type!!!
#endif
#if defined STAR_LED
#if defined STAR_LED or defined ADF_PIXIE_BLADE
enum ConfigModeSubStatesEnum {CS_SOUNDFONT, CS_SLEEPINIT, CS_FLICKERTYPE, CS_MAINCOLOR, CS_CLASHCOLOR, CS_BLASTCOLOR, CS_SWINGSENSITIVITY, CS_VOLUME, CS_LASTMEMBER, CS_BATTERYLEVEL, CS_POWERONOFFTYPE, CS_STORAGEACCESS, CS_UARTMODE}; // never delete CS_LASTMEMBER!!! Needed to calculate number of elements in the enum type!!!
#endif
#if defined PIXELBLADE
enum ConfigModeSubStatesEnum {CS_SOUNDFONT, CS_SLEEPINIT, CS_FLICKERTYPE, CS_MAINCOLOR, CS_CLASHCOLOR, CS_BLASTCOLOR, CS_SWINGSENSITIVITY, CS_LASTMEMBER, CS_VOLUME, CS_POWERONOFFTYPE, CS_BATTERYLEVEL, CS_STORAGEACCESS, CS_UARTMODE}; // never delete CS_LASTMEMBER!!! Needed to calculate number of elements in the enum type!!!
enum ConfigModeSubStatesEnum {CS_SOUNDFONT, CS_VOLUME, CS_SLEEPINIT, CS_FLICKERTYPE, CS_MAINCOLOR, CS_CLASHCOLOR, CS_BLASTCOLOR, CS_SWINGSENSITIVITY, CS_LASTMEMBER, CS_POWERONOFFTYPE, CS_BATTERYLEVEL, CS_STORAGEACCESS, CS_UARTMODE}; // never delete CS_LASTMEMBER!!! Needed to calculate number of elements in the enum type!!!
#endif

// ====================================================================================
Expand Down
54 changes: 32 additions & 22 deletions Config_HW.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
* If you have a home-brew solution using the Arduino Nano, choose DIYINO_PRIME below
*/

#define DIYINO_PRIME
//#define DIYINO_STARDUST
//#define DIYINO_PRIME
#define DIYINO_STARDUST

/***** BOARD PINOUT DEFINITIONS ******/

Expand All @@ -36,7 +36,7 @@
// If your saber has only a single button to interact with the electronics, uncomment the next line
// in case you have 2 buttons (referred to as main and aux buttons) leave this line commented out

//#define SINGLEBUTTON
#define SINGLEBUTTON

#ifdef DIYINO_PRIME
#define MAIN_BUTTON 12
Expand All @@ -60,8 +60,9 @@
* blocks from compile
*************************************/
//#define LEDSTRINGS
//#define STAR_LED
#define PIXELBLADE
#define STAR_LED
//#define PIXELBLADE
//#define ADF_PIXIE_BLADE

/************************************/
/*
Expand Down Expand Up @@ -111,13 +112,27 @@
#define LED_BLUE 9
#endif

// How many leds in one strip?
#define NUMPIXELS 60 // can go up to 120, could lead to memory overflow if further increased, causing instability
#if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE
#include <Wire.h>
#endif
#if defined LEDSTRINGS or defined STAR_LED
#define NUMPIXELS 0
#endif

#ifdef PIXELBLADE
// How many leds in one strip?
#define NUMPIXELS 115 // can go up to 120, could lead to memory overflow if further increased, causing instability
// For led chips like NEOPIXELs, which have a data line, ground, and power, you just
// need to define DATA_PIN.
#define DATA_PIN 13 // D13
#endif

#ifdef ADF_PIXIE_BLADE
#define NUMPIXELS 1
#define PIXIEPIN 13 // Pin number for SoftwareSerial output
#endif

// For led chips like NEOPIXELs, which have a data line, ground, and power, you just
// need to define DATA_PIN.
#define DATA_PIN 13 // D13


#ifdef CROSSGUARDSABER
// define how many pixels are used for the crossguard and how many for the main blade
Expand Down Expand Up @@ -153,17 +168,14 @@
* Enable/disable management of
* a button accent led
*************************************/
#define ACCENT_LED 14 //A0

//#define MULTICOLOR_ACCENT_LED
#if defined MULTICOLOR_ACCENT_LED
#define RED_ACCENT_LED 16 //A2
#define GREEN_ACCENT_LED 17 //A3
#define BLUE_ACCENT_LED A7 //.... A7 is input only ...
#ifdef DIYINO_PRIME
#define ACCENT_LED 14 //A0
#else if DIYINO_STARDUST
#define ACCENT_LED 14 //A0 is an auxiliary pin on Stardust v2
#endif



/*
* MP3 chips YX5200 or YX6300 Tx and Rx ins, as well as the ADC pins connected to the SPK terminals for AudioTracker
*/
#define DFPLAYER_RX 8
#define DFPLAYER_TX 7
#define SPK1 20 //A6
Expand All @@ -172,8 +184,6 @@



#define BUTTONLEDPIN 16 //A2

#define BATTERY_CHECK // comment to disable
#ifdef BATTERY_CHECK
#ifdef DIYINO_PRIME
Expand Down
33 changes: 27 additions & 6 deletions Config_SW.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@
#define CLASH_THRESHOLD 10 // 10 was the original value in LSOS, Jason's value changed it to 6, but it resulted in false clash trigges at more forceful swings
/************************************/

#if defined STAR_LED
#endif

#if defined LEDSTRINGS
#define CONFIG_VERSION "L01"
#endif
Expand All @@ -38,12 +35,22 @@
#endif
#if defined PIXELBLADE
#define CONFIG_VERSION "L03"
//#define FIREBLADE
static const uint8_t rgbFactor = 255;
#endif
#if defined ADF_PIXIE_BLADE
#define CONFIG_VERSION "L05"
static const uint8_t rgbFactor = 255;
#endif

/*
* SOFTWARE SWITCHES FOR DFPLAYER CHISET
*************************************/


#ifdef ADF_PIXIE_BLADE
#define OLD_DPFPLAYER_LIB
#include "Adafruit_Pixie.h"
#include <SoftwareSerial.h>
#endif
/**********END of blade type hardware settings **************************/

/*
Expand Down Expand Up @@ -108,9 +115,23 @@
*************************************/
#define DEEP_SLEEP
#if defined DEEP_SLEEP
#define SLEEP_TIMER 20000 //20 secs, after which the board will automatically go to sleep mode (to be implemented)
#define SLEEPYTIME 60000 //20 secs, after which the board will automatically go to sleep mode (to be implemented)
#include <avr/sleep.h>
#include <avr/power.h>
#endif // DEEP_SLEEP


/* COLOR CHANGE OPTIONS
* If you want to use the advanced Gravity Color method developed for FX-SaberOS
* leave the GRAVITY_COLOR compile directive defined.
* If instead you would like to work with pre-set color profiles (15 different, pre-defined colors)
* comment out the line with GRAVITY_COLOR, which will define COLOR_PROFILE to be used.
*************************************/
#define GRAVITY_COLOR
#ifndef GRAVITY_COLOR
#define COLOR_PROFILE
#endif

/*
* Enable Jukebox, an integrated MP3/WAV player which can play songs/music files
* stored in the jukebox folder on your storage media (SD-card or SPI flash).
Expand Down
Loading

0 comments on commit c947d73

Please sign in to comment.