Go Down

Topic: Simple code for RTC DS1302 (Read 1 time) previous topic - next topic

1Pats

Jan 05, 2011, 10:59 pm Last Edit: Jan 05, 2011, 11:56 pm by 1Pats Reason: 1
Hi,
I had verified code from nuelectronics.com, http://sheepdogguides.com.
It works, works fine, but it is in format of library, is objects-oriented, uses a lot of macroses . huge amount of includes etc. Class/object in this case means that always full functionality has to be embedded (e.g "time set" functionality even if only time-reading is used...)
Or, in other words ,this code is not simple and readable. Does anybody knows where I can get simple, plain code?  I guess I should  not to invent bicycle here as smbdy already did it instead of me.

PaulS

Quote
Class/object in this case means that always full functionality has to be embedded (e.g "time set" functionality even if only time-reading is used...)

This is an incorrect assumption on your part. Only the functions that are actually used are linked into your program.

1Pats

#2
Jan 06, 2011, 08:12 pm Last Edit: Jan 06, 2011, 08:15 pm by 1Pats Reason: 1
Best way to confirm, is to verify.
Commented one call and result was much shorter. Not only  shorter by calling code, but by whole objects function.
So looks like this c compiler for Arduino  does this optimization as no tricks like pointers to functions an dynamic calls.
Good to know, thank you to pointing to this.

But returning to my initial question - does smbdy can point me to readable code. Supporting n-platforms and versions are good, but simplified version of code also have rights to live. At least to understand for what macroses and type re-definitions are for .

Senso

Open the library files and read it yourself, then copy and paste/port the code to what ever you want.

1Pats

#4
Jan 08, 2011, 12:23 pm Last Edit: Jan 08, 2011, 12:38 pm by 1Pats Reason: 1
Thank you for such smart suggestion

At some point I started to do it in way you suggested. First conclusion - code has includes for almost all possible arduiono libraries. second - you need to know arduino versions and internal architecture, to be able do recompilations of huge amount of macroses in mind, third- it requires knowledge of DS1302 chip, or, at least, serious styding of its specification, forth - coding style is unnecessary complex.

Instead of pretending to be a compiler,  better would be if smbdy with understanding of DS1302 and atmega chips architcture would  present simple analog.

Go Up