RTC ds 1307 code explanation

#include <WProgram.h>
#include <Wire.h>
#include <DS1307.h> // written by  mattt on the Arduino forum and modified by D. Sjunnesson
 
void setup()
{
  Serial.begin(9600);
 
  RTC.stop();
  RTC.set(DS1307_SEC,1);        //set the seconds
  RTC.set(DS1307_MIN,23);     //set the minutes
  RTC.set(DS1307_HR,12);       //set the hours
  RTC.set(DS1307_DOW,4);       //set the day of the week
  RTC.set(DS1307_DATE,5);       //set the date
  RTC.set(DS1307_MTH,3);        //set the month
  RTC.set(DS1307_YR,9);         //set the year
  RTC.start();
 
}
 
void loop()
{
 
  Serial.print(RTC.get(DS1307_HR,true)); 
  Serial.print(":");
  Serial.print(RTC.get(DS1307_MIN,false));
  Serial.print(":");
  Serial.print(RTC.get(DS1307_SEC,false));
  Serial.print("      ");                 
  Serial.print(RTC.get(DS1307_DATE,false));
  Serial.print("/");
  Serial.print(RTC.get(DS1307_MTH,false));
  Serial.print("/");
  Serial.print(RTC.get(DS1307_YR,false)); 
  Serial.println();
 
  delay(1000);

I get a sample coding RTC ds 1307, but I am confused about this coding explanation, why only (DS1307_HR, true)) true and the other false?

is there anything that can help me explain the coding?

please help me

If you look at the function deifinition you may understand :)

int DS1307::get(int c, boolean refresh)  // aquire individual RTC item from buffer, return as int, refresh buffer if required
{
  if(refresh) read();
  ...

Weird, if it was me I would make that read() function available and do

RTC.read();
Serial.print(RTC.get(DS1307_HR)); 
Serial.print(":");
Serial.print(RTC.get(DS1307_MIN));
...

More clear this way...

guix: If you look at the function deifinition you may understand :)

int DS1307::get(int c, boolean refresh)  // aquire individual RTC item from buffer, return as int, refresh buffer if required
{
  if(refresh) read();
  ...

Weird, if it was me I would make that read() function available and do

RTC.read();
Serial.print(RTC.get(DS1307_HR)); 
Serial.print(":");
Serial.print(RTC.get(DS1307_MIN));
...

More clear this way...

why weird? I do not understand, could be explained a little more

You use that second parameter when you want to tell the library to read new values from the DS1307, for example if you read the time every second then every second you must call the "RTC.get' function with that second parameter set to true (that's why I say it's a weird way to request an update)... What about RTFM :)

@Fightforjuly, please do not cross-post.

[quote author=Coding Badly link=topic=169200.msg1258927#msg1258927 date=1369886822]

@Fightforjuly, please do not cross-post.

[/quote]

i'm sorry sir...