Using FastLED in own library

I am currently programming my 777 RGB LED Cube consisting of WS2811 F8 LEDs which are driven by the FastLED Library. To create multiple animations I made many different voids and it is getting messy in the ino file. So i decided to make a library that includes all these voids.
I generally know how I have to write a library in the Arduino IDE but how can I integrate the FastLED library in my own library? The voids often look somehow like this:
You do not need to understand the functions, its just that you know what i want to do.

//Creative Commons Attribution 4.0 International (CC BY 4.0) Wieland B.
void fademulti(uint8_t startr, uint8_t startg, uint8_t startb, uint8_t endr, uint8_t endg, uint8_t endb, int wait, uint8_t step, int quantity, int ledmultitest[]) {
  int difr = endr - startr;
  int difg = endg - startg;
  int difb = endb - startb;
  float difrl = (float)difr;
  float difgl = (float)difg;
  float difbl = (float)difb;
  float facr, facg, facb;
  uint8_t rgb[3];
  float highest;
  if ((difr > difg) && (difr > difb))
    highest = difr;
  if ((difg > difr) && (difg > difb))
    highest = difgl;
  if ((difb > difr) && (difb > difg))
    highest = difb;
  if ((difb > difr) && (difb == difg))
    highest = difb;
  if ((difr > difg) && (difb == difg))
    highest = difr;
  if ((difg > difb) && (difg == difr))
    highest = difg;
  if ((difg == difr) && (difr == difb))
    highest = difr;
  if (highest < 0)
    highest *= -1;
  facr = difrl / highest;
  facg = difgl / highest;
  facb = difbl / highest;
  for (int i = 0; i < (int)highest; i += step) {
    for (int j = 0; j < quantity; j++) {
      setLED(ledmultitest[j], startr + i * facr, startg + i * facg, startb + i * facb);  //CAUSING PROBLEMS
    }
    FastLED.show();
    delayMicroseconds(wait);
  }
}

void setLED(int lednumber, uint8_t r, uint8_t g, uint8_t b) {
  if (lednumber >= 0) {
    leds[lednumber].r = r;  //CAUSING PROBLEMS
    leds[lednumber].g = g;  //CAUSING PROBLEMS
    leds[lednumber].b = b;  //CAUSING PROBLEMS
  }
}

What I did until now:

/*
LEDCube.cpp
*/
#include "Arduino.h"
#include "LEDCube.h"
#include <FastLED.h>

LEDCube::LEDCube() {
  FastLED.addLeds<WS2811, 7>(leds, 343);
}

int LEDCube::xyz2lednum(uint8_t x, uint8_t y, uint8_t z) {
  int lednumber;
  if ((y % 2) == 0) {
    lednumber = (z * limitsqu) + (y * limit) + (x);
  } else {
    lednumber = (z * limitsqu) + (y * limit) + (limit - 1 - x);
  }
  return lednumber;
}

void LEDCube::setLED(int lednumber, uint8_t r, uint8_t g, uint8_t b) {
  if (lednumber >= 0) {
    if (lednumber >= 0) {
    leds[lednumber].r = r;
    leds[lednumber].g = g;
    leds[lednumber].b = b;
  }
}
/*
LEDCube.h
*/
#ifndef LEDCube_H
#define LEDCube_H
#include "Arduino.h"
#include <FastLED.h>
class LEDCube
{
	public:
	LEDCube();
	int xyz2lednum(uint8_t x, uint8_t y, uint8_t z);
	void setLED(int lednumber, uint8_t r, uint8_t g, uint8_t b);
        CRGB leds[343];
private:
	int  limit = 7;
	int  limitsqu = limit * limit;
	int  numLeds = limitsqu * limit;
};
#endif
/*
LEDCube.ino
*/
#include <LEDCube.h>
#include <FastLED.h>

int limit = 7;  //ENTER HERE YOUR LED NUMBER
int numLeds = limit * limit * limit;
int limitsqu = limit * limit;

int testvar;

LEDCube cube;

void setup() {
  delay(500);
  Serial.begin(9600);
}

void loop() {
  testvar = cube.xyz2lednum(1,1,1);
}

I get errors that the CRGB “leds” Matrix that is used by the library is not declared in this scope what is totally logical. FastLED.show(); compiles completly normal but because i am not at home for a week i have no way of testing if it really works.
I already thought of passing the “leds” Matrix as a parameter of the functions but i do not really like this method because i have many functions that have many parameters already. I declared the “leds” Matrix in the public section of the Header file but it is still not declared in the scope.
Where should I execute FastLED.addLeds? In the Constructor of LEDCube as i did or in setup() ?
How can i solve the problem with the CRGB leds Matrix?
I am using my own voids inside my own voids. How do i have to call or treat his? cube.myvoid(); ?

Sorry for bad language, i do not natively speak english.

Thanks in Advance

The correct term is "functions", not "voids". void is just the return type of the function. It wouldn't make sense to call functions that return an int "ints" just as it doesn't make sense to call functions that don't return anything "voids".

For some reason it's very common for beginners to call functions "voids" but it's important to get the terminology right because if you use the term "voids" in a search query you're going to get a bunch of beginner support requests as the results instead of the information you're really searching for.

It’s not clear to me what you’re trying to do, but the code you posted does compile after a couple basic fixes. For quick testing, I combined everything in one .ino file:

#include <FastLED.h>
class LEDCube
{
  public:
  LEDCube();
  int xyz2lednum(uint8_t x, uint8_t y, uint8_t z);
  void setLED(int lednumber, uint8_t r, uint8_t g, uint8_t b);
        CRGB leds[343];
private:
  int  limit = 7;
  int  limitsqu = limit * limit;
  int  numLeds = limitsqu * limit;
};


LEDCube::LEDCube() {
  FastLED.addLeds<WS2811, 7>(leds, 343);
}

int LEDCube::xyz2lednum(uint8_t x, uint8_t y, uint8_t z) {
  int lednumber;
  if ((y % 2) == 0) {
    lednumber = (z * limitsqu) + (y * limit) + (x);
  } else {
    lednumber = (z * limitsqu) + (y * limit) + (limit - 1 - x);
  }
  return lednumber;
}

void LEDCube::setLED(int lednumber, uint8_t r, uint8_t g, uint8_t b) {
  if (lednumber >= 0) {
    if (lednumber >= 0) {
      leds[lednumber].r = r;
      leds[lednumber].g = g;
      leds[lednumber].b = b;
    }
  }
}



int testvar;
LEDCube cube;

void setup() {
  delay(500);
  Serial.begin(9600);
}

void loop() {
  testvar = cube.xyz2lednum(1,1,1);
}

Thanks at you both.
I copied what you wrote in a .ino .h and .cpp file and now it compiles well. I do dont really know what you changed but thank you.
Is it possible to sort multiple voids in three different .cpp files (utilities, animations, anitilities(dont ask what name this is))? I am asking because i would need to call functions of file utilities in a function which is in another file. Is this possible and if how?

pert:
The correct term is “functions”, not “voids”. void is just the return type of the function. It wouldn’t make sense to call functions that return an int “ints” just as it doesn’t make sense to call functions that don’t return anything “voids”.

For some reason it’s very common for beginners to call functions “voids” but it’s important to get the terminology right because if you use the term “voids” in a search query you’re going to get a bunch of beginner support requests as the results instead of the information you’re really searching for.

Sorry :smiley: wont happen again