Commit d64294e9 authored by alex@thinkpad's avatar alex@thinkpad
Browse files

menu.set: relaxed conditions for trying every single string value

(arbitrary durations now working with intervalometer)

--HG--
branch : lua_fix
parent 1900af4e4204
......@@ -427,12 +427,19 @@ function test_menu()
-- note: setting menu by string works by brute force
-- that is, trying every possible value and comparing the string
-- the range for this menu is huge, so it only checks round values
-- for speed reasons (so entering 1m10s will fail)
-- smaller ranges are OK for trying every single value
assert(menu.set("Intervalometer", "Take a pic every", "1m10s"))
assert(menu.get("Intervalometer", "Take a pic every", 0) == 70)
assert(menu.get("Intervalometer", "Take a pic every") == "1m10s")
-- going from 1m10s to 1m30s should be easy
assert(menu.set("Intervalometer", "Take a pic every", "1m30s"))
assert(menu.get("Intervalometer", "Take a pic every", 0) == 90)
assert(menu.get("Intervalometer", "Take a pic every") == "1m30s")
-- going back to 1m10s would have to go through LOTS of intermediate values
assert(menu.set("Intervalometer", "Take a pic every", "1m10s"))
assert(menu.get("Intervalometer", "Take a pic every", 0) == 70)
assert(menu.get("Intervalometer", "Take a pic every") == "1m10s")
sleep(1)
-- actual string will be 10s
......@@ -441,7 +448,8 @@ function test_menu()
assert(menu.get("Intervalometer", "Take a pic every") == "10s")
sleep(1)
-- integer should work as well - e.g. 1m10s should work now
-- integer should work as well, as long as the internal state variable matches the menu value
-- on other menus, where internal state is some index, integer argument may not be the best choice
assert(menu.set("Intervalometer", "Take a pic every", 70))
assert(menu.get("Intervalometer", "Take a pic every", 0) == 70)
assert(menu.get("Intervalometer", "Take a pic every") == "1m10s")
......
......@@ -6580,13 +6580,13 @@ int menu_set_str_value_from_script(const char* name, const char* entry_name, cha
int wait_after_toggle = 0;
int start_time = get_ms_clock();
int elapsed_time = 0;
for (int i = 0; (elapsed_time = get_ms_clock() - start_time) < 2000; i++)
for (int i = 0; (elapsed_time = get_ms_clock() - start_time) < 5000; i++)
{
if (wait_after_toggle)
{
/* maybe we need to wait for other tasks? */
int delay = (elapsed_time < 500) ? 200 :
(elapsed_time < 1500) ? 50 : 10;
int delay = (elapsed_time < 2000) ? 200 :
(elapsed_time < 4000) ? 50 : 10;
//~ printf("menu.set('%s', '%s'): wait for %d ms\n", entry_name, value, delay);
msleep(delay);
}
......@@ -6692,7 +6692,7 @@ int menu_set_str_value_from_script(const char* name, const char* entry_name, cha
}
else if IS_ML_PTR(entry->priv)
{
if (entry->max - entry->min > 1000)
if (entry->max - entry->min > (wait_after_toggle ? 100 : 100000))
{
/* for very long min-max ranges, don't try every single value */
menu_numeric_toggle_fast(entry->priv, 1, entry->min, entry->max, entry->unit, entry->edit_mode, 1);
......
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