Keypad is a class and the setHoldTime is declared as public, so accessible on any instance of that class.
when you try to do
[b]K[/b]eypad.setHoldTime(1000);
you are trying to call a class method (because of the capital K) which does not work. what you need to do is call the method after initialization of your instance of the keypad and for your specific instance
in your program you will create an instance of the Keypad class with something like
const byte rows = 4; //four rows
const byte cols = 3; //three columns
char keys[rows][cols] = {
{'1','2','3'},
{'4','5','6'},
{'7','8','9'},
{'#','0','*'}
};
byte rowPins[rows] = {5, 4, 3, 2}; //connect to the row pinouts of the keypad
byte colPins[cols] = {8, 7, 6}; //connect to the column pinouts of the keypad
Keypad myKeypad = Keypad( makeKeymap(keys), rowPins, colPins, rows, cols );
and then in the setup function you can call on your own instance myKeypad the setHoldTime method
myKeypad.setHoldTime(1000);
this will set the Hold time for your specific instance of Keypad to 1000
OK - trying to explain this in simple terms - not 100% accurate or complete but will get the point across:
A class is a template, something that defines a concept. here for example the concept of a Keypad.
An instance is an object in real life. like your physical keypad you touch, in your experiment
you are instantiating the class to get an object you can then manipulate. if you had two keyPads, you would then create a second instance with a different name and each object (or instance) would have it's own attributes (instance variables). For example which pins they are connected to, which keys are represented, the number of rows and cols.
when you develop a class, you can define public methods (public = they can be called from outside the class) that applies to an instance of that class (the physical object). For example if you had two keyPads, you could set the HoldTime to 100 for one and to 5000 for the other one. The call applies to your specific object. You have two instances of the same conceptual object (a Keypad) but they have slight differences.
but when you develop a class you can also provide private methods, those are utilities that only the class can use. And in some programming languages, you can also provide class methods which would affect then every single instance of the class.
thanks for that explanation. I understand it in principle, but it is like a different language. I read the example you suggested in link, which explained the creation of a library. I could now repeat that exercise, but without too much knowledge of "why".
But I have now learnt about calling functions using the prefix as you mentioned earlier. I now also understand a bit better how to distinguish the public and private variables (usually and _ before the name) - in the library.