Преглед изворни кода

Display alarm fixed! Bug- sometimes cant exit alarm with esc button

guusvdongen пре 9 година
родитељ
комит
b11303d156
4 измењених фајлова са 39 додато и 11 уклоњено
  1. 28 4
      displayHandler.c
  2. 4 4
      main.c
  3. 6 2
      network.c
  4. 1 1
      vs10xx.c

+ 28 - 4
displayHandler.c

@@ -63,17 +63,41 @@ void displayDate(int line_number) {
 void displayAlarm(int line_number, int line_numberTwo, int idx)
 {
 	int i;
-    char str[12];
+	int j;
+	int startidx;
+    char str[16];
 	struct _alarm am = getAlarm(idx);
+	
     sprintf(str, "    %02d:%02d:%02d    ", am.time.tm_hour, am.time.tm_min, am.time.tm_sec);
     if (line_number > -1 && line_number < 2){
-        (*write_display_ptr[line_number])(str, 12);
+        (*write_display_ptr[line_number])(str, 16);
     }
     playStream(am.ip, am.port, am.url);
 
+	j = 0;
     char str2[16];
-	for(i = 0; i < 17; i++){
-		str2[i] = am.name[i];
+	for (i = 0; i < 16;i++){
+		if (am.name[i] != 0){
+			j = j + 1;
+		}
+	}
+	
+	if (j != 16){
+		startidx = (8-(j/2));
+	}
+	printf("startidx: %d, %d",startidx, j);
+	j = 0;
+	for(i = 0; i < 16; i++){
+		if (i >= startidx){
+			if (am.name[j] != 0){
+				str2[i] = am.name[j];
+			} else {
+				str2[i] = ' ';
+			}
+			j++;
+		} else {
+			str2[i] = ' ';
+		}
 	}
     if (line_numberTwo > -1 && line_numberTwo < 2){
         (*write_display_ptr[line_numberTwo])(str2, 16);

+ 4 - 4
main.c

@@ -308,12 +308,12 @@ 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);
+    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,"    test5678      ", "0.0.0.0","", 8001,1,0,1);*/
 
 /*    if(hasNetworkConnection() == true){
         playStream("145.58.53.152", 80, "/3fm-bb-mp3");
@@ -363,7 +363,7 @@ int main(void)
         }
         else if(timer(start) >= 5 && checkAlarms() == 1)
         {
-			for (idx = 0; idx < 3; idx++){
+			for (idx = 0; idx < 2; idx++){
 				if (getState(idx) == 1){
 					displayAlarm(0,1,idx);
 					if (KbGetKey() == KEY_ESC){

+ 6 - 2
network.c

@@ -140,7 +140,11 @@ void parseAlarmJson(char* content){
         char url[24];
         char ip[24];
         char name[16];
-        int id;
+		memset(url, 0, 24);
+		memset(ip, 0, 24);
+		memset(name, 0, 16);
+        
+		int id;
         for (i = i; !((i + start) % 23 == 0); i++) {
             if (jsoneq(content, &token[i], "YYYY") == 0) {
                 time.tm_year= getIntegerToken(content, &token[i + 1]) - 1900;
@@ -173,7 +177,7 @@ void parseAlarmJson(char* content){
                 getStringToken(content, &token[i + 1], url);
                 i++;
             }else if (jsoneq(content, &token[i], "name") == 0) {
-                getStringToken(name, &token[i + 1], name);
+                getStringToken(content, &token[i + 1], name);
                 i++;
             }
         }

+ 1 - 1
vs10xx.c

@@ -513,7 +513,7 @@ int VsPlayerKick(void)
 //        LogMsg_P(LOG_DEBUG,PSTR("Kick: CLOCKF = [0x%02X]"),VsRegRead(VS_CLOCKF_REG));
 //        LogMsg_P(LOG_DEBUG,PSTR("Kick: CLOCKF = [0x%02X]"),VsRegRead(VS_CLOCKF_REG));
 
-        //VsLoadProgramCode();
+        VsLoadProgramCode();
         vs_status = VS_STATUS_RUNNING;
         VsPlayerFeed(NULL);
         VsPlayerInterrupts(1);