Fast Led code merging error

trying to merge the crossfade button example code and add in a pallet rgb, no errors until trying to merge the pallet into the base code

//      Bailey Williams    //
  //      NCEA Level 1       //
//                            //
 //        |      |            //
  //          >             //
//        )----------)       //
  //                          //





#include <FastLED.h>
#include <OneButton.h>

#define NUM_LEDS  76
#define LED_PIN   4
#define BTN_PIN   3       

CRGB source1[NUM_LEDS];
CRGB source2[NUM_LEDS];
CRGB output[NUM_LEDS];

uint8_t blendAmount = 0;
uint8_t patternCounter = 0;
uint8_t source1Pattern = 0;
uint8_t source2Pattern = 1;
bool useSource1 = false;

// Push button connected between pin 7 and GND (no resistor required)
OneButton btn = OneButton(BTN_PIN, true, true);

// Gradient palette "rainbow_gp", originally from
// http://soliton.vm.bytemark.co.uk/pub/cpt-city/rc/tn/rainbow.png.index.html
// converted for FastLED with gammas (2.6, 2.2, 2.5)
// Size: 48 bytes of program space.

DEFINE_GRADIENT_PALETTE( rainbow_gp ) {
    0, 126,  1,142,
   25, 171,  1, 26,
   48, 224,  9,  1,
   71, 237,138,  1,
   94,  52,173,  1,
  117,   1,201,  1,
  140,   1,211, 54,
  163,   1,124,168,
  186,   1,  8,149,
  209,  12,  1,151,
  232,  12,  1,151,
  255, 171,  1,190};
CRGBPalette16 myPal = rainbow_gp;

void setup() {
  FastLED.addLeds<WS2812B, LED_PIN, GRB>(output, NUM_LEDS);
  FastLED.setBrightness(50);
  Serial.begin(57600);

  btn.attachClick(nextPattern);
}

void loop() {

  EVERY_N_MILLISECONDS(10) {
    blend(source1, source2, output, NUM_LEDS, blendAmount);   // Blend between the two sources

    if (useSource1) {
      if (blendAmount < 255) blendAmount++;                   // blendAmount 'up' to source 2
    } else {
      if (blendAmount > 0) blendAmount--;                     // blendAmount 'down' to source 1
    }
  }

  runPattern(source1Pattern, source1);                  // Run both patterns simultaneously
  runPattern(source2Pattern, source2);
  
  FastLED.show();

  btn.tick();
}

void nextPattern() {
  patternCounter = (patternCounter + 1) % 3;           // Change the number after the % to the number of patterns you have

  if (useSource1) source1Pattern = patternCounter;     // Determine which source array for new pattern
  else source2Pattern = patternCounter;

  useSource1 = !useSource1;                            // Swap source array for next time around
}

void runPattern(uint8_t pattern, CRGB *LEDArray) {
  switch (pattern) {
    case 0:
      palletrgb(LEDArray);
      break;
    case 1:
      Beat(LEDArray);
      break;
    case 2:
      White(LEDArray);
      break;
  }
}

//------- Put your patterns below -------//

void palletrgb(CRGB *LEDarray) 
  fill_palette(leds, NUM_LEDS, paletteIndex, 255 / NUM_LEDS, myPal, 255, LINEARBLEND);
  
  EVERY_N_MILLISECONDS(10){
    paletteIndex++;
}

void Beat(CRGB *LEDarray) {
  
  uint16_t beatA = beatsin16(30, 0, 255);
  uint16_t beatB = beatsin16(20, 0, 255);
  fill_rainbow(LEDarray, NUM_LEDS, (beatA+beatB)/2, 8);
}


void White(CRGB *LEDarray) {

fill_solid(LEDarray, NUM_LEDS, CRGB::White);
  

  FastLED.setCorrection(TypicalLEDStrip);
  //leds[0] = CRGB::Green;
}

errors

Arduino: 1.8.15 (Mac OS X), Board: "Arduino Nano, ATmega328P (Old Bootloader)"











In file included from /Users/baileywilliams/Downloads/FastLED-basics-main/5. Multiple patterns/crossfadeButton/crossfadeButton.ino:13:0:
/Users/baileywilliams/Documents/Arduino/libraries/FastLED/src/FastLED.h:14:21: note: #pragma message: FastLED version 3.004.000
 #    pragma message "FastLED version 3.004.000"
                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/baileywilliams/Downloads/FastLED-basics-main/5. Multiple patterns/crossfadeButton/crossfadeButton.ino: In function 'void runPattern(uint8_t, CRGB*)':
crossfadeButton:93:7: error: 'palletrgb' was not declared in this scope
       palletrgb(LEDArray);
       ^~~~~~~~~
