预计“诠释”之前不合格-ID? Arduino的库[关闭]

问题描述 投票:0回答:1

这可能是某事愚蠢的我错过了,但它现在每天我不断收到此错误:(。请帮助!这是我在C首先++库,所以我可能会搞砸的语法。

出现在这行代码此错误

  displayLED(int heightOfDisplay = 8, int widthOfDisplay = 32);

这里是在.h文件中的代码

#ifndef displayLED
#define displayLED
#include "Arduino.h"
#include <math.h>
#include <string.h>

class displayLED
{

private:

static const int heightOfDisplay;
static const int widthOfDisplay;
int verticalArray[8];
int horizontalArray[32];
int cursorPosition=0;
const int latchPin = 8;
const int clkPin = 7;
const int REDhorizontalSO = 6;
const int GREENhorizontalSO = 11;
const int BLUEhorizontalSO = 9;
const int verticalSO = 12;



public:

displayLED(int heightOfDisplay = 8, int widthOfDisplay = 32);
displayLED();
void constructWord(String   Word = "WELCOME");
void slideIn(String colorAnimator);
void fillArrays();
void pushToRegister(int sthToWrite1[], int sthToWrite2[], int sthToWrite3[],  int sthToWrite4[], int SOpin1, int SOpin2, int SOpin3, int SOpin4);
void shiftOutMultiple(uint8_t dataPin1, uint8_t dataPin2, uint8_t dataPin3, uint8_t dataPin4, uint8_t clockPin, uint8_t bitOrder, uint8_t val1, uint8_t val2, uint8_t val3, uint8_t val4)


};



#endif

这里是我的.cpp。我已经省略了其它功能简洁。我希望它的清楚。

#include "displayLED.h"


displayLED::displayLED(int heightOfDisplay, int widthOfDisplay) {
this->heightOfDisplay = heightOfDisplay;
this->widthOfDisplay = widthOfDisplay;
pinMode(latchPin , OUTPUT);
pinMode(clkPin , OUTPUT);
pinMode(REDhorizontalISO , OUTPUT);
pinMode(GREENhorizontalSO , OUTPUT);
pinMode(BLUEhorizontalSO , OUTPUT);
pinMode(vertcalISO , OUTPUT);
fillArrays();
}

displayLED::displayLED()    {
}


//this function fills all the array with zeros
void displayLED::fillArrays()   {
for(int j=0; j <= heightOfDisplay; j++) {
    verticalArray[j] = 0;
}

for(int j=0; j <= widthOfDisplay; j++)  {
    horizontalArray[j] = 1;
}
}
c++ arduino
1个回答
3
投票

我想与你的类名的#define警卫发生冲突。预处理器将删除所有提到displayLed,这将产生非常奇怪的编译错误。

警惕更改为类似

#ifndef DISPLAYLED_H
#define DISPLAYLED_H

或者,你可以尝试使用#pragma once。大多数编译器支持时下。

© www.soinside.com 2019 - 2024. All rights reserved.