Auto Focus Mechanics Plugins Development Guide

Auto Focus Mechanics Plugins Development Guide

Overview

The DevWare application provides a dialog plug-in API which allows developers to integrate their own DLLs in DevWare. The Auto Focus Mechanics (AFM) plug-in API described in this document is an extended version of the original plug-in API. Developers can modify the C++ source code to meet their specific AF Mechanics requirements. Please read the Plugin Dialog Development Guide before reading this document.

AFM Plug-in Dialog

Besides the standard Dialog Plug-in functions that must exported to DevWare, the AFM Plug-in adds two functions which the Developer needs to export to DevWare.

Include Files

#include "apbase.h"
#include "DlgImport.h"
#include "miafmlib.h"// in the samples folder, or any other name the developer prefer
These files are in the include directory where the Aptina Imaging software is installed, typically C:\Aptina Imaging\include.

DLL exported Functions

The plug-in dialog must be compiled into a DLL. The DLL file must have the extension ".dll" and should export the functions described below. The exported functions must use the standard WIN32 calling convention, normally indicated with the __stdcall keyword. (Parameters passed right to left, called function restores the stack.) The addition two functions user must export are as follows:

GetAFMParams()

Definition:

__declspec(dllexport)
mi_AFMParams* GetAFMParams(void);

Summary:

This function is called when the DevWare auto focus algorithm started.

Parameters:

None.

Return value:

The structure mi_AFMParams is defined as:

typedef struct AFMParams_S {
int m_nMinPosition;
int m_nMaxPosition;
int m_afBigStep;
int m_afSmallStep;
int m_afGap;
} mi_AFMParams;

Where:

m_nMinPosition - is the minimum position the mechanics module can reach.
m_nMaxPosition - is the maximum position the module can reach.
m_afBigStep – the step coarse step size.
m_afSmallStep – the fine step size.
m_afGap – the gap between the specified movement and the actual physical movement of the mechanics (Hysteresis).

SetAFMPosition()

Definition:

__declspec(dllexport)
int SetAFMPosition(int nNewPosition);

Summary:

This function called when the internal Devware AF algorithm finished calculate the new actuator position.

Parameters:

nNewPosition - DevWare pass this value to the AFM Plug-ins. The developer can use this number to move the mechanics modules to the new positions. This number should be between m_nMinPosition and m_nMaxPosition.

Return value:

Non zero value for success. Zero for failure.


Initializing and Closing the Mechanism

In addition to the two exported functions, the developer may want to add special handling code to open and close the mechanics. Corresponding calls are made in the provided example inside the functions OpenDialog() and CloseDialog().
Refer to miAFM_Open() and miAFM_Close() in the section SAMPLE CODE for additional details.

Sample code

There is a sample AFM plug-in dialog called "SampleAFMDLL", located in the samples directory. The sample code is in C++ and includes visual studio project files. Please refer the "DialogDll" sample code for the original (non-AFM specific) Dialog Plug-in DLL. In SampleAFMDLL the "miAFMLib.cpp" and "miAFMLib.h" files are AFM specific and the Developer needs to modify to fit their requirements. Here is some suggested functionality for AFM specific code.
/////////////////////////////////////////////////////////////////////////////
// miafmlib.cpp : Defines the entry point for the DLL application :
//
// Abstract:
// ---------
// Control the autofocus mechanism (AFM), if present.
// It is anticipated that this class will control any type of AFM,
// automatically detecting which is present.
//
// Classes:
// --------
// CAFMechanics
//
// Methods:
// -----------------------
// miAFM_Open()
// miAFM_Cloase()
// miAFM_GetParameters()
// miAFM_SetPosition()
//
//
/****************************************************************************