Hi thanks for the replys.
I think I haven´t explained my problem properly.
So I´ll try once again.
I´m using the RTC and a 4D System Display (with the Libary from ReiVilos HP : http://sites.google.com/site/vilorei/arduino/13--serial-touch-320x240-lcd-screen)where I´m displaying the time from the RTC and a touchbutton to trigger the setTime of the RTC.
#include <Serial_LCD.h>
#include <proxySerial.h>
#include <button.h>
#include <Wire.h>
#include <Time.h>
#include <DS1307RTC.h>
#include "NewSoftSerial.h"
NewSoftSerial myNSS(2, 3);
ProxySerial mySerial(&myNSS);
Serial_LCD myLCD( &mySerial); //Init myLCD
uint16_t x, y; //Touchcoordinates
button bStop( &myLCD); //init buttonStop
button bSetTime( &myLCD); //init buttonSetTime
void setup() { //Setup
Serial.begin(19200);
Serial.print("\n\n\n***\n");
// // === Serial port initialisation
// // --- SoftwareSerial Case - Arduino only
myNSS.begin(9600);
Serial.print("SoftwareSerial\t");
Serial.print("\n");
myLCD.begin(); //start myLCD
delay(10);
myLCD.setSpeed(38400);
// // === Serail port speed up
// // --- SoftwareSerial Case - Arduino only
myNSS.begin(38400);
myLCD.setOrientation(0x03); // sets the orientation of the Display
myLCD.setPenSolid(true);
myLCD.setFontSolid(true);
myLCD.setFont(0);
myLCD.gText( 0, 210, 0xffff, myLCD.WhoAmI());
myLCD.setTouch(true); // activate Touch
// Button Stop
bStop.define( 0, 0, 79, 59, "Stop", myLCD.rgb16(0xff, 0xff, 0xff), myLCD.rgb16(0x00, 0xff, 0x00), myLCD.rgb16(0x88, 0x00, 0xff), 9);
bStop.enable(true);
bStop.draw();
// Button Set Time
bSetTime.define( 80, 0, 79, 59, "Set Time", myLCD.rgb16(0xff, 0xff, 0xff), myLCD.rgb16(0x00, 0xff, 0x00), myLCD.rgb16(0x88, 0x00, 0xff), 9);
bSetTime.enable(true);
bSetTime.draw();
setSyncProvider(RTC.get); // the function to get the time from the RTC
if(timeStatus()!= timeSet)
Serial.println("Unable to sync with the RTC");
else
Serial.println("RTC has set the system time");
delay(10);
}
uint8_t c;
void loop() {
c=myLCD.getTouchActivity();
myGetTime(); // shows actual Time
if (c>0) {
myLCD.getTouchXY(x, y);
// quit
if (bStop.check()) {
myLCD.off();
while(true);
}
// if buttonSetTime is pressed set the Time
if ( bSetTime.check()) {
mySetTime();
}
}
}
void myGetTime(){
String strTime = "Zeit: "; //my TimeString
if(hour() < 10) // hour with leading 0 if < 10
strTime += "0";
strTime += hour();
strTime += ":";
if(minute() < 10) // minute with leading 0 if < 10
strTime += "0";
strTime += minute();
strTime += ":";
if(second() < 10) // second with leading 0 if < 10
strTime += "0";
strTime += second();
strTime += " "; // Leerzeichen als Abstandhalter zum Datum
if(day() < 10) //day with leading 0 if < 10
strTime += "0";
strTime += day();
strTime += ".";
if(month() < 10) //month with leading 0 if < 10
strTime += "0";
strTime += month();
strTime += ".";
strTime += year(); //year
Serial.println(strTime); //print to serial
// uint8_t gText(uint16_t x, uint16_t y, uint16_t colour, String s); // Draw ‚String 53hex
myLCD.setFont(0);
myLCD.setFontSolid(true);
myLCD.gText( 10, 220, 0xffff, strTime ); // print to 4D Display
}
void mySetTime(){
setTime(15, 42, 0, 28, 11, 2011); // set Time to 15:42:00 28.11.2011
}
And know when I reset the Arduino board and I have the
setSyncProvider(RTC.get); // the function to get the time from the RTC
if(timeStatus()!= timeSet)
Serial.println("Unable to sync with the RTC");
else
Serial.println("RTC has set the system time");
delay(10);
in the Setup {} the time is reset to 00:00:00 31.12.1999 and when
setSyncProvider(RTC.get); // the function to get the time from the RTC
if(timeStatus()!= timeSet)
Serial.println("Unable to sync with the RTC");
else
Serial.println("RTC has set the system time");
delay(10);
is not in the Setup{} the RTC is reset to 00:00:00 1.1.1970
I hope the description is clearer know.
And now I will try the hint of James C4S to call the RTC.set();
Stefan