2011-07-12 22:07:36 +00:00
|
|
|
#include <sysinit.h>
|
2011-07-14 00:03:27 +00:00
|
|
|
#include <string.h>
|
2011-07-12 22:07:36 +00:00
|
|
|
|
|
|
|
#include "basic/basic.h"
|
|
|
|
#include "lcd/lcd.h"
|
|
|
|
#include "lcd/allfonts.h"
|
2011-07-12 23:13:50 +00:00
|
|
|
#include "lcd/print.h"
|
2011-07-12 22:07:36 +00:00
|
|
|
#include "usb/usbmsc.h"
|
|
|
|
#include "filesystem/ff.h"
|
2011-07-17 00:02:45 +00:00
|
|
|
#include "filesystem/select.h"
|
|
|
|
#include "filesystem/execute.h"
|
2011-07-12 22:07:36 +00:00
|
|
|
|
|
|
|
/**************************************************************************/
|
|
|
|
|
|
|
|
void execute_menu(void){
|
|
|
|
while(getInput()!=BTN_NONE);
|
2011-07-17 00:02:45 +00:00
|
|
|
executeSelect("C0D");
|
2011-07-12 23:13:50 +00:00
|
|
|
lcdRefresh();
|
2011-07-12 22:07:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
void msc_menu(void){
|
|
|
|
DoString(0,8,"MSC Enabled.");
|
2011-07-18 20:09:31 +00:00
|
|
|
lcdDisplay();
|
2011-07-12 22:07:36 +00:00
|
|
|
usbMSCInit();
|
2011-07-12 23:13:50 +00:00
|
|
|
while(!getInputRaw())delayms(10);
|
2011-07-12 22:07:36 +00:00
|
|
|
DoString(0,16,"MSC Disabled.");
|
|
|
|
usbMSCOff();
|
|
|
|
};
|
|
|
|
|
|
|
|
void gotoISP(void) {
|
|
|
|
DoString(0,0,"Enter ISP!");
|
2011-07-18 20:09:31 +00:00
|
|
|
lcdDisplay();
|
|
|
|
ISPandReset();
|
2011-07-12 22:07:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void lcd_mirror(void) {
|
|
|
|
lcdToggleFlag(LCD_MIRRORX);
|
|
|
|
};
|
|
|
|
|
|
|
|
void adc_check(void) {
|
|
|
|
int dx=0;
|
|
|
|
int dy=8;
|
|
|
|
// Print Voltage
|
|
|
|
dx=DoString(0,dy,"Voltage:");
|
|
|
|
while ((getInputRaw())==BTN_NONE){
|
|
|
|
DoInt(dx,dy,GetVoltage());
|
2011-07-18 20:09:31 +00:00
|
|
|
lcdDisplay();
|
2011-07-12 22:07:36 +00:00
|
|
|
};
|
|
|
|
dy+=8;
|
|
|
|
dx=DoString(0,dy,"Done.");
|
|
|
|
};
|
|
|
|
|
|
|
|
/**************************************************************************/
|
|
|
|
|
|
|
|
const struct MENU_DEF menu_ISP = {"Invoke ISP", &gotoISP};
|
|
|
|
const struct MENU_DEF menu_mirror = {"Mirror", &lcd_mirror};
|
|
|
|
const struct MENU_DEF menu_volt = {"Akku", &adc_check};
|
|
|
|
const struct MENU_DEF menu_nop = {"---", NULL};
|
|
|
|
const struct MENU_DEF menu_msc = {"MSC", &msc_menu};
|
|
|
|
const struct MENU_DEF menu_exe = {"Exec", &execute_menu};
|
|
|
|
|
|
|
|
static menuentry menu[] = {
|
|
|
|
&menu_msc,
|
|
|
|
&menu_exe,
|
|
|
|
&menu_nop,
|
|
|
|
&menu_mirror,
|
|
|
|
&menu_volt,
|
|
|
|
&menu_ISP,
|
|
|
|
NULL,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct MENU mainmenu = {"Mainmenu", menu};
|
|
|
|
|
|
|
|
void main_exe(void) {
|
|
|
|
|
|
|
|
lcdSetPixel(0,0,0);
|
|
|
|
|
|
|
|
while (1) {
|
|
|
|
lcdFill(0); // clear display buffer
|
2011-07-18 20:09:31 +00:00
|
|
|
lcdDisplay();
|
2011-07-12 22:07:36 +00:00
|
|
|
handleMenu(&mainmenu);
|
|
|
|
gotoISP();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
void tick_exe(void){
|
|
|
|
static int foo=0;
|
|
|
|
static int toggle=0;
|
|
|
|
if(foo++>50){
|
|
|
|
toggle=1-toggle;
|
|
|
|
foo=0;
|
|
|
|
gpioSetValue (RB_LED0, toggle);
|
|
|
|
};
|
|
|
|
return;
|
|
|
|
};
|
|
|
|
|
|
|
|
|