[SOLVED]Keypad Library Compile Not Finding Correct Constructor
i've started project using keypad library found here.
i have created own class in project using separate .h , .cpp file. here code files:
keyinput.h
keyinput.cpp
for main .ino file empty containing setup , loop functions no code in either function.
my problem described follows compiler:
here makekeymap macro reference:
i'm not trying use constructor no arguments compiler thinks am.
i have created own class in project using separate .h , .cpp file. here code files:
keyinput.h
code: [select]
#ifndef _keyinput_h_
#define _keyinput_h_
#include "../libraries/keypad/keypad.h"
class keyinput
{
private:
//constants
static const byte rows = 4, cols = 3;
//variables
keypad kypd;
public:
//functions
keyinput();
};
#endif
keyinput.cpp
code: [select]
#include "keyinput.h"
keyinput::keyinput()
{
char keys[rows][cols] =
{
{'1', '2', '3'},
{'4', '5', '6'},
{'7', '8', '9'},
{'*', '0', '#'}
};
byte rowpins[rows] = {5, 4, 3, 2}; //connect row pinouts of kpd
byte colpins[cols] = {8, 7, 6}; //connect column pinouts of kpd
kypd = keypad(makekeymap(keys), rowpins, colpins, rows, cols);
}
for main .ino file empty containing setup , loop functions no code in either function.
my problem described follows compiler:
quote
compiling garageopener...now thoughts makekeymap macro causing problems when take out macro , cast keys directly same error. code more or less copy past of multikey example comes library , have no issue compiling example. have insight on this?
creating d:\users\j.nielsen\documents\arduino_build\garageopener\garageopener.ino.cpp.o...
creating d:\users\j.nielsen\documents\arduino_build\garageopener\keyinput.cpp.o...
d:\users\j.nielsen\documents\arduino\garageopener\keyinput.cpp: in constructor 'keyinput::keyinput()':
d:\users\j.nielsen\documents\arduino\garageopener\keyinput.cpp:3: error: no matching function call 'keypad::keypad()'
d:\users\j.nielsen\documents\arduino\garageopener\/../libraries/keypad/keypad.h:85: note: candidates are: keypad::keypad(char*, byte*, byte*, byte, byte)
d:\users\j.nielsen\documents\arduino\garageopener\/../libraries/keypad/keypad.h:82: note: keypad::keypad(const keypad&)
here makekeymap macro reference:
code: [select]
#define makekeymap(x) ((char*)x)
i'm not trying use constructor no arguments compiler thinks am.
hi fatdollar
because have in .h file ...
... , in body of .cpp file ...
... compiler treating constructor no arguments.
one way fix change kypd pointer ...
... , use new create instance of keypad in constructor ...
when add methods use object, use pointer style of referencing them. for example ...
edit added
i'm not sure way have declared rowpins, colpins , keys local variables in constructor. pass addresses when instance keypad, imagine destroyed when constructor ends , addresses no longer valid.
maybe @ moving them private member variables of keyinput class.
regards
ray
because have in .h file ...
code: [select]
keypad kypd;
... , in body of .cpp file ...
code: [select]
kypd = keypad(makekeymap(keys), rowpins, colpins, rows, cols);
... compiler treating constructor no arguments.
one way fix change kypd pointer ...
code: [select]
keypad* kypd;
... , use new create instance of keypad in constructor ...
code: [select]
kypd = new keypad(makekeymap(keys), rowpins, colpins, rows, cols);
when add methods use object, use pointer style of referencing them. for example ...
code: [select]
kypd->begin();
edit added
i'm not sure way have declared rowpins, colpins , keys local variables in constructor. pass addresses when instance keypad, imagine destroyed when constructor ends , addresses no longer valid.
maybe @ moving them private member variables of keyinput class.
regards
ray
Arduino Forum > Using Arduino > Programming Questions > [SOLVED]Keypad Library Compile Not Finding Correct Constructor
arduino
Comments
Post a Comment