?? sssa.m
字號:
% SSSA 3SA driver and base interface creator.
% SSSA(800) runs 3SA 768x416 mode
% SSSA(1024) runs 3SA in 960x520 mode
% SSSA(1280) runs 3SA in 1200x650 mode
% Completeed: July 24, 2005
% Terrence Irving
% 2005 NSF REU in SDR
% Stevens Institute of Technology
% Hoboken, NJ USA
% Start 3SA based on user's selected screen width.
function [] = sssa(screen_width)
% 3SA instructions.
sssa_instructions = [' SSSA(800) runs 3SA 768x416 mode' char(10),...
' SSSA(1024) runs 3SA in 960x520 mode' char(10),...
' SSSA(1280) runs 3SA in 1200x650 mode'];
% If user gives no input argument, display instructions.
if nargin == 0
disp(sssa_instructions);
return;
end
% Check to see that only one instance of the application is currently
% running. If it is, bring that figure window to the front and do not
% create another instance (from p. 442 of Graphics and GUIs with MATLAB).
current_figs = get(0, 'children'); % get names of all open figures
fig_exists = 0;
for fig = current_figs'
fig_exists = strcmp(get(fig, 'name'), '3SA');
if fig_exists % if the application is already running (based on finding its name in the current figures array)...
figure(fig); % ...bring it to the front
return;
end
end
% Make object handles global so that function and subfunction calls are
% able to make uicontrol property changes.
global about adc_pb bpsk_pb dac_pb debpsk_pb despread_pb file help img
global instructions_txt mic_image mic_disabled_image about_image mic_pb
global new quit speakers_pb spkrs_image spkrs_disabled_image spread_pb
global sssa_base ss_help srrc_1_pb srrc_2_pb file_new
global status_txt help_string about_string contact_string about_image
% Make dimension data global so that subfunction calls can access it.
global help_window_dims help_txt_dims help_txt_fontsize
global about_window_dims about_txt_dims about_txt_fontsize
global contact_txt_dims contact_txt_fontsize
%----------------------------DIMENSIONS----------------------------%
% Load image RGB data and set uicontrol object dimensions based on user's
% selected resolution.
switch screen_width
case 1280
image_data_1200 = load('image_data_1200');
mic_image = image_data_1200.mic_image_1200;
mic_disabled_image = image_data_1200.mic_disabled_image_1200;
spkrs_image = image_data_1200.spkrs_image_1200;
spkrs_disabled_image = image_data_1200.spkrs_disabled_image_1200;
about_image = image_data_1200.about_image_1200;
sssa_base_image = image_data_1200.sssa_base_image_1200x650;
% Set window dimensions and positions.
sssa_base_dims = [50 50 1200 650];
help_window_dims = [250 200 800 400];
about_window_dims = [500 150 301 518];
% Set pushbutton dimensions, positions, and fontsizes.
mic_pb_dims = [12 475 300 163];
speakers_pb_dims = [888 13 300 163];
spread_pb_dims = [72 351 180 98];
adc_pb_dims = [291 351 180 98];
bpsk_pb_dims = [507 351 180 98];
srrc_1_pb_dims = [723 351 180 98];
srrc_2_pb_dims = [291 202 180 98];
debpsk_pb_dims = [507 202 180 98];
dac_pb_dims = [723 202 180 98];
despread_pb_dims = [948 202 180 98];
pb_fontsize = 15;
% Set text dimensions, positions, and fontsizes.
status_txt_dims = [.40 .8 .32 .1];
status_txt_fontsize = 30;
instructions_txt_dims = [.02 .06 .6 .15];
instructions_txt_fontsize = 14;
help_txt_dims = [.1 .1 .8 .8];
help_txt_fontsize = 12;
about_txt_dims = [.05 .25 .9 .255];
about_txt_fontsize = 8;
contact_txt_dims = [.05 .025 .9 .205];
contact_txt_fontsize = 13;
% Globalize and set "DONE" text and fontsize.
global done_text_fontsize
done_text_fontsize = 13;
global spread_done_dims adc_done_dims bpsk_done_dims
global srrc_trans_done_dims srrc_rec_done_dims debpsk_done_dims
global dac_done_dims despread_done_dims
spread_done_dims = [72 332 180 20];
adc_done_dims = [291 332 180 20];
bpsk_done_dims = [507 332 180 20];
srrc_trans_done_dims = [723 332 180 20];
srrc_rec_done_dims = [291 183 180 20];
debpsk_done_dims = [507 183 180 20];
dac_done_dims = [723 183 180 20];
despread_done_dims = [948 183 180 20];
case 1024
% Load image data.
image_data_960 = load('image_data_960');
mic_image = image_data_960.mic_image_960;
mic_disabled_image = image_data_960.mic_disabled_image_960;
spkrs_image = image_data_960.spkrs_image_960;
spkrs_disabled_image = image_data_960.spkrs_disabled_image_960;
about_image = image_data_960.about_image_960;
sssa_base_image = image_data_960.sssa_base_image_960x520;
% Set window dimensions and positions.
sssa_base_dims = [30 125 960 520];
help_window_dims = [200 200 640 400];
about_window_dims = [400 100 241 575];
% Set pushbutton dimensions, positions, and fontsizes.
mic_pb_dims = [9 382 240 131];
speakers_pb_dims = [710 11 240 131];
spread_pb_dims = [57 282 143 77];
adc_pb_dims = [233 282 143 77];
bpsk_pb_dims = [405 282 143 77];
srrc_1_pb_dims = [580 282 143 77];
srrc_2_pb_dims = [233 163 143 77];
debpsk_pb_dims = [405 163 143 77];
dac_pb_dims = [580 163 143 77];
despread_pb_dims = [762 163 143 77];
pb_fontsize = 12;
% Set text dimensions, positions, and fontsizes.
status_txt_dims = [.40 .8 .32 .1];
status_txt_fontsize = 20;
instructions_txt_dims = [.02 .06 .6 .15];
instructions_txt_fontsize = 12;
help_txt_dims = [.1 .1 .8 .8];
help_txt_fontsize = 10;
about_txt_dims = [.05 .23 .9 .3];
about_txt_fontsize = 4;
contact_txt_dims = [.05 .025 .9 .15];
contact_txt_fontsize = 10;
% Globalize and set "DONE" text and fontsize.
global done_text_fontsize
done_text_fontsize = 9;
global spread_done_dims adc_done_dims bpsk_done_dims
global srrc_trans_done_dims srrc_rec_done_dims debpsk_done_dims
global dac_done_dims despread_done_dims
spread_done_dims = [57 267 143 15];
adc_done_dims = [233 267 143 15];
bpsk_done_dims = [405 267 143 15];
srrc_trans_done_dims = [580 267 143 15];
srrc_rec_done_dims = [233 148 143 15];
debpsk_done_dims = [405 148 143 15];
dac_done_dims = [580 148 143 15];
despread_done_dims = [762 148 143 15];
case 800
% Load image data.
image_data_768 = load('image_data_768');
mic_image = image_data_768.mic_image_768;
mic_disabled_image = image_data_768.mic_disabled_image_768;
spkrs_image = image_data_768.spkrs_image_768;
spkrs_disabled_image = image_data_768.spkrs_disabled_image_768;
about_image = image_data_768.about_image_768;
sssa_base_image = image_data_768.sssa_base_image_768x416;
% Set window dimensions and positions.
sssa_base_dims = [15 250 768 416];
help_window_dims = [180 290 450 340];
about_window_dims = [325 210 193 500];
% Set pushbutton dimensions, positions, and fontsizes.
mic_pb_dims = [9 305 192 105];
speakers_pb_dims = [568 10 192 105];
spread_pb_dims = [46 226 114 62];
adc_pb_dims = [187 226 114 62];
bpsk_pb_dims = [325 226 114 62];
srrc_1_pb_dims = [464 226 114 62];
srrc_2_pb_dims = [187 130 114 62];
debpsk_pb_dims = [325 130 114 62];
dac_pb_dims = [464 130 114 62];
despread_pb_dims = [610 130 114 62];
pb_fontsize = 9;
% Set text dimensions, positions, and fontsizes.
status_txt_dims = [.40 .8 .32 .1];
status_txt_fontsize = 20;
instructions_txt_dims = [.02 .06 .6 .15];
instructions_txt_fontsize = 12;
help_txt_dims = [.05 .01 .9 .9];
help_txt_fontsize = 7;
about_txt_dims = [.05 .148 .9 .45];
about_txt_fontsize = 4;
contact_txt_dims = [.05 .025 .9 .15];
contact_txt_fontsize = 10;
% Globalize and set "DONE" text and fontsize.
global done_text_fontsize
done_text_fontsize = 9;
global spread_done_dims adc_done_dims bpsk_done_dims
global srrc_trans_done_dims srrc_rec_done_dims debpsk_done_dims
global dac_done_dims despread_done_dims
spread_done_dims = [46 211 114 15];
adc_done_dims = [187 211 114 15];
bpsk_done_dims = [325 211 114 15];
srrc_trans_done_dims = [464 211 114 15];
srrc_rec_done_dims = [187 115 114 15];
debpsk_done_dims = [325 115 114 15];
dac_done_dims = [464 115 114 15];
despread_done_dims = [610 115 114 15];
otherwise
disp(sssa_instructions);
return;
end
%----------------------------DIMENSIONS----------------------------%
%-------------------CALLBACK STRINGS, STATIC TEXT------------------%
% SPEAKERS callback
speakers_cb = ['global voice_data; global input_player; input_player = ',...
'audioplayer(voice_data, 8000); component_window_launcher(''speakers_pb'', ' num2str(screen_width) ');'];
% SPREAD callback
spread_cb = ['global voice_data; global input_player; input_player = ',...
'audioplayer(voice_data, 8000); global spread_string; ',...
'component_window_launcher(''spread_pb'', ' num2str(screen_width) ');'];
% ADC callback
adc_cb = ['global adc_string_1 adc_math_string adc_string_2; ',...
'component_window_launcher(''adc_pb'', ' num2str(screen_width) ');'];
% DAC callback
dac_cb = ['global dac_string_1 dac_math_string dac_string_2; ',...
'component_window_launcher(''dac_pb'', ' num2str(screen_width) ');'];
% Instructions
instructions_string = ['Spread Spectrum Simulation Application (3SA) is an educational ',...
'tool designed to give the user a basic introduction to the world of Direct ',...
'Sequence Spread Spectrum (DSSS) communications. Click the microphone to begin.'];
% Help text
help_string = ['MICROPHONE PROBLEMS: ' char(10) 'If you notice that your recorded ',...
'voice input sounds quiet when played back in MATLAB, try adjusting your ',...
'microphone input sensitivy by adjusting your Volume settings (Control ',...
'Panel, Sounds and Audio Devices, Device volume, Advanced, Options, ',...
'Properties will take you to the microphone input controls on Windows XP ',...
'Professional--other Windows operating systems should follow similar ',...
'instructions). If this doesn''t help and even if the loudness ',...
'(amplitude) of your input signal seems reasonable, trying putting the ',...
'microphone closer to your mouth. If all else fails, you can use Windows ',...
'Sound Recorder to record an input and then resample it appropriately ',...
'with MATLAB or another tool (3SA''s input sampling frequency is 8 kHz).',...
char(10) char(10) char(10),...
'3SA RUNS SLOWLY: ' char(10) '3SA processes quite a bit of data, and it ',...
'may appear to be running sluggishly on your machine at times during the ',...
'full simulation. It was created on a machine that had 512 MB of DDR memory, ',...
'so if your computer has less, you may consider running 3SA at a time when ',...
'other memory-intensize applications are NOT running.',...
char(10) char(10) char(10),...
'Please send email regarding any other issues.'];
% About text
about_string = ['3SA (Spread Spectrum Simulation Application) is the result of 10 ',...
'weeks of summer research (May to July 2005) conducted under the National Science ',...
'Foundation''s Research Experience for Undergraduates in Software-Defined Radio ',...
'(NSF REU in SDR). The underlying research and creation of the application ',...
'was completed at the Stevens Institute of Technology in Hoboken, NJ. The ',...
'contact information below can be selected and copied. Please feel free to ',...
'email me with any comments, questions, or suggestions regarding 3SA.'];
% Contact text (to go in editable field so user can copy and paste)
contact_string = ['Terrence Irving' char(10) 'Dartmouth College ''06' char(10),...
'odr@dartmouth.edu' char(10) 'www.cs.dartmouth.edu/~tmi'];
% Base window CLOSEREQUESTFCN callback
SSSA_CRF_cb = ['current_objs = findobj; ',...
'x = size(current_objs); ',...
'x = x(1, 1); ',... % get number of objects
'current_objs = current_objs(2:x, :); ',... % ignore root object (can't be deleted)
'delete(current_objs);' ,... % close all open objects
'global spread_input_player; ',...
'clear spread_input_player; ',... % stop the spread input player
'clear global; ',...
'clear SSSA_CRF_cb about about_image about_string adc_cb; ',... % clear all data created by 3SA...
'clear adc_math_string adc_pb adc_string_1 adc_string_2; ',... % and try and leave other data alone
'clear bpsk_pb bpsk_string contact_string current_figs; ',...
'clear current_objs dac_cb dac_math_string dac_pb dac_string_1; ',...
'clear dac_string_2 debpsk_pb debpsk_string despread_pb; ',...
'clear despread_string fig fig_exists file file_new help; ',...
'clear help_string hi img input_hear input_player; ',...
'clear instructions_string instructions_txt mic_disabled_image; ',...
'clear mic_image mic_pb microphone_string new quit show_about; ',...
'clear show_about_image speakers speakers_cb; ',...
'clear speakers_pb spkrs_disabled_image spkrs_image spkrs_instructions; ',...
'clear spkrs_outro spread_cb spread_pb; ',...
'clear spread_string srrc_1_pb srrc_1_string srrc_2_pb srrc_2_string; ',...
'clear ss_help sssa_base sssa_base_axes sssa_base_image status_txt; ',...
'clear voice_data x about_bg about_text about_window contact_text ',...
'demo explore_mode full_mode mic_continue mic_hear mode save save_as test ',...
'title_txt about_bg about_text about_window contact_text help_text help_window; '];
% FILE: NEW callback
% Exits and restarts 3SA.
file_new = [SSSA_CRF_cb, 'pause(1);' 'sssa(' num2str(screen_width) ');'];
%-------------------CALLBACK STRINGS, STATIC TEXT------------------%
%----------------------------------BASE WINDOW CREATION----------------------------------%
% Set up figure window and menus.
sssa_base = figure('position', sssa_base_dims,...
'menubar', 'none',...
'numbertitle', 'off',...
'resize', 'off',...
'name', '3SA',...
'CloseRequestFcn', SSSA_CRF_cb);
% This MathWorks code (from www.mathworks.com) will display the base window's
% background.
% Create background axes.
sssa_base_axes = axes('units', 'normalized',...
'position', [0 0 1 1]);
% Move the background axes to the bottom of the UI stack.
uistack(sssa_base_axes, 'bottom');
% Load background image.
hi = imagesc(sssa_base_image);
colormap gray;
% Turn the handlevisibility off and make the axes invisible.
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -