DS3234 RTC Programming issues.

Hello I have been playing around with my new 4D systems touch screen and ive been running into some issues sending the time and date to my touch screen. The touch screens using the arduino UART lines for communication.

I have been using the sparkfun arduino example which sends out the time and date via "ReadTimeDate()" the problem with that is that the touch screens onboard processor will only understand single data stream e.g int Hour = 12 instead of "ReadTimeDate()" which is as shown below.

temp.concat(TimeDate[4]);
temp.concat("/") ;
temp.concat(TimeDate[5]);
temp.concat("/") ;
temp.concat(TimeDate[6]);
temp.concat(" ") ;
temp.concat(TimeDate[2]);
temp.concat(":") ;
temp.concat(TimeDate[1]);
temp.concat(":") ;
temp.concat(TimeDate[0]);

How would I go around splitting "ReadTimeDate()" into seperate int's i.e Hour, Minutes, Seconds, Day, Month, Year, so i can sent it to the touch screen.I have added the sparkfun example code below.

#include <SPI.h>
const int cs=10; //chip select

void setup() {
  Serial.begin(9600);
  RTC_init();
  //day(1-31), month(1-12), year(0-99), hour(0-23), minute(0-59), second(0-59)
  SetTimeDate(11,12,13,14,15,16);
}

void loop() {
  Serial.println(ReadTimeDate());
  delay(1000);
}
//=====================================
int RTC_init(){
pinMode(cs,OUTPUT); // chip select
// start the SPI library:
SPI.begin();
SPI.setBitOrder(MSBFIRST);
SPI.setDataMode(SPI_MODE3); // both mode 1 & 3 should work
//set control register
digitalWrite(cs, LOW);
SPI.transfer(0x8E);
SPI.transfer(0x60); //60= disable Osciallator and Battery SQ wave @1hz, temp compensation, Alarms disabled
digitalWrite(cs, HIGH);
delay(10);
}
//=====================================
int SetTimeDate(int d, int mo, int y, int h, int mi, int s){
int TimeDate [7]={s,mi,h,0,d,mo,y};
for(int i=0; i<=6;i++){
if(i==3)
i++;
int b= TimeDate[i]/10;
int a= TimeDate[i]-b*10;
if(i==2){
if (b==2)
b=B00000010;
else if (b==1)
b=B00000001;
}	
TimeDate[i]= a+(b<<4);

digitalWrite(cs, LOW);
SPI.transfer(i+0x80);
SPI.transfer(TimeDate[i]);
digitalWrite(cs, HIGH);
  }
}
//=====================================
String ReadTimeDate(){
String temp;
int TimeDate [7]; //second,minute,hour,null,day,month,year
for(int i=0; i<=6;i++){
if(i==3)
i++;
digitalWrite(cs, LOW);
SPI.transfer(i+0x00);
unsigned int n = SPI.transfer(0x00);
digitalWrite(cs, HIGH);
int a=n & B00001111;
if(i==2){	
int b=(n & B00110000)>>4; //24 hour mode
if(b==B00000010)
b=20;
else if(b==B00000001)
b=10;
TimeDate[i]=a+b;
}
else if(i==4){
int b=(n & B00110000)>>4;
TimeDate[i]=a+b*10;
}
else if(i==5){
int b=(n & B00010000)>>4;
TimeDate[i]=a+b*10;
}
else if(i==6){
int b=(n & B11110000)>>4;
TimeDate[i]=a+b*10;
}
else{	
int b=(n & B01110000)>>4;
TimeDate[i]=a+b*10;

}
}
temp.concat(TimeDate[4]);
temp.concat("/") ;
temp.concat(TimeDate[5]);
temp.concat("/") ;
temp.concat(TimeDate[6]);
temp.concat(" ") ;
temp.concat(TimeDate[2]);
temp.concat(":") ;
temp.concat(TimeDate[1]);
temp.concat(":") ;
temp.concat(TimeDate[0]);
  return(temp);
}

Thank you for your time.

There is part of RTC DS3132 communication that I use, so you may be inspired

