私のベルトの下で Comp Sci の 1 学期、ここでは何もありません。
FastLED のストリップにある LED の数に使用する定数 int を呼び出す必要があります。要するに、私は交換しようとしています...
#include "FastLED.h"
#define NUM_LEDS_RT 174
#define DATA_PIN_RT 6
#define CLOCK_PIN_RT 5
...
CRGB led[NUM_LEDS_RT + NUM_LEDS_MID + NUM_LEDS_LF + NUM_LEDS_FIRE];
FastLED.addLeds<WS2801, DATA_PIN_RT, CLOCK_PIN_RT, BGR> (led, NUM_LEDS_RT);
私が作成した独自のライブラリを使用して、LED ストリップの構造体を作成し、プログラムのドライバー ファイルによってシードされた上記の情報を保持します。すべて正常に動作しているはずですが、この最初のエラーを回避できません。たとえば、私のデータを含むオブジェクトは...
Strip::Strip(int data, int clock, int num)
{
#define DATA_Pin data
#define CLOCK_Pin clock
#define NUM_LEDS num
}
ドライバーによってシードされます...
Strip RIGHT(6, 5, 174);
簡単に言えば、オブジェクトを呼び出して定数値を持つ方法はありますか? 発生するエラーは、RIGHT.name が定数変数ではないことを示し、「Led.cpp:39: エラー: テンプレート引数の数が間違っています (4、3 にする必要があります)」またはそのバリエーションを受け取ります。
助けてください!さらに情報が必要な場合はお知らせください。ありがとうございました!
編集: 参照用にコードを追加: ストリップ クラス
#ifndef Strip_h
#define Strip_h
#include "Arduino.h"
#include <String>
#include "C:/Program Files (x86)/Arduino/libraries/FastLED/FastLED.h"
class Strip
{
public:
Strip(int data, int clock, int num);
private:
int DATA_Pin;
int CLOCK_Pin;
int NUM_LEDS;
};
#endif
#include "Strip.h"
Strip::Strip(int data, int clock, int num)
{
DATA_Pin = data;
CLOCK_Pin = clock;
NUM_LEDS = num;
}
導かれたクラス
#ifndef Led_h
#define Led_h
include "C:/Program Files (x86)/Arduino/libraries/FastLED/FastLED.h"
#include "Strip.h"
class Led
{
public:
Led(const Strip& name);
Led(const Strip& name, const Strip& name2);
Led(const Strip& name, const Strip& name2, const Strip& name3);
Led(const Strip& name, const Strip& name2, const Strip& name3, const Strip& name4);
private:
};
#endif
Led::Led(const Strip& const Strip&, const Strip& name2, const Strip& name3, const Strip& name4)
{
CRGB led[name.NUM_LEDS + name2.NUM_LEDS + name3.NUM_LEDS + name4.NUM_LEDS];
FastLED.addLeds<WS2801, name.DATA_Pin, name.CLOCK_Pin, BGR>(led, name.NUM_LEDS);
FastLED.addLeds<WS2801, name2.DATA_Pin, name2.CLOCK_Pin, BGR>(led, name.NUM_LEDS, name.NUM_LEDS + name2.NUM_LEDS);
FastLED.addLeds<WS2801, name3.DATA_Pin, name3.CLOCK_Pin, BGR>(led, name.NUM_LEDS + name2.NUM_LEDS, name.NUM_LEDS + name2.NUM_LEDS + name3.NUM_LEDS);
FastLED.addLeds<WS2801, name4.DATA_Pin, name4.CLOCK_Pin, BGR>(led, name.NUM_LEDS + name2.NUM_LEDS + name3.NUM_LEDS, name.NUM_LEDS + name2.NUM_LEDS + name3.NUM_LEDS + name4.NUM_LEDS);
}
運転者
#include "Led.h"
#include "MusicChip.h"
#include "Shapes.h"
#include "Strip.h"
const Strip RIGHT(6, 5, 174);
const Strip MID(4, 3, 200);
const Strip LEFT(22, 23, 177);
const Strip FIRE(10, 12, 97);
void setup()
{
delay(1000); // Sanity Check, allows input to settle
Serial.begin(9600);
Led running(RIGHT, MID, LEFT, FIRE);
MusicChip MAIN(0, 8, 7);
}