Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
ev3-toolbox-matlab
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Container registry
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mindstorms
ev3-toolbox-matlab
Commits
6c382d35
Commit
6c382d35
authored
8 years ago
by
Tim Stadtmann
Browse files
Options
Downloads
Patches
Plain Diff
Add BrickConfig-tool for renaming
parent
b21de407
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
tools/BrickConfig.fig
+0
-0
0 additions, 0 deletions
tools/BrickConfig.fig
tools/BrickConfig.m
+173
-0
173 additions, 0 deletions
tools/BrickConfig.m
with
173 additions
and
0 deletions
tools/BrickConfig.fig
0 → 100644
+
0
−
0
View file @
6c382d35
File added
This diff is collapsed.
Click to expand it.
tools/BrickConfig.m
0 → 100644
+
173
−
0
View file @
6c382d35
function
varargout
=
BrickConfig
(
varargin
)
% BRICKCONFIG MATLAB code for BrickConfig.fig
% BRICKCONFIG, by itself, creates a new BRICKCONFIG or raises the existing
% singleton*.
%
% H = BRICKCONFIG returns the handle to a new BRICKCONFIG or the handle to
% the existing singleton*.
%
% BRICKCONFIG('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in BRICKCONFIG.M with the given input arguments.
%
% BRICKCONFIG('Property','Value',...) creates a new BRICKCONFIG or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before BrickConfig_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to BrickConfig_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 BrickConfig
% Last Modified by GUIDE v2.5 04-Nov-2016 11:21:20
% Begin initialization code - DO NOT EDIT
gui_Singleton
=
1
;
gui_State
=
struct
(
'gui_Name'
,
mfilename
,
...
'gui_Singleton'
,
gui_Singleton
,
...
'gui_OpeningFcn'
,
@
BrickConfig_OpeningFcn
,
...
'gui_OutputFcn'
,
@
BrickConfig_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 BrickConfig is made visible.
function
BrickConfig_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 BrickConfig (see VARARGIN)
% Open connection
[
handles
.
brick
,
succ
]
=
connect
();
if
~
succ
handles
.
connected
=
false
;
else
handles
.
connected
=
true
;
updateFigures
(
handles
);
t
=
timer
;
t
.
TimerFcn
=
@
updateFigures
;
t
.
Period
=
2
;
t
.
StartDelay
=
2
;
t
.
ExecutionMode
=
'fixedSpacing'
;
handles
.
timer
=
t
;
end
% Choose default command line output for BrickConfig
handles
.
output
=
hObject
;
% Update handles structure
guidata
(
hObject
,
handles
);
% UIWAIT makes BrickConfig wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function
varargout
=
BrickConfig_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
;
if
~
handles
.
connected
figure1_CloseRequestFcn
(
hObject
,
eventdata
,
handles
);
end
% --- Executes on button press in pushbutton_close.
function
pushbutton_close_Callback
(
hObject
,
eventdata
,
handles
)
% hObject handle to pushbutton_close (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
figure1_CloseRequestFcn
(
gcbf
,
eventdata
,
handles
)
% --- Executes on button press in pushbutton_rename.
function
pushbutton_rename_Callback
(
hObject
,
eventdata
,
handles
)
% hObject handle to pushbutton_rename (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
b
=
handles
.
brick
;
if
~
(
isa
(
b
,
'CommunicationInterface'
)
&&
b
.
isvalid
)
return
;
end
answer
=
inputdlg
(
'Enter Brick name:'
,
'Rename Brick'
);
if
~
isempty
(
answer
)
b
.
comSetBrickName
(
answer
{:});
updateFigures
(
handles
);
end
msgbox
([
'Renaming will be only be fully effective after '
,
...
'executing the btconnect-script with the old name once!'
]);
figure1_CloseRequestFcn
(
gcbf
,
eventdata
,
handles
)
function
[
b
,
succ
]
=
connect
()
succ
=
false
;
b
=
0
;
l
=
{
'USB'
,
'Bluetooth: rfcomm0'
,
'Bluetooth: rfcomm1'
,
'Bluetooth: rfcomm2'
};
[
selection
,
ok
]
=
listdlg
(
'PromptString'
,
'Select your connection:'
,
...
'SelectionMode'
,
'single'
,
...
'Name'
,
'Connection'
,
...
'ListString'
,
l
);
if
ok
try
switch
selection
case
1
b
=
CommunicationInterface
(
'usb'
);
case
2
b
=
CommunicationInterface
(
'bt'
,
'serPort'
,
'/dev/rfcomm0'
);
case
3
b
=
CommunicationInterface
(
'bt'
,
'serPort'
,
'/dev/rfcomm1'
);
case
4
b
=
CommunicationInterface
(
'bt'
,
'serPort'
,
'/dev/rfcomm2'
);
end
succ
=
true
;
catch
ME
errordlg
(
'Failed to connect to the Brick!'
,
'Connection Error'
);
end
end
return
;
function
updateFigures
(
handles
)
if
handles
.
connected
set
(
handles
.
text_name
,
'String'
,
handles
.
brick
.
comGetBrickName
());
set
(
handles
.
text_mac
,
'String'
,
handles
.
brick
.
comGetBTID
());
set
(
handles
.
text_charge
,
'String'
,
strcat
(
int2str
(
handles
.
brick
.
uiReadLbatt
()),
'%'
));
end
% --- Executes when user attempts to close figure1.
function
figure1_CloseRequestFcn
(
hObject
,
eventdata
,
handles
)
% hObject handle to figure1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: delete(hObject) closes the figure
if
handles
.
connected
handles
.
brick
.
delete
();
end
delete
(
hObject
);
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment