Clear Filters
Clear Filters

GUI FAULT INDICATOR (GREEN, RED)

3 views (last 30 days)
Daniel
Daniel on 25 Apr 2016
Commented: Meade on 25 Apr 2016
HI, i want a FAULT indicator in my GUI. lets say A red circle, or a green circle. is there something simple, built in the GUI that i can use? i dont really want to draw a circle from scratch every place i want an indicator
  3 Comments
Adam
Adam on 25 Apr 2016
If you are using R2016a and the App Designer you can use
doc uilamp
to do this I would think. I haven't used the App Designer or its components yet myself though so I don't know what the limitations are on GUIs created that way are.
Meade
Meade on 25 Apr 2016
For dead-simple notification, just fill the BackgroundColor of your favorie ui object.
Try this as a template:
function toggleTest
% Make fig
figure('Visible','off',...
'OuterPosition', [0 40 400 400],...
'MenuBar', 'none',...
'ToolBar', 'none');
hFig = gcf;
% A simple pushbutton
uicontrol(hFig,'Style','pushbutton',...
'Units', 'norm',...
'Position',[0.2 0.6 0.6 0.25],...
'String','TOGGLE',...
'Callback',@toggleColor);
% STATUS INDICATOR --------------------------
uipanel(gcf,'units','norm',...
'Position',[0.2 0.2 0.6 0.25],...
'BackgroundColor','g',...
'tag', 'PANEL_TOGGLE')
% --------------------------------------------
% Save toggle state
data.TOGGLE_STATE = true;
% Pass Handles
data.Handles = guihandles(hFig);
% Save & Launch
guidata(hFig,data);
movegui(hFig,'center')
hFig.Visible = 'on';
end
function toggleColor(hObj,~)
h = guidata(hObj);
switch h.TOGGLE_STATE
case true
h.Handles.PANEL_TOGGLE.BackgroundColor = 'r';
case false
h.Handles.PANEL_TOGGLE.BackgroundColor = 'g';
end
h.TOGGLE_STATE = ~h.TOGGLE_STATE
guidata(hObj,h);
end

Sign in to comment.

Answers (0)

Categories

Find more on Migrate GUIDE Apps in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!