Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - alext

#1
I put dryos.h and module.h at the top and checked if I got every header needed but I get the same error as before: no *.o file. What does the *.o file contain and how is it created? probably I can dig into it and find my mistake if I know what to look for.

The idea behind this module is to focus on different points an a plane (e.g. painting, poster...) and to turn and tilt the camera with the information of the focus position until the optical axis is (nearly) orthogonal to the plane. This is a project I'm doing for university and the fist step is to test under which conditions it is possible to record small changes of the angle. If I manage to get this module running, those tests would be a lot easier than with the lua script I allready wrote.

@a1ex
I have to admit that I did not think about the different focus modes in LV, thanks for reminding me. I think I'll use the contrast detection in a different stage of this project  ;)
Thanks for always helping with my questions and my full respect for all the work you put in magic lantern and this community
#2
Module writing Q&A / problem compiling my first module
August 02, 2017, 03:54:39 PM
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:

# 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:


#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()
#3
thanks for your quick reply
@dmilligan it worked with keys:start() but like I suspected, there is no key code for this event.
@a1ex I found your tutorial on writing modules and I'll try to solve it this way. I set everything up for compiling modules and allready found a few things in the source code but I didn't find anything on how to use autofocus. could you give me a few hints on how to solve this?
#4
I'm working on a projekt, where I try to get the orientation of a plane by reading the focus motor position with different focuspoints on my 50d with the magiclanter-lua_fix.2017Jul06.50D109 build.
I already managed to automaticly focus and get the correct motor position with lens.focus_pos but I always have to change the focuspoint manually.
I got the Idea to use the key.press() funktion to automaticly change the focuspoints, but KEY.ZOOMIN (same hardware key as for choosing focuspoints) only works to zoom in on pictures.
I tried to use the keys:getkey() funtion to see, if i used the wrong key code for choosing focuspoints, but I always get an error in ML/Scripts/lib/keys.lua. With the following code I get an error in line 48: bad argument #1 to 'remove' ...


require('keys')
console.clear()
console.show()
console.write('press Key')
task.yield(500)
console.write(keys:getkey())


By using keys:keys() befor calling keys:getkey() I get the error: attempt to call a nil value (method 'keys)

Is there any point I'm missing or does anyone have a better idea for solving this problem?

Thanks in advance

Alexander