function varargout = Digitizer_GUI(varargin)
% DIGITIZER_GUI MATLAB code for Digitizer_GUI.fig
%      DIGITIZER_GUI, by itself, creates a new DIGITIZER_GUI or raises the existing
%      singleton*.
%
%      H = DIGITIZER_GUI returns the handle to a new DIGITIZER_GUI or the handle to
%      the existing singleton*.
%
%      DIGITIZER_GUI('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in DIGITIZER_GUI.M with the given input arguments.
%
%      DIGITIZER_GUI('Property','Value',...) creates a new DIGITIZER_GUI or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before Digitizer_GUI_OpeningFcn gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to Digitizer_GUI_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 Digitizer_GUI



% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @Digitizer_GUI_OpeningFcn, ...
                   'gui_OutputFcn',  @Digitizer_GUI_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 Digitizer_GUI is made visible.
function Digitizer_GUI_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 Digitizer_GUI (see VARARGIN)

% Choose default command line output for Digitizer_GUI

% Update handles structure
guidata(hObject, handles);

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


% --- Outputs from this function are returned to the command line.
function varargout = Digitizer_GUI_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 pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
g = str2double(get(handles.text2,'String'));    % nastavenie GAIN
if g < 7
    g = g + 1;
    set(handles.text2,'String',num2str(g));
end

% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
g = str2double(get(handles.text3,'String'));    % nastavenie GAIN
if g < 7
    g = g + 1;
    set(handles.text3,'String',num2str(g));
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)
g = str2double(get(handles.text2, 'String'));   % nastavenie GAIN
if g > 0
    g = g - 1;
    set(handles.text2,'String',num2str(g));
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)
g = str2double(get(handles.text3, 'String'));   % nastavenie GAIN
if g > 0
    g = g - 1;
    set(handles.text3,'String',num2str(g));
end


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