/Users/baileywilliams/Downloads/FastLED-basics-main/5. Multiple patterns/crossfadeButton/crossfadeButton.ino: At global scope:
crossfadeButton:107:3: error: expected initializer before 'fill_palette'
   fill_palette(leds, NUM_LEDS, paletteIndex, 255 / NUM_LEDS, myPal, 255, LINEARBLEND);
   ^~~~~~~~~~~~
In file included from /Users/baileywilliams/Documents/Arduino/libraries/FastLED/src/pixeltypes.h:7:0,
                 from /Users/baileywilliams/Documents/Arduino/libraries/FastLED/src/controller.h:9,
                 from /Users/baileywilliams/Documents/Arduino/libraries/FastLED/src/FastLED.h:47,
                 from /Users/baileywilliams/Downloads/FastLED-basics-main/5. Multiple patterns/crossfadeButton/crossfadeButton.ino:13:
/Users/baileywilliams/Documents/Arduino/libraries/FastLED/src/lib8tion.h:1156:64: error: expected unqualified-id before 'if'
 #define EVERY_N_MILLIS_I(NAME,N) static CEveryNMillis NAME(N); if( NAME )
                                                                ^
/Users/baileywilliams/Documents/Arduino/libraries/FastLED/src/lib8tion.h:1155:27: note: in expansion of macro 'EVERY_N_MILLIS_I'
 #define EVERY_N_MILLIS(N) EVERY_N_MILLIS_I(CONCAT_MACRO(PER, __COUNTER__ ),N)
                           ^~~~~~~~~~~~~~~~
/Users/baileywilliams/Documents/Arduino/libraries/FastLED/src/lib8tion.h:1167:33: note: in expansion of macro 'EVERY_N_MILLIS'
 #define EVERY_N_MILLISECONDS(N) EVERY_N_MILLIS(N)
                                 ^~~~~~~~~~~~~~
/Users/baileywilliams/Downloads/FastLED-basics-main/5. Multiple patterns/crossfadeButton/crossfadeButton.ino:109:3: note: in expansion of macro 'EVERY_N_MILLISECONDS'
   EVERY_N_MILLISECONDS(10){
   ^~~~~~~~~~~~~~~~~~~~
exit status 1
'palletrgb' was not declared in this scope


This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

Hi, @16bails16
Welcome to the forum.

void palletrgb(CRGB *LEDarray) 
  fill_palette(leds, NUM_LEDS, paletteIndex, 255 / NUM_LEDS, myPal, 255, LINEARBLEND);
  
  EVERY_N_MILLISECONDS(10){
    paletteIndex++;
}

Missing a SET OF { } to make it a function.

Tom... :smiley: :+1: :coffee: :australia:
PS. Thanks for using code tags and formatting your detent in your code.

where abouts would they go ? quite new to merging

@TomGeorge Added them in,

//------- Put your patterns below -------//

void palletrgb(CRGB *LEDarray)  {
  fill_palette(leds, NUM_LEDS, paletteIndex, 255 / NUM_LEDS, myPal, 255, LINEARBLEND);


  EVERY_N_MILLISECONDS(10)
    paletteIndex++;
}

void Beat(CRGB *LEDarray) {
  
  uint16_t beatA = beatsin16(30, 0, 255);
  uint16_t beatB = beatsin16(20, 0, 255);
  fill_rainbow(LEDarray, NUM_LEDS, (beatA+beatB)/2, 8);
}

gives this error

Arduino: 1.8.15 (Mac OS X), Board: "Arduino Nano, ATmega328P (Old Bootloader)"











In file included from /Users/baileywilliams/Downloads/FastLED-basics-main/5. Multiple patterns/crossfadeButton/crossfadeButton.ino:13:0:
/Users/baileywilliams/Documents/Arduino/libraries/FastLED/src/FastLED.h:14:21: note: #pragma message: FastLED version 3.004.000
 #    pragma message "FastLED version 3.004.000"
                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/baileywilliams/Downloads/FastLED-basics-main/5. Multiple patterns/crossfadeButton/crossfadeButton.ino: In function 'void palletrgb(CRGB*)':
crossfadeButton:108:16: error: 'leds' was not declared in this scope
   fill_palette(leds, NUM_LEDS, paletteIndex, 255 / NUM_LEDS, myPal, 255, LINEARBLEND);
                ^~~~
/Users/baileywilliams/Downloads/FastLED-basics-main/5. Multiple patterns/crossfadeButton/crossfadeButton.ino:108:16: note: suggested alternative: 'gets'
   fill_palette(leds, NUM_LEDS, paletteIndex, 255 / NUM_LEDS, myPal, 255, LINEARBLEND);
                ^~~~
                gets
crossfadeButton:108:32: error: 'paletteIndex' was not declared in this scope
   fill_palette(leds, NUM_LEDS, paletteIndex, 255 / NUM_LEDS, myPal, 255, LINEARBLEND);
                                ^~~~~~~~~~~~
exit status 1
'leds' was not declared in this scope


This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.