This is my first try on writing modules and I wrote a few lines and wanted to try it out and see if it works like intended. I took the makefile from the ettr module and changed the names for the output but if I run make, no *.o file is produced. compiling the other modules works fine but not with my *.c file. I looked through other *.c and makefiles but could not solve it.
I work with the lua_fix branch and took a lot of code from the sourcefiles or other modules (especially lua module, I tried some of this with a lua sript). I'm not very experienced with programming in C so feel free to comment
my makefile:
and my .c file:
I work with the lua_fix branch and took a lot of code from the sourcefiles or other modules (especially lua module, I tried some of this with a lua sript). I'm not very experienced with programming in C so feel free to comment
my makefile:
Code Select
# this is a very simple makefile for modules
TOP_DIR=../..
# define the module name - make sure name is max 8 characters
MODULE_NAME=ortho
MODULE_OBJS=ortho.o
# include modules environment
include $(TOP_DIR)/modules/Makefile.modules
and my .c file:
Code Select
#include "module.h"
#include "focus.h"
#include "dryos.h"
#include "bmp.h"
#include "menu.h"
#include "property.h"
#include "config.h"
#include "af_patterns.h"
#include "lens.h"
#include "lvinfo.h"
#include "shoot.h"
extern void bmp_on;
extern void bmp_off;
static int afp[2];
static int afp_len = 0;
static int x=720;
static int y=480;
PROP_HANDLER(PROP_AFPOINT)
{
afp[0] = buf[0];
afp[1] = buf[1];
afp_len = len;
}
static int autofocus()
{
msleep(500);
module_send_keypress(MODULE_KEY_PRESS_HALFSHUTTER);
if (wait_focus_status(3000, 3, 3))
{
if (wait_focus_status(5000, 1, 2))
{
module_send_keypress(MODULE_KEY_UNPRESS_HALFSHUTTER);
lens_focus(1,1,1,0);
lens_focus(1,-1,1,0);
msleep(500);
return 1;
}
}
else
{
module_send_keypress(MODULE_KEY_UNPRESS_HALFSHUTTER);
return 0;
}
}
static void orthogonator()
{
msleep(2000);
force_liveview();
bmp_off();
bmp_on();
if (!afp_len || !lens_info.name) return;
lens_setup_af(AF_ENABLE);
afp[0] = AF_POINT_C;
prop_request_change(PROP_AFPOINT, afp, afp_len);
if(autofocus()) bmp_printf(FONT_MED,x/2,y/2,"%d",lens_info.focus_pos);
afp[0] = AF_POINT_T;
prop_request_change(PROP_AFPOINT, afp, afp_len);
if(autofocus()) bmp_printf(FONT_MED,x/2,y/4,"%d",lens_info.focus_pos);
afp[0] = AF_POINT_R;
prop_request_change(PROP_AFPOINT, afp, afp_len);
if(autofocus()) bmp_printf(FONT_MED,3*x/4,y/2,"%d",lens_info.focus_pos);
afp[0] = AF_POINT_B;
prop_request_change(PROP_AFPOINT, afp, afp_len);
if(autofocus()) bmp_printf(FONT_MED,x/2,y*3/4,"%d",lens_info.focus_pos);
afp[0] = AF_POINT_L;
prop_request_change(PROP_AFPOINT, afp, afp_len);
if(autofocus()) bmp_printf(FONT_MED,x/4,y/2,"%d",lens_info.focus_pos);
}
static struct menu_entry ortho_menu[] =
{
{
.name = "Orthogonator",
.select = run_in_separate_task,
.priv = orthogonator,
.help = "",
},
};
static unsigned int ortho_init()
{
menu_add("Focus", ortho_menu, COUNT(ortho_menu));
return 0;
}
static unsigned int ortho_deinit()
{
return 0;
}
MODULE_INFO_START()
MODULE_INIT(ortho_init)
MODULE_DEINIT(ortho_deinit)
MODULE_INFO_END()
MODULE_PROPHANDLERS_START()
MODULE_PROPHANDLER(PROP_AFPOINT)
MODULE_PROPHANDLERS_END()