while (1) {
Read_Time(&sec,&min1,&hr,&week_day,&day,&mn,&year); // citaj podatoci od RTC(DS1307)
if(Button(&PORTB,3,1,0)){
number1 = number1 + 1;
ShortToStr(number1, prv);
MMC_Fat_Assign(&filename, 0);
MMC_Fat_Append(); // Prepare file for append
MMC_RTC_Data[0] = ((hr >> 4) + 48);
MMC_RTC_Data[1] = ((hr & 0x0F) + 48);
MMC_RTC_Data[2] = ':';
MMC_RTC_Data[3] = ((min1 >> 4) + 48);
MMC_RTC_Data[4] = ((min1 & 0x0F) + 48);
MMC_RTC_Data[5] = ':';
MMC_RTC_Data[6] = ((sec >> 4) + 48);
MMC_RTC_Data[7] = ((sec & 0x0F) + 48);
MMC_Fat_Write(MMC_RTC_Data, 8); //write data to the assigned file
MMC_Fat_Write(tab1, 5);
MMC_Fat_Write(prv, 5);
MMC_Fat_Write(rtrn,4);
}
Display_init1();
if(Button(&PORTB,1,1,0)){
number2 = number2 + 1;
ShortToStr(number2, vtor);
MMC_Fat_Assign(&filename, 0);
MMC_Fat_Append(); // Prepare file for append
MMC_RTC_Data[0] = ((hr >> 4) + 48);
MMC_RTC_Data[1] = ((hr & 0x0F) + 48);
MMC_RTC_Data[2] = ':';
MMC_RTC_Data[3] = ((min1 >> 4) + 48);
MMC_RTC_Data[4] = ((min1 & 0x0F) + 48);
MMC_RTC_Data[5] = ':';
MMC_RTC_Data[6] = ((sec >> 4) + 48);
MMC_RTC_Data[7] = ((sec & 0x0F) + 48);
MMC_Fat_Write(MMC_RTC_Data, 8); //write data to the assigned file
MMC_Fat_Write(tab2, 19);
MMC_Fat_Write(vtor, 5);
MMC_Fat_Write(rtrn,4);
}
Display_init2();
if(Button(&PORTB,0,1,0)){
number3 = number3 + 1;
MMC_Fat_Assign(&filename, 0);
MMC_Fat_Append(); // Prepare file for append
MMC_RTC_Data[0] = ((hr >> 4) + 48);
MMC_RTC_Data[1] = ((hr & 0x0F) + 48);
MMC_RTC_Data[2] = ':';
MMC_RTC_Data[3] = ((min1 >> 4) + 48);
MMC_RTC_Data[4] = ((min1 & 0x0F) + 48);
MMC_RTC_Data[5] = ':';
MMC_RTC_Data[6] = ((sec >> 4) + 48);
MMC_RTC_Data[7] = ((sec & 0x0F) + 48);
MMC_Fat_Write(MMC_RTC_Data, 8); //write data to the assigned file
MMC_Fat_Write(rtrn,4);
}
Display_init3();
Transform_Time(&sec,&min1,&hr,&week_day,&day,&mn,&year); // formatiraj gi
Display_Time(sec, min1, hr, day, mn, year); // prikazigi na LCD
Delay_ms(150); // cekaj 50 ms
}