function varargout = CamKnob(varargin)
% CAMKNOB M-file for CamKnob.fig
%      CAMKNOB, by itself, creates a new CAMKNOB or raises the existing
%      singleton*.
%
%      H = CAMKNOB returns the handle to a new CAMKNOB or the handle to
%      the existing singleton*.
%
%      CAMKNOB('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in CAMKNOB.M with the given input arguments.
%
%      CAMKNOB('Property','Value',...) creates a new CAMKNOB or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before CamKnob_OpeningFunction gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to CamKnob_OpeningFcn via varargin.
%
%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
%      instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES

% Edit the above text to modify the response to help CamKnob

% Last Modified by GUIDE v2.5 14-Aug-2007 16:20:25

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @CamKnob_OpeningFcn, ...
                   'gui_OutputFcn',  @CamKnob_OutputFcn, ...
                   'gui_LayoutFcn',  [] , ...
                   'gui_Callback',   []);
if nargin && ischar(varargin{1})
    gui_State.gui_Callback = str2func(varargin{1});
end

if nargout
    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
    gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT

function cameras = getcameras()

nc = 1;
cameras(nc).name ='CT.MTV0265'; cameras(nc).filtname='CT.MTV0263FLT'; nc=nc+1;
cameras(nc).name ='CT.MTV0305'; cameras(nc).filtname='CT.MTV0305FLT'; nc=nc+1;
cameras(nc).name ='CT.MTV0435'; cameras(nc).filtname='CT.MTV0435FLT'; nc=nc+1;



% --- Executes just before CamKnob is made visible.
function CamKnob_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% varargin   command line arguments to CamKnob (see VARARGIN)
cameras = getcameras();

nc = length(cameras);
if (nc < 1)
  error('No cameras defined');
end  

camlist = cameras(1).name;
for i=2:nc
 camlist = strcat(camlist,['|' cameras(i).name]);
end

set(handles.cameralist,'String',camlist);


% Choose default command line output for CamKnob
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);


% UIWAIT makes CamKnob wait for user response (see UIRESUME)
% uiwait(handles.figure1);

updateinfo(handles)


% --- Outputs from this function are returned to the command line.
function varargout = CamKnob_OutputFcn(hObject, eventdata, handles) 
% varargout  cell array for returning output args (see VARARGOUT);
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure
varargout{1} = handles.output;


% --------------------------------------------------------------------
function ON_Callback(hObject, eventdata, handles)
% hObject    handle to ON (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
fprintf(1,'Menu: Camera ON Pressed\n');

% --------------------------------------------------------------------
function OFF_Callback(hObject, eventdata, handles)
% hObject    handle to OFF (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
fprintf(1,'Menu: Camera OFF Pressed\n');

% --------------------------------------------------------------------
function CamOnOff_Callback(hObject, eventdata, handles)
% hObject    handle to CamOnOff (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --- Executes on button press in onoffbutt.
function onoffbutt_Callback(hObject, eventdata, handles)
% hObject    handle to onoffbutt (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

fprintf(1,'ButtONOFF: Camera ON/OFF Pressed\n');

bstate = get(hObject,'Value');
fprintf(1,'Current but state is %d\n', bstate);

idx = get(handles.cameralist,'Value');
fprintf(1,'Selected camera is %d\n', idx);

if (bstate == 0)
  
end




% --- Executes on button press in pushbutton3.
function pushbutton3_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of pushbutton3


% --- Executes on slider movement.
function light1intenslid_Callback(hObject, eventdata, handles)
% hObject    handle to light1intenslid (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'Value') returns position of slider
%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider



% --- Executes during object creation, after setting all properties.
function light1intenslid_CreateFcn(hObject, eventdata, handles)
% hObject    handle to light1intenslid (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor',[.9 .9 .9]);
end



function light1intenval_Callback(hObject, eventdata, handles)
% hObject    handle to light1intenval (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of light1intenval as text
%        str2double(get(hObject,'String')) returns contents of light1intenval as a double


% --- Executes during object creation, after setting all properties.
function light1intenval_CreateFcn(hObject, eventdata, handles)
% hObject    handle to light1intenval (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


% --- Executes during object creation, after setting all properties.
function onoffbutt_CreateFcn(hObject, eventdata, handles)
% hObject    handle to onoffbutt (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called


% --- Executes on selection change in cameralist.
function cameralist_Callback(hObject, eventdata, handles)
% hObject    handle to cameralist (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = get(hObject,'String') returns cameralist contents as cell array
%        contents{get(hObject,'Value')} returns selected item from cameralist

idx = get(hObject,'Value');
fprintf(1,'Selected a camera no %d\n', idx);


return;









% --- Executes during object creation, after setting all properties.
function cameralist_CreateFcn(hObject, eventdata, handles)
% hObject    handle to cameralist (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: listbox controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end



% --- Executes on button press in pushbutton4.
function pushbutton4_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton4 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


function updateinfo(handles)
%updates info on the bottom panel

m = 'Camera is ';




