📄 sssa.m
字号:
set(sssa_base_axes, 'handlevisibility', 'off',...
'visible', 'off')
%----------------------------------MENU BAR----------------------------------%
% FILE
file = uimenu(sssa_base,...
'label', 'File');
new = uimenu(file,...
'label', 'New',...
'enable', 'off',... % disabled until the full simulation is run
'accelerator', 'N',...
'callback', file_new);
quit = uimenu(file,...
'label', 'Quit',...
'accelerator', 'Q',...
'callback', SSSA_CRF_cb,...
'separator', 'on'); % horizontal separator above this item
% HELP
help = uimenu(sssa_base,...
'label', 'Help');
ss_help = uimenu(help,...
'label', '3SA Help',...
'accelerator', 'H',...
'callback', @show_help);
about = uimenu(help,...
'label', 'About',...
'accelerator', 'A',...
'callback', @show_about,...
'separator', 'on'); % horizontal separator above this item
%----------------------------------MENU BAR----------------------------------%
%------------------------------MICROPHONE BUTTON-----------------------------%
% Basically the "Start" button.
mic_pb = uicontrol(sssa_base,...
'style', 'pushbutton',...
'string', '',...
'cdata', mic_image,...
'position', mic_pb_dims,... % top left corner
'callback', ['global microphone_string; component_window_launcher(''mic_pb'', ' num2str(screen_width) ');'],...
'tooltipstring', 'Click the microphone to record an input signal and begin');
%------------------------------MICROPHONE BUTTON-----------------------------%
%--------------------------------SPEAKER BUTTON------------------------------%
% The "Playback" button.
speakers_pb = uicontrol(sssa_base,...
'style', 'pushbutton',...
'string', '',...
'cdata', spkrs_disabled_image,...
'position', speakers_pb_dims,... % bottom right corner
'enable', 'off',... % disabled until the full simulation is complete
'callback', speakers_cb,...
'tooltipstring', 'Click the speakers to play back the processed signal');
%--------------------------------SPEAKER BUTTON------------------------------%
%------------------------------COMPONENT BUTTONS-----------------------------%
% Spread
spread_pb = uicontrol(sssa_base,...
'style', 'pushbutton',...
'string', '2. Spread',...
'backgroundcolor', 'black',...
'foregroundcolor', [.5 0 0],...
'fontsize', pb_fontsize,...
'position', spread_pb_dims,...
'enable', 'off',... % disabled until the full simulation is complete
'callback', spread_cb,...
'tooltipstring', 'Spreads the input signal using a 2-bit Walsh Code');
% % delete this
% spread_done = uicontrol(sssa_base,...
% 'style', 'text',...
% 'fontsize', done_text_fontsize,...
% 'foregroundcolor', 'white',...
% 'backgroundcolor', [.5 0 0],... % matches background image color
% 'horizontalalignment', 'center',...
% 'string', 'DONE',...
% 'position', spread_done_dims);
%
% adc_done = uicontrol(sssa_base,...
% 'style', 'text',...
% 'fontsize', done_text_fontsize,...
% 'foregroundcolor', 'white',...
% 'backgroundcolor', [.5 0 0],... % matches background image color
% 'horizontalalignment', 'center',...
% 'string', 'DONE',...
% 'position', adc_done_dims);
%
% bpsk_done = uicontrol(sssa_base,...
% 'style', 'text',...
% 'fontsize', done_text_fontsize,...
% 'foregroundcolor', 'white',...
% 'backgroundcolor', [.5 0 0],... % matches background image color
% 'horizontalalignment', 'center',...
% 'string', 'DONE',...
% 'position', bpsk_done_dims);
%
% srrc_1_done = uicontrol(sssa_base,...
% 'style', 'text',...
% 'fontsize', done_text_fontsize,...
% 'foregroundcolor', 'white',...
% 'backgroundcolor', [.5 0 0],... % matches background image color
% 'horizontalalignment', 'center',...
% 'string', 'DONE',...
% 'position', srrc_trans_done_dims);
%
% srrc_2_done = uicontrol(sssa_base,...
% 'style', 'text',...
% 'fontsize', done_text_fontsize,...
% 'foregroundcolor', 'white',...
% 'backgroundcolor', [.5 0 0],... % matches background image color
% 'horizontalalignment', 'center',...
% 'string', 'DONE',...
% 'position', srrc_rec_done_dims);
%
% debpsk_done = uicontrol(sssa_base,...
% 'style', 'text',...
% 'fontsize', done_text_fontsize,...
% 'foregroundcolor', 'white',...
% 'backgroundcolor', [.5 0 0],... % matches background image color
% 'horizontalalignment', 'center',...
% 'string', 'DONE',...
% 'position', debpsk_done_dims);
%
% dac_done = uicontrol(sssa_base,...
% 'style', 'text',...
% 'fontsize', done_text_fontsize,...
% 'foregroundcolor', 'white',...
% 'backgroundcolor', [.5 0 0],... % matches background image color
% 'horizontalalignment', 'center',...
% 'string', 'DONE',...
% 'position', dac_done_dims);
%
% despread_done = uicontrol(sssa_base,...
% 'style', 'text',...
% 'fontsize', done_text_fontsize,...
% 'foregroundcolor', 'white',...
% 'backgroundcolor', [.5 0 0],... % matches background image color
% 'horizontalalignment', 'center',...
% 'string', 'DONE',...
% 'position', despread_done_dims);
% ADC
adc_pb = uicontrol(sssa_base,...
'style', 'pushbutton',...
'string', '3. ADC',...
'backgroundcolor', 'black',...
'foregroundcolor', [.5 0 0],...
'fontsize', pb_fontsize,...
'position', adc_pb_dims,...
'enable', 'off',... % disabled until the full simulation is complete
'callback', adc_cb,...
'tooltipstring', 'Compresses the input signal and then creates a binary representation of its data');
% BPSK
bpsk_pb = uicontrol(sssa_base,...
'style', 'pushbutton',...
'string', '4. BPSK',...
'backgroundcolor', 'black',...
'foregroundcolor', [.5 0 0],...
'fontsize', pb_fontsize,...
'position', bpsk_pb_dims,...
'enable', 'off',... % disabled until the full simulation is complete
'callback', ['global bpsk_string; component_window_launcher(''bpsk_pb'', ' num2str(screen_width) ');'],...
'tooltipstring', 'Uses a sinusoidial carrier wave to create an analog represenstation of the binary data');
% SRRC Filter #1
srrc_1_pb = uicontrol(sssa_base,...
'style', 'pushbutton',...
'string', '5. SRRC Filter #1',...
'backgroundcolor', 'black',...
'foregroundcolor', [.5 0 0],...
'fontsize', pb_fontsize,...
'position', srrc_1_pb_dims,...
'enable', 'off',... % disabled until the full simulation is complete
'callback', ['global srrc_1_string; component_window_launcher(''srrc_1_pb'', ' num2str(screen_width) ');'],...
'tooltipstring', 'Filters and upsamples the data prior to transmission');
% SRRC Filter #2
srrc_2_pb = uicontrol(sssa_base,...
'style', 'pushbutton',...
'string', '6. SRRC Filter #2',...
'backgroundcolor', 'black',...
'foregroundcolor', [.5 0 0],...
'fontsize', pb_fontsize,...
'position', srrc_2_pb_dims,...
'enable', 'off',... % disabled until the full simulation is complete
'callback', ['global srrc_2_string; component_window_launcher(''srrc_2_pb'', ' num2str(screen_width) ');'],...
'tooltipstring', 'Filters the received signal');
% de-BPSK
debpsk_pb = uicontrol(sssa_base,...
'style', 'pushbutton',...
'string', '7. de-BPSK',...
'backgroundcolor', 'black',...
'foregroundcolor', [.5 0 0],...
'fontsize', pb_fontsize,...
'position', debpsk_pb_dims,...
'enable', 'off',... % disabled until the full simulation is complete
'callback', ['global debpsk_string; component_window_launcher(''debpsk_pb'', ' num2str(screen_width) ');'],...
'tooltipstring', 'Demodulates the carrier signal');
% DAC
dac_pb = uicontrol(sssa_base,...
'style', 'pushbutton',...
'string', '8. DAC',...
'backgroundcolor', 'black',...
'foregroundcolor', [.5 0 0],...
'fontsize', pb_fontsize,...
'position', dac_pb_dims,...
'enable', 'off',... % disabled until the full simulation is complete
'callback', dac_cb,...
'tooltipstring', 'Recovers the analog data');
% de-Spread
despread_pb = uicontrol(sssa_base,...
'style', 'pushbutton',...
'string', '9. de-Spread',...
'backgroundcolor', 'black',...
'foregroundcolor', [.5 0 0],...
'fontsize', pb_fontsize,...
'position', despread_pb_dims,...
'enable', 'off',... % disabled until the full simulation is complete
'callback', ['global despread_string; component_window_launcher(''despread_pb'', ' num2str(screen_width) ');'],...
'tooltipstring', 'Undoes the spreading operation');
%------------------------------COMPONENT BUTTONS-----------------------------%
%----------------------------------BASE WINDOW CREATION----------------------------------%
%---------------------------------STATIC TEXT--------------------------------%
% Status text
status_txt = uicontrol(sssa_base,...
'style', 'text',...
'fontsize', status_txt_fontsize,...
'foregroundcolor', 'white',...
'fontangle', 'italic',...
'backgroundcolor', [.5 0 0],... % matches background image color
'horizontalalignment', 'center',...
'string', 'Not running...',...
'units', 'normalized',...
'position', status_txt_dims);
% Instructions
instructions_txt = uicontrol(sssa_base,...
'style', 'text',...
'fontsize', instructions_txt_fontsize,...
'foregroundcolor', 'white',...
'backgroundcolor', [.5 0 0],... % matches background image color
'horizontalalignment', 'left',...
'string', instructions_string,...
'units', 'normalized',...
'position', instructions_txt_dims);
%---------------------------------STATIC TEXT--------------------------------%
%------------------------------CALLBACK FUNCTIONS----------------------------%
% DISPLAY HELP WINDOW callback
function [] = show_help(obj, eventdata)
% Globalize dimension data and uicontrol objects that this function must access.
global help_string help_window_dims
global help_txt_dims help_txt_fontsize
% Create Help window.
help_window = figure('position', help_window_dims,...
'menubar', 'none',...
'numbertitle', 'off',...
'resize', 'off',...
'color', [.5 0 0],...
'name', 'Help');
% Add Help text.
help_txt = uicontrol(help_window,...
'style', 'text',...
'fontsize', help_txt_fontsize,...
'foregroundcolor', 'white',...
'backgroundcolor', [.5 0 0],...
'horizontalalignment', 'center',...
'string', help_string,...
'units', 'normalized',...
'position', help_txt_dims);
% DISPLAY ABOUT WINDOW callback
function [] = show_about(obj, eventdata)
% Globalize dimension data and uicontrol objects that this function must access.
global about_window_dims about_string contact_string about_image
global about_txt_dims about_txt_fontsize
global contact_txt_dims contact_txt_fontsize
% Create About window.
about_window = figure('position', about_window_dims,...
'menubar', 'none',...
'numbertitle', 'off',...
'resize', 'off',...
'color', [.5 0 0],...
'name', 'About 3SA');
% Create About text.
about_txt = uicontrol(about_window,...
'style', 'text',...
'fontsize', about_txt_fontsize,...
'foregroundcolor', 'white',...
'backgroundcolor', [.5 0 0],...
'horizontalalignment', 'center',...
'string', about_string,...
'units', 'normalized',...
'position', about_txt_dims);
% Create Contact text.
contact_txt = uicontrol(about_window,...
'style', 'edit',...
'fontsize', contact_txt_fontsize,...
'foregroundcolor', [.5 0 0],...
'backgroundcolor', 'white',...
'horizontalalignment', 'center',...
'string', contact_string,...
'max', 10,... % as long as max > min, multiple lines allowed (can't specify how many though)
'min', 1,...
'units', 'normalized',...
'position', contact_txt_dims);
% Display 3SA logo in background using MathWorks code from above.
about_bg = axes('units', 'normalized',...
'position', [0 0 1 1]);
uistack(about_bg, 'bottom'); % move image axes to bottom of UI stack
hi = imagesc(about_image); % specify image data
colormap gray;
set(about_bg, 'handlevisibility', 'off', 'visible', 'off'); % prevent use of these axes
%------------------------------CALLBACK FUNCTIONS----------------------------%
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -