Skip to content

Commit

Permalink
Adding build control (USaberConfig)
Browse files Browse the repository at this point in the history
  • Loading branch information
JakeS0ft committed Jun 25, 2016
1 parent 7593134 commit 0f5f506
Show file tree
Hide file tree
Showing 6 changed files with 101 additions and 1 deletion.
5 changes: 5 additions & 0 deletions DFPlayerSoundPlayer.cpp
Expand Up @@ -21,6 +21,9 @@
* Author: JakeSoft <http://forum.arduino.cc/index.php?topic=261980.0>
*/

#include <USaberConfig.h>

#ifdef BUILD_DFPLAYERSOUNDPLAYER
#include <Arduino.h>
#include "sound/DFPlayerSoundPlayer.h"
#include "SoftwareSerial.h"
Expand Down Expand Up @@ -346,3 +349,5 @@ void DFPlayerSoundPlayer::SetFont(unsigned char aFontIdx)
{
mFontIdx = aFontIdx;
}

#endif //BUILD_DFPLAYERSOUNDPLAYER
6 changes: 6 additions & 0 deletions I2Cdev.cpp
Expand Up @@ -43,6 +43,10 @@ THE SOFTWARE.
===============================================
*/

#include "USaberConfig.h"

#ifdef BUILD_I2CDEV

#include "support/I2Cdev/I2Cdev.h"

#if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE
Expand Down Expand Up @@ -1434,3 +1438,5 @@ uint16_t I2Cdev::readTimeout = I2CDEV_DEFAULT_READ_TIMEOUT;
}

#endif

#endif //BUILD_I2CDEV
3 changes: 3 additions & 0 deletions MPU6050.cpp
Expand Up @@ -35,7 +35,9 @@ THE SOFTWARE.
*/

#include "support/MPU6050/MPU6050.h"
#include "USaberConfig.h"

#ifdef BUILD_MPU6050
/** Default constructor, uses default I2C address.
* @see MPU6050_DEFAULT_ADDRESS
*/
Expand Down Expand Up @@ -3211,3 +3213,4 @@ uint8_t MPU6050::getDMPConfig2() {
void MPU6050::setDMPConfig2(uint8_t config) {
I2Cdev::writeByte(devAddr, MPU6050_RA_DMP_CFG_2, config);
}
#endif //BUILD_MPU6050
7 changes: 6 additions & 1 deletion Mpu6050MotionManager.cpp
Expand Up @@ -21,11 +21,16 @@
* Author: Neskweek
*/

#include "USaberConfig.h"

#ifdef BUILD_MPU6050

#include "motion/Mpu6050MotionManager.h"
#include <Arduino.h>
#include "support/MPU6050/MPU6050_6Axis_MotionApps20.h"
#if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE
#include <Wire.h>

#endif

/*
Expand Down Expand Up @@ -302,4 +307,4 @@ void Mpu6050MotionManager::Update() {
// - quaternion_last->z * multiplier;
}
}

#endif //BUILD_MPU6050
5 changes: 5 additions & 0 deletions SoftwareSerial.cpp
Expand Up @@ -29,6 +29,9 @@ The latest version of this library can always be found at
http://arduiniana.org.
*/

#include "USaberConfig.h"

#ifdef BUILD_SOFTWARE_SERIAL
// When set, _DEBUG co-opts pins 11 and 13 for debugging with an
// oscilloscope or logic analyzer. Beware: it also slightly modifies
// the bit times, so don't rely on it too much at high baud rates
Expand Down Expand Up @@ -513,3 +516,5 @@ int SoftwareSerial::peek()
// Read from "head"
return _receive_buffer[_receive_buffer_head];
}

#endif //BUILD_SOFTWARE_SERIAL
76 changes: 76 additions & 0 deletions USaberConfig.h
@@ -0,0 +1,76 @@
/*
This file is part of the Universal Saber library.
The Universal Saber library is free software: you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of the License,
or (at your option) any later version.
The Universal Saber library is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with the Universal Saber library. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* USaberConfig.h
*
* This file is to be included in certain "heavy weight" features of the
* Universal Saber library so that they can be optionally excluded from the
* build. The code in certain files is #ifdef wrapped such that they contain
* no code or only "Light Weight" code unless their corresponding BUILD_XXX
* #define exists.
*
* To remove a feature by preventing it from building, simply comment out the
* corresponding #define for the feature.
*
* The reason this is necessary is that some of the libraries introduce
* declarations that allocate static or global memory or inflate the compiled
* hex file size regardless of if the feature is actually used. Not only is
* this is an unnecessary waste of resources, it may also introduce
* incompatibility with certain MCUs such as the ATTiny chips which don't
* support I2C or Wire.
*
* Note that features that do not perform these kinds of "Heavy" actions are
* always included as they cost little or nothing in the way of RAM or
* compiled hex file size unless they are actually used.
*
* For now, all features are enabled by default.
*
* Created on: Jun 24, 2016
* Author: JakeSoft
*/

#ifndef _USABER_USABERCONFIG_H_
#define _USABER_USABERCONFIG_H_

//Comment out the line for which you'd like to exclude the corresponding feature

/**
* Build the MPU6050MotionManager.
* Note: This requires that I2CDEV also be enabled below.
*/
//#define BUILD_MPU6050

/**
* Build USaber's built-in I2CDev library.
* Note: This requires that Wire also be included in the sketch.
*/
//#define BUILD_I2CDEV

/**
* Build USaber's built-in Software Serial library.
* Note: This must be included for the DFPlayerSouundPlayer to build.
* Note: Some other features may not work if this is excluded from the build.
*/
//#define BUILD_SOFTWARE_SERIAL

/**
* Build the DFPlayerSoundPlayer.
* Note: Software serial must also be enabled for this to work.
*/
//#define BUILD_DFPLAYERSOUNDPLAYER

#endif /* LIBRARIES_USABER_USABERCONFIG_H_ */

0 comments on commit 0f5f506

Please sign in to comment.