Can somebody plss help me how to put keypad.addEventListener for int function...
MENU3.ino: In function 'void eventSchedM(KeypadEvent)':
MENU3:112: error: invalid conversion from 'int ()()' to 'void ()(char)'
MENU3:112: error: initializing argument 1 of 'void Keypad::addEventListener(void (*)(char))'
void eventSchedM(KeypadEvent key){
switch (keypad.getState()){
case PRESSED:
switch (key){
case 'C':
GLCD.DrawBitmap(viewMenu, 0,0, BLACK);
keypad.addEventListener(eventView2);
break;
case 'A': //GLCD.DrawBitmap(schedMenu, 0,0, BLACK);
keypad.addEventListener(c1); //keypad.addEventListener(c1);
//c1();
break;
}
break;
peanutbread:
Can somebody plss help me how to put keypad.addEventListener for int function...
MENU3.ino: In function 'void eventSchedM(KeypadEvent)':
MENU3:112: error: invalid conversion from 'int ()()' to 'void ()(char)'
MENU3:112: error: initializing argument 1 of 'void Keypad::addEventListener(void (*)(char))'
keypad.addEventListener(name_of_event_function) creates a new call-back function everytime you call it. So everytime you press the A or C key you are creating a duplicate function pointer for the associated name. In your code that would be the function c1(). Also, you are trying to create two event listeners (c1() and eventView2()) when the library only supports one. Unless you understand function pointers you may not want to do that. Plus, you are trying to change the call-back function from a return value of void to int. It doesn't make sense for it to have a return value because it is called within the library and never from your sketch.
It's a bit abstract and if you don't understand call-backs and function pointers then you should follow the EventKeypad.ino example provided with the library.
From the main menu "File -> Examples -> Keypad -> EventKeypad" will load a sketch that demonstrates proper usage.
From your attempts to use addEventListener() I can see that you are struggling with understanding its proper use. I can help you with that but it might be a lot easier if you were to tell me what you are trying to accomplish. Then we might be able to help you design your sketch.