⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 adns3060_library.m

📁 MatLab图像传感器网络仿真平台WiSNAP
💻 M
字号:
function status = adns3060_library(command);
%Agilent ADNS-3060 Mouse Sensor Library.
%   STATUS = ADNS3060_LIBRARY(COMMAND);
%
%   Input Parameters:
%   ================
%
%      command -----------> Library function (string):
%                           'open'  - Open communications session.
%                           'init'  - Initialize mouse sensor.
%                           'frame' - Capture current frame.
%                           'close' - Close communications session.
%
%   Output Parameters:
%   =================
%
%      status ------------> Success status (-1 = error, +1 = success).
%
%   See also N/A.

% Stephan Hengstler
% Stanford Wireless Sensor Networks Lab
% January 06, 2005
%
% Last modified: 02-03-2005

%************************ Agilent ADNS-3060 Mouse Sensor Library **************************

%--- Section: Global Variables ------------------------------------------------------------

global		colorm;							% color map
global		handle;							% device handle
global		imager;							% image array
global 		PORT;								% communications port

%--- Section: System Parameters -----------------------------------------------------------

MS_REG_PRODUCT_ID		= hex2dec('00');	% Register: Product ID.

%--- Command: Open Communications Session -------------------------------------------------

if (~isempty(strmatch('open',command,'exact')))
   
	% open parallel port to mouse sensor
   if (~isempty(strmatch(PORT,strvcat('03BC','0378','0278'),'exact')))
      handle 		= hex2dec(PORT);
      status      = 1;
   else
      handle      = 0;
      status      = -1;
   end
   if (status < 0), return, end
   
   % reset mouse sensor
   status      = ms_reset(dec2hex(handle));
   if (status < 0), return, end

   % return status
   status		= 1;
   
%--- Command: Initialize Mouse Sensor -----------------------------------------------------

elseif (~isempty(strmatch('init',command,'exact')))

   % power up mouse sensor
   status      = ms_power(handle,1);
   if (status < 0), return, end
   
	% get mouse sensor product id
	product_id	= dec2hex(spi_read_register(handle,MS_REG_PRODUCT_ID),2)
   
   % return status
   status		= 1;

%--- Command: Capture Current Frame -------------------------------------------------------

elseif (~isempty(strmatch('frame',command,'exact')))

   % read-out image data
   imager      = ms_frame(handle);

   % return status
   status		= 1;

%--- Command: Close Communications Session ------------------------------------------------

elseif (~isempty(strmatch('close',command,'exact')))

   % reset mouse sensor (required after frame capture in burst mode)
   status      = ms_reset(handle);
   if (status < 0), return, end
   
   % power down mouse sensor
   status      = ms_power(handle,0);
   if (status < 0), return, end

   % return status
   status		= 1;

%--- Command: Undefined -------------------------------------------------------------------

else

   % return status
   status		= -1;

end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -