2011-05-21 10:05:48 +00:00
|
|
|
#include <sysinit.h>
|
2011-06-13 21:39:21 +00:00
|
|
|
#include "basic/basic.h"
|
2011-05-21 10:05:48 +00:00
|
|
|
|
2011-07-17 00:00:02 +00:00
|
|
|
#include "lcd/lcd.h"
|
2011-07-18 16:19:22 +00:00
|
|
|
#include "lcd/fonts/smallfonts.h"
|
2011-07-17 00:00:02 +00:00
|
|
|
#include "lcd/print.h"
|
|
|
|
#include "filesystem/ff.h"
|
2011-07-23 21:47:42 +00:00
|
|
|
#include "basic/random.h"
|
2011-07-17 00:00:02 +00:00
|
|
|
|
2011-05-21 10:05:48 +00:00
|
|
|
/**************************************************************************/
|
|
|
|
|
2011-06-20 21:33:42 +00:00
|
|
|
void main_default(void) {
|
2011-07-26 22:25:24 +00:00
|
|
|
systickInit(SYSTICKSPEED);
|
2011-07-04 20:49:35 +00:00
|
|
|
|
|
|
|
if(getInputRaw()==BTN_ENTER){
|
2011-07-18 20:09:31 +00:00
|
|
|
ISPandReset();
|
2011-07-04 20:49:35 +00:00
|
|
|
};
|
|
|
|
|
2011-07-26 22:57:36 +00:00
|
|
|
readConfig();
|
|
|
|
applyConfig();
|
2011-07-24 14:03:19 +00:00
|
|
|
randomInit();
|
2011-07-17 00:00:02 +00:00
|
|
|
|
2011-05-21 10:05:48 +00:00
|
|
|
return;
|
2011-06-13 21:19:18 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// every 10 ms
|
|
|
|
void tick_default(void) {
|
|
|
|
static int ctr;
|
|
|
|
ctr++;
|
2011-07-24 13:44:35 +00:00
|
|
|
incTimer();
|
2011-07-26 22:25:24 +00:00
|
|
|
if(ctr>1000/SYSTICKSPEED){
|
2011-07-25 21:26:18 +00:00
|
|
|
if(!adcMutex){
|
|
|
|
VoltageCheck();
|
|
|
|
LightCheck();
|
2011-07-25 21:41:26 +00:00
|
|
|
ctr=0;
|
|
|
|
}else{
|
|
|
|
ctr--;
|
2011-07-25 21:26:18 +00:00
|
|
|
};
|
2011-06-13 21:19:18 +00:00
|
|
|
};
|
2011-07-23 23:51:28 +00:00
|
|
|
|
|
|
|
if(isNight())
|
2011-07-26 23:15:52 +00:00
|
|
|
backlightSetBrightness(globalconfig.backlightvalue);
|
2011-07-23 23:51:28 +00:00
|
|
|
else
|
|
|
|
backlightSetBrightness(0);
|
|
|
|
|
2011-07-26 22:25:24 +00:00
|
|
|
if(ctr%(50/SYSTICKSPEED)==0){
|
2011-07-09 20:47:38 +00:00
|
|
|
|
|
|
|
if(GetVoltage()<3600
|
|
|
|
#ifdef SAFE
|
|
|
|
|| GetVoltage() > 10000 // pin not connected
|
|
|
|
#endif
|
|
|
|
){
|
2011-06-13 21:39:21 +00:00
|
|
|
IOCON_PIO1_11 = 0x0;
|
|
|
|
gpioSetDir(RB_LED3, gpioDirection_Output);
|
2011-07-26 22:25:24 +00:00
|
|
|
if( (ctr/(50/SYSTICKSPEED))%10 == 1 )
|
2011-06-13 21:39:21 +00:00
|
|
|
gpioSetValue (RB_LED3, 1);
|
|
|
|
else
|
|
|
|
gpioSetValue (RB_LED3, 0);
|
|
|
|
};
|
|
|
|
};
|
2011-06-13 21:19:18 +00:00
|
|
|
|
|
|
|
return;
|
|
|
|
};
|