guusvdongen 9 anos atrás
pai
commit
e83a495ac3
4 arquivos alterados com 14 adições e 41 exclusões
  1. 1 11
      alarm.c
  2. 3 4
      displayHandler.c
  3. 10 9
      main.c
  4. 0 17
      ntp.c

+ 1 - 11
alarm.c

@@ -173,17 +173,7 @@ void deleteAlarm(int idx){
 }
 
 void handleAlarm(int idx){
-		if ((alarm[idx].time.tm_mday + 1) <= daysInMonth((alarm[idx].time.tm_mon+1), (alarm[idx].time.tm_year+1900))){ 
-		alarm[idx].time.tm_mday += 1;
-	} else {
-		alarm[idx].time.tm_mday = 1;
-		if ((alarm[idx].time.tm_mon + 1) > 11){					
-			alarm[idx].time.tm_mon = 0;
-			alarm[idx].time.tm_year += 1;
-		} else {
-			alarm[idx].time.tm_mon += 1;
-		}
-	}
+	alarm[idx].time.tm_mday += 1;
 	alarm[idx].state = 0;
 }
 

+ 3 - 4
displayHandler.c

@@ -26,7 +26,7 @@ void displayTime(int line_number){
     X12RtcGetClock(&time);
 
     char str[16];
-    if (NtpTimeIsValid()){
+    if (1){
         sprintf(str, "    %02d:%02d:%02d    ", time.tm_hour, time.tm_min, time.tm_sec);
     }else {
         sprintf(str, "    ??:??:??    ");
@@ -43,7 +43,7 @@ void displayDate(int line_number) {
 
     char str[16];
 
-    if (NtpTimeIsValid()) {
+    if (1) {
         sprintf(str, "   %02d-%02d-%04d      ", time->tm_mday, time->tm_mon + MONTH_OFFSET, time->tm_year + YEAR_OFFSET);
     } else {
         sprintf(str, "   ??-??-????      ");
@@ -72,7 +72,7 @@ void displayAlarm(int line_number, int line_numberTwo, int idx)
     if (line_number > -1 && line_number < 2){
         (*write_display_ptr[line_number])(str, 16);
     }
-    playStream(am.ip, am.port, am.url);
+    //playStream(am.ip, am.port, am.url);
 
 	j = 0;
     char str2[16];
@@ -85,7 +85,6 @@ void displayAlarm(int line_number, int line_numberTwo, int idx)
 	if (j != 16){
 		startidx = (8-(j/2));
 	}
-	printf("startidx: %d, %d",startidx, j);
 	j = 0;
 	for(i = 0; i < 16; i++){
 		if (i >= startidx){

+ 10 - 9
main.c

@@ -256,7 +256,7 @@ long timerStruct(struct _tm s){
 }
 
 int checkOffPressed(){
-    if (KbGetKey() == KEY_UNDEFINED){
+    if (KbGetKey() != KEY_UNDEFINED){
         LcdBackLight(LCD_BACKLIGHT_ON);
         return 1;
     } else {
@@ -318,24 +318,25 @@ int main(void)
 	/* Enable global interrupts */
 	sei();
 
-    /*struct _tm tm;
+    struct _tm tm;
 	tm = GetRTCTime();
 	tm.tm_sec += 10;
-    setAlarm(tm,"    test1234      ", "0.0.0.0","", 8001,1,0,0);
-	tm.tm_sec +=20;
-	setAlarm(tm,"    test5678      ", "0.0.0.0","", 8001,1,0,1);*/
+    setAlarm(tm,"test1234", "0.0.0.0","", 8001,1,0,0);
+	//tm.tm_sec +=20;
+	//setAlarm(tm,"    test5678      ", "0.0.0.0","", 8001,1,0,1);*/
 
 /*    if(hasNetworkConnection() == true){
         playStream("145.58.53.152", 80, "/3fm-bb-mp3");
     }*/
     unsigned char VOL = 64;
 	
+	LcdBackLight(LCD_BACKLIGHT_OFF);
 	X12RtcGetClock(&timeCheck);
 	X12RtcGetClock(&start);
-	LcdBackLight(LCD_BACKLIGHT_OFF);
 
     for (;;)
     {
+		printf("running = %d, time = %d\n", running, timerStruct(start));
 		
 		if (timerStruct(start) < 0){
 			X12RtcGetClock(&start);
@@ -349,7 +350,7 @@ int main(void)
 		if (checkOffPressed() == 1){
 			X12RtcGetClock(&start);
 			running = 1;
-            LcdBacklight(LCD_BACKLIGHT_ON);
+            LcdBackLight(LCD_BACKLIGHT_ON);
 		}
 
 		//Check if background LED is on, and compare to timer
@@ -391,11 +392,11 @@ int main(void)
 						handleAlarm(idx);
 						NutDelay(50);
 						LcdBackLight(LCD_BACKLIGHT_OFF);
-                        stopStream();
+                        //stopStream();
 					} else if (KbGetKey() == KEY_01 || KbGetKey() == KEY_02 || KbGetKey() == KEY_03 || KbGetKey() == KEY_04 || KbGetKey() == KEY_05 || KbGetKey() == KEY_ALT){
 						setSnooze(idx);
 						LcdBackLight(LCD_BACKLIGHT_OFF);
-                        stopStream();
+                        //stopStream();
 					}
 				}
 			}

+ 0 - 17
ntp.c

@@ -77,23 +77,6 @@ void NtpCheckValidTime(void){
 
 //Tests if t1 is after t2.
 bool NtpCompareTime(tm t1, tm t2){
-    char debug[120];
-    sprintf(&debug, "Comparing two times\nt1=%04d-%02d-%02d+%02d:%02d:%02d\nt2=%04d-%02d-%02d+%02d:%02d:%02d \n",
-            t1.tm_year+1900,
-            t1.tm_mon+1,
-            t1.tm_mday,
-            t1.tm_hour,
-            t1.tm_min,
-            t1.tm_sec,
-
-            t2.tm_year+1900,
-            t2.tm_mon+1,
-            t2.tm_mday,
-            t2.tm_hour,
-            t2.tm_min,
-            t2.tm_sec
-    );
-    puts(debug);
 
     if (t1.tm_year > t2.tm_year)
         return true;