%% GUI题头
function varargout = DTMF(varargin)
% DTMF MATLAB code for DTMF.fig
% DTMF, by itself, creates a new DTMF or raises the existing
% singleton*.
%
% H = DTMF returns the handle to a new DTMF or the handle to
% the existing singleton*.
%
% DTMF('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in DTMF.M with the given input arguments.
%
% DTMF('Property','Value',...) creates a new DTMF or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before DTMF_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to DTMF_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 DTMF
% Last Modified by GUIDE v2.5 12-May-2013 12:25:02
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @DTMF_OpeningFcn, ...
'gui_OutputFcn', @DTMF_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
%% 打开GUI
% --- Executes just before DTMF is made visible.
function DTMF_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 DTMF (see VARARGIN)
% Choose default command line output for DTMF
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% logo
% web http://www.ilovematlab.cn/forum.php?mod=viewthread&tid=21915
% 备选方案(即将被matlab删除)
%newIcon = javax.swing.ImageIcon('dllgp.jpg');
%figFrame = get(handles.DTMF,'JavaFrame'); %取得Figure的JavaFrame。
%figFrame.setFigureIcon(newIcon); %修改图标
% web http://blog.sina.com.cn/s/blog_4bb051200100w7es.html
ChangeIcon(handles.DTMF,'dllgp.jpg')
% logo(show the image)
axes(handles.axes3);
logo2 = imread('dllgl.jpg');
imshow(logo2);
% 拨号绘图相关
global NUM
NUM = zeros(0,0);
NoCtrl='';
set(handles.ShowNum,'string',NoCtrl);
%axes1绘图生成
cla(handles.axes1);
axes(handles.axes1);
axis([0,200,-2.2,2.2]);
grid on
set(gca,'XTick',0:40:200)
set(gca,'XTickLabel',{'0','40','80','120','160','200'})
title('Wave Figure');
xlabel('n');
ylabel('y');
%axes2绘图生成
cla(handles.axes2);
axes(handles.axes2);
grid on
axis([0,2000,-20,800]);
title('Frequence Figure');
xlabel('n');
ylabel('F');
% 摄像头
Camera_Preview(hObject, eventdata, handles);
Camera_Set(hObject, eventdata, handles);
% UIWAIT makes DTMF wait for user response (see UIRESUME)
% uiwait(handles.DTMF);
% --- Outputs from this function are returned to the command line.
function varargout = DTMF_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;
%% 键盘监控函数
function DTMF_WindowKeyPressFcn(hObject, eventdata, handles)
% 函数用于实现键盘控制
cmd=get(hObject,'currentkey');
switch cmd
case {'0','numpad0'} %数字0
Num0_Callback(hObject, eventdata, handles);
case {'1','numpad1'} %数字1
Num1_Callback(hObject, eventdata, handles);
case {'2','numpad2'} %数字2
Num2_Callback(hObject, eventdata, handles);
case {'3','numpad3'} %数字3
Num3_Callback(hObject, eventdata, handles);
case {'4','numpad4'} %数字4
Num4_Callback(hObject, eventdata, handles);
case {'5','numpad5'} %数字5
Num5_Callback(hObject, eventdata, handles);
case {'6','numpad6'} %数字6
Num6_Callback(hObject, eventdata, handles);
case {'7','numpad7'} %数字7
Num7_Callback(hObject, eventdata, handles);
case {'8','numpad8'} %数字8
Num8_Callback(hObject, eventdata, handles);
case {'9','numpad9'} %数字9
Num9_Callback(hObject, eventdata, handles);
case {'hyphen','subtract'} %*('-号'和'数字-号')
Sign1_Callback(hObject, eventdata, handles);
case {'equal','add'} %#('=号'和'数字+号')
Sign2_Callback(hObject, eventdata, handles);
end
%% 拨号函数组(数字0-9、*号、#号)
function Num0_Callback(hObject, eventdata, handles)
x=get(handles.ShowNum,'string'); % 获得屏幕参数
if(length(x)>15)
errordlg('Sorry . The number you have input is too long !','Input Error','modal')
else
n=1:410; %每个数字410个采样点
%注意 采样fs为8192
y=sin(0.7225*n)+sin(1.0247*n); %对应行频列频时域叠加,数字0的低频942Hz和高频1336Hz叠加
wavplay(y,8192) %产生拨号音
space=zeros(1,410) ; %100个0模拟静音信号
global NUM
phone=[NUM,y]; % 循环储存
NUM=[phone,space]; % 储存连续的拨号音信号
NoCtrl=x;
NoCtrl=[NoCtrl,'0'];
set(handles.ShowNum,'string',NoCtrl);
%axes1绘图生成
axes(handles.axes1);
plot(y);grid
axis([0,200,-2.2,2.2]);
set(gca,'XTick',0:40:200)
set(gca,'XTickLabel',{'0','40','80','120','160','200'})
title('Wave Figure: Number 0');
xlabel('n');
ylabel('y');
%axes2绘图生成
fy=fft(y,8192);
axes(handles.axes2);
plot(abs(fy));grid
axis([0,2000,-20,800]);
title('Frequence Figure: Number 0');
xlabel('n');
ylabel('F');
end
%清空接收栏
NoCtrl1 = [];
set(handles.RecBox,'string',NoCtrl1);
function Num1_Callback(hObject, eventdata, handles)
x=get(handles.ShowNum,'string'); % 获得屏幕参数
if(length(x)>15)
errordlg('Sorry . The number you have input is too long !','Input Error','modal')
else
n=1:410; %每个数字410个采样点
y=sin(0.5208*n)+sin(0.9272*n); %对应行频列频时域叠加,数字1的低频679Hz和高频1207Hz叠加
wavplay(y,8192) %产生拨号音
space=zeros(1,410) ; %100个0模拟静音信号
global NUM
phone=[NUM,y]; % 循环储存
NUM=[phone,space]; % 储存连续的拨号音信号
NoCtrl=x;
NoCtrl=[NoCtrl,'1'];
set(handles.ShowNum,'string',NoCtrl);
%axes1绘图生成
axes(handles.axes1);
plot(y);grid
axis([0,200,-2.2,2.2]);
set(gca,'XTick',0:40:200)
set(gca,'XTickLabel',{'0','40','80','120','160','200'})
title('Wave Figure: Number 1');
xlabel('n');
ylabel('y');
%axes2绘图生成
fy=fft(y,8192);
axes(handles.axes2);
plot(abs(fy));grid
axis([0,2000,-20,800]);
title('Frequence Figure: Number 1');
xlabel('n');
ylabel('F');
end
%清空接收栏
NoCtrl1 = [];
set(handles.RecBox,'string',NoCtrl1);
function Num2_Callback(hObject, eventdata, handles)
x=get(handles.ShowNum,'string'); % 获得屏幕参数
if(length(x)>15)
errordlg('Sorry . The number you have input is too long !','Input Error','modal')
else
n=1:410; %每个数字410个采样点
y=sin(0.5208*n)+sin(1.0247*n); %对应行频列频时域叠加,数字2的低频679Hz和高频1336Hz叠加
wavplay(y,8192) %产生拨号音
space=zeros(1,410) ; %100个0模拟静音信号
global NUM
phone=[NUM,y]; % 循环储存
NUM=[phone,space]; % 储存连续的拨号音信号
NoCtrl=x;
NoCtrl=[NoCtrl,'2'];
set(handles.ShowNum,'string',NoCtrl);
%axes1绘图生成
axes(handles.axes1);
plot(y);grid
axis([0,200,-2.2,2.2]);
set(gca,'XTick',0:40:200)
set(gca,'XTickLabel',{'0','40','80','120','160','200'})
title('Wave Figure: Number 2');
xlabel('n');
ylabel('y');
%axes2绘
普通网友
- 粉丝: 484
- 资源: 1万+
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