Skip to content

Commit

Permalink
Makefile Compilation Fix (#490)
Browse files Browse the repository at this point in the history
* renamed boolean to bool

* Rename byte to uint8_t

* Fix compilation error: 'NULL' was not declared in this scope

* Always typedef RoReg and RwReg for the AVR platform

* Include stdlib.h if abs() is not available
This is required as Arduino.h #define's its own abs() makro. Outside of Arduino environments stdlib is required.
Also see: https://github.com/arduino/Arduino/issues/6684

* Replace digitalWrite() with Pin Class by FastLed

* Include string.h for memset function
This include is normally done by Arduino.h but still required for makefile environments
$ grep string.h . -r
./Arduino.h:#include <string.h>

* Include math.h for pow()
math.h is normally included by Arduino.h but required for a makefile build
$ grep math.h . -r
./Arduino.h:#include <math.h>
  • Loading branch information
NicoHood authored and focalintent committed Nov 2, 2017
1 parent e3125f1 commit 64d729e
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 10 deletions.
2 changes: 1 addition & 1 deletion FastLED.cpp
Expand Up @@ -105,7 +105,7 @@ void CFastLED::showColor(const struct CRGB & color, uint8_t scale) {
countFPS(); countFPS();
} }


void CFastLED::clear(boolean writeData) { void CFastLED::clear(bool writeData) {
if(writeData) { if(writeData) {
showColor(CRGB(0,0,0), 0); showColor(CRGB(0,0,0), 0);
} }
Expand Down
2 changes: 1 addition & 1 deletion FastLED.h
Expand Up @@ -489,7 +489,7 @@ class CFastLED {


/// clear the leds, wiping the local array of data, optionally black out the leds as well /// clear the leds, wiping the local array of data, optionally black out the leds as well
/// @param writeData whether or not to write out to the leds as well /// @param writeData whether or not to write out to the leds as well
void clear(boolean writeData = false); void clear(bool writeData = false);


/// clear out the local data array /// clear out the local data array
void clearData(); void clearData();
Expand Down
1 change: 1 addition & 0 deletions colorutils.cpp
Expand Up @@ -2,6 +2,7 @@
#define __PROG_TYPES_COMPAT__ #define __PROG_TYPES_COMPAT__


#include <stdint.h> #include <stdint.h>
#include <math.h>


#include "FastLED.h" #include "FastLED.h"


Expand Down
9 changes: 5 additions & 4 deletions controller.h
Expand Up @@ -8,6 +8,7 @@
#include "led_sysdefs.h" #include "led_sysdefs.h"
#include "pixeltypes.h" #include "pixeltypes.h"
#include "color.h" #include "color.h"
#include <stddef.h>


FASTLED_NAMESPACE_BEGIN FASTLED_NAMESPACE_BEGIN


Expand Down Expand Up @@ -254,18 +255,18 @@ struct PixelController {
#define VIRTUAL_BITS RECOMMENDED_VIRTUAL_BITS #define VIRTUAL_BITS RECOMMENDED_VIRTUAL_BITS


// R is the digther signal 'counter'. // R is the digther signal 'counter'.
static byte R = 0; static uint8_t R = 0;
R++; R++;


// R is wrapped around at 2^ditherBits, // R is wrapped around at 2^ditherBits,
// so if ditherBits is 2, R will cycle through (0,1,2,3) // so if ditherBits is 2, R will cycle through (0,1,2,3)
byte ditherBits = VIRTUAL_BITS; uint8_t ditherBits = VIRTUAL_BITS;
R &= (0x01 << ditherBits) - 1; R &= (0x01 << ditherBits) - 1;


// Q is the "unscaled dither signal" itself. // Q is the "unscaled dither signal" itself.
// It's initialized to the reversed bits of R. // It's initialized to the reversed bits of R.
// If 'ditherBits' is 2, Q here will cycle through (0,128,64,192) // If 'ditherBits' is 2, Q here will cycle through (0,128,64,192)
byte Q = 0; uint8_t Q = 0;


// Reverse bits in a byte // Reverse bits in a byte
{ {
Expand Down Expand Up @@ -293,7 +294,7 @@ struct PixelController {


// Setup the initial D and E values // Setup the initial D and E values
for(int i = 0; i < 3; i++) { for(int i = 0; i < 3; i++) {
byte s = mScale.raw[i]; uint8_t s = mScale.raw[i];
e[i] = s ? (256/s) + 1 : 0; e[i] = s ? (256/s) + 1 : 0;
d[i] = scale8(Q, e[i]); d[i] = scale8(Q, e[i]);
#if (FASTLED_SCALE8_FIXED == 1) #if (FASTLED_SCALE8_FIXED == 1)
Expand Down
1 change: 1 addition & 0 deletions fastpin.h
Expand Up @@ -4,6 +4,7 @@
#include "FastLED.h" #include "FastLED.h"


#include "led_sysdefs.h" #include "led_sysdefs.h"
#include <stddef.h>


#pragma GCC diagnostic push #pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wignored-qualifiers" #pragma GCC diagnostic ignored "-Wignored-qualifiers"
Expand Down
1 change: 1 addition & 0 deletions noise.cpp
@@ -1,5 +1,6 @@
#define FASTLED_INTERNAL #define FASTLED_INTERNAL
#include "FastLED.h" #include "FastLED.h"
#include <string.h>


FASTLED_NAMESPACE_BEGIN FASTLED_NAMESPACE_BEGIN


Expand Down
4 changes: 4 additions & 0 deletions pixelset.h
Expand Up @@ -3,6 +3,10 @@


#include "FastLED.h" #include "FastLED.h"


#ifndef abs
#include "stdlib.h"
#endif

/// Represents a set of CRGB led objects. Provides the [] array operator, and works like a normal array in that case. /// Represents a set of CRGB led objects. Provides the [] array operator, and works like a normal array in that case.
/// This should be kept in sync with the set of functions provided by CRGB as well as functions in colorutils. Note /// This should be kept in sync with the set of functions provided by CRGB as well as functions in colorutils. Note
/// that a pixel set is a window into another set of led data, it is not its own set of led data. /// that a pixel set is a window into another set of led data, it is not its own set of led data.
Expand Down
2 changes: 0 additions & 2 deletions platforms/avr/led_sysdefs_avr.h
Expand Up @@ -13,10 +13,8 @@
#include <avr/interrupt.h> // for cli/se definitions #include <avr/interrupt.h> // for cli/se definitions


// Define the register types // Define the register types
#if defined(ARDUINO) // && ARDUINO < 150
typedef volatile uint8_t RoReg; /**< Read only 8-bit register (volatile const unsigned int) */ typedef volatile uint8_t RoReg; /**< Read only 8-bit register (volatile const unsigned int) */
typedef volatile uint8_t RwReg; /**< Read-Write 8-bit register (volatile unsigned int) */ typedef volatile uint8_t RwReg; /**< Read-Write 8-bit register (volatile unsigned int) */
#endif




// Default to disallowing interrupts (may want to gate this on teensy2 vs. other arm platforms, since the // Default to disallowing interrupts (may want to gate this on teensy2 vs. other arm platforms, since the
Expand Down
4 changes: 2 additions & 2 deletions power_mgt.cpp
Expand Up @@ -125,7 +125,7 @@ uint8_t calculate_max_brightness_for_power_mW( uint8_t target_brightness, uint32
if( requested_power_mW < max_power_mW) { if( requested_power_mW < max_power_mW) {
#if POWER_LED > 0 #if POWER_LED > 0
if( gMaxPowerIndicatorLEDPinNumber ) { if( gMaxPowerIndicatorLEDPinNumber ) {
digitalWrite(gMaxPowerIndicatorLEDPinNumber, LOW); // turn the LED off Pin(gMaxPowerIndicatorLEDPinNumber).lo(); // turn the LED off
} }
#endif #endif
#if POWER_DEBUG_PRINT == 1 #if POWER_DEBUG_PRINT == 1
Expand All @@ -148,7 +148,7 @@ uint8_t calculate_max_brightness_for_power_mW( uint8_t target_brightness, uint32


#if POWER_LED > 0 #if POWER_LED > 0
if( gMaxPowerIndicatorLEDPinNumber ) { if( gMaxPowerIndicatorLEDPinNumber ) {
digitalWrite( gMaxPowerIndicatorLEDPinNumber, HIGH); // turn the LED on Pin(gMaxPowerIndicatorLEDPinNumber).hi(); // turn the LED on
} }
#endif #endif


Expand Down

0 comments on commit 64d729e

Please sign in to comment.