This instance will be upgraded to Heptapod 0.31.0 (final) on 2022-05-24 at 14:00 UTC+2 (a few minutes of down time)

Commit 8ac3a647 authored by alex@thinkpad's avatar alex@thinkpad
Browse files

Experimental option to load ML only when holding SET pressed at startup

https://www.magiclantern.fm/forum/index.php?topic=21765.msg198779#msg198779

--HG--
branch : lua_fix
parent b2de18ea98a1
......@@ -460,6 +460,35 @@ static void my_big_init_task()
{
_mem_init();
_find_ml_card();
/* should we require SET for loading ML, or not? */
extern int _set_at_startup;
_set_at_startup = config_flag_file_setting_load("ML/SETTINGS/REQUIRE.SET");
// at this point, gui_main_task should be started and should be able to tell whether SET was pressed at startup
if (magic_off_request != _set_at_startup)
{
/* should we bypass loading ML? */
/* (pressing SET after this point will be ignored) */
magic_off = 1;
#if !defined(CONFIG_NO_ADDITIONAL_VERSION)
/* fixme: enable on all models */
extern char additional_version[];
additional_version[0] = '-';
additional_version[1] = 'm';
additional_version[2] = 'l';
additional_version[3] = '-';
additional_version[4] = 'o';
additional_version[5] = 'f';
additional_version[6] = 'f';
additional_version[7] = '\0';
#endif
/* do not continue loading ML */
return;
}
_load_fonts();
#ifdef CONFIG_HELLO_WORLD
......@@ -876,37 +905,12 @@ my_init_task(int a, int b, int c, int d)
while (!bmp_vram_raw()) msleep(100);
// wait for overriden gui_main_task (but use a timeout so it doesn't break if you disable that for debugging)
for (int i = 0; i < 30; i++)
for (int i = 0; i < 50; i++)
{
if (ml_gui_initialized) break;
msleep(100);
}
msleep(200);
// at this point, gui_main_start should be started and should be able to tell whether SET was pressed at startup
if (magic_off_request)
{
magic_off = 1; // magic off request might be sent later (until ml is fully started), but will be ignored
for (int i = 0; i < 10; i++)
{
if (DISPLAY_IS_ON) break;
msleep(100);
}
bmp_printf(FONT_CANON, 0, 0, "Magic OFF");
info_led_off();
#if !defined(CONFIG_NO_ADDITIONAL_VERSION)
extern char additional_version[];
additional_version[0] = '-';
additional_version[1] = 'm';
additional_version[2] = 'l';
additional_version[3] = '-';
additional_version[4] = 'o';
additional_version[5] = 'f';
additional_version[6] = 'f';
additional_version[7] = '\0';
#endif
return ans;
msleep(50);
}
msleep(50);
task_create("ml_init", 0x1e, 0x4000, my_big_init_task, 0 );
......
......@@ -302,7 +302,6 @@ static MENU_SELECT_FUNC(config_autosave_toggle)
snprintf(autosave_flag_file, sizeof(autosave_flag_file), "%sAUTOSAVE.NEG", get_config_dir());
config_flag_file_setting_save(autosave_flag_file, !!config_autosave);
msleep(50);
config_autosave = !config_flag_file_setting_load(autosave_flag_file);
}
......@@ -856,14 +855,36 @@ static char* config_choose_startup_preset()
}
/* initialized and used in boot-hack.c */
int _set_at_startup = 0;
static MENU_SELECT_FUNC(set_at_startup_toggle)
{
/* this one is a bit hard to integrate with config presets, so it's made global */
const char * flag_file = "ML/SETTINGS/REQUIRE.SET";
config_flag_file_setting_save(flag_file, !_set_at_startup);
_set_at_startup = config_flag_file_setting_load(flag_file);
}
static struct menu_entry cfg_menus[] = {
{
.name = "Config files",
.name = "Config options",
.select = menu_open_submenu,
.update = config_preset_update,
.submenu_width = 710,
.help = "Config auto save, manual save, restore defaults...",
.children = (struct menu_entry[]) {
{
.name = "SET at startup",
.priv = &_set_at_startup,
.max = 1,
.choices = CHOICES("Bypass loading ML", "Required to load ML"),
.select = set_at_startup_toggle,
.icon_type = IT_BOOL,
.help = "[GLOBAL] If you hold the SET button pressed at camera startup:",
.help2 = "Do not load ML if you start the camera with SET pressed (default)\n"
"Load ML only if SET is pressed at startup (optional)"
},
{
.name = "Config preset",
.priv = &config_new_preset_index,
......
......@@ -25,6 +25,9 @@ static MENU_UPDATE_FUNC(set_scrollwheel_display)
}
}
/* config.c */
extern int _set_at_startup;
static struct menu_entry help_menus[] = {
{
.select = menu_nav_help_open,
......@@ -114,6 +117,15 @@ static struct menu_entry help_menus[] = {
.choices = CHOICES("Shortcuts (LV only)"),
},
#endif
{
.select = menu_nav_help_open,
.name = "SET at startup",
.priv = &_set_at_startup,
.max = 1,
.icon_type = IT_ACTION,
.choices = CHOICES("Bypass loading ML", "Required to load ML"),
.help = "To change this setting: Prefs -> Config options",
},
{
.name = "Key Shortcuts",
.select = menu_help_go_to_label,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment