我正在为智能家居arduino DIY项目编写图书馆 我想使用另一个图书馆(不是我写的) 这是代码:
boiler.cpp
#include "Boiler.h"
Boiler::Boiler(int pin)
{
_pin = pin;
dev.setDevice(_pin); // Set Device Output (on/off)
turnOff();
}
boiler.h
#ifndef BOILER_H_
#define BOILER_H_
// include RF24 libs
#include "RF24.h"
#include "RF24Network.h"
#include "RF24Mesh.h"
#include <SPI.h>
// SmartHome Lib Includes
#include "Device.h"
#include "TimerOne.h"
#include "timeSet.h"
class Boiler
{
private:
RF24 radio(7, 8);
RF24Network network(radio);
RF24Mesh mesh(radio, network);
int _pin ;
void timerIsr();
void DrawSCR();
public:
.
.
.
Boiler (int pin );
void turnOn();
void turnOff();
};
问题是它没有编译
我得到的错误是:
Boiler.h:32:14:错误:数字常数之前的预期标识符
RF24无线电(7,8)
我做错了什么? 谢谢,
答案 0 :(得分:0)
我找到答案(错误地)
我已将包含添加到Boiler.cpp文件中
并移动了
RF24 radio(7, 8); // Init RF24 Radio
RF24Network network(radio); // Init RF24 Network
RF24Mesh mesh(radio, network); // Init RF24 Mesh
这是新代码:
#include "RF24.h"
#include "RF24Network.h"
#include "RF24Mesh.h"
#include <SPI.h>
.
.
.
#include "Boiler.h"
RF24 radio(7, 8); // Init RF24 Radio
RF24Network network(radio); // Init RF24 Network
RF24Mesh mesh(radio, network); // Init RF24 Mesh
Boiler::Boiler(int pin ,float Rev , String Last )
{
_pin = pin;
dev.setDevice(_pin); // Set Device Output (on/off)
turnOff();
}
void Boiler::init( char nodeID)
{
_nodeID = nodeID;
// Connect to the mesh and set Node ID
mesh.setNodeID(_nodeID);
if (_DEBUG) Serial.println(F("Connecting to the mesh..."));
mesh.begin();
// init LCD and print init data on LCD
myGLCD.InitLCD(60); // Init LCD 55 contrast
myGLCD.setFont(SmallFont); // Set small font
myGLCD.clrScr(); // clr screen
myGLCD.print("Boiler Device",0,0); //Print init Data on screen
myGLCD.print("Rev :" , 0 , 10);
myGLCD.printNumF(_rev,1 ,35,10,'.',1,'0');
myGLCD.print(_last,0,40);
myGLCD.update(); // Update display
turnOff();
}
现在它编译;-)