I'm using a ds1307 chip to bring real time into my Ard Pro Mini and someone posted some code out here in 2008 that looks like what I want. However I don't exactly understand the syntax that's being used here. My problem is that I do need to change hex values from the ds1307 to dec values and I'm having a problem doing this so far. This is the code that I think I need to utilize but I don't exactly understand it's syntax:
This was posted by windmis in 2008. My questions are as follows:
On this code what's going on with the double colon, "::" ?
After byte there appears to be a function name and then a variable or vice versa, how does this work? ie, "byte DS1305::bcdToDec".
After the function name there are three variables in the parenthesis, "(const byte bcd)" . I guess this is a variable, datatype, variable ?
.
Your help would be appreciated. Thank you,
.
Tim
The :: indicates that you have a method bcdToDec of the class DS1305. If you have an object of this class, you can access this functions as:
DS1305 foo;
...
int baz = foo.bcdToDec (35);
The "const byte bcd" just means there's one parameter called bcd of type byte which isn't expected to changed inside the function (the const part). The last const is mostly a hint for the optimiser so that it knows it can do nasty things without having to worry about restoring the original value.
robtillaart and Korman thank you for your advice. This will certainly help. And the reference to the function syntax was a magic bullet. Thanks guys!
.
Tim