ソースを参照

Merge branch 'developer' into Twitch

# Conflicts:
#	contentparser.c
#	displayHandler.c
#	displayHandler.h
#	jsmn.c
#	main.c
jancoow 9 年 前
コミット
62df55ce10
18 ファイル変更191 行追加325 行削除
  1. 16 9
      alarm.c
  2. 7 7
      alarm.h
  3. 8 7
      contentparser.c
  4. 0 60
      display.c
  5. 63 57
      displayHandler.c
  6. 19 7
      displayHandler.h
  7. 4 1
      jsmn.c
  8. 0 13
      keyboard.c
  9. 1 1
      keyboard.h
  10. 47 113
      main.c
  11. 7 6
      mp3stream.c
  12. 3 2
      mp3stream.h
  13. 5 2
      network.c
  14. 4 4
      network.h
  15. 4 22
      ntp.c
  16. 3 3
      ntp.h
  17. 0 3
      uart0driver.c
  18. 0 8
      vs10xx.c

+ 16 - 9
alarm.c

@@ -4,6 +4,7 @@
 #include <string.h>
 #include <time.h>
 #include <assert.h>
+#include <math.h>
 
 #include "log.h"
 #include "rtc.h"
@@ -27,9 +28,10 @@ int checkAlarms(){
 	int i = 0;
 	int check = 0;
 	for (i = 0; i < n; i++){
-		setState(i);
 		if (alarm[i].time.tm_year == 0){
 			alarm[i].state = 0;
+		}else{
+			setState(i);
 		}
 		if (alarm[i].state == 1){
 			check = 1;
@@ -52,8 +54,18 @@ int alarmExist(int id){
 	return -1;
 }
 
-struct _alarm getAlarm(int idx){
-	return alarm[idx];
+struct _alarm* getAlarm(int idx){
+	return &alarm[idx];
+}
+
+char getRunningAlarmID(){
+	char idx;
+	for (idx = 0; idx < 5; idx++) {
+		if (getState(idx) == 1) {
+			return idx;
+		}
+	}
+	return -1;
 }
 
 int getState(int idx){
@@ -164,12 +176,7 @@ void setState(int idx){
 	}
 }
 
-/*void getAlarm(struct _alarm *am){
-	int i = 0;
-	for (i = 0; i < n; i++){
-		am[i] = alarm[i]; 
-	}
-}*/
+
 
 void setAlarm(struct _tm time, char* name, char* ip, u_short port, char* url, int snooze, int id, int idx){
 	alarm[idx].time = time;

+ 7 - 7
alarm.h

@@ -1,10 +1,7 @@
 /* Alarm get/set status values */
-#define ALARM_1 	5
-#define ALARM_2		6
-
-#define AFLGS		0b11111111
 
 #ifndef _ALARM_DEFINED
+#define _ALARM_DEFINED
 struct _alarm
 {
 	struct _tm time;
@@ -16,8 +13,6 @@ struct _alarm
 	int id;
 	int state;
 };
-#define _ALARM_DEFINED
-#endif
 
 void handleAlarm(int idx);
 int checkAlarms(void);
@@ -27,4 +22,9 @@ void deleteAlarm(int idx);
 int compareTime(tm t1, tm t2);
 void setState(int idx);
 int getState(int idx);
-struct _alarm getAlarm(int idx);
+struct _alarm* getAlarm(int idx);
+char getRunningAlarmID();
+int maxAlarms(void);
+int isLeapYear(int y);
+void setSnooze(int idx);
+#endif

+ 8 - 7
contentparser.c

@@ -14,7 +14,9 @@ int streamid;
 
 void parseAlarmJson(char* content){
     int r;
-    int i = 2;
+    int i;
+    int usedAlarms[maxAlarms()];
+    int j;
     jsmn_parser p;
     jsmntok_t token[160]; /* We expect no more than 128 tokens */
 
@@ -27,16 +29,15 @@ void parseAlarmJson(char* content){
         printf("Aantal tokens found: %d \n", r);
     }
 
-    int usedAlarms[maxAlarms()];
-    int j;
+
     struct _tm time = GetRTCTime();
     for(j = 0; j < maxAlarms(); j++){
         usedAlarms[j] = 0;
     }
-    for(i; i < r; i++)
+    for(i = 2; i < r; i++)
     {
-        int id;
-        u_short port;
+        int id = 0;
+        u_short port = 0;
         char url[24];
         char ip[24];
         char name[16];
@@ -46,7 +47,7 @@ void parseAlarmJson(char* content){
         memset(ip, 0, 24);
         memset(name, 0, 17);
 
-        for (i; (st == -1 && i < r); i+=2) {                                //Zodra oo is gevonden, betekent dit de laatste token van een alarm.
+        for (i = i; (st == -1 && i < r); i+=2) {                                //Zodra ST is gevonden, betekent dit de laatste token van een alarm.
             if (jsoneq(content, &token[i], "YYYY") == 0) {
                 time.tm_year= getIntegerToken(content, &token[i + 1]) - 1900;
             }else if (jsoneq(content, &token[i], "MM") == 0) {

+ 0 - 60
display.c

@@ -42,33 +42,6 @@ static void LcdWriteByte(u_char, u_char);
 static void LcdWriteNibble(u_char, u_char);
 static void LcdWaitBusy(void);
 
-int timerLCD(u_char Mode){
-    time_t Start;
-    if(Mode == startLCD)
-    {
-            time_t diff = time(0) - Start;
-            return diff;
-    }
-    else if(Mode == stopLCD)
-    {
-        Start = time(0);
-    }
-}
-/*!
- * \addtogroup Display
- */
-
-/*@{*/
-
-/*-------------------------------------------------------------------------*/
-/*                         start of code                                   */
-/*-------------------------------------------------------------------------*/
-
-/* ����������������������������������������������������������������������� */
-/*!
- * \brief control backlight
- */
-/* ����������������������������������������������������������������������� */
 void LcdBackLight(u_char Mode)
 {
     if (Mode==LCD_BACKLIGHT_ON)
@@ -82,39 +55,6 @@ void LcdBackLight(u_char Mode)
     }
 }
 
-
-/* ����������������������������������������������������������������������� */
-
-/*
- * Lcdbacklight knipperen
- */
-
-void LcdBacklightKnipperen(u_char Mode)
-{
-    time_t Start;
-    time_t Stop;
-    if (Mode==startLCD)
-    {
-        sbi(LCD_BL_PORT, LCD_BL_BIT);   // Turn on backlight
-        timer(Start);
-    }
-    if (Mode==stopLCD)
-    {
-        cbi(LCD_BL_PORT, LCD_BL_BIT);   // Turn off backlight
-        timer(Stop);
-    }
-}
-/*
-
-/* ����������������������������������������������������������������������� */
-/*!
- * \brief Write a single character on the LCD
- *
- * Writes a single character on the LCD on the current cursor position
- *
- * \param LcdChar character to write
- */
-/* ����������������������������������������������������������������������� */
 void LcdChar(char MyChar)
 {
     LcdWriteByte(WRITE_DATA, MyChar);

+ 63 - 57
displayHandler.c

@@ -1,8 +1,6 @@
 //
 // Created by Jordy Sipkema on 26/02/16.
 //
-#define LOG_MODULE  LOG_MAIN_MODULE
-
 #include <stdlib.h>
 #include <string.h>
 #include <time.h>
@@ -11,73 +9,94 @@
 #include "displayHandler.h"
 #include "ntp.h"
 #include "log.h"
+#include "mp3stream.h"
 #include "rtc.h"
 #include "alarm.h"
 #include "network.h"
 
-#define MONTH_OFFSET 1
-#define YEAR_OFFSET 1900
-
-bool displayingCustomMessage = false;
+struct _tm lastDisplayTime;
+viewDisplays currentViewDisplay;
+u_long displayTime;
 
-void (*write_display_ptr[2])(char*, int) = {LcdArrayLineOne, LcdArrayLineTwo};
+void setCurrentDisplay(viewDisplays d, u_long dt){
+    X12RtcGetClock(&lastDisplayTime);
+    LcdBackLight(LCD_BACKLIGHT_ON);
+    currentViewDisplay = d;
+    displayTime = dt;
+}
 
-void displayTime(int line_number){
-    tm time;
-    X12RtcGetClock(&time);
+viewDisplays getCurrentDisplay(void){
+    return currentViewDisplay;
+}
 
-    char str[16];
-    if (1){
-        sprintf(str, "    %02d:%02d:%02d    ", time.tm_hour, time.tm_min, time.tm_sec);
-    }else {
-        sprintf(str, "    ??:??:??    ");
+void refreshScreen(){
+    if(timerStruct(lastDisplayTime) > displayTime){
+        currentViewDisplay = DISPLAY_DateTime;
+        LcdBackLight(LCD_BACKLIGHT_OFF);
     }
 
-    if (line_number > -1 && line_number < 2){
-        (*write_display_ptr[line_number])(str, 16);
+    if(currentViewDisplay == DISPLAY_DateTime){
+        displayDateTime();
+    }else if(currentViewDisplay == DISPLAY_Volume){
+        displayVolume();
+    }else if(currentViewDisplay == DISPLAY_Alarm){
+        displayAlarm(getRunningAlarmID());
     }
 }
 
-void displayDate(int line_number) {
-    tm *time;
-    X12RtcGetClock(time);
+long timerStruct(struct _tm s){
+    struct _tm ct;
+    X12RtcGetClock(&ct);
 
-    char str[16];
+    long stime = (s.tm_hour * 3600) + (s.tm_min * 60) + s.tm_sec;
+    long ctime = (ct.tm_hour * 3600) + (ct.tm_min * 60) + ct.tm_sec;
 
-    if (1) {
-        sprintf(str, "   %02d-%02d-%04d      ", time->tm_mday, time->tm_mon + MONTH_OFFSET, time->tm_year + YEAR_OFFSET);
-    } else {
-        sprintf(str, "   ??-??-????      ");
-    }
+    return ctime - stime;
+}
+
+void (*write_display_ptr[2])(char*, int) = {LcdArrayLineOne, LcdArrayLineTwo};
 
+void displayDateTime(void){
+    tm time;
+    X12RtcGetClock(&time);
+
+    char str1[16];
+    char str2[16];
+    if (1){
+        sprintf(str1, "    %02d:%02d:%02d    ", time.tm_hour, time.tm_min, time.tm_sec);
+        sprintf(str2, "   %02d-%02d-%04d      ", time.tm_mday, time.tm_mon + MONTH_OFFSET, time.tm_year + YEAR_OFFSET);
+    }else {
+        sprintf(str1, "    ??:??:??    ");
+        sprintf(str2, "    ??:??:??    ");
+    }
     if (NtpIsSyncing()) {
-       str[1] = 'S';
+        str2[1] = 'S';
     }else if(NetworkIsReceiving()){
-        str[1] = 'N';
+        str2[1] = 'N';
     }
 
-    if (line_number > -1 && line_number < 2){
-        (*write_display_ptr[line_number])(str, 16);
-    }
+    (*write_display_ptr[0])(str1, 16);
+    (*write_display_ptr[1])(str2, 16);
 }
 
-void displayAlarm(int line_number, int line_numberTwo, int idx)
+void displayAlarm(char idx)
 {
+    if(idx == -1){
+        currentViewDisplay = DISPLAY_DateTime;
+    }
 	int i;
 	int j;
 	int startidx;
     char str[16];
-	struct _alarm am = getAlarm(idx);
+    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, 16);
-    }
+    sprintf(str, "    %02d:%02d:%02d    ", am->time.tm_hour, am->time.tm_min, am->time.tm_sec);
+    (*write_display_ptr[0])(str, 16);
 
 	j = 0;
     char str2[16];
 	for (i = 0; i < 16;i++){
-		if (am.name[i] != 0){
+		if (am->name[i] != 0){
 			j = j + 1;
 		}
 	}
@@ -88,8 +107,8 @@ void displayAlarm(int line_number, int line_numberTwo, int idx)
 	j = 0;
 	for(i = 0; i < 16; i++){
 		if (i >= startidx){
-			if (am.name[j] != 0){
-				str2[i] = am.name[j];
+			if (am->name[j] != 0){
+				str2[i] = am->name[j];
 			} else {
 				str2[i] = ' ';
 			}
@@ -98,16 +117,12 @@ void displayAlarm(int line_number, int line_numberTwo, int idx)
 			str2[i] = ' ';
 		}
 	}
-    if (line_numberTwo > -1 && line_numberTwo < 2){
-        (*write_display_ptr[line_numberTwo])(str2, 16);
-        LcdBackLight(LCD_BACKLIGHT_ON);
-    }
-
-
+    (*write_display_ptr[1])(str2, 16);
 }
 
-void displayVolume(int pos)
+void displayVolume()
 {
+    u_char pos = getVolume();
     ClearLcd();
     int i;
     LcdArrayLineOne("     Volume     ", 16);
@@ -118,7 +133,7 @@ void displayVolume(int pos)
     {
         characters[i] = 0xFF;
     }
-        LcdArrayLineTwo(characters,pos);
+    LcdArrayLineTwo(characters,pos);
 }
 
 void displayTwitter(int lineNumber,char text[])
@@ -134,17 +149,8 @@ void displayTwitter(int lineNumber,char text[])
 
 void displayTwitch(char name[], char title[], char game[])
 {
-    displayingCustomMessage = true;
     ClearLcd();
     LcdArrayLineOne(name, strlen(name));
     LcdArrayLineTwo("Streaming", 9);
     LcdBackLight(LCD_BACKLIGHT_ON);
 }
-
-bool isDisplayingCustomMessage(){
-    return displayingCustomMessage;
-}
-
-void setDisplayingCustomMessage(bool value){
-    displayingCustomMessage = value;
-}

+ 19 - 7
displayHandler.h

@@ -6,12 +6,24 @@
 #define MUTLI_OS_BUILD_DISPLAYHANDLER_H
 #include "ntp.h"
 
-void displayTime(int);
-void displayDate(int);
-void displayAlarm(int line_number, int line_numberTwo, int idx);
-void displayVolume(int pos);
-void displayTwitch(char name[], char title[], char game[]);
-bool isDisplayingCustomMessage();
-void setDisplayingCustomMessage(bool value);
+
+#include <time.h>
+#include "alarm.h"
+#define MONTH_OFFSET 1
+#define YEAR_OFFSET 1900
+
+typedef enum {DISPLAY_DateTime, DISPLAY_Alarm, DISPLAY_Volume, DISPLAY_Twitch, DISPLAY_Twitter} viewDisplays;
+
+long timerStruct(struct _tm s);
+void setCurrentDisplay(viewDisplays d, u_long dt);
+viewDisplays getCurrentDisplay(void);
+void refreshScreen(void);
+
+void displayDateTime(void);
+void displayAlarm(char idx);
+void displayVolume();
 void displayTwitter(int lineNumber,char text[]);
+void displayTwitch(char name[], char title[], char game[]);
+
+
 #endif //MUTLI_OS_BUILD_DISPLAYHANDLER_H

+ 4 - 1
jsmn.c

@@ -1,6 +1,9 @@
 #include "jsmn.h"
+#include <stdio.h>
+#include <string.h>
 #include <assert.h>
 
+
 /**
  * Allocates a fresh unused token from the token pull.
  */
@@ -340,4 +343,4 @@ void getStringToken(const char *json, jsmntok_t *tok, char *res, char maxlength)
 		printf("ERROR: String to large! output string length: %d - Input string length: %d - String: %.*s \n", maxlength - 1, (tok->end - tok->start), tok->end - tok->start, json + tok->start);
 		res[0] = '\0';
 	};
-}
+}

+ 0 - 13
keyboard.c

@@ -192,19 +192,6 @@ static u_char KbRemapKey(u_short LongKey)
     }
 }
 
-/* ����������������������������������������������������������������������� */
-/*!
- * \brief Return the repeating property for this key
- *
- * \return 'TRUE' in case the key was repeating, 'FALSE' if not
- *
- */
-/* ����������������������������������������������������������������������� */
-static u_char KbKeyIsRepeating(u_short Key)
-{
-    return(KeyRepeatArray[KbRemapKey(Key)]==KEY_REPEAT);
-}
-
 /* ����������������������������������������������������������������������� */
 /*!
  * \brief set the property of this key to repeating or not-repeating

+ 1 - 1
keyboard.h

@@ -91,7 +91,7 @@
 /*-------------------------------------------------------------------------*/
 void    KbInit(void);
 void  KbScan(void);
-int 	CheckKey();
+int 	CheckKey(void);
 int     KbWaitForKeyEvent(u_long);
 u_char  KbGetKey(void);
 void    KbSetKeyRepeating(u_char, u_char);

+ 47 - 113
main.c

@@ -44,6 +44,7 @@
 #include "system.h"
 #include "typedefs.h"
 #include "uart0driver.h"
+#include "vs10xx.h"
 #include "watchdog.h"
 
 
@@ -69,6 +70,12 @@ static void SysControlMainBeat(u_char);
 /*                         start of code                                   */
 /*-------------------------------------------------------------------------*/
 
+/*-------------------------------------------------------------------------*/
+/* global variable definitions                                             */
+/*-------------------------------------------------------------------------*/
+bool isAlarmSyncing = false;
+bool initialized = false;
+bool running = false;
 
 /*!
  * \brief ISR MainBeat Timer Interrupt (Timer 2 for Mega128, Timer 0 for Mega256).
@@ -82,15 +89,7 @@ static void SysControlMainBeat(u_char);
  */
 static void SysMainBeatInterrupt(void *p)
 {
-
-    /*
-     *  scan for valid keys
-     */
     KbScan();
-
-    if(KbGetKey() != KEY_NO_KEY){
-        LcdBackLight(LCD_BACKLIGHT_ON);
-    }
 }
 
 /*!
@@ -179,14 +178,6 @@ static void SysControlMainBeat(u_char OnOff)
     }
 }
 
-
-/*-------------------------------------------------------------------------*/
-/* global variable definitions                                             */
-/*-------------------------------------------------------------------------*/
-bool isAlarmSyncing = false;
-bool initialized = false;
-bool running = false;
-
 /*-------------------------------------------------------------------------*/
 /* local variable definitions                                              */
 /*-------------------------------------------------------------------------*/
@@ -205,6 +196,18 @@ THREAD(StartupInit, arg)
     NutThreadExit();
 }
 
+THREAD(AlarmCheck, arg)
+{
+    NutThreadSetPriority(100);
+    for(;;){
+        if(checkAlarms() == 1){
+          setCurrentDisplay(DISPLAY_Alarm, 1000);
+        }
+        NutSleep(1000);
+    }
+
+}
+
 THREAD(AlarmSync, arg)
 {
     NutThreadSetPriority(50);
@@ -252,30 +255,9 @@ int timer(time_t start){
     return diff;
 }
 
-long timerStruct(struct _tm s){
-	struct _tm ct;
-	X12RtcGetClock(&ct);
-	
-	long stime = (s.tm_hour * 3600) + (s.tm_min * 60) + s.tm_sec;
-	long ctime = (ct.tm_hour * 3600) + (ct.tm_min * 60) + ct.tm_sec;
-	
-	return ctime - stime;
-}
-
-int checkOffPressed(){
-    if (KbGetKey() != KEY_UNDEFINED){
-        LcdBackLight(LCD_BACKLIGHT_ON);
-        return 1;
-    } else {
-        return 0;
-    }
-}
-
 int main(void)
 {
     struct _tm timeCheck;
-	struct _tm start;
-	int idx = 0;
 
     WatchDogDisable();
 
@@ -301,7 +283,7 @@ int main(void)
 
     NutThreadCreate("BackgroundThread", StartupInit, NULL, 1024);
     NutThreadCreate("BackgroundThread", AlarmSync, NULL, 2500);
-    //NutThreadCreate("BackgroundThread", NTPSync, NULL, 700);
+    NutThreadCreate("BackgroundThread", AlarmCheck, NULL, 256);
     /** Quick fix for turning off the display after 10 seconds boot */
 
 	KbInit();
@@ -316,88 +298,40 @@ int main(void)
 	/* Enable global interrupts */
 	sei();
 	
-	LcdBackLight(LCD_BACKLIGHT_OFF);
-	X12RtcGetClock(&timeCheck);
-	X12RtcGetClock(&start);
+	LcdBackLight(LCD_BACKLIGHT_ON);
+    setCurrentDisplay(DISPLAY_DateTime, 5);
+
+    X12RtcGetClock(&timeCheck);
 
     for (;;)
     {
-		//printf("running = %d, time = %d\n", running, timerStruct(start));
-		
-		if (timerStruct(start) < 0){
-			X12RtcGetClock(&start);
-		}
-		
-		if (timerStruct(timeCheck) < 0){
-			X12RtcGetClock(&timeCheck);
-		}
-		
-		//Check if a button is pressed
-		if (checkOffPressed() == 1){
-			X12RtcGetClock(&start);
-			running = true;
+        //Key detecten
+        if(KbGetKey() != KEY_UNDEFINED){
+            //Backlight aanzetten.
             LcdBackLight(LCD_BACKLIGHT_ON);
-		}
-
-        //If escape is pressed, stop displaying custom message
-        if(KbGetKey() == KEY_ESC){
-            setDisplayingCustomMessage(false);
-        }
-
-		//Check if background LED is on, and compare to timer
-		if (running == true){
-			if (timerStruct(start) >= 10){
-				running = false;
-				LcdBackLight(LCD_BACKLIGHT_OFF);
-			}
-		}
-
-        if(KbGetKey() == KEY_DOWN)
-        {
-            NutSleep(150);
-            X12RtcGetClock(&timeCheck);
-
-            u_char newVolume = volumeDown();
-            displayVolume((int)newVolume);
-        }
-        else if(KbGetKey() == KEY_UP)
-        {
-            NutSleep(150);
-            X12RtcGetClock(&timeCheck);
-
-            u_char newVolume = volumeUp();
-            displayVolume((int)newVolume);
-        }
-        else if(timerStruct(timeCheck) >= 5 && checkAlarms() == 1)
-        {
-			for (idx = 0; idx < 5; idx++){
-				if (getState(idx) == 1){
-					displayAlarm(0,1,idx);
-					if (KbGetKey() == KEY_ESC){
-						//NutDelay(50);
-						handleAlarm(idx);
-						//NutDelay(50);
-						LcdBackLight(LCD_BACKLIGHT_OFF);
-                    } 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);
-                        killPlayerThread();
-                    }
-				}
-			}
-		}else if(isDisplayingCustomMessage() == true){
-            if(timerStruct(timeCheck) >= 5)
-            {
-                setDisplayingCustomMessage(false);
-                LcdBackLight(LCD_BACKLIGHT_OFF);
+            if(getCurrentDisplay() == DISPLAY_Alarm){
+                if(KbGetKey() == KEY_01 || KbGetKey() == KEY_02 || KbGetKey() == KEY_03 || KbGetKey() == KEY_04 || KbGetKey() == KEY_05 || KbGetKey() == KEY_ALT){
+                    setSnooze(getRunningAlarmID());
+                    killPlayerThread();
+                    setCurrentDisplay(DISPLAY_DateTime, 2);
+                }else if(KbGetKey() == KEY_ESC){
+                    handleAlarm(getRunningAlarmID());
+                    killPlayerThread();
+                    setCurrentDisplay(DISPLAY_DateTime, 5);
+                }
+            }else{
+                if(KbGetKey() == KEY_DOWN){
+                    setCurrentDisplay(DISPLAY_Volume, 5);
+                    volumeDown();
+                }else if(KbGetKey() == KEY_UP){
+                    setCurrentDisplay(DISPLAY_Volume, 5);
+                    volumeUp();
+                }
             }
         }
-		else if (timerStruct(timeCheck) >= 5){
-            displayTime(0);
-            displayDate(1);
-		}
-
+        refreshScreen();
         WatchDogRestart();
+        NutSleep(100);
     }
     return(0);
 }

+ 7 - 6
mp3stream.c

@@ -122,7 +122,7 @@ bool play()
     return true;
 }
 
-u_char volumeUp(void)
+void volumeUp(void)
 {
     if (VS_volume >= 16)
         return VS_volume;
@@ -131,11 +131,9 @@ u_char volumeUp(void)
     ++VS_volume;
     VS_volume = VS_volume % 17;
     setVolume();
-
-    return VS_volume;
 }
 
-u_char volumeDown(void)
+void volumeDown(void)
 {
     if (VS_volume <= 0)
         return VS_volume;
@@ -144,8 +142,6 @@ u_char volumeDown(void)
     --VS_volume;
     VS_volume = VS_volume % 17;
     setVolume();
-
-    return VS_volume;
 }
 
 void setVolume(void){
@@ -154,6 +150,11 @@ void setVolume(void){
     printf("- VS_volume level: %d/16\n", VS_volume);
 }
 
+u_char getVolume(void){
+    return VS_volume;
+}
+
+
 void killPlayerThread(void)
 {
     printf("Signal to stop the stream sent.\n");

+ 3 - 2
mp3stream.h

@@ -17,9 +17,10 @@ bool play(void);
 bool connectToStream(char* ipaddr, u_short port, char *radioUrl);
 void killPlayerThread(void);
 
-u_char volumeUp(void);
-u_char volumeDown(void);
+void volumeUp(void);
+void volumeDown(void);
 void setVolume(void); // Do not use this one, this is invoked by volumeUp/Down
+u_char getVolume(void);
 
 
 #endif //MUTLI_OS_BUILD_MP3STREAM_H

+ 5 - 2
network.c

@@ -7,6 +7,7 @@
 #include <sys/confnet.h>
 #include <sys/socket.h>
 #include <netinet/tcp.h>
+#include <sys/types.h>
 
 #include <stdlib.h>
 #include <string.h>
@@ -17,6 +18,8 @@
 
 #include <stdio.h>
 #include <io.h>
+#include <sys/version.h>
+#include <dev/irqreg.h>
 #include <arpa/inet.h>
 #include <pro/dhcp.h>
 #include <pro/sntp.h>
@@ -47,7 +50,7 @@ void NetworkInit() {
 }
 
 char* getMacAdress(){
-    ether_ntoa(confnet.cdn_mac);
+    return ether_ntoa(confnet.cdn_mac);
 }
 
 void httpGet(char address[], void (*parser)(char*)){
@@ -108,4 +111,4 @@ bool NetworkIsReceiving(void){
 
 bool hasNetworkConnection(void){
     return hasNetwork;
-}
+}

+ 4 - 4
network.h

@@ -4,11 +4,11 @@
 
 #ifndef _Network_H
 #define _Network_H
-
-//bool hasNetworkConnection(void);
-//bool NetworkIsReceiving(void);
+#include "typedefs.h"
+bool hasNetworkConnection(void);
+bool NetworkIsReceiving(void);
 extern void NetworkInit(void);
 extern void httpGet(char address[], void (*parser)(char*));
-char* getMacAdress();
+char* getMacAdress(void);
 
 #endif /* _Network_H */

+ 4 - 22
ntp.c

@@ -21,6 +21,8 @@
 #include "log.h"
 #include "ntp.h"
 #include "contentparser.h"
+#include "alarm.h"
+#include "network.h"
 
 int TIME_ZONE = 1;
 #define LOG_MODULE  LOG_NTP_MODULE
@@ -68,7 +70,7 @@ void NtpCheckValidTime(void){
     tm current_tm;
     X12RtcGetClock(&current_tm);
 
-    validTime = NtpCompareTime(current_tm, stored_tm);
+    validTime = compareTime(current_tm, stored_tm);
     if (validTime){
         puts("NtpCheckValidTime(): Time was valid \n");
     }else {
@@ -76,26 +78,6 @@ void NtpCheckValidTime(void){
     }
 }
 
-//Tests if t1 is after t2.
-bool NtpCompareTime(tm t1, tm t2){
-
-    if (t1.tm_year > t2.tm_year)
-        return true;
-    if (t1.tm_mon > t2.tm_mon)
-        return true;
-    if (t1.tm_mday > t2.tm_mday)
-        return true;
-    if (t1.tm_hour > t2.tm_hour)
-        return true;
-    if (t1.tm_min > t2.tm_min)
-        return true;
-    if (t1.tm_sec > t2.tm_sec)
-        return true;
-
-    //else
-    return false;
-}
-
 bool NtpTimeIsValid(void){
     return validTime;
 }
@@ -105,7 +87,7 @@ void NtpSync(void){
     isSyncing = true;
     httpGet("/gettimezone.php", parsetimezone);
     _daylight = 0;
-    printf(TIME_ZONE);
+    printf("Timezone is: %d", TIME_ZONE);
     NutDelay(100);
     //puts("Tijd ophalen van pool.ntp.org (213.154.229.24)");
     timeserver = inet_addr("213.154.229.24");

+ 3 - 3
ntp.h

@@ -6,6 +6,7 @@
 #define _Ntp_H
 
 #include "typedefs.h"
+#include <time.h>
 
 extern bool NtpIsSyncing(void);
 extern void NtpInit(void);
@@ -14,9 +15,8 @@ extern void setTimeZone(int timezone);
 extern bool NtpTimeIsValid(void);
 
 void NtpCheckValidTime(void);
-void NtpWriteTimeToEeprom(tm);
-bool NtpCompareTime(tm, tm);
+void NtpWriteTimeToEeprom(tm time_struct);
 
 void setTimeZone(int timezone);
-int getTimeZone();
+int getTimeZone(void);
 #endif /* _Ntp_H */

+ 0 - 3
uart0driver.c

@@ -106,9 +106,6 @@ THREAD(Uart0KeyEvents, arg)
         result = fgets(result, 16, stream);
         short _reset_received = strcmp(rst, result);
 
-        *rst = "abcde\n";
-        *result = "";
-
         if (_reset_received == 0){
             LogMsg_P(LOG_INFO, PSTR(">>>>>> RESET COMMAND RECEIVED"));
             //RESET SIR!

+ 0 - 8
vs10xx.c

@@ -91,7 +91,6 @@
 /*-------------------------------------------------------------------------*/
 static volatile u_char vs_status = VS_STATUS_STOPPED;
 static u_short g_vs_type;
-static u_char VsPlayMode;
 
 
 static void VsLoadProgramCode(void);
@@ -787,13 +786,6 @@ u_short VsMemoryTest(void)
 int VsSetVolume(u_char left, u_char right)
 {
     u_char ief;
-    if(left < 0){
-        left = 0;
-    }
-    if(right < 0){
-        right = 0;
-    }
-    printf("%d %d", left, right);
 
     ief = VsPlayerInterrupts(0);