shiftPWM compiling error problem(teensy 3.2)

Status
Not open for further replies.

dakdeu

New member
I do not know why that error occurred.
What's the problem?
Below is the error message.





Code:
Arduino:1.6.7 (Mac OS X), TD: 1.28, Board:"Teensy 3.2 / 3.1, Serial, 96 MHz optimized (overclock), US English"


In file included from /var/folders/jv/lpvjh58j1xn8g8fcv9fvz5dr0000gn/T/arduino_3af926170f20c7c65a136cb2f2d69967/ShiftPWM_RGB_Example.ino:35:0:
/Users/Jymno/Downloads/Arduino 3.app/Contents/Java/hardware/teensy/avr/libraries/ShiftPWM/ShiftPWM.h: In function 'void ShiftPWM_handleInterrupt()':
/Users/Jymno/Downloads/Arduino 3.app/Contents/Java/hardware/teensy/avr/libraries/ShiftPWM/ShiftPWM.h:125:27: warning: unused variable 'latchPort' [-Wunused-variable]
  volatile uint8_t * const latchPort = port_to_output_PGM_ct[digital_pin_to_port_PGM_ct[ShiftPWM_latchPin]];
                           ^
/var/folders/jv/lpvjh58j1xn8g8fcv9fvz5dr0000gn/T/build3af926170f20c7c65a136cb2f2d69967.tmp/sketch/ShiftPWM_RGB_Example.ino.cpp.o: In function `setup':
/var/folders/jv/lpvjh58j1xn8g8fcv9fvz5dr0000gn/T/arduino_3af926170f20c7c65a136cb2f2d69967/ShiftPWM_RGB_Example.ino:51: undefined reference to `CShiftPWM::SetAmountOfRegisters(unsigned char)'
/var/folders/jv/lpvjh58j1xn8g8fcv9fvz5dr0000gn/T/arduino_3af926170f20c7c65a136cb2f2d69967/ShiftPWM_RGB_Example.ino:55: undefined reference to `CShiftPWM::SetPinGrouping(int)'
/var/folders/jv/lpvjh58j1xn8g8fcv9fvz5dr0000gn/T/arduino_3af926170f20c7c65a136cb2f2d69967/ShiftPWM_RGB_Example.ino:57: undefined reference to `CShiftPWM::Start(int, unsigned char)'
/var/folders/jv/lpvjh58j1xn8g8fcv9fvz5dr0000gn/T/build3af926170f20c7c65a136cb2f2d69967.tmp/sketch/ShiftPWM_RGB_Example.ino.cpp.o: In function `rgbLedRainbow(int, int, int, int)':
/var/folders/jv/lpvjh58j1xn8g8fcv9fvz5dr0000gn/T/arduino_3af926170f20c7c65a136cb2f2d69967/ShiftPWM_RGB_Example.ino:175: undefined reference to `CShiftPWM::SetAll(unsigned char)'
/var/folders/jv/lpvjh58j1xn8g8fcv9fvz5dr0000gn/T/arduino_3af926170f20c7c65a136cb2f2d69967/ShiftPWM_RGB_Example.ino:180: undefined reference to `CShiftPWM::SetHSV(int, unsigned int, unsigned int, unsigned int, int)'
/var/folders/jv/lpvjh58j1xn8g8fcv9fvz5dr0000gn/T/build3af926170f20c7c65a136cb2f2d69967.tmp/sketch/ShiftPWM_RGB_Example.ino.cpp.o: In function `loop':
/var/folders/jv/lpvjh58j1xn8g8fcv9fvz5dr0000gn/T/arduino_3af926170f20c7c65a136cb2f2d69967/ShiftPWM_RGB_Example.ino:65: undefined reference to `CShiftPWM::SetAll(unsigned char)'
/var/folders/jv/lpvjh58j1xn8g8fcv9fvz5dr0000gn/T/arduino_3af926170f20c7c65a136cb2f2d69967/ShiftPWM_RGB_Example.ino:68: undefined reference to `CShiftPWM::PrintInterruptLoad()'
/var/folders/jv/lpvjh58j1xn8g8fcv9fvz5dr0000gn/T/arduino_3af926170f20c7c65a136cb2f2d69967/ShiftPWM_RGB_Example.ino:71: undefined reference to `CShiftPWM::OneByOneFast()'
/var/folders/jv/lpvjh58j1xn8g8fcv9fvz5dr0000gn/T/arduino_3af926170f20c7c65a136cb2f2d69967/ShiftPWM_RGB_Example.ino:75: undefined reference to `CShiftPWM::SetAll(unsigned char)'
/var/folders/jv/lpvjh58j1xn8g8fcv9fvz5dr0000gn/T/arduino_3af926170f20c7c65a136cb2f2d69967/ShiftPWM_RGB_Example.ino:80: undefined reference to `CShiftPWM::SetAll(unsigned char)'
/var/folders/jv/lpvjh58j1xn8g8fcv9fvz5dr0000gn/T/arduino_3af926170f20c7c65a136cb2f2d69967/ShiftPWM_RGB_Example.ino:87: undefined reference to `CShiftPWM::SetAll(unsigned char)'
/var/folders/jv/lpvjh58j1xn8g8fcv9fvz5dr0000gn/T/arduino_3af926170f20c7c65a136cb2f2d69967/ShiftPWM_RGB_Example.ino:89: undefined reference to `CShiftPWM::SetOne(int, unsigned char)'
/var/folders/jv/lpvjh58j1xn8g8fcv9fvz5dr0000gn/T/arduino_3af926170f20c7c65a136cb2f2d69967/ShiftPWM_RGB_Example.ino:90: undefined reference to `CShiftPWM::SetOne(int, unsigned char)'
/var/folders/jv/lpvjh58j1xn8g8fcv9fvz5dr0000gn/T/arduino_3af926170f20c7c65a136cb2f2d69967/ShiftPWM_RGB_Example.ino:97: undefined reference to `CShiftPWM::SetAllHSV(unsigned int, unsigned int, unsigned int)'
/var/folders/jv/lpvjh58j1xn8g8fcv9fvz5dr0000gn/T/arduino_3af926170f20c7c65a136cb2f2d69967/ShiftPWM_RGB_Example.ino:106: undefined reference to `CShiftPWM::SetRGB(int, unsigned char, unsigned char, unsigned char, int)'
/var/folders/jv/lpvjh58j1xn8g8fcv9fvz5dr0000gn/T/arduino_3af926170f20c7c65a136cb2f2d69967/ShiftPWM_RGB_Example.ino:109: undefined reference to `CShiftPWM::SetRGB(int, unsigned char, unsigned char, unsigned char, int)'
/var/folders/jv/lpvjh58j1xn8g8fcv9fvz5dr0000gn/T/arduino_3af926170f20c7c65a136cb2f2d69967/ShiftPWM_RGB_Example.ino:112: undefined reference to `CShiftPWM::SetRGB(int, unsigned char, unsigned char, unsigned char, int)'
/var/folders/jv/lpvjh58j1xn8g8fcv9fvz5dr0000gn/T/arduino_3af926170f20c7c65a136cb2f2d69967/ShiftPWM_RGB_Example.ino:115: undefined reference to `CShiftPWM::SetRGB(int, unsigned char, unsigned char, unsigned char, int)'
/var/folders/jv/lpvjh58j1xn8g8fcv9fvz5dr0000gn/T/arduino_3af926170f20c7c65a136cb2f2d69967/ShiftPWM_RGB_Example.ino:118: undefined reference to `CShiftPWM::SetRGB(int, unsigned char, unsigned char, unsigned char, int)'
/var/folders/jv/lpvjh58j1xn8g8fcv9fvz5dr0000gn/T/build3af926170f20c7c65a136cb2f2d69967.tmp/sketch/ShiftPWM_RGB_Example.ino.cpp.o:/var/folders/jv/lpvjh58j1xn8g8fcv9fvz5dr0000gn/T/arduino_3af926170f20c7c65a136cb2f2d69967/ShiftPWM_RGB_Example.ino:121: more undefined references to `CShiftPWM::SetRGB(int, unsigned char, unsigned char, unsigned char, int)' follow
/var/folders/jv/lpvjh58j1xn8g8fcv9fvz5dr0000gn/T/build3af926170f20c7c65a136cb2f2d69967.tmp/sketch/ShiftPWM_RGB_Example.ino.cpp.o: In function `loop':
/var/folders/jv/lpvjh58j1xn8g8fcv9fvz5dr0000gn/T/arduino_3af926170f20c7c65a136cb2f2d69967/ShiftPWM_RGB_Example.ino:130: undefined reference to `CShiftPWM::SetHSV(int, unsigned int, unsigned int, unsigned int, int)'
/var/folders/jv/lpvjh58j1xn8g8fcv9fvz5dr0000gn/T/arduino_3af926170f20c7c65a136cb2f2d69967/ShiftPWM_RGB_Example.ino:156: undefined reference to `CShiftPWM::SetHSV(int, unsigned int, unsigned int, unsigned int, int)'
/var/folders/jv/lpvjh58j1xn8g8fcv9fvz5dr0000gn/T/arduino_3af926170f20c7c65a136cb2f2d69967/ShiftPWM_RGB_Example.ino:159: undefined reference to `CShiftPWM::SetRGB(int, unsigned char, unsigned char, unsigned char, int)'
/var/folders/jv/lpvjh58j1xn8g8fcv9fvz5dr0000gn/T/build3af926170f20c7c65a136cb2f2d69967.tmp/sketch/ShiftPWM_RGB_Example.ino.cpp.o: In function `__static_initialization_and_destruction_0':
/Users/Jymno/Downloads/Arduino 3.app/Contents/Java/hardware/teensy/avr/libraries/ShiftPWM/ShiftPWM.h:68: undefined reference to `CShiftPWM::CShiftPWM(int, bool, int, int, int)'
/var/folders/jv/lpvjh58j1xn8g8fcv9fvz5dr0000gn/T/build3af926170f20c7c65a136cb2f2d69967.tmp/sketch/ShiftPWM_RGB_Example.ino.cpp.o: In function `_GLOBAL__sub_I_ShiftPWM':
/var/folders/jv/lpvjh58j1xn8g8fcv9fvz5dr0000gn/T/arduino_3af926170f20c7c65a136cb2f2d69967/ShiftPWM_RGB_Example.ino:185: undefined reference to `CShiftPWM::~CShiftPWM()'
collect2: error: ld returned 1 exit status
Error compiling for "Teensy 3.2 / 3.1"
 
Hi and welcome,

As mentioned at the top of the forum, please include the sources, to reproduce.

I am assuming from the error messages, that you are using the ShiftPWM_RGB_Example program that is in the examples for the library.
I tried loading it, found that it would not compile without: #define SHIFTPWM_NOSPI
So I uncommented that line, plus the two lines below and it appeared to compile
 
Code:
/************************************************************************************************************************************
 * ShiftPWM blocking RGB fades example, (c) Elco Jacobs, updated August 2012.
 *
 * ShiftPWM blocking RGB fades example. This example uses simple delay loops to create fades.
 * If you want to change the fading mode based on inputs (sensors, buttons, serial), use the non-blocking example as a starting point.
 * Please go to www.elcojacobs.com/shiftpwm for documentation, fuction reference and schematics.
 * If you want to use ShiftPWM with LED strips or high power LED's, visit the shop for boards.
 ************************************************************************************************************************************/
 
// ShiftPWM uses timer1 by default. To use a different timer, before '#include <ShiftPWM.h>', add
// #define SHIFTPWM_USE_TIMER2  // for Arduino Uno and earlier (Atmega328)
// #define SHIFTPWM_USE_TIMER3  // for Arduino Micro/Leonardo (Atmega32u4)

// Clock and data pins are pins from the hardware SPI, you cannot choose them yourself if you use the hardware SPI.
// Data pin is MOSI (Uno and earlier: 11, Leonardo: ICSP 4, Mega: 51, Teensy 2.0: 2, Teensy 2.0++: 22) 
// Clock pin is SCK (Uno and earlier: 13, Leonardo: ICSP 3, Mega: 52, Teensy 2.0: 1, Teensy 2.0++: 21)

// You can choose the latch pin yourself.
const int ShiftPWM_latchPin=8;

// ** uncomment this part to NOT use the SPI port and change the pin numbers. This is 2.5x slower **
 #define SHIFTPWM_NOSPI
 const int ShiftPWM_dataPin = 11;
 const int ShiftPWM_clockPin = 13;


// If your LED's turn on if the pin is low, set this to true, otherwise set it to false.
const bool ShiftPWM_invertOutputs = false; 

// You can enable the option below to shift the PWM phase of each shift register by 8 compared to the previous.
// This will slightly increase the interrupt load, but will prevent all PWM signals from becoming high at the same time.
// This will be a bit easier on your power supply, because the current peaks are distributed.
const bool ShiftPWM_balanceLoad = false;

#include </Users/Jymno/Downloads/Arduino 3.app/Contents/Java/hardware/teensy/avr/libraries/ShiftPWM/ShiftPWM.h>   // include ShiftPWM.h after setting the pins!

// Here you set the number of brightness levels, the update frequency and the number of shift registers.
// These values affect the load of ShiftPWM.
// Choose them wisely and use the PrintInterruptLoad() function to verify your load.
// There is a calculator on my website to estimate the load.

unsigned char maxBrightness = 255;
unsigned char pwmFrequency = 75;
int numRegisters = 6;
int numRGBleds = numRegisters*8/3;

void setup(){
  Serial.begin(9600);

  // Sets the number of 8-bit registers that are used.
  ShiftPWM.SetAmountOfRegisters(numRegisters);

  // SetPinGrouping allows flexibility in LED setup. 
  // If your LED's are connected like this: RRRRGGGGBBBBRRRRGGGGBBBB, use SetPinGrouping(4).
  ShiftPWM.SetPinGrouping(1); //This is the default, but I added here to demonstrate how to use the funtion
  
  ShiftPWM.Start(pwmFrequency,maxBrightness);
}



void loop()
{    
  // Turn all LED's off.
  ShiftPWM.SetAll(0);

  // Print information about the interrupt frequency, duration and load on your program
  ShiftPWM.PrintInterruptLoad();

  // Fade in and fade out all outputs one by one fast. Usefull for testing your hardware. Use OneByOneSlow when this is going to fast.
  ShiftPWM.OneByOneFast();

  // Fade in all outputs
  for(int j=0;j<maxBrightness;j++){
    ShiftPWM.SetAll(j);  
    delay(20);
  }
  // Fade out all outputs
  for(int j=maxBrightness;j>=0;j--){
    ShiftPWM.SetAll(j);  
    delay(20);
  }


  // Fade in and out 2 outputs at a time
  for(int output=0;output<numRegisters*8-1;output++){
    ShiftPWM.SetAll(0);
    for(int brightness=0;brightness<maxBrightness;brightness++){
      ShiftPWM.SetOne(output+1,brightness);
      ShiftPWM.SetOne(output,maxBrightness-brightness);
      delay(1);
    }
  }

  // Hue shift all LED's
  for(int hue = 0; hue<360; hue++){
    ShiftPWM.SetAllHSV(hue, 255, 255); 
    delay(50);
  }

  // Alternate LED's in 6 different colors
  for(int shift=0;shift<6;shift++){
    for(int led=0; led<numRGBleds; led++){
      switch((led+shift)%6){
      case 0:
        ShiftPWM.SetRGB(led,255,0,0);    // red
        break;
      case 1:
        ShiftPWM.SetRGB(led,0,255,0);    // green
        break;
      case 2:
        ShiftPWM.SetRGB(led,0,0,255);    // blue
        break;
      case 3:
        ShiftPWM.SetRGB(led,255,128,0);  // orange
        break;
      case 4:
        ShiftPWM.SetRGB(led,0,255,255);  // turqoise
        break;
      case 5:
        ShiftPWM.SetRGB(led,255,0,255);  // purple
        break;
      }
    }
    delay(2000);
  }

  // Update random LED to random color. Funky!
  for(int i=0;i<1000;i++){
    ShiftPWM.SetHSV(random(numRGBleds),random(360),255,255);
    delay(15);
  }


  // Immitate a VU meter
  int peak=0;
  int prevPeak=0;

  int currentLevel = 0;
  for(int i=0;i<40;i++){
    prevPeak = peak;
    while(abs(peak-prevPeak)<5){
      peak =  random(numRGBleds); // pick a new peak value that differs at least 5 from previous peak
    }
    // animate to new top
    while(currentLevel!=peak){
      if(currentLevel<peak){
        currentLevel++;
      }
      else{
        currentLevel--;
      }
      for(int led=0;led<numRGBleds;led++){
        if(led<=currentLevel){
          int hue = (numRGBleds-1-led)*120/numRGBleds; // From green to red
          ShiftPWM.SetHSV(led,hue,255,255); 
        }
        else{
          ShiftPWM.SetRGB(led,0,0,0);
        }
      }
      delay((64/numRGBleds)*(numRGBleds-currentLevel)); // go slower near the top
    }
  }

  //  A moving rainbow for RGB leds:
  rgbLedRainbow(numRGBleds, 5, 3, numRegisters*8/3); // Fast, over all LED's
  rgbLedRainbow(numRGBleds, 10, 3, numRegisters*8/3*4); //slower, wider than the number of LED's
}

void rgbLedRainbow(int numRGBLeds, int delayVal, int numCycles, int rainbowWidth){
  // Displays a rainbow spread over a few LED's (numRGBLeds), which shifts in hue. 
  // The rainbow can be wider then the real number of LED's.

  ShiftPWM.SetAll(0);
  for(int cycle=0;cycle<numCycles;cycle++){ // loop through the hue shift a number of times (numCycles)
    for(int colorshift=0;colorshift<360;colorshift++){ // Shift over full color range (like the hue slider in photoshop)
      for(int led=0;led<numRGBLeds;led++){ // loop over all LED's
        int hue = ((led)*360/(rainbowWidth-1)+colorshift)%360; // Set hue from 0 to 360 from first to last led and shift the hue
        ShiftPWM.SetHSV(led, hue, 255, 255); // write the HSV values, with saturation and value at maximum
      }
      delay(delayVal); // this delay value determines the speed of hue shift
    } 
  }  
}

Thank you for answer.
I used to compile and uncomment the two parts.
#define SHIFTPWM_NOSPI
const int ShiftPWM_dataPin = 11;
const int ShiftPWM_clockPin = 13;
 
Change this line

Code:
#include </Users/Jymno/Downloads/Arduino 3.app/Contents/Java/hardware/teensy/avr/libraries/ShiftPWM/ShiftPWM.h>   // include ShiftPWM.h after setting the pins!

to this:

Code:
#include <ShiftPWM.h>   // include ShiftPWM.h after setting the pins!

I verified it compiles correctly. Here's screenshot:

sc.png
 
Status
Not open for further replies.
Back
Top