Pages: [1]   Go Down
Author Topic: Simple code for RTC DS1302  (Read 1863 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 13
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
« Last Edit: January 05, 2011, 05:56:52 pm by 1Pats » Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 617
Posts: 49463
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 13
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 .
« Last Edit: January 06, 2011, 02:15:45 pm by 1Pats » Logged

Portugal
Offline Offline
God Member
*****
Karma: 6
Posts: 962
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

0
Offline Offline
Newbie
*
Karma: 0
Posts: 13
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
« Last Edit: January 08, 2011, 06:38:11 am by 1Pats » Logged

Pages: [1]   Go Up
Jump to: