function varargout = Bboard(varargin)
% BBOARD MATLAB code for Bboard.fig
%    Help function under construction  

%    

% Last Modified by GUIDE v2.5 01-Mar-2015 13:48:13

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @Bboard_OpeningFcn, ...
                   'gui_OutputFcn',  @Bboard_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


% --- Executes just before Bboard is made visible.
function Bboard_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 Bboard (see VARARGIN)

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

% Update handles structure
guidata(hObject, handles);

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


% --- Outputs from this function are returned to the command line.
function varargout = Bboard_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;


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

set(hObject,'string',get(hObject,'Value'))
LightLogic(hObject, handles)



% --- Executes on button press in Light1.
function Light1_Callback(hObject, eventdata, handles)
% hObject    handle to Light1 (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 Button2.
function Button2_Callback(hObject, eventdata, handles)
% hObject    handle to Button2 (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 Button2
set(hObject,'string',get(hObject,'Value'))
LightLogic(hObject, handles)

% --- Executes on button press in Button3.
function Button3_Callback(hObject, eventdata, handles)
% hObject    handle to Button3 (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 Button3
set(hObject,'string',get(hObject,'Value'))
LightLogic(hObject, handles)

% --- Executes on button press in Light2.
function Light2_Callback(hObject, eventdata, handles)
% hObject    handle to Light2 (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 Light3.
function Light3_Callback(hObject, eventdata, handles)
% hObject    handle to Light3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)



function Logic1_Callback(hObject, eventdata, handles)
% hObject    handle to Logic1 (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 Logic1 as text
%        str2double(get(hObject,'String')) returns contents of Logic1 as a double
LightLogic(hObject, handles)

% --- Executes during object creation, after setting all properties.
function Logic1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to Logic1 (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



function Logic2_Callback(hObject, eventdata, handles)
% hObject    handle to Logic2 (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 Logic2 as text
%        str2double(get(hObject,'String')) returns contents of Logic2 as a double
LightLogic(hObject, handles)

% --- Executes during object creation, after setting all properties.
function Logic2_CreateFcn(hObject, eventdata, handles)
% hObject    handle to Logic2 (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



function edit6_Callback(hObject, eventdata, handles)
% hObject    handle to edit6 (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 edit6 as text
%        str2double(get(hObject,'String')) returns contents of edit6 as a double


% --- Executes during object creation, after setting all properties.
function edit6_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit6 (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



function Logic3_Callback(hObject, eventdata, handles)
% hObject    handle to Logic3 (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 Logic3 as text
%        str2double(get(hObject,'String')) returns contents of Logic3 as a double
LightLogic(hObject, handles)

% --- Executes during object creation, after setting all properties.
function Logic3_CreateFcn(hObject, eventdata, handles)
% hObject    handle to Logic3 (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

function LightLogic(hObject, handles)
% LightLogic(hObject, handles)
% S. Scott Moor                     February 2015
% This program is designed to work in a GUI program using GUIDE
% The inputs are the hObject and handles variables created by GUIDE
% It allows the creation of three boolean expressions with three inputs
% It works with a GUI that has 
%  - three toggle button inputs 
%  - three string inputs of logical expressions
%  - three "light" outputs 

% Get values from i
a = get(handles.Button1,'Value');
b = get(handles.Button2,'Value');
c = get(handles.Button3,'Value');


L1 = eval(get(handles.Logic1,'string'));
L2 = eval(get(handles.Logic2,'string'));
L3 = eval(get(handles.Logic3,'string'));

if length(L1) > 1
    L1 = 0;
    disp('Expression 1 must result in a scalar')
end
if length(L2) > 1
     L2 = 0;
    disp('Expression 2 must result in a scalar')
end
if length(L3) > 1
     L3 = 0;
    disp('Expression 3 must result in a scalar')
end
set(handles.Light1, 'BackgroundColor',[1 0 1]*logical(L1))
set(handles.Light2, 'BackgroundColor',[0 1 1]*logical(L2))
set(handles.Light3, 'BackgroundColor',[1 1 0]*logical(L3))


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