Hi all,
I am trying to compile some code that I edited written by sean coates. I'm wondering if someone can help me debug the following error. Below is the code that I have for the .c and .h files. I'm getting the following error "/beercontroller.h:57: error: extra qualification 'BeerController::' on member 'setStatus'"
Any help would be greatly appreciated.
Here is BeerController.h
#ifndef beerController_h
#define beerController_h
#include <stdint.h>
#define FER1_SENSOR_PIN 0
#define FER1_COOL_PIN 4
#define FER2_SENSOR_PIN 1
#define FER2_COOL_PIN 5
#define FER3_SENSOR_PIN 2
#define FER3_COOL_PIN 6
#define FER4_SENSOR_PIN 3
#define FER4_COOL_PIN 7
#define CHEST_SENSOR_PIN 4
#define CHEST_COOL_PIN 2
#define CHEST_HEAT_PIN 3
#define FER1_EEPROM_LOW 0x1
#define FER1_EEPROM_HIGH 0x2
#define FER2_EEPROM_LOW 0x3
#define FER2_EEPROM_HIGH 0x4
#define FER3_EEPROM_LOW 0x5
#define FER3_EEPROM_HIGH 0x6
#define FER4_EEPROM_LOW 0x7
#define FER4_EEPROM_HIGH 0x8
#define CHEST_EEPROM_LOW 0x9
#define CHEST_EEPROM_HIGH 0xA
// 300000ms = 5 minutes
#define STATE_PERIOD 300000
#define BEER_CONTROLLER_STATUS_OFF 0
#define BEER_CONTROLLER_STATUS_ON 1
#define BEER_CONTROLLER_TEMP_SAMPLE 500
class BeerController {
private:
uint8_t _relayPinCool;
uint8_t _relayPinHeat;
uint8_t _sensorPin;
uint8_t _addressLow;
uint8_t _addressHigh;
public:
BeerController(uint8_t, uint8_t, char[4], uint8_t, uint8_t = 255, uint8_t = 255, uint8_t = 0);
unsigned long lastReading;
unsigned long lastToggleTime;
char* name;
uint8_t status;
void checkTemp();
void tooHot();
void tooCold();
void inRange();
void setLow(uint8_t);
void setHigh(uint8_t);
uint8_t getLow();
uint8_t getHigh();
void BeerController::setStatus(uint8_t);
void dump();
};
#endif
And here is BeerController.cpp
#include "beerdebug.h"
#include "beercontroller.h"
#include "sprint.h"
#include <wiring.h>
#include <avr/eeprom.h>
#include <avr/pgmspace.h>
#include <HardwareSerial.h>
extern uint8_t debugMode;
BeerController::BeerController(uint8_t addrLow, uint8_t addrHigh, char controllerName[4], uint8_t sensorPin, uint8_t relayPinCool, uint8_t relayPinHeat, uint8_t status) {
_addressLow = addrLow;
_addressHigh = addrHigh;
_sensorPin = sensorPin;
_relayPinCool = relayPinCool;
_relayPinHeat = relayPinHeat;
status = BEER_CONTROLLER_STATUS_OFF;
lastReading = 0;
lastToggleTime = 0;
if (_relayPinCool != 255) {
pinMode(_relayPinCool, OUTPUT);
}
if (_relayPinHeat != 255) {
pinMode(_relayPinHeat, OUTPUT);
}
name = controllerName;
};
void BeerController::checkTemp() {
unsigned long aRead = 0;
if (millis() < STATE_PERIOD) {
lastToggleTime = 0; // millis() overflow hack
}
debug(this->name, "checkTemp()");
for (int i=0; i<BEER_CONTROLLER_TEMP_SAMPLE; i++) {
aRead = aRead + ( 5.0 * analogRead(_sensorPin) * 100.0) * 10.0 / 1024.0;
}
aRead = aRead / BEER_CONTROLLER_TEMP_SAMPLE;
aRead = (aRead * 9)/5 + 32; //converts to farenheit
lastReading = aRead;
debug(this->name, "Last Reading: %lu", aRead);
if ((lastToggleTime + STATE_PERIOD) < millis()) { // has been in state for long enough
SNdebug(this->name, "Toggle Time Exceeded; checking temps");
if (lastReading > getHigh()) {
// getting too hot
tooHot();
} else if (lastReading < getLow()) {
// getting too cold
tooCold();
} else if (lastReading >= getLow() && lastReading <= getHigh()) {
inRange();
}
} else {
debug(this->name, "Not checking temps.");
}
}
void BeerController::tooHot() {
SNdebug(name, "tooHot()");
if (status == BEER_CONTROLLER_STATUS_ON) {
SNdebug(this->name, "already cooling...");
} else {
SNdebug(this->name, "not cooling...");
if (_relayPinCool == 255) {
SNdebug(this->name, "relayPinCool not set");
status = BEER_CONTROLLER_STATUS_OFF;
} else {
SNdebug(this->name, "Setting relayPinCool HIGH");
digitalWrite(_relayPinCool, HIGH);
status = BEER_CONTROLLER_STATUS_ON;
}
lastToggleTime = millis();
}
}
void BeerController::tooCold() {
SNdebug(this->name, "tooCold()");
if (status == BEER_CONTROLLER_STATUS_OFF) {
SNdebug(this->name, "already off...");
} else {
SNdebug(this->name, "not heating...");
if (this->_relayPinCool == 255) {
SNdebug(this->name, "relayPinCool not set");
} else {
SNdebug(this->name, "Setting relayPinCool LOW");
digitalWrite(this->_relayPinCool, LOW);
status = BEER_CONTROLLER_STATUS_OFF;
}
lastToggleTime = millis();
}
}
void BeerController::inRange() {
SNdebug(this->name, "inRange()");
SNdebug(this->name, "No message");
}
uint8_t BeerController::getLow() {
uint8_t ret;
eeprom_busy_wait();
_EEGET(ret, _addressLow);
return ret;
}
uint8_t BeerController::getHigh() {
uint8_t ret;
eeprom_busy_wait();
_EEGET(ret, _addressHigh);
return ret;
}
void BeerController::setLow(uint8_t val) {
eeprom_busy_wait();
debug(this->name, "setLow() val: %u", val);
_EEPUT(_addressLow, val);
}
void BeerController::setHigh(uint8_t val) {
eeprom_busy_wait();
debug(this->name, "setHigh() val: %u", val);
_EEPUT(_addressHigh, val);
}
void BeerController::setStatus(uint8_t val) {
debug(this->name, "setStatus() val: %u", val);
status = val;
lastToggleTime = 0;
}
void BeerController::dump() {
SNdebug(this->name, "DUMPING...");
debug(this->name, " Current temp: %lu", lastReading);
debug(this->name, " State: %i", status);
debug(this->name, " Low: %lu", getLow());
debug(this->name, " High: %lu", getHigh());
debug(this->name, " Will check temp? %u", (int) ((lastToggleTime + STATE_PERIOD) < millis()));
debug(this->name, " Time to next check: %i s", (min(0, (int) (lastToggleTime + STATE_PERIOD) - millis() / 1000)));
debug(this->name, " Last toggle time: %lu", lastToggleTime);
debug(this->name, " lastToggleTime + STATE_PERIOD: %lu", lastToggleTime + STATE_PERIOD);
debug(this->name, " STATE_PERIOD: %lu", STATE_PERIOD);
debug(this->name, " millis(): %lu", millis());
debug(this->name, " millis() < STATE_PERIOD: %lu", millis() < STATE_PERIOD);
}