I am trying to set the status of an object from a private enum and I'm not sure how to get the private member to the public version in the constructor, and I'm pretty sure I should not be using byte
in the constructor when it's an enum.
Also, I'm not sure if I should even have the values of the enum inside the header at all. Here is my code:
.h
class CandleRack
{
public:
CandleRack(byte candleRackStatus);
~CandleRack();
void begin();
void pushButton();
void selectRandomCandle();
void turnOnCandle(byte candlePosition);
void burnCandlesForMs();
void fadeOutCandle(byte candlePosition);
private:
Bounce *_debouncePushButton;
byte _pushButtonPin;
enum _candleRackStatus
{
inactive = 0,
candlesOn = 1,
rewardAnimation = 2,
tweetArrived = 3,
partyMode = 4,
};
byte _candlePosition;
byte _candleStatus[NUM_LEDS];
elapsedMillis _candleTimeElapsed[NUM_LEDS];
unsigned int _candleOnForMs;
};
.cpp
CandleRack::CandleRack(byte candleRackStatus)
{
_candleRackStatus = candleRackStatus;
_debouncePushButton = NULL;
}
in the sketch
CandleRack MyCandleRack(0);
error:
error: expected unqualified-id before '=' token
_candleRackStatus = candleRackStatus;
Thanks!
switch-case
statements, since you can define a "default" case.CandleRack MyCandleRack(0);
beCandleRack MyCandleRack(inactive);
or maybe CandleRack::inactive. My C++ is a bit rusty (very rusty). Also, in the interests of program readability the enum would be useful outside the class otherwise you're just assigning a bunch of numbers.MyCandleRack(inactive);
though.