use a toggle button with check boxes selection for controling other toggle buttons at same time

2 vues (au cours des 30 derniers jours)
I am using uibutton. i try to make a function that i can tick several checkboxes and push the 'open all' toggle button to open different number of individual toggles that catch different slider value. however i can not find any good solutions for my problem. Very Thanks First.
  2 commentaires
Adam
Adam le 18 Juil 2018
What does your function look like so far?
Kuang-Yu WANG
Kuang-Yu WANG le 18 Juil 2018
Modifié(e) : Kuang-Yu WANG le 18 Juil 2018
function checkpump(hObject, ~, ~)
global GUI vc p1 p2 p3 p4 p5 p6
val=get(hObject,'value');
check = get(hObject, 'UserData');
if strcmp(check, 'Pump1')
check = slider1; %slider is for pump control
elseif strcmp(check, 'Pump2')
check = slider2;
elseif strcmp(check, 'Pump3')
check = slider3;
else errordlg('pump_Callback cannot recognize which pump to operate.');
check = 0;
end
if check ~= 0
if val==1 % button down
set(hObject,'BackgroundColor',GUI.offcolor,... %yellow = pump running
'string',[get(hObject, 'UserData') ' running'],'FontSize',10);
if check == slider1
if get(checkbox1,'value',1)
GUI.p1Running = 1;
p1.ts = 0;
p1.num = str2num(get(edit1),'String')); %edit provide the values which pump1 select
ps=get(slider,'Max')-
get(slider1,'value')+20;
set(p1.t, 'Period', ps/1000); %the number can change pumping speed
start(p1.t);
end
elseif check == slider2
check = slider2;
if get(checkbox2,'value',1)
GUI.p2Running = 1;
p2.ts = 0;
p2.num = str2num(get(edit2,'String'));
ps=get(slider2,'Max')-get(slider2,'value')+20;
set(p2.t, 'Period', ps/1000);
start(p2.t);
end
elseif check == slider3
if get(checkbox3,'value',1)
GUI.p3Running = 1;
p3.ts = 0;
p3.num = str2num(edit3,'String'));
ps=get(slider3,'Max')-get(slider3,'value')+20;
set(p3.t, 'Period', ps/1000);
start(p3.t);
end
elseif val==0
set(hObject,'BackgroundColor',GUI.menucolor,...
'string',[get(hObject, 'UserData') ' stopped'],'FontSize',9);
if check == slider1
GUI.p1Running = 0;
stop(p1.t);
vc = vc_set_bits_ac(vc, p1.num, [1 1 1]);
elseif check == slider2
GUI.p2Running = 0;
stop(p2.t);
vc = vc_set_bits_ac(vc, p2.num, [1 1 1]);
else check == slider3
GUI.p3Running = 0;
stop(p3.t);
vc = vc_set_bits_ac(vc, p3.num, [1 1 1]);
end
end
end
this function is for the'open all' toggle button

Connectez-vous pour commenter.

Réponses (0)

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by