BS2p40 with DS1307
NewBee
Posts: 35
Can some one help me with this piece of code.
'
[noparse][[/noparse] Variables ]
day············ VAR···· Byte··················· ' weekday
pntr··········· VAR···· Byte··················· ' ee pointer
'
[noparse][[/noparse] EEPROM Data ]
DayNames······· DATA··· "SunMonTueWedThuFriSat"
· pntr = DayNames + ((day - 1) * 3)············ ' point to 1st char
I don't understand how DayNames as a string of eprom data is being used in the formula.
Thanks,
Bob
'
[noparse][[/noparse] Variables ]
day············ VAR···· Byte··················· ' weekday
pntr··········· VAR···· Byte··················· ' ee pointer
'
[noparse][[/noparse] EEPROM Data ]
DayNames······· DATA··· "SunMonTueWedThuFriSat"
· pntr = DayNames + ((day - 1) * 3)············ ' point to 1st char
I don't understand how DayNames as a string of eprom data is being used in the formula.
Thanks,
Bob
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
Daynames is being used by the compiler to track the Eeprom ADDRESS location
Daynames ALSO contains all of the names of the weekdays in 3 letter/byte format.
Day is deing used by YOU the user to select the day you want from inside the DAYNAMES location.
You need the *3 to move from name to name.
By using Daynames, you don't have to know where pntr has to point.
the compiler will handle that for you.
In the end, pntr ends up telling you where to read your 3 bytes/letters you specified·in·Day.
One last thing ... since Sun is first. it's day one... (Can't use zero, don't forget the -1 )
hope this helps.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Before you criticize someone, walk a mile in his shoes. That way if he gets angry, he'll be a mile away and barefoot. - unknown
Post Edited (sumdawgy) : 6/10/2010 3:33:18 PM GMT