#include <Wire.h>
#define CHRONODOT_ADDRESS 104
#define MAX_TEMPERATURE_EXCEED 111.11   // Celsius, bad sensor if exceed
int rtc_day;
int rtc_hour;
int rtc_minute;
int rtc_month;
int rtc_second;
int rtc_weekday;
int rtc_year;
bool RTCworking = false;
///////////////////////////////////////////////////////////////////////////////
byte decToBcd(byte val)
{
  return ( (val/10*16) + (val%10) );
};
byte bcdToDec(byte val)
{
  return ( (val/16*10) + (val%16) );
};
bool set_rtc_datum()
 {
 Wire.beginTransmission(CHRONODOT_ADDRESS);
 Wire.write(3);//set register to day
 Wire.write(decToBcd(rtc_weekday));
 Wire.write(decToBcd(rtc_day));
 Wire.write(decToBcd(rtc_month));
 Wire.write(decToBcd(rtc_year-2000));
 if (Wire.endTransmission() == 0) {
 return true; 
 }
 else{
 return false;  
 };
 };
 bool set_rtc_time()
 {
 Wire.beginTransmission(CHRONODOT_ADDRESS);
 Wire.write(0);//set register to time
 Wire.write(decToBcd(rtc_second));
 Wire.write(decToBcd(rtc_minute));
 Wire.write(decToBcd(rtc_hour));
 if (Wire.endTransmission() == 0) {
 return true;  
 }
 else{
 return false;  
 };
 };
bool get_rtc_datum()
{
  Wire.beginTransmission(CHRONODOT_ADDRESS);
  Wire.write(3);//set register to day
  Wire.endTransmission();
  if (Wire.requestFrom(CHRONODOT_ADDRESS, 4) == 4) { //get 4 bytes(day,date,month,year);
    rtc_weekday = bcdToDec(Wire.read());
    rtc_day     = bcdToDec(Wire.read());
    rtc_month   = bcdToDec(Wire.read());
    rtc_year    = bcdToDec(Wire.read())+2000;
    RTCworking  = true;
    return true;
  }
  else{
    RTCworking = false;
    return false;
  };
};
bool get_rtc_time()
{
  Wire.beginTransmission(CHRONODOT_ADDRESS);
  Wire.write(0);//set register to time
  Wire.endTransmission();
  if (Wire.requestFrom(CHRONODOT_ADDRESS, 3) == 3) { //get 3 bytes (seconds,minutes,hours);
    rtc_second = bcdToDec(Wire.read() & 0x7f);
    rtc_minute = bcdToDec(Wire.read());
    rtc_hour   = bcdToDec(Wire.read() & 0x3f);
    return true;
  }
  else{
    return false;
  };
};
float get_rtc_temperature()
{
  Wire.beginTransmission(CHRONODOT_ADDRESS);
  Wire.write(17);//set register to DS3132 internal temperature sensor
  Wire.endTransmission();
  if (Wire.requestFrom(CHRONODOT_ADDRESS, 2) == 2) {
    float ttc = (float)(int)Wire.read();
    byte portion = Wire.read();
    if(portion == 0b01000000) ttc += 0.25;
    if(portion == 0b10000000) ttc += 0.5;
    if(portion == 0b11000000) ttc += 0.75;
    return ttc;
  }
  else{
    return MAX_TEMPERATURE_EXCEED;
  };
};
///////////////////////////////////////////////////////////////////////////////

@redknight,

if you use the Arduino IDE just hit CTRL-T before saving/copying the file. It will auto-indent the file for you which makes it more readable.

the problem with that is that the touch screens onboard processor will only understand single data stream

No. The crappy code snippet you post only understands the broken out data. You could ditch the String class and that snippet, and learn to use the data that ReadTimeData() creates.

Since you haven't posted the code in ReadTimeData(), you're on your own.

The ReadTimeDate() is located in the second code screen and also added below.

//=====================================
String ReadTimeDate(){
  String temp;
  int TimeDate [7]; //second,minute,hour,null,day,month,year
  for(int i=0; i<=6;i++){
    if(i==3)
      i++;
    digitalWrite(cs, LOW);
    SPI.transfer(i+0x00);
    unsigned int n = SPI.transfer(0x00);
    digitalWrite(cs, HIGH);
    int a=n & B00001111;
    if(i==2){	
      int b=(n & B00110000)>>4; //24 hour mode
      if(b==B00000010)
        b=20;
      else if(b==B00000001)
        b=10;
      TimeDate[i]=a+b;
    }
    else if(i==4){
      int b=(n & B00110000)>>4;
      TimeDate[i]=a+b*10;
    }
    else if(i==5){
      int b=(n & B00010000)>>4;
      TimeDate[i]=a+b*10;
    }
    else if(i==6){
      int b=(n & B11110000)>>4;
      TimeDate[i]=a+b*10;
    }
    else{	
      int b=(n & B01110000)>>4;
      TimeDate[i]=a+b*10;

    }
  }
  temp.concat(TimeDate[4]);
  temp.concat("/") ;
  temp.concat(TimeDate[5]);
  temp.concat("/") ;
  temp.concat(TimeDate[6]);
  temp.concat(" ") ;
  temp.concat(TimeDate[2]);
  temp.concat(":") ;
  temp.concat(TimeDate[1]);
  temp.concat(":") ;
  temp.concat(TimeDate[0]);
  return(temp);
}