Alex, here is logic that can make the algo parameters tunable if you'd like to go that route. I couldn't get a submenu-within-a-submenu working so these options are at the same menu level as the others:
top of module:
static CONFIG_INT( "dottune.number_scans", dottune_number_scans, 2);
static CONFIG_INT( "dottune.max_time_10ms_initial_af_confirm", dottune_max_time_10ms_initial_af_confirm, 200/10);
static CONFIG_INT( "dottune.min_time_10ms_sustain_af_confirm", dottune_min_time_10ms_sustain_af_confirm, 500/10);
// we have to wait until the AFMA change is operated into Canon firmware
static int afma_ack = 0;
afma_auto_tune():
SW1(1,100);
for (int k = 0; k < dottune_number_scans; k++)
{
for (int c = 0; c <= 80; c++) // -20 ... 20 and back to -20
{
int i = (c <= 40) ? c-20 : 60-c;
set_afma(i * range_expand_factor, afma_mode);
msleep(100);
int fc;
// initial focus must occur within quick period to exclude AF confirm lags
fc = wait_for_focus_confirmation_val(dottune_max_time_10ms_initial_af_confirm*10, 1);
if (fc)
{
// weak or strong confirmation? use a higher score if strong
// focus must sustain for long period be considered strong
if (!wait_for_focus_confirmation_val(dottune_min_time_10ms_sustain_af_confirm*10, 0))
// focus sustained
fc = 3;
}
score[i+20] += fc;
afma_print_status(score, range_expand_factor);
if (!HALFSHUTTER_PRESSED)
{
beep();
set_afma(afma0, afma_mode);
NotifyBox(2000, "Canceled by user.");
return;
}
}
}
SW1(0,100);
Bottom of module:
static MENU_UPDATE_FUNC(dottune_max_initial_af_confirm)
{
MENU_SET_VALUE("%d ms", dottune_max_time_10ms_initial_af_confirm * 10);
}
static MENU_UPDATE_FUNC(dottune_min_sustain_af_confirm)
{
MENU_SET_VALUE("%d ms", dottune_min_time_10ms_sustain_af_confirm * 10);
}
static struct menu_entry afma_menu[] = {
And added menu options:
{
.name = "AFMA mode",
.priv = &afma_mode_index,
.select = afma_mode_toggle,
.min = 0,
#ifdef CONFIG_AFMA_WIDE_TELE
.max = 3,
#else
.max = 2,
#endif
.choices = CHOICES(
"Disabled",
"All lenses",
#ifdef CONFIG_AFMA_WIDE_TELE
"This lens, wide/prime",
"This lens, tele"
#else
"This lens"
#endif
),
.help = "Where to apply the AFMA adjustment.",
.icon_type = IT_DICE_OFF,
},
{
.name = "No. range scans",
.priv = &dottune_number_scans,
.min = 1,
.max = 99,
.help = "Larger values increase sample size.",
},
{
.name = "Max 1st AF confirm(ms)",
.priv = &dottune_max_time_10ms_initial_af_confirm,
.min = 10/10, /* 10ms */
.max = 10000/10, /* 10 seconds */
.update = dottune_max_initial_af_confirm,
.help = "Smaller values are more discerning.",
},
{
.name = "Min cont AF confirm(ms)",
.priv = &dottune_min_time_10ms_sustain_af_confirm,
.min = 10/10, /* 10ms */
.max = 30000/10, /* 30 seconds */
.update = dottune_min_sustain_af_confirm,
.help = "Larger values are more discerning.",
},
MENU_EOL,
},
},
};