2017-09-26 15:44:10 +00:00
|
|
|
#include <msp430.h>
|
|
|
|
|
|
|
|
#include "apps.h"
|
|
|
|
#include "lcdtext.h"
|
|
|
|
|
|
|
|
#include "applist.h"
|
|
|
|
|
2017-09-26 16:59:02 +00:00
|
|
|
//! We begin on the clock.
|
2017-09-26 17:25:50 +00:00
|
|
|
static int appindex=0, idlecount=0;
|
|
|
|
|
|
|
|
//! Every 3 minutes we return to the clock unless this is called.
|
|
|
|
void app_cleartimer(){
|
|
|
|
idlecount=0;
|
|
|
|
}
|
2017-09-26 15:44:10 +00:00
|
|
|
|
|
|
|
//! Renders the current app to the screen.
|
2017-09-26 16:59:02 +00:00
|
|
|
void app_draw(){
|
2017-09-26 17:25:50 +00:00
|
|
|
static int lastmin=0;;
|
|
|
|
|
2017-09-26 15:44:10 +00:00
|
|
|
void (*tocall)(void)=apps[appindex].draw;
|
2017-09-26 17:25:50 +00:00
|
|
|
|
|
|
|
//If we go three minutes without action, return to main screen.
|
|
|
|
if(lastmin!=RTCMIN){
|
|
|
|
lastmin=RTCMIN;
|
|
|
|
idlecount++;
|
|
|
|
}
|
|
|
|
if(idlecount>3){
|
|
|
|
app_cleartimer();
|
|
|
|
appindex=0;
|
|
|
|
}
|
|
|
|
|
|
|
|
//Call the cap if it exists, or switch to the clock if we're at the
|
|
|
|
//end of the list.
|
2017-09-26 15:44:10 +00:00
|
|
|
if(tocall)
|
|
|
|
tocall();
|
|
|
|
else
|
|
|
|
appindex=0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-09-26 16:59:02 +00:00
|
|
|
//! Renders the current app to the screen.
|
|
|
|
void app_init(){
|
|
|
|
void (*tocall)(void)=apps[appindex].init;
|
|
|
|
if(tocall)
|
|
|
|
tocall();
|
|
|
|
else
|
|
|
|
appindex=0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
//! Move to the next application.
|
|
|
|
void app_next(){
|
|
|
|
void (*tocall)(void)=apps[++appindex].draw;
|
2017-09-26 17:25:50 +00:00
|
|
|
|
|
|
|
//Clear the 3-minute timer when we switch apps.
|
|
|
|
app_cleartimer();
|
|
|
|
|
2017-09-26 16:59:02 +00:00
|
|
|
if(!tocall)
|
|
|
|
appindex=0;
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|