|
@@ -183,6 +183,7 @@ static void SysControlMainBeat(u_char OnOff)
|
|
|
/*-------------------------------------------------------------------------*/
|
|
/*-------------------------------------------------------------------------*/
|
|
|
int isAlarmSyncing;
|
|
int isAlarmSyncing;
|
|
|
int initialized;
|
|
int initialized;
|
|
|
|
|
+int running = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------*/
|
|
/*-------------------------------------------------------------------------*/
|
|
@@ -244,8 +245,18 @@ int timer(time_t start){
|
|
|
return diff;
|
|
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(){
|
|
int checkOffPressed(){
|
|
|
- if (KbGetKey() == KEY_POWER){
|
|
|
|
|
|
|
+ if (KbGetKey() == KEY_UNDEFINED){
|
|
|
LcdBackLight(LCD_BACKLIGHT_ON);
|
|
LcdBackLight(LCD_BACKLIGHT_ON);
|
|
|
return 1;
|
|
return 1;
|
|
|
} else {
|
|
} else {
|
|
@@ -259,11 +270,10 @@ int main(void)
|
|
|
{
|
|
{
|
|
|
initialized = 0;
|
|
initialized = 0;
|
|
|
int VOL2;
|
|
int VOL2;
|
|
|
- time_t start;
|
|
|
|
|
|
|
+ struct _tm timeCheck;
|
|
|
|
|
+ struct _tm start;
|
|
|
int idx = 0;
|
|
int idx = 0;
|
|
|
|
|
|
|
|
- int running;
|
|
|
|
|
-
|
|
|
|
|
WatchDogDisable();
|
|
WatchDogDisable();
|
|
|
|
|
|
|
|
NutDelay(100);
|
|
NutDelay(100);
|
|
@@ -286,7 +296,7 @@ int main(void)
|
|
|
|
|
|
|
|
VsPlayerInit();
|
|
VsPlayerInit();
|
|
|
|
|
|
|
|
- LcdBackLight(LCD_BACKLIGHT_ON);
|
|
|
|
|
|
|
+
|
|
|
NtpInit();
|
|
NtpInit();
|
|
|
|
|
|
|
|
NutThreadCreate("BackgroundThread", StartupInit, NULL, 1024);
|
|
NutThreadCreate("BackgroundThread", StartupInit, NULL, 1024);
|
|
@@ -318,23 +328,33 @@ int main(void)
|
|
|
/* if(hasNetworkConnection() == true){
|
|
/* if(hasNetworkConnection() == true){
|
|
|
playStream("145.58.53.152", 80, "/3fm-bb-mp3");
|
|
playStream("145.58.53.152", 80, "/3fm-bb-mp3");
|
|
|
}*/
|
|
}*/
|
|
|
- start = time(0) - 10;
|
|
|
|
|
unsigned char VOL = 64;
|
|
unsigned char VOL = 64;
|
|
|
-
|
|
|
|
|
- running = 1;
|
|
|
|
|
|
|
+
|
|
|
|
|
+ X12RtcGetClock(&timeCheck);
|
|
|
|
|
+ X12RtcGetClock(&start);
|
|
|
|
|
+ LcdBackLight(LCD_BACKLIGHT_OFF);
|
|
|
|
|
|
|
|
for (;;)
|
|
for (;;)
|
|
|
{
|
|
{
|
|
|
|
|
+
|
|
|
|
|
+ if (timerStruct(start) < 0){
|
|
|
|
|
+ X12RtcGetClock(&start);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (timerStruct(timeCheck) < 0){
|
|
|
|
|
+ X12RtcGetClock(&timeCheck);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
//Check if a button is pressed
|
|
//Check if a button is pressed
|
|
|
if (checkOffPressed() == 1){
|
|
if (checkOffPressed() == 1){
|
|
|
- start = time(0);
|
|
|
|
|
|
|
+ X12RtcGetClock(&start);
|
|
|
running = 1;
|
|
running = 1;
|
|
|
- LcdBacklightKnipperen(startLCD);
|
|
|
|
|
|
|
+ LcdBacklight(LCD_BACKLIGHT_ON);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//Check if background LED is on, and compare to timer
|
|
//Check if background LED is on, and compare to timer
|
|
|
if (running == 1){
|
|
if (running == 1){
|
|
|
- if (timer(start) >= 10){
|
|
|
|
|
|
|
+ if (timerStruct(start) >= 10 || running > 1){
|
|
|
running = 0;
|
|
running = 0;
|
|
|
LcdBackLight(LCD_BACKLIGHT_OFF);
|
|
LcdBackLight(LCD_BACKLIGHT_OFF);
|
|
|
}
|
|
}
|
|
@@ -344,7 +364,7 @@ int main(void)
|
|
|
if(KbGetKey() == KEY_DOWN)
|
|
if(KbGetKey() == KEY_DOWN)
|
|
|
{
|
|
{
|
|
|
NutSleep(150);
|
|
NutSleep(150);
|
|
|
- start = time(0);
|
|
|
|
|
|
|
+ X12RtcGetClock(&timeCheck);
|
|
|
if(VOL > 8){
|
|
if(VOL > 8){
|
|
|
VOL -= 8;
|
|
VOL -= 8;
|
|
|
VsSetVolume (128-VOL, 128-VOL);
|
|
VsSetVolume (128-VOL, 128-VOL);
|
|
@@ -354,14 +374,14 @@ int main(void)
|
|
|
else if(KbGetKey() == KEY_UP)
|
|
else if(KbGetKey() == KEY_UP)
|
|
|
{
|
|
{
|
|
|
NutSleep(150);
|
|
NutSleep(150);
|
|
|
- start = time(0);
|
|
|
|
|
|
|
+ X12RtcGetClock(&timeCheck);
|
|
|
if(VOL < 128) {
|
|
if(VOL < 128) {
|
|
|
VOL += 8;
|
|
VOL += 8;
|
|
|
VsSetVolume(128-VOL, 128-VOL);
|
|
VsSetVolume(128-VOL, 128-VOL);
|
|
|
displayVolume(VOL/8);
|
|
displayVolume(VOL/8);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- else if(timer(start) >= 5 && checkAlarms() == 1)
|
|
|
|
|
|
|
+ else if(timerStruct(timeCheck) >= 5 && checkAlarms() == 1)
|
|
|
{
|
|
{
|
|
|
for (idx = 0; idx < 2; idx++){
|
|
for (idx = 0; idx < 2; idx++){
|
|
|
if (getState(idx) == 1){
|
|
if (getState(idx) == 1){
|
|
@@ -371,12 +391,16 @@ int main(void)
|
|
|
handleAlarm(idx);
|
|
handleAlarm(idx);
|
|
|
NutDelay(50);
|
|
NutDelay(50);
|
|
|
LcdBackLight(LCD_BACKLIGHT_OFF);
|
|
LcdBackLight(LCD_BACKLIGHT_OFF);
|
|
|
|
|
+ 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();
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- else if (timer(start) >= 5){
|
|
|
|
|
|
|
+ else if (timerStruct(timeCheck) >= 5){
|
|
|
displayTime(0);
|
|
displayTime(0);
|
|
|
displayDate(1);
|
|
displayDate(1);
|
|
|
}
|
|
}
|