
function varargout = Feuchtesensor(varargin)

gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @Feuchtesensor_OpeningFcn, ...
                   'gui_OutputFcn',  @Feuchtesensor_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




function Feuchtesensor_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 Feuchtesensor (see VARARGIN)

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

% Update handles structure
guidata(hObject, handles);




function varargout = Feuchtesensor_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)
createtimer(hObject, eventdata, handles)
update( object,eventdata,handles)
%eee = get(gcf,'Children')
%childrn = get(eee,'Children')
%update(hObj,[],[])

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


   function t = createtimer(hObject, eventdata, handles)

    t = timer;
    t.TimerFcn = @update;
    t.Period = 5;
    t.StartDelay = 1;
    t.ExecutionMode = 'fixedRate';

   

   start(t);
   
   function update(~,~,~)

       hf = findobj('type','figure');
       hc = get(hf,'children');
       h1 = hc(6);
       h2 = hc(5);
       h3 = hc(4);
       antwort = Feuchtesensortest;
 TD = antwort(1,11:16)
 TDF = antwort(1,24:29)
 MV = antwort(1,35:41)
 
 disp([TD TDF MV])



    set(h1,'String',TD);
    set(h2,'String',TDF);
    set(h3,'String',MV);

  %guidata(object, handles);

function antwort = Feuchtesensortest

portnr='COM7';
X='send';

s = serial(portnr); 
set(s,'BaudRate',9600,'DataBits', 8, 'Parity', 'none','StopBits', 1, 'FlowControl', 'none','Terminator','cr'); 
fopen(s); 
fprintf(s,X);
antwort = fgets(s);
fclose(s); 




function edit1_Callback(hObject, eventdata, handles)

handles.wert1 = str2double(get(hObject,'String'));
guidata(hObject,handles);


function edit1_CreateFcn(hObject, eventdata, handles)

if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


    antwort = Feuchtesensortest;
    handles.wert1 = antwort(1,11:16);
    set(hObject,'String',handles.wert1);

guidata(hObject,handles);



function edit2_Callback(hObject, eventdata, handles)

handles.wert2 = str2double(get(hObject,'String'));
guidata(hObject,handles);


function edit2_CreateFcn(hObject, eventdata, handles)

if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


    antwort2 =Feuchtesensortest;
    handles.wert2 = antwort2(1,24:29);
    set(hObject,'String',handles.wert2);

guidata(hObject,handles);


function edit3_Callback(hObject, eventdata, handles)

handles.wert3 = str2double(get(hObject,'String'));
guidata(hObject,handles);


function edit3_CreateFcn(hObject, eventdata, handles)

if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


    antwort3 =Feuchtesensortest;
    handles.wert3 = antwort3(1,35:41);
    set(hObject,'String',handles.wert3);

guidata(hObject,handles);
    