% --- Executes during object creation, after setting all properties.
function edit1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit1 (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 on selection change in listbox1.
function listbox1_Callback(hObject, eventdata, handles)
% hObject    handle to listbox1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

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


% --- Executes during object creation, after setting all properties.
function listbox1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to listbox1 (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 pushbutton5.
function pushbutton5_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton5 (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 pushbutton6.
function pushbutton6_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton6 (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 pushbutton7.
function pushbutton7_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton7 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)



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


% --- Executes during object creation, after setting all properties.
function edit2_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit2 (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 on selection change in listbox2.
function listbox2_Callback(hObject, eventdata, handles)
% hObject    handle to listbox2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

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


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

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


% --- Executes during object creation, after setting all properties.
function edit3_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit3 (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 edit5_Callback(hObject, eventdata, handles)
% hObject    handle to edit5 (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 edit5 as text
%        str2double(get(hObject,'String')) returns contents of edit5 as a double


% --- Executes during object creation, after setting all properties.
function edit5_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit5 (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 on button press in pushbutton8.
function pushbutton8_Callback(hObject, eventdata, handles) % START
% hObject    handle to pushbutton8 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

Fs = 1041.6666666667; % vzorkovaci kmitocet

port = get(handles.edit6,'String'); % nastavenie serioveho portu

N = (get(handles.listbox2,'String'));   % pocet vzorkov na ramec
v = (get(handles.listbox2,'Value'));    
N = str2double(N(v));
 
weigth = get(handles.listbox1, 'Value');    % vyber vahovacieho okna

timeFrames = str2double(get(handles.edit3,'String')); % pocet ramcov na jeden graf

dataSize = str2double(get(handles.edit5,'String')); % max. pocet ramcov na jeden beh programu

delta_f = 1000 * Fs / N;
set(handles.text28,'String',num2str(delta_f,5));

f = Fs/2*linspace(0,1,N/2+1);   
t = 1:timeFrames;

DATA = zeros(N/2 + 1, dataSize);    % DATA = cely zaznam spektier za beh programu
Z = zeros(N/2 + 1, timeFrames);     % Z = matica alokovana iba pre vypocet a zobrazenie grafu

SIGNAL = zeros(N,dataSize);         % SIGNAL = zaznam priebehov signalov za beh programu

buff = zeros(N, 1);

xhigh = 100;
xlow = 2 * Fs / N;

xhigh2 = 30;
xlow2 = 2 * Fs / N;

[F, T] = meshgrid(f,t); % priprava matic pre grafy
F = transpose(F);
T = transpose(T);

% vytvorenie objektu nastavenia seriovej komunikacie
s = serial(port,'BaudRate',1000000,'InputBufferSize', 40000,'ByteOrder', 'littleEndian',...
    'StopBits', 2,'RequestToSend', 'off','BytesAvailableFcnCount', 1,'BytesAvailableFcnMode', 'byte');

fopen(s);   % pripojenie MCU cez seriovy port
pause(0.3);
fwrite(s,"$start;;",'char');
flushinput(s); % flushinput je vsade tam, kde mozem zmazat stare data a je to tam vzdy,
               % pretoze nejaky uviaznuty byte v buffere, by znehodnotil
               % cely timeframe
               % Priklad -> zmazem buffer, poslem prikaz nech MCU posle
               % data a pokial nieco predtym v buffery uviazlo, je to prec,
               % tiez posielam jeden prazdny byte navyše, keby zlyhal
               % prenos, aby sa nezasekol sériový prenos
               
c = 0;

while c ~= dataSize
    c = c + 1;
    flushinput(s);
    gain = str2double(get(handles.text2,'String'));
    
    if((gain >= 0) && (gain < 8))
        fwrite(s, "$gain ", 'char', 'sync');
        fwrite(s,num2str(gain),'char','sync');
        fwrite(s, ";;", 'char', 'sync');
    end
    
    fwrite(s,"$send;;",'char'); 
    header = fread(s, 28, 'uint8');
    check = fread(s,1,'uint32');        % nacitam hodnotu checksum poslanu po datach
    data = fread(s,4096,'uint16');      % nacitam data z bufferu, vzorky
    checksum = sum(header) + sum(data);
    data = double(data);  
    data = 3.3 * data / 2^16;
    avg = mean(data);
    
    while 1
        if checksum == check
            break;
        end
        
        fwrite(s,"$resend;;", 'char');
        header = fread(s, 28, 'uint8');
        check = fread(s,1,'uint32');        % nacitam hodnotu checksum poslanu po datach
        data = fread(s,4096,'uint16');      % nacitam data z bufferu, vzorky
        checksum = sum(header) + sum(data);
        data = double(data);  
        data = 3.3 * data / 2^16;        
    end      
        
    tic;

    set(handles.text35,'String',num2str(c));
    
    var = data - mean(data);
    
    rms = sum(var.^2) / 4096;
    rms = sqrt(rms);
    ampl_t = max(abs(var));
    
    
    
    data = data - 1.65; % nemozem odcitat mean, pretoze by to pri posuvnom okne
                        % sposobovalo skoky !
    
    if (ampl_t < 1.55 )% a ked tak nastavit farbu indikacneho panelu 
        set(handles.uipanel2,'BackgroundColor','g');
    end
    if (ampl_t > 1.549999)
        set(handles.uipanel2,'BackgroundColor','r');
    end
    
    set(handles.text32,'String',num2str(1000*ampl_t,4));
    set(handles.text39,'String',num2str(avg,4));
    set(handles.text41,'String',num2str(1000*rms,4));
    
    
    if(ampl_t > (str2double(get(handles.edit10,'String')) / 1000))
        eval(cell2mat({'save(' '''' 'catch\catch_' num2str(c) '.mat' ''''...
        ',' '''data''' ')'}));        
    end

    if get(handles.togglebutton3,'Value') == 1
        eval(cell2mat({'save(' '''' 'log\' get(handles.edit2,'String') num2str(c) '.mat' ''''...
        ',' '''data''' ')'}));
    end
    
    buff = circshift(buff, -4096);
    buff(N-4095 : N) = double(data(1:4096));
    
    if get(handles.pushbutton11,'Value') == 1 % pokial je stlaceny STOP, tak sa vypne program
        break
    end
    
    c_map = get(handles.edit1,'String'); % nacitanie farebnej palety
    v = get(handles.edit1,'Value');
    c_map = c_map(v);
    
    cScale = floor(str2double(get(handles.edit9,'String')))/10000; % nastavenie
    if cScale < 2                                                  % hornej hodnoty pre fareb. paletu
        cScale = inf;                                              % cscale je koeficient
    end
    
    
    y = buff - mean(buff);
        
    if weigth == 1
        Y_n = fft(y.*hanning(N),N)./N;
    end
    if weigth == 2
        Y_n = fft(y.*hamming(N),N)./N;
    end
    if weigth == 3
        Y_n = fft(y,N)./N;
    end
    % zlim je nastavenie spodnej hranice osy z, tj urovne spektr. zloziek
    zlim = str2double(get(handles.edit7, 'String')) / 10000;
        
    if isnan(zlim) || zlim == 0
        zlim = -inf;
    end
    cmax = abs(zlim) * cScale; % vysledna horna hranica hodnoty pre far. paletu
        
    DATA(:,(c + timeFrames)) = abs(Y_n(1:N/2+1)); % zapisanie spektra
    Z = DATA(:,c+1 : c + timeFrames);   % vyber spektier pre graf
    surf(handles.axes1,F,T,Z,'FaceAlpha',0.6, 'EdgeColor', 'none')
    set(handles.axes1,'view',([-0 90]),...
         'xlim', ([xlow xhigh]), 'ylim', ([1 timeFrames]),...
         'zlim', ([zlim inf]) );
    cmax = num2str(cmax);
    zlim = num2str(zlim);
    eval(['caxis ([' zlim ' ' cmax ']);']);
    
    zlim = str2double(get(handles.edit7, 'String'))/10000;
        
    if isnan(zlim) || zlim == 0
        zlim = -inf;
    end
    cmax = abs(zlim) * cScale; % vysledna horna hranica hodnoty pre far. paletu    
    
    surf(handles.axes4,F,T,Z,'FaceAlpha',0.6, 'EdgeColor', 'none')
    set(handles.axes4,'view',([-0 90]),...
         'xlim', ([xlow2 xhigh2]), 'ylim', ([1 timeFrames]),...
         'zlim', ([zlim inf]) );    
    cmax = num2str(cmax);
    zlim = num2str(zlim);
    eval(['caxis ([' zlim ' ' cmax ']);']);
    
    eval(cell2mat(['colormap' ' ' c_map])); % nstavit colormap
    drawnow;                    % vykreslit graf
    load = (toc + 0.0103) / (4096 / Fs);
    load = load * 100;
    set(handles.text23,'String',num2str(load,3));
end
fclose(s);  % vypnutie seriovej komunikacie


% --- Executes on button press in pushbutton9.
function pushbutton9_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton9 (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 pushbutton11.
function pushbutton11_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton11 (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 pushbutton12.
function pushbutton12_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton12 (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 togglebutton1.
function togglebutton1_Callback(hObject, eventdata, handles)
% hObject    handle to togglebutton1 (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 togglebutton1


% --- Executes on button press in togglebutton2.
function togglebutton2_Callback(hObject, eventdata, handles)
% hObject    handle to togglebutton2 (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 togglebutton2


% --- If Enable == 'on', executes on mouse press in 5 pixel border.
% --- Otherwise, executes on mouse press in 5 pixel border or over pushbutton8.
function pushbutton8_ButtonDownFcn(hObject, eventdata, handles)
% hObject    handle to pushbutton8 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


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

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


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

% Hint: popupmenu 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 togglebutton3.
function togglebutton3_Callback(hObject, eventdata, handles)
% hObject    handle to togglebutton3 (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 togglebutton3


% --- Executes on button press in togglebutton4.
function togglebutton4_Callback(hObject, eventdata, handles)
% hObject    handle to togglebutton4 (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 togglebutton4



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


% --- Executes during object creation, after setting all properties.
function edit7_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit7 (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 edit8_Callback(hObject, eventdata, handles)
% hObject    handle to edit8 (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 edit8 as text
%        str2double(get(hObject,'String')) returns contents of edit8 as a double


% --- Executes during object creation, after setting all properties.
function edit8_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit8 (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 on key press with focus on figure1 and none of its controls.
function figure1_KeyPressFcn(hObject, eventdata, handles)
% hObject    handle to figure1 (see GCBO)
% eventdata  structure with the following fields (see MATLAB.UI.FIGURE)
%	Key: name of the key that was pressed, in lower case
%	Character: character interpretation of the key(s) that was pressed
%	Modifier: name(s) of the modifier key(s) (i.e., control, shift) pressed
% handles    structure with handles and user data (see GUIDATA)

switch eventdata.Key  % klavesove skratky

end



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


% --- Executes during object creation, after setting all properties.
function edit9_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit9 (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 edit10_Callback(hObject, eventdata, handles)
% hObject    handle to edit10 (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 edit10 as text
%        str2double(get(hObject,'String')) returns contents of edit10 as a double


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