I want to create a custom library in C++ with the FastLED library but i keep getting errors.
The error i get is
In file included from lib\LED/LED.h:5:0,
from src\main.cpp:8:
.pio\libdeps\esp32dev\FastLED\src/FastLED.h:14:21: note: #pragma message: FastLED version 3.004.000
# pragma message "FastLED version 3.004.000"
^
In file included from .pio\libdeps\esp32dev\FastLED\src/FastLED.h:65:0,
from lib\LED/LED.h:5,
from src\main.cpp:8:
.pio\libdeps\esp32dev\FastLED\src/fastspi.h:135:23: note: #pragma message: No hardware SPI pins defined. All SPI access will default to bitbanged output
# pragma message "No hardware SPI pins defined. All SPI access will default to bitbanged output"
^
Compiling .pio\build\esp32dev\lib856\LED\LED.cpp.o
In file included from lib\LED/LED.h:5:0,
from lib\LED\LED.cpp:2:
.pio\libdeps\esp32dev\FastLED\src/FastLED.h:14:21: note: #pragma message: FastLED version 3.004.000
# pragma message "FastLED version 3.004.000"
^
In file included from .pio\libdeps\esp32dev\FastLED\src/FastLED.h:65:0,
from lib\LED/LED.h:5,
from lib\LED\LED.cpp:2:
.pio\libdeps\esp32dev\FastLED\src/fastspi.h:135:23: note: #pragma message: No hardware SPI pins defined. All SPI access will default to bitbanged output
# pragma message "No hardware SPI pins defined. All SPI access will default to bitbanged output"
^
lib\LED\LED.cpp: In constructor 'LED::LED()':
lib\LED\LED.cpp:11:55: error: no matching function for call to 'CFastLED::addLeds(CRGB&, int)'
FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS);
^
In file included from lib\LED/LED.h:5:0,
from lib\LED\LED.cpp:2:
.pio\libdeps\esp32dev\FastLED\src/FastLED.h:223:130: note: candidate: template<ESPIChipsets CHIPSET, unsigned char DATA_PIN, unsigned char CLOCK_PIN, EOrder RGB_ORDER, unsigned int SPI_DATA_RATE> CLEDController& CFastLED::addLeds(CRGB*, int, int)
template<ESPIChipsets CHIPSET, uint8_t DATA_PIN, uint8_t CLOCK_PIN, EOrder RGB_ORDER, uint32_t SPI_DATA_RATE > CLEDController &addLeds(struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) {
^
.pio\libdeps\esp32dev\FastLED\src/FastLED.h:223:130: note: template argument deduction/substitution failed:
.pio\libdeps\esp32dev\FastLED\src/FastLED.h:237:95: note: candidate: template<ESPIChipsets CHIPSET, unsigned char DATA_PIN, unsigned char CLOCK_PIN> static CLEDController& CFastLED::addLeds(CRGB*, int, int)
template<ESPIChipsets CHIPSET, uint8_t DATA_PIN, uint8_t CLOCK_PIN > static CLEDController &addLeds(struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) {
^
.pio\libdeps\esp32dev\FastLED\src/FastLED.h:237:95: note: template argument deduction/substitution failed:
.pio\libdeps\esp32dev\FastLED\src/FastLED.h:251:113: note: candidate: template<ESPIChipsets CHIPSET, unsigned char DATA_PIN, unsigned char CLOCK_PIN, EOrder RGB_ORDER> static CLEDController& CFastLED::addLeds(CRGB*, int, int)
template<ESPIChipsets CHIPSET, uint8_t DATA_PIN, uint8_t CLOCK_PIN, EOrder RGB_ORDER > static CLEDController &addLeds(struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) {
^
.pio\libdeps\esp32dev\FastLED\src/FastLED.h:251:113: note: template argument deduction/substitution failed:
.pio\libdeps\esp32dev\FastLED\src/FastLED.h:301:25: note: candidate: template<template<unsigned char DATA_PIN, EOrder RGB_ORDER> class CHIPSET, unsigned char DATA_PIN, EOrder RGB_ORDER> static CLEDController& CFastLED::addLeds(CRGB*, int, int)
static CLEDController &addLeds(struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) {
^
.pio\libdeps\esp32dev\FastLED\src/FastLED.h:301:25: note: template argument deduction/substitution failed:
.pio\libdeps\esp32dev\FastLED\src/FastLED.h:307:25: note: candidate: template<template<unsigned char DATA_PIN, EOrder RGB_ORDER> class CHIPSET, unsigned char DATA_PIN> static CLEDController& CFastLED::addLeds(CRGB*, int, int)
static CLEDController &addLeds(struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) {
^
.pio\libdeps\esp32dev\FastLED\src/FastLED.h:307:25: note: template argument deduction/substitution failed:
.pio\libdeps\esp32dev\FastLED\src/FastLED.h:313:25: note: candidate: template<template<unsigned char DATA_PIN> class CHIPSET, unsigned char DATA_PIN> static CLEDController& CFastLED::addLeds(CRGB*, int, int)
static CLEDController &addLeds(struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) {
^
.pio\libdeps\esp32dev\FastLED\src/FastLED.h:313:25: note: template argument deduction/substitution failed:
lib\LED\LED.cpp:11:41: note: cannot convert '((LED*)this)->LED::leds' (type 'CRGB') to type 'CRGB*'
FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS);
^
In file included from lib\LED/LED.h:5:0,
from lib\LED\LED.cpp:2:
.pio\libdeps\esp32dev\FastLED\src/FastLED.h:357:25: note: candidate: template<template<EOrder RGB_ORDER> class CHIPSET, EOrder RGB_ORDER> static CLEDController& CFastLED::addLeds(CRGB*, int, int)
static CLEDController &addLeds(struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) {
^
.pio\libdeps\esp32dev\FastLED\src/FastLED.h:357:25: note: template argument deduction/substitution failed:
lib\LED\LED.cpp:11:55: error: invalid conversion from 'int' to 'EOrder' [-fpermissive]
FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS);
^
In file included from lib\LED/LED.h:5:0,
from lib\LED\LED.cpp:2:
.pio\libdeps\esp32dev\FastLED\src/FastLED.h:363:25: note: candidate: template<template<EOrder RGB_ORDER> class CHIPSET> static CLEDController& CFastLED::addLeds(CRGB*, int, int)
static CLEDController &addLeds(struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset = 0) {
^
.pio\libdeps\esp32dev\FastLED\src/FastLED.h:363:25: note: template argument deduction/substitution failed:
lib\LED\LED.cpp:11:55: error: wrong number of template arguments (2, should be 1)
FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS);
^
lib\LED\LED.cpp: In member function 'void LED::begin()':
lib\LED\LED.cpp:16:13: warning: large integer implicitly truncated to unsigned type [-Woverflow]
leds[0] = CRGB::Red;
^
*** [.pio\build\esp32dev\lib856\LED\LED.cpp.o] Error 1
This is my LED.h file:
#ifndef LED_h
#define LED_h
#include <Arduino.h>
#include <FastLED.h>
class LED
{
public:
LED();
void begin();
private:
CRGB leds;
};
#endif
And this is my LED.cpp file
#include <Arduino.h>
#include <LED.h>
#include <FastLED.h>
#define NUM_LEDS 1
#define DATA_PIN 34
LED::LED()
{
leds[NUM_LEDS];
FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS);
}
void LED::begin()
{
leds[0] = CRGB::Red;
FastLED.show();
}
The first error is:
lib\LED\LED.cpp:11:55: error: no matching function for call to ‘CFastLED::addLeds(CRGB&, int)’
But i cannot understand why it doesn’t find the function because the code i use is exactly as the examples apart from using it in a custom library. What am i doing wrong?
Thank you