Marvas / Mbed OS rtc_uygulama_Seri_port_ayarlamali
Revision:
5:33ba76bbad1e
Parent:
2:c8b4159048f0
diff -r 3d395620e01a -r 33ba76bbad1e main.cpp
--- a/main.cpp	Fri Jun 23 16:54:10 2017 -0500
+++ b/main.cpp	Sat Dec 22 07:12:50 2018 +0000
@@ -1,34 +1,22 @@
-/* mbed Example Program
- * Copyright (c) 2006-2014 ARM Limited
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
 #include "mbed.h"
 
 int main() {
-    set_time(1256729737);  // Set RTC time to Wed, 28 Oct 2009 11:35:37
+    struct tm t;
+    printf("Asagidaki formatta tarih ve saati girin:\n");
+    printf("YYYY Ay(MM) gun(DD) saat(HH) dakika(MM) saniye(SS)[enter] \n");    
+    scanf("%d %d %d %d %d %d", &t.tm_year, &t.tm_mon, &t.tm_mday
+                             , &t.tm_hour, &t.tm_min, &t.tm_sec);//Seri porttan değer girilmesi beklenir
 
-    while (true) {
+   // tm yapısı gerekli değerleri için ayarlama
+    t.tm_year = t.tm_year - 1900;
+    t.tm_mon = t.tm_mon - 1;
+    
+    // zamanı ayarla
+    set_time(mktime(&t));
+
+    while(1) {    
         time_t seconds = time(NULL);
-        
-        printf("Time as seconds since January 1, 1970 = %d\n", seconds);
-        
-        printf("Time as a basic string = %s", ctime(&seconds));
-
-        char buffer[32];
-        strftime(buffer, 32, "%I:%M %p\n", localtime(&seconds));
-        printf("Time as a custom formatted string = %s", buffer);
-        
+        printf("Tarih ve Saat = %s", ctime(&seconds));
         wait(1);
     }
-}
+}
\ No newline at end of file