📄 7300cwav.c
字号:
WS_CHILD | WS_VISIBLE | ES_LEFT,
output_pos[13].x+90, input_pos[15].y+20,60, 20, hWnd, IDC_EDIT1, hInst, NULL);
wsprintf(n,"%d",sample_rate/1000);
SetWindowText(hEdit,n);
wsprintf(n,"%d",data_size);
SetWindowText(hEdit1,n);
CreateWindow("SCROLLBAR", NULL,
WS_CHILD | WS_VISIBLE | SBS_VERT,
output_pos[13].x+10, input_pos[15].y+20,20, 20, hWnd, IDC_SCROLL, hInst, NULL);
hStart = CreateWindow("BUTTON","Start" ,
WS_CHILD | WS_VISIBLE ,
output_pos[10].x+110, input_pos[10].y+10,50, 30, hWnd, IDC_START, hInst, NULL);
hStop = CreateWindow("BUTTON","Stop" ,
WS_CHILD | WS_VISIBLE ,
output_pos[10].x+170, input_pos[10].y+10,50, 30, hWnd, IDC_STOP, hInst, NULL);
CreateWindow("BUTTON","Data Value" ,
WS_CHILD | WS_VISIBLE ,
output_pos[10].x+230, input_pos[10].y+10,80, 30, hWnd, IDC_SHOW, hInst, NULL);
EnableWindow(hStop, FALSE);
hBlackBrush= CreateSolidBrush(RGB(0,0,0));
hRedPen= CreatePen(PS_SOLID,1,RGB(255,0,0));
hBlackPen= CreatePen(PS_SOLID,1,RGB(0,0,0));
break;
case WM_PAINT:
hDC = BeginPaint(hWnd, &ps);
// Digital Input Box
SelectObject(hDC, GetStockObject(GRAY_BRUSH));
Rectangle(hDC, output_pos[15].x-10, io_pos[15].y-24, output_pos[0].x+26, io_pos[0].y+195);
SetTextColor(hDC,RGB(255,255,0));
SetBkColor(hDC, RGB(0, 0, 255));
TextOut(hDC, io_pos[15].x, io_pos[15].y-35, "DMA Input", 9);
SelectObject(hDC, hBlackBrush);
Rectangle(hDC, output_pos[15].x+40/*35*/, io_pos[15].y-2, output_pos[15].x+456/*41*/, io_pos[0].y+172);
SetBkMode(hDC,TRANSPARENT);
TextOut(hDC,output_pos[13].x-60, input_pos[10].y,"Samping Rate",12);
TextOut(hDC,output_pos[13].x+30, input_pos[15].y+20,"KHZ",3);
TextOut(hDC,output_pos[13].x+70, input_pos[10].y,"Buffer Size",11);
TextOut(hDC,output_pos[15].x-4, io_pos[15].y-8,"ffffffffh",9);
TextOut(hDC,output_pos[15].x+24, io_pos[15].y+162,"0",1);
EndPaint(hWnd, &ps);
break;
// Sample Rate Spin Control
case WM_VSCROLL:
switch (LOWORD(wParam)) {
case SB_LINEUP :
sample_rate+=10000;
if (sample_rate > 200000) sample_rate=200000;
break;
case SB_LINEDOWN:
sample_rate-=10000;
if (sample_rate < 10000) sample_rate=10000;
break;
}
wsprintf(n,"%d",sample_rate/1000);
SetWindowText(hEdit,n);
break;
case WM_COMMAND:
switch(LOWORD(wParam)) {
case IDM_EXIT:
SendMessage(hWnd, WM_CLOSE, 0, 0L);
break;
case IDC_SHOW :
DialogBox(hInst, "DMABox", hWnd, ShowDMA);
break;
case IDC_START:
data_size=GetDlgItemInt(hWnd,IDC_EDIT1,NULL ,FALSE);
//setting the DMA buffers
err = DI_ContMultiBufferSetup (card, in_buf, data_size, &BufferId);
if (err < 0) {
wsprintf(s, "DI_ContMultiBufferSetup Error = %d", err);
MessageBox(hWnd, s, "Error", MB_OK);
SendMessage(hWnd, WM_CLOSE, 0, 0L);
break;
}
err = DI_ContMultiBufferSetup (card, in_buf2, data_size, &BufferId);
if (err < 0) {
wsprintf(s, "DI_ContMultiBufferSetup Error = %d", err);
MessageBox(hWnd, s, "Error", MB_OK);
SendMessage(hWnd, WM_CLOSE, 0, 0L);
break;
}
err = DI_ContMultiBufferSetup (card, in_buf3, data_size, &BufferId);
if (err < 0) {
wsprintf(s, "DI_ContMultiBufferSetup Error = %d", err);
MessageBox(hWnd, s, "Error", MB_OK);
SendMessage(hWnd, WM_CLOSE, 0, 0L);
break;
}
err = DI_ContMultiBufferSetup (card, in_buf4, data_size, &BufferId);
if (err < 0) {
wsprintf(s, "DI_ContMultiBufferSetup Error = %d", err);
MessageBox(hWnd, s, "Error", MB_OK);
SendMessage(hWnd, WM_CLOSE, 0, 0L);
break;
}
hMainWnd = hWnd;
clear_op = FALSE;
db_times = 0;
DI_EventCallBack (card, 1, DIEnd, (U32) DI_CallBack );
DI_EventCallBack (card, 1, DBEvent, (U32) DI_DBCallBack );
err = DO_ContWritePort (card, 0, out_buf, 2*data_size, 0, 5000000, ASYNCH_OP);
if (err < 0) {
wsprintf(s, "DO_ContWritePort Error = %d", err);
MessageBox(hWnd, s, "Error", MB_OK);
SendMessage(hWnd, WM_CLOSE, 0, 0L);
break;
}
//start multi-buffered DI
err = DI_ContMultiBufferStart (card, 0, 1);
if (err < 0) {
wsprintf(s, "DI_ContReadPort Error = %d", err);
MessageBox(hWnd, s, "Error", MB_OK);
SendMessage(hWnd, WM_CLOSE, 0, 0L);
break;
}
EnableWindow(hStart, FALSE);
EnableWindow(hStop, TRUE);
MessageBeep(0);
break;
case IDC_STOP:
clear_op = TRUE;
DI_AsyncClear(card, &count);
EnableWindow(hStop, FALSE);
break;
default:
return(DefWindowProc(hWnd, message, wParam, lParam));
}
break;
case WM_DESTROY:
if (card >= 0) Release_Card(card);
DeleteObject(hBlackBrush);
DeleteObject(hRedPen);
PostQuitMessage(0);
break;
default:
return(DefWindowProc(hWnd, message, wParam, lParam));
}
return(NULL);
}
BOOL PASCAL ShowDMA(hDlg, message, wParam, lParam)
HWND hDlg;
UINT message;
WPARAM wParam;
LPARAM lParam;
{
int nTabs[2] = {32, 92};
long i;
char cBuf[100];
char string[10]=" ";
char data_str[3]=" ";
U16 *pp;
switch (message) {
case WM_INITDIALOG:
hListBox = CreateWindow("LISTBOX", "Index Data (Hex)",
WS_CHILD | WS_VISIBLE | LBS_HASSTRINGS | LBS_STANDARD | LBS_USETABSTOPS |WS_CAPTION,
50, 40, 240, 180, hDlg, 100, hInst, NULL);
SendMessage(hListBox, LB_RESETCONTENT, 0, 0L);
SendMessage(hListBox, LB_SETTABSTOPS, 2, (DWORD)(LPINT) nTabs);
SetDlgItemText(hDlg, DMA_DESCP, "This ListBox can show at most 4000 data");
itoa( data_size, string, 10);
SetDlgItemText(hDlg, DMA_SPACE, string);
pp = (U16 *) in_buf;
if (data_size > 4000) data_size = 4000;
for(i=0;i<data_size; i++) {
wsprintf(cBuf, "%5d\t %08x", i, pp[i]);
SendMessage(hListBox, LB_INSERTSTRING, -1, (DWORD)(LPSTR)cBuf);
}
ShowWindow(hListBox, SW_SHOW);
return (TRUE);
case WM_COMMAND:
if (LOWORD(wParam) == ID_STOP) {
DestroyWindow(hListBox);
EndDialog(hDlg, TRUE);
return (TRUE);
}
break;
}
return (FALSE);
}
//void ProcessThread(void* pArg)
void DI_DBCallBack()
{
BOOLEAN HalfReady=0;
DI_AsyncMultiBufferNextReady(card, &HalfReady, &viewidx);
db_times = (db_times+1)%4;
}
void DI_CallBack()
{
HDC hDC;
U32 i, j;
hDC = GetDC(hMainWnd);
for(j=0; j<4; j++) {
SelectObject(hDC, hBlackBrush);
SelectObject(hDC, hBlackPen);
Rectangle(hDC,output_pos[15].x+40,io_pos[0].y-3,output_pos[15].x+456,io_pos[0].y+175);
SelectObject(hDC, hRedPen);
for (i=0; i<data_size; i++) {
switch((viewidx+1+j)%4) {
case 0:
adinput = in_buf[i];
break;
case 1:
adinput = in_buf2[i];
break;
case 2:
adinput = in_buf3[i];
break;
case 3:
adinput = in_buf4[i];
break;
}
adinput=io_pos[0].y+173-((175*adinput)/0xffff);
if (oldinput!=-1)
MoveToEx(hDC,i*416/data_size+output_pos[15].x+40,oldinput,NULL );
else
MoveToEx(hDC,i*416/data_size+output_pos[15].x+40,adinput,NULL );
LineTo(hDC,i*416/data_size+output_pos[15].x+41,adinput);
oldinput=adinput;
}
}
ReleaseDC(hMainWnd, hDC);
DO_AsyncClear(card, &out_count);
EnableWindow(hStart, TRUE);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -