PaulStoffregen / DS1307RTC

Use a DS1307 Real Time Clock chip with the Time library
http://www.pjrc.com/teensy/td_libs_DS1307RTC.html
143 stars 86 forks source link

Add sqw line handling #3

Open lx1 opened 8 years ago

lx1 commented 8 years ago

Add a function to set the chip sqw line

PaulStoffregen commented 8 years ago

I intend to merge this, but I'd really like to see a somewhat more "Ardiuno like" API.

Can you change this to swqOutput(uint32_t frequency), where "frequency" is the actual output frequency in Hz, rather than arbitrary integers? I know that will make the code somewhat less efficient, but I believe it's important to try using input numbers people can understand when they look at the code whenever possible.

lx1 commented 8 years ago

Hi Paul,

Thank you for your answer. I'm not an expert, so please forgive me for not having a clear idea of what an "Arduino like" API should be. I agree not to use arbitrary integers to select the frequency. But from what I understand of the DS1307 datasheet, only 4 particular frequencies are selectable for SQW/OUT pin: 1HZ, 4096, 8192, and 32768. So I created the sqwOutput(uint32_t frequency) function, but it only accepts these values (and 0, which means no pulsing on the pin). I left the sqw() function, but now I use it for raw setting of the control register.

Thanks