reloj con ds1307 y LCD de 20x4

Dependencies:   RTC-DS1307 TextLCD mbed

Fork of Rtc_Ds1307_Sample by Henry Leinen

Files at this revision

API Documentation at this revision

Comitter:
tony63
Date:
Sun May 01 11:25:30 2016 +0000
Parent:
2:3be003301107
Commit message:
reloj con ds1307 y LCD de 20x4

Changed in this revision

TextLCD.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TextLCD.lib	Sun May 01 11:25:30 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/avallejopo/code/TextLCD/#aba8ab3dde9d
--- a/main.cpp	Wed Jun 26 21:07:13 2013 +0000
+++ b/main.cpp	Sun May 01 11:25:30 2016 +0000
@@ -1,13 +1,46 @@
+/*
+reloj con ds1307 para que el circuitotrabaje bien se hacen las siguientes recomendaciones
+1. ponerle un cristal de un reloj de buena calidad no usar el cristal originalmente instalado..retirelo
+2. retire las resistencias de superficie pull up que son R2 y R3
+3.conforme un circuito externo con dos nuevas pull up de al menos 4.7k a una linea de alimentacion de 3,3v
+4 coloque diodos in4148 con los anodos a masa y cada catodo conectado a las lineas sda y scl
+
+si hace esto el circuito trabajara muy bien
+antes de configurar parar el reloj y despues de configurar darle start al reloj, no lo olvide
+
+el reloj se configura desde la pc
+adicionalmente al ejemplo de mbed este programa imprime en una lcd y pide el dia ya que originalmente solo se
+ajusta a un dia domingo
+
+originalmente trabaja en modo 24 horas seria interesante trabajarlo a modo 12 horas haciendo uno la flag
+bool thm = true;
+de la libreria en la linea 64  Rtc_Ds1307,ccp
+los registros son en bcd
+segundos 00h
+minutos  01h
+horas    02h    bit 6 es el modo 24/12 --0/1.. y el bit 5 es el indicador si la hora es am/pm  0/1
+dia      03h
+date     04h
+mes      05h
+año      06h
+control  07h
+zona de ram 08h-3fh
+
+*/
+
 #include "mbed.h"
 #include "Rtc_Ds1307.h"
+#include "TextLCD.h"
 
+TextLCD lcd(PTB10, PTB11, PTE2, PTE3, PTE4, PTE5, TextLCD::LCD20x4); // rs, e, d4-d7
 //RtcCls rtc(p28, p27, p29, true);
-Rtc_Ds1307 rtc(p28, p27);
+Rtc_Ds1307 rtc(PTE0, PTE1);
 
 Serial pc(USBTX, USBRX, "pc");
 
 char buffer[128];
 int readptr = 0;
+int segundos =0;
 
 int main() {
     char c;
@@ -31,9 +64,19 @@
         if (strncmp(buffer, "read", 4) == 0) {
             //  perform read
             pc.printf("Performing read operation\n");
-            if (rtc.getTime(tm) ) {
-                pc.printf("The current time is : %02d:%02d:%02d\n", tm.hour, tm.min, tm.sec);
-                pc.printf("The current date is : %s, %02d/%02d/%04d\n", rtc.weekdayToString(tm.wday), tm.mon, tm.date, tm.year);
+   lop1:        if (rtc.getTime(tm) ) {
+                //pc.printf("The current time is : %02d:%02d:%02d\n", tm.hour, tm.min, tm.sec);
+                //pc.printf("The current date is : %s, %02d/%02d/%04d\n", rtc.weekdayToString(tm.wday), tm.mon, tm.date, tm.year);
+                    
+                lcd.cls();
+                lcd.locate(0,0);
+                lcd.printf("%02d:%02d:%02d", tm.hour, tm.min, tm.sec);
+                lcd.locate(0,1);
+                lcd.printf("%s/%02d/%02d/%4d", rtc.weekdayToString(tm.wday), tm.date, tm.mon, tm.year);
+                wait_ms(200);
+                goto lop1;
+    
+                 
             }
             
         }
@@ -51,6 +94,8 @@
             pc.scanf("%d", &tm.min);
             pc.printf("Enter the time (seconds 0..59)");
             pc.scanf("%d", &tm.sec);
+            pc.printf("Enter the day (sunday=1)");
+            pc.scanf("%d", &tm.wday);
             pc.printf("Performing write operation\n");
             
             while(pc.readable())