/* loadsave values: * 0 : Load Model * 1 : Save Model * 2 : Load Template * 3 : Load Icon * 4 : Load Layout */ void MODELPage_ShowLoadSave(int loadsave, void(*return_page)(int page)) { u8 num_models = 0; PAGE_RemoveAllObjects(); PAGE_SetModal(1); mp->return_page = return_page; _show_buttons(loadsave); if (loadsave == LOAD_TEMPLATE) { //Template num_models = count_files("template", ".ini", NULL); mp->selected = 1; } else if (loadsave == LOAD_ICON) { //Icon mp->selected = 0; num_models = 1 + count_files("modelico", ".bmp", Model.icon[0] ? Model.icon+9 : NULL); const char *ico = mp->selected == 0 ? CONFIG_GetIcon(Model.type) : CONFIG_GetCurrentIcon(); strlcpy(mp->iconstr, ico, sizeof(mp->iconstr)); mp->selected++; } else if (loadsave == LOAD_LAYOUT) { //Layout mp->selected = 1; num_models = count_files("layout", ".ini", "default.ini"); mp->file_state = num_models; num_models += model_count(); } else { num_models = model_count(); strlcpy(mp->iconstr, CONFIG_GetCurrentIcon(), sizeof(mp->iconstr)); if (loadsave == SAVE_MODEL) mp->selected = 0; else mp->selected = CONFIG_GetCurrentModel(); } _show_list(loadsave, num_models); }
static void select_cb(guiObject_t *obj, u16 sel, void *data) { (void)obj; (void)data; const char *ico; mp->selected = sel + 1; if(! OBJ_IS_USED(&gui->image)) return; if ((long)data == LOAD_ICON) { ico = CONFIG_GetIcon(mp->modeltype); if (sel > 0 && FS_OpenDir("modelico")) { char filename[13]; int count = 0; int type; while((type = FS_ReadDir(filename)) != 0) { if (type == 1 && strncasecmp(filename + strlen(filename) - 4, ".bmp", 4) == 0) { count++; if (sel == count) { CONFIG_ParseIconName(mp->iconstr, filename); ico = mp->iconstr; break; } } } FS_CloseDir(); } } else { sprintf(tempstring, "models/model%d.ini", mp->selected); mp->modeltype = 0; mp->iconstr[0] = 0; ini_parse(tempstring, ini_handle_icon, NULL); if (mp->selected == CONFIG_GetCurrentModel() && Model.icon[0]) ico = Model.icon; else { if (mp->iconstr[0]) ico = mp->iconstr; else ico = CONFIG_GetIcon(mp->modeltype); } if (! fexists(ico)) ico = UNKNOWN_ICON; } GUI_ReplaceImage(&gui->image, ico, 0, 0); }
static void okcancel_cb(guiObject_t *obj, const void *data) { int msg = (long)data; (void)obj; if (msg == LOAD_MODEL + 1) { /* Load Model */ if (mp->selected != CONFIG_GetCurrentModel()) { // don't do that if model didn't change CONFIG_SaveModelIfNeeded(); PROTOCOL_DeInit(); CONFIG_ReadModel(mp->selected); CONFIG_SaveTxIfNeeded(); //Save here to ensure in case of crash we restart on the right model /* Need to recalculate channels to see if we're in a safe state */ MIXER_Init(); MIXER_CalcChannels(); PROTOCOL_Init(0); } } else if (msg == SAVE_MODEL + 1) { /* Save Model */ CONFIG_WriteModel(mp->selected); CONFIG_ReadModel(mp->selected); //Reload the model after saving to switch (for future saves) } else if (msg == LOAD_TEMPLATE + 1) { /* Load Template */ get_idx_filename(tempstring, "template", ".ini", mp->selected-1, ""); CONFIG_ReadTemplate(tempstring); } else if (msg == LOAD_ICON + 1) { if (mp->selected == 1) Model.icon[0] = 0; else strcpy(Model.icon, mp->iconstr); } else if (msg == LOAD_LAYOUT + 1) { /* Load Layout */ if (mp->selected > mp->file_state) { sprintf(tempstring, "models/model%d.ini", mp->selected - mp->file_state); } else { get_idx_filename(tempstring, "layout", ".ini", mp->selected-1, "layout/"); } CONFIG_ReadLayout(tempstring); } PAGE_SetModal(0); PAGE_RemoveAllObjects(); mp->return_page(-1); // -1 for devo10 means return to the focus of previous page, which is important so that users don't need to scroll down from the 1st item }
static const char *string_cb(u8 idx, void *data) { (void)data; FILE *fh; if ((long)data == LOAD_TEMPLATE) { //Template if (! get_idx_filename(tempstring, "template", ".ini", idx, "template/")) return _tr("Unknown"); } else if ((long)data == LOAD_ICON) { //Icon if (idx == 0) return _tr("Default"); if (! get_idx_filename(tempstring, "modelico", ".bmp", idx-1, "")) return _tr("Unknown"); return tempstring; } else if ((long)data == LOAD_LAYOUT) { if (idx >= mp->file_state) sprintf(tempstring, "models/model%d.ini", idx + 1 - mp->file_state); else if (! get_idx_filename(tempstring, "layout", ".ini", idx, "layout/")) return _tr("Unknown"); } else { if (idx + 1 == CONFIG_GetCurrentModel()) { sprintf(tempstring, "%d: %s%s", idx + 1, Model.name, CONFIG_IsModelChanged() ? " (unsaved)" : ""); return tempstring; } sprintf(tempstring, "models/model%d.ini", idx + 1); } fh = fopen(tempstring, "r"); sprintf(tempstring, "%d: NONE", idx + 1); if (fh) { long user = idx + 1; if ((long)data == LOAD_TEMPLATE) user = -user; ini_parse_file(fh, ini_handle_name, (void *)user); fclose(fh); } if ((long)data == LOAD_LAYOUT && idx >= mp->file_state) strcat(tempstring + strlen(tempstring), "(M)"); return tempstring; }
int main() { Init(); #ifndef MODULAR //Banner(); #endif if(PWR_CheckPowerSwitch()) PWR_Shutdown(); LCD_Clear(0x0000); #ifdef TEST_ADC ADC_ScanChannels(); while(1); #endif u32 buttons = ScanButtons(); if(CHAN_ButtonIsPressed(buttons, BUT_ENTER) || !FS_Mount(NULL, NULL)) { LCD_DrawUSBLogo(LCD_WIDTH, LCD_HEIGHT); USB_Connect(); LCD_Clear(0x0000); FS_Mount(NULL, NULL); } CONFIG_LoadTx(); SPI_ProtoInit(); CONFIG_ReadDisplay(); CONFIG_ReadModel(CONFIG_GetCurrentModel()); CONFIG_ReadLang(Transmitter.language); BACKLIGHT_Brightness(Transmitter.backlight); LCD_Contrast(Transmitter.contrast); LCD_SetFont(DEFAULT_FONT.font); LCD_SetFontColor(DEFAULT_FONT.font_color); #if !HAS_EXTENDED_AUDIO // If Extended Audio is present, move startup msg to Splash page to allow additional audio hardware initialization time MUSIC_Play(MUSIC_STARTUP); #else if (Transmitter.splash_delay < 5) MUSIC_Play(MUSIC_STARTUP); // if no splash page startup msg is used force playing here #endif GUI_HandleButtons(1); MIXER_Init(); PAGE_Init(); CLOCK_StartWatchdog(); #if HAS_DATALOG DATALOG_Init(); #endif priority_ready = 0; CLOCK_SetMsecCallback(LOW_PRIORITY, LOW_PRIORITY_MSEC); CLOCK_SetMsecCallback(MEDIUM_PRIORITY, MEDIUM_PRIORITY_MSEC); // We need to wait until we've actually measured the ADC before proceeding while(! (priority_ready & (1 << LOW_PRIORITY))) ; //Only do this after we've initialized all channel data so the saftey works PROTOCOL_InitModules(); GUI_DrawScreen(); #ifdef HAS_EVENT_LOOP start_event_loop(); #else while(1) { if(priority_ready) { EventLoop(); } //This does not appear to have any impact on power //and has been disabled in common/devo/power.c //but it helps a huge amount for the emulator PWR_Sleep(); } #endif }
int main() { Init(); #ifndef MODULAR //Banner(); #endif if(PWR_CheckPowerSwitch()) PWR_Shutdown(); LCD_Clear(0x0000); #ifdef TEST_ADC ADC_ScanChannels(); while(1); #endif u32 buttons = ScanButtons(); if(CHAN_ButtonIsPressed(buttons, BUT_ENTER) || !FS_Mount(NULL, NULL)) { LCD_DrawUSBLogo(LCD_WIDTH, LCD_HEIGHT); USB_Connect(); LCD_Clear(0x0000); FS_Mount(NULL, NULL); } CONFIG_LoadTx(); SPI_ProtoInit(); CONFIG_ReadDisplay(); CONFIG_ReadModel(CONFIG_GetCurrentModel()); CONFIG_ReadLang(Transmitter.language); BACKLIGHT_Brightness(Transmitter.brightness); LCD_Contrast(Transmitter.contrast); LCD_SetFont(DEFAULT_FONT.font); LCD_SetFontColor(DEFAULT_FONT.font_color); MUSIC_Play(MUSIC_STARTUP); GUI_HandleButtons(1); MIXER_Init(); PAGE_Init(); CLOCK_StartWatchdog(); #if DATALOG_ENABLED DATALOG_Init(); #endif priority_ready = 0; CLOCK_SetMsecCallback(LOW_PRIORITY, LOW_PRIORITY_MSEC); CLOCK_SetMsecCallback(MEDIUM_PRIORITY, MEDIUM_PRIORITY_MSEC); // We need to wait until we've actually measured the ADC before proceeding while(! (priority_ready & (1 << LOW_PRIORITY))) ; //Only do this after we've initialized all channel data so the saftey works PROTOCOL_Init(0); GUI_DrawScreen(); #ifdef HAS_EVENT_LOOP start_event_loop(); #else while(1) { if(priority_ready) { EventLoop(); } //PWR_Sleep(); //This does not appear to have any impact on power } #endif }
int main() { Init(); #ifndef ENABLE_MODULAR //Banner(); #endif if(PWR_CheckPowerSwitch()) PWR_Shutdown(); LCD_Clear(0x0000); #ifdef TEST_ADC ADC_ScanChannels(); while(1); #endif u32 buttons = ScanButtons(); if (CHAN_ButtonIsPressed(buttons, BUT_ENTER) || !FS_Init()) { LCD_DrawUSBLogo(LCD_WIDTH, LCD_HEIGHT); USB_Connect(); LCD_Clear(0x0000); FS_Init(); } CONFIG_LoadTx(); SPI_ProtoInit(); CONFIG_ReadDisplay(); CONFIG_ReadModel(CONFIG_GetCurrentModel()); CONFIG_ReadLang(Transmitter.language); BACKLIGHT_Brightness(Transmitter.backlight); LCD_Contrast(Transmitter.contrast); LCD_SetFont(DEFAULT_FONT.font); LCD_SetFontColor(DEFAULT_FONT.font_color); GUI_HandleButtons(1); MIXER_Init(); PAGE_Init(); CLOCK_StartWatchdog(); #if HAS_DATALOG DATALOG_Init(); #endif priority_ready = 0; CLOCK_SetMsecCallback(LOW_PRIORITY, LOW_PRIORITY_MSEC); CLOCK_SetMsecCallback(MEDIUM_PRIORITY, MEDIUM_PRIORITY_MSEC); // We need to wait until we've actually measured the ADC before proceeding while(! (priority_ready & (1 << LOW_PRIORITY))) PWR_Sleep(); //Only do this after we've initialized all channel data so the saftey works PROTOCOL_InitModules(); GUI_DrawScreen(); // Add startup delay to make sure audio player is initialized // AUDIO_Init() has already been called by CONFIG_ReadModel() #if HAS_EXTENDED_AUDIO audio_queue_time = CLOCK_getms() + 1500; num_audio=1; next_audio=1; #if (LCD_WIDTH == 480) || (LCD_WIDTH == 320) if(Display.background.drawn_background) while(CLOCK_getms() < audio_queue_time - 1200); #endif AUDIO_SetVolume(); // Initial setting of voice volume #endif MUSIC_Play(MUSIC_STARTUP); #ifdef HAS_EVENT_LOOP start_event_loop(); #else while(1) { if(priority_ready) { EventLoop(); } //This does not appear to have any impact on power //and has been disabled in common/devo/power.c //but it helps a huge amount for the emulator PWR_Sleep(); } #endif }