Here is the code I have now, super super basic very long too, I am sure a real programmer can easily simplify what I have here if anyone wishes to that would be ok by me and maybe make use of the IME input module somehow.
#define CONFIG_CONSOLE
#include <module.h>
#include <dryos.h>
#include <property.h>
#include <bmp.h>
#include <menu.h>
#include <config.h>
#include "edmac.h"
#include "lens.h"
/* focus data */
//static int inf_focus = 0;
static unsigned CONFIG_INT("inf_range_a", inf_range_a, 18);
static unsigned CONFIG_INT("inf_range_b", inf_range_b, 18);
static unsigned CONFIG_INT("inf_range_c", inf_range_c, 18);
static unsigned CONFIG_INT("inf_range_a", inf_range_d, 18);
static unsigned CONFIG_INT("inf_range_b", inf_range_e, 18);
static unsigned CONFIG_INT("inf_range_c", inf_range_f, 18);
static unsigned CONFIG_INT("inf_range_a", inf_range_g, 18);
static unsigned CONFIG_INT("inf_range_b", inf_range_h, 18);
static unsigned CONFIG_INT("inf_range_c", inf_range_i, 18);
static unsigned CONFIG_INT("inf_steps_a", inf_steps_a, 0);
static unsigned CONFIG_INT("inf_steps_b", inf_steps_b, 0);
static unsigned CONFIG_INT("inf_steps_c", inf_steps_c, 0);
static unsigned CONFIG_INT("inf_steps_a", inf_steps_d, 0);
static unsigned CONFIG_INT("inf_steps_b", inf_steps_e, 0);
static unsigned CONFIG_INT("inf_steps_c", inf_steps_f, 0);
static unsigned CONFIG_INT("inf_steps_a", inf_steps_g, 0);
static unsigned CONFIG_INT("inf_steps_b", inf_steps_h, 0);
static unsigned CONFIG_INT("inf_steps_c", inf_steps_i, 0);
static unsigned CONFIG_INT("inf_size_a", inf_size_a, 2);
static unsigned CONFIG_INT("inf_size_b", inf_size_b, 2);
static unsigned CONFIG_INT("inf_size_c", inf_size_c, 2);
static unsigned CONFIG_INT("inf_size_a", inf_size_d, 2);
static unsigned CONFIG_INT("inf_size_b", inf_size_e, 2);
static unsigned CONFIG_INT("inf_size_c", inf_size_f, 2);
static unsigned CONFIG_INT("inf_size_a", inf_size_g, 2);
static unsigned CONFIG_INT("inf_size_b", inf_size_h, 2);
static unsigned CONFIG_INT("inf_size_c", inf_size_i, 2);
static unsigned CONFIG_INT("inf_custom", inf_custom, 1);
/* Focus Infinity */
static MENU_SELECT_FUNC(inf_focus_toggle)
{
if(is_manual_focus())
{
beep();
msleep(200);
beep();
msleep(200);
beep();
msleep(200);
return;
}
if (inf_custom == 1 && lens_info.focal_len == inf_range_a && !is_manual_focus())
{
lens_focus_start(-3);
msleep(1000);
lens_focus_stop();
msleep(200);
lens_focus(inf_steps_a, inf_size_a, 1, 20);
msleep(200);
beep();
}
else
{
if (inf_custom == 2 && lens_info.focal_len == inf_range_b && !is_manual_focus())
{
lens_focus_start(-3);
msleep(1000);
lens_focus_stop();
msleep(200);
lens_focus(inf_steps_b, inf_size_b, 1, 20);
msleep(200);
beep();
}
else
{
if (inf_custom == 3 && lens_info.focal_len == inf_range_c && !is_manual_focus())
{
lens_focus_start(-3);
msleep(1000);
lens_focus_stop();
msleep(200);
lens_focus(inf_steps_c, inf_size_c, 1, 20);
msleep(200);
beep();
}
else
{
if (inf_custom == 4 && lens_info.focal_len == inf_range_d && !is_manual_focus())
{
lens_focus_start(-3);
msleep(1000);
lens_focus_stop();
msleep(200);
lens_focus(inf_steps_d, inf_size_d, 1, 20);
msleep(200);
beep();
}
else
{
if (inf_custom == 5 && lens_info.focal_len == inf_range_e && !is_manual_focus())
{
lens_focus_start(-3);
msleep(1000);
lens_focus_stop();
msleep(200);
lens_focus(inf_steps_e, inf_size_e, 1, 20);
msleep(200);
beep();
}
else
{
if (inf_custom == 6 && lens_info.focal_len == inf_range_f && !is_manual_focus())
{
lens_focus_start(-3);
msleep(1000);
lens_focus_stop();
msleep(200);
lens_focus(inf_steps_f, inf_size_f, 1, 20);
msleep(200);
beep();
}
else
{
if (inf_custom == 7 && lens_info.focal_len == inf_range_g && !is_manual_focus())
{
lens_focus_start(-3);
msleep(1000);
lens_focus_stop();
msleep(200);
lens_focus(inf_steps_g, inf_size_g, 1, 20);
msleep(200);
beep();
}
else
{
if (inf_custom == 8 && lens_info.focal_len == inf_range_h && !is_manual_focus())
{
lens_focus_start(-3);
msleep(1000);
lens_focus_stop();
msleep(200);
lens_focus(inf_steps_h, inf_size_h, 1, 20);
msleep(200);
beep();
}
else
{
if (inf_custom == 9 && lens_info.focal_len == inf_range_i && !is_manual_focus())
{
lens_focus_start(-3);
msleep(1000);
lens_focus_stop();
msleep(200);
lens_focus(inf_steps_i, inf_size_i, 1, 20);
msleep(200);
beep();
}
else
{
msleep(200);
beep();
msleep(200);
beep();
msleep(200);
beep();
msleep(200);
return;
}
}
}
}
}
}
}
}
}
}
static MENU_UPDATE_FUNC(custom_display_a)
{
if (inf_custom == 1)
{
MENU_SET_ENABLED(1);
}
else
{
MENU_SET_ENABLED(0);
}
}
static MENU_UPDATE_FUNC(custom_display_b)
{
if (inf_custom == 2)
{
MENU_SET_ENABLED(1);
}
else
{
MENU_SET_ENABLED(0);
}
}
static MENU_UPDATE_FUNC(custom_display_c)
{
if (inf_custom == 3)
{
MENU_SET_ENABLED(1);
}
else
{
MENU_SET_ENABLED(0);
}
}
static MENU_UPDATE_FUNC(custom_display_d)
{
if (inf_custom == 4)
{
MENU_SET_ENABLED(1);
}
else
{
MENU_SET_ENABLED(0);
}
}
static MENU_UPDATE_FUNC(custom_display_e)
{
if (inf_custom == 5)
{
MENU_SET_ENABLED(1);
}
else
{
MENU_SET_ENABLED(0);
}
}
static MENU_UPDATE_FUNC(custom_display_f)
{
if (inf_custom == 6)
{
MENU_SET_ENABLED(1);
}
else
{
MENU_SET_ENABLED(0);
}
}
static MENU_UPDATE_FUNC(custom_display_g)
{
if (inf_custom == 7)
{
MENU_SET_ENABLED(1);
}
else
{
MENU_SET_ENABLED(0);
}
}
static MENU_UPDATE_FUNC(custom_display_h)
{
if (inf_custom == 8)
{
MENU_SET_ENABLED(1);
}
else
{
MENU_SET_ENABLED(0);
}
}
static MENU_UPDATE_FUNC(custom_display_i)
{
if (inf_custom == 9)
{
MENU_SET_ENABLED(1);
}
else
{
MENU_SET_ENABLED(0);
}
}
static struct menu_entry step_menu[] = {
{
.name = "Infinity",
.select = inf_focus_toggle,
.choices = CHOICES("Press SET"),
.select_Q = menu_open_submenu,
.children = (struct menu_entry[]) {
{
.name = "Activate",
.priv = &inf_custom,
.choices = CHOICES("Lens 1", "Lens 2", "Lens 3", "Lens 4", "Lens 5", "Lens 6", "Lens 7", "Lens 8", "Lens 9"),
.min = 1,
.max = 9,
},
{
},
{
.name = "Lens 1 mm",
.priv = &inf_range_a,
.update = custom_display_a,
.min = 4,
.max = 900,
},
{
.name = "Steps Right",
.priv = &inf_steps_a,
.update = custom_display_a,
.min = 1,
.max = 1000,
},
{
.name = "Step Size",
.priv = &inf_size_a,
.update = custom_display_a,
.min = 1,
.max = 3,
},
{
},
{
.name = "Lens 2 mm",
.priv = &inf_range_b,
.update = custom_display_b,
.min = 4,
.max = 900,
},
{
.name = "Steps Right",
.priv = &inf_steps_b,
.update = custom_display_b,
.min = 1,
.max = 1000,
},
{
.name = "Step Size",
.priv = &inf_size_b,
.update = custom_display_b,
.min = 1,
.max = 3,
},
{
},
{
.name = "Lens 3 mm",
.priv = &inf_range_c,
.update = custom_display_c,
.min = 4,
.max = 900,
},
{
.name = "Steps Right",
.priv = &inf_steps_c,
.update = custom_display_c,
.min = 1,
.max = 1000,
},
{
.name = "Step Size",
.priv = &inf_size_c,
.update = custom_display_c,
.min = 1,
.max = 3,
},
{
},
{
.name = "Lens 4 mm",
.priv = &inf_range_d,
.update = custom_display_d,
.min = 4,
.max = 900,
},
{
.name = "Steps Right",
.priv = &inf_steps_d,
.update = custom_display_d,
.min = 1,
.max = 1000,
},
{
.name = "Step Size",
.priv = &inf_size_d,
.update = custom_display_d,
.min = 1,
.max = 3,
},
{
},
{
.name = "Lens 5 mm",
.priv = &inf_range_e,
.update = custom_display_e,
.min = 4,
.max = 900,
},
{
.name = "Steps Right",
.priv = &inf_steps_e,
.update = custom_display_e,
.min = 1,
.max = 1000,
},
{
.name = "Step Size",
.priv = &inf_size_e,
.update = custom_display_e,
.min = 1,
.max = 3,
},
{
},
{
.name = "Lens 6 mm",
.priv = &inf_range_f,
.update = custom_display_f,
.min = 4,
.max = 900,
},
{
.name = "Steps Right",
.priv = &inf_steps_f,
.update = custom_display_f,
.min = 1,
.max = 1000,
},
{
.name = "Step Size",
.priv = &inf_size_f,
.update = custom_display_f,
.min = 1,
.max = 3,
},
{
},
{
.name = "Lens 7 mm",
.priv = &inf_range_g,
.update = custom_display_g,
.min = 4,
.max = 900,
},
{
.name = "Steps Right",
.priv = &inf_steps_g,
.update = custom_display_g,
.min = 1,
.max = 1000,
},
{
.name = "Step Size",
.priv = &inf_size_g,
.update = custom_display_g,
.min = 1,
.max = 3,
},
{
},
{
.name = "Lens 8 mm",
.priv = &inf_range_h,
.update = custom_display_h,
.min = 4,
.max = 900,
},
{
.name = "Steps Right",
.priv = &inf_steps_h,
.update = custom_display_h,
.min = 1,
.max = 1000,
},
{
.name = "Step Size",
.priv = &inf_size_h,
.update = custom_display_h,
.min = 1,
.max = 3,
},
{
},
{
.name = "Lens 9 mm",
.priv = &inf_range_i,
.update = custom_display_i,
.min = 4,
.max = 900,
},
{
.name = "Steps Right",
.priv = &inf_steps_i,
.update = custom_display_i,
.min = 1,
.max = 1000,
},
{
.name = "Step Size",
.priv = &inf_size_i,
.update = custom_display_i,
.min = 1,
.max = 3,
},
{
},
MENU_EOL
},
},
};
static unsigned int foc_inf_init()
{
menu_add( "Focus", step_menu, COUNT(step_menu) );
return 0;
}
static unsigned int foc_inf_deinit()
{
return 0;
}
MODULE_INFO_START()
MODULE_INIT(foc_inf_init)
MODULE_DEINIT(foc_inf_deinit)
MODULE_INFO_END()
MODULE_CONFIGS_START()
MODULE_CONFIG(inf_range_a)
MODULE_CONFIG(inf_range_b)
MODULE_CONFIG(inf_range_c)
MODULE_CONFIG(inf_range_d)
MODULE_CONFIG(inf_range_e)
MODULE_CONFIG(inf_range_f)
MODULE_CONFIG(inf_range_g)
MODULE_CONFIG(inf_range_h)
MODULE_CONFIG(inf_range_i)
MODULE_CONFIG(inf_steps_a)
MODULE_CONFIG(inf_steps_b)
MODULE_CONFIG(inf_steps_c)
MODULE_CONFIG(inf_steps_d)
MODULE_CONFIG(inf_steps_e)
MODULE_CONFIG(inf_steps_f)
MODULE_CONFIG(inf_steps_g)
MODULE_CONFIG(inf_steps_h)
MODULE_CONFIG(inf_steps_i)
MODULE_CONFIG(inf_size_a)
MODULE_CONFIG(inf_size_b)
MODULE_CONFIG(inf_size_c)
MODULE_CONFIG(inf_size_d)
MODULE_CONFIG(inf_size_e)
MODULE_CONFIG(inf_size_f)
MODULE_CONFIG(inf_size_g)
MODULE_CONFIG(inf_size_h)
MODULE_CONFIG(inf_size_i)
MODULE_CONFIG(inf_custom)
MODULE_CONFIGS_END()