I am trying to create a class that will handle events. class2
represents events, class1
is a structure where events are stored and handled. Here is my simplified code to prove the concept, it doesn't work:
class TestClass2{
public:
TestClass2(int x,int y,int z) {
_x=x;
_y=y;
_z=z;
}
private:
int _x,_y,_z;
};
class TestClass{
public:
void putVal(TestClass2 x)volatile{
// The error is happening here.
test=x;
return;
}
private:
TestClass2 test;
};
volatile TestClass testObj = TestClass();
IRAM_ATTR void testISR(){
TestClass2 testInput = TestClass2(1,2,3);
testObj.putVal(testInput);
}
uint8_t EventPin = 5;
void setup() {
Serial.begin(115200);
pinMode(EventPin, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(EventPin), testISR, CHANGE);
}
void loop() {
// put your main code here, to run repeatedly:
Serial.println(millis());
delay(1000);
}
I am getting this error:
Compilation error: passing 'volatile TestClass2' as 'this' argument discards qualifiers \[-fpermissive\]
If I replace the array of TestClass2
with an array of integers, it works.
Where am I making a mistake?