I am trying to learn/implement classes in my program, however I have hit a strange compiler error that I can't solve. Some how there references to the Teensyduino libraries are getting broken. However this only happens in one case.
I am not confident in my implementation, and use of static, however I can't find any error between the two implementations. One compiles, and one gives weird errors. Any help or suggestions welcome!
Arduino 1.0.6
Teensyduino 1.20 (downloaded and installed today)
The code should compile on copy/paste, but swap the commented //#define and the second should fail stating OUTPUT undefined, and highlighting the wrong line.
I am not confident in my implementation, and use of static, however I can't find any error between the two implementations. One compiles, and one gives weird errors. Any help or suggestions welcome!
Arduino 1.0.6
Teensyduino 1.20 (downloaded and installed today)
The code should compile on copy/paste, but swap the commented //#define and the second should fail stating OUTPUT undefined, and highlighting the wrong line.
Code:
#define ZARL_01 //Set my hardware version to 01
//#define ZARL_00 //Set my hardware version to 01
#include "math.h"
#ifdef ZARL_01
class PINS{
public:
static const int Qo_Leds = 12;
static const int PwmRes = 16;
static const int PwmMaxValue = pow( 2, PwmRes) -1;
int Led[2][Qo_Leds] = {
{
25, 32, 3, 4, 5, 9, 21, 22, 6, 10, 20, 23 }
, // RGBW, 1-8 spots addressed clockwise starting at 4 o'clock
{
} // Second row to hold set values
};
const int Red = Led[0][0];
const int Green = Led[0][1];
const int Blue = Led[0][2];
const int White = Led[0][3];
const int Touch[3][5] = {
{
0, 1, 16, 17, 33
}
, // 5 touch pins; touch pin calibration; last reading
{
}
,
{
}
};
const int TeensyLed = 13;
const int vibe = A14;
const int audio = 15;
const int light = 14;
const int SysVoltage = A13;
const int BattPowerGood = 11;
const int BattStatOne = 7;
const int BattStatTwo = 8;
const int MpuInterrupt = 2;
void Config() {
for ( int i = 0; i < Qo_Leds; ++i ) pinMode( Led[0][i], OUTPUT );
for ( int i = 0; i < 5; ++i ) pinMode( Touch[0][i], INPUT );
pinMode( TeensyLed, OUTPUT );
pinMode( vibe, OUTPUT );
pinMode( audio, INPUT );
pinMode( light, INPUT );
pinMode( SysVoltage, INPUT );
pinMode( BattPowerGood, INPUT );
pinMode( BattStatOne, INPUT );
pinMode( BattStatTwo, INPUT );
pinMode( MpuInterrupt, INPUT );
}
};
#endif
#ifdef ZARL_00
class PINS {
public:
static const int Qo_Leds = 4;
static const int PwmRes = 16;
static const int PwmMaxValue = (pow( 2, PwmRes) -1);
int Led[2][Qo_Leds] = {
{
3, 4, 5, 6
}
, // RGBW, 1-8 spots addressed clockwise starting at 4 o'clock
{
} // Second row to hold values
};
static const int audio = 23;
static const int light = 22;
static const int MpuInterrupt = 14;
static const int TeensyLed = 13;
void Config() { //Comment out the next 5 lines, and the code will compile
for ( int i = 0; i < Qo_Leds; ++i ) pinMode( Led[0][i], OUTPUT );
pinMode( TeensyLed, OUTPUT );
pinMode( audio, INPUT );
pinMode( light, INPUT );
pinMode( MpuInterrupt, INPUT );
}
};
#endif
PINS pin;
void setup() {
pin.Config();
}
void loop() {
}