// sample1Dlg.cpp : implementation file // #include "stdafx.h" #include "sample1.h" #include "sample1Dlg.h" #include "ACCES32.H" #include #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif #define RLD 0x80 #define XRLD 0x00 #define YRLD XRLD #define Rst_BP 0x01 #define Rst_CTR 0x02 #define Rst_FLAGS 0x04 #define Rst_E 0x06 #define Trf_PR_CTR 0x08 #define Trf_CTR_OL 0x10 #define Trf_PS0_PSC 0x18 #define CMR 0xA0 #define XCMR 0x20 #define YCMR XCMR #define BINCnt 0x00 #define BCDCnt 0x01 #define NrmCnt 0x00 #define RngLmt 0x02 #define NRcyc 0x04 #define ModN 0x06 #define NQDX 0x00 #define QDX1 0x08 #define QDX2 0x10 #define QDX4 0x18 #define IOR 0xC0 #define XIOR 0x40 #define YIOR 0x00 #define DisAB 0x00 #define EnAB 0x01 #define LCTR 0x00 #define LOL 0x02 #define RCTR 0x00 #define ABGate 0x04 #define CYBW 0x00 #define CPBW 0x08 #define CB_UPDN 0x10 #define IDX_ERR 0x18 #define IDR 0xE0 #define XIDR 0x60 #define YIDR XIDR #define DisIDX 0x00 #define EnIDX 0x01 #define NIDX 0x00 #define PIDX 0x02 #define LIDX 0x00 #define RIDX 0x04 #define PI 3.141593 #define SLIDER 1 #define TIMER_DELAY 200 //global function prototypes void Init_7266(unsigned short Addr); int Read_7266_OL(unsigned short Addr); ///////////////////////////////////////////////////////////////////////////// // CSample1Dlg dialog CSample1Dlg::CSample1Dlg(CWnd* pParent /*=NULL*/) : CDialog(CSample1Dlg::IDD, pParent) { //{{AFX_DATA_INIT(CSample1Dlg) m_currentRPM0 = _T(""); m_currentRPM1 = _T(""); m_currentRPM2 = _T(""); m_currentRPM3 = _T(""); m_currentRPM4 = _T(""); m_currentRPM5 = _T(""); m_currentRPM6 = _T(""); m_currentRPM7 = _T(""); m_maxRpmBarLabel0 = _T(""); m_maxRpmBarLabel1 = _T(""); m_maxRpmBarLabel2 = _T(""); m_maxRpmBarLabel3 = _T(""); m_maxRpmBarLabel4 = _T(""); m_maxRpmBarLabel5 = _T(""); m_maxRpmBarLabel6 = _T(""); m_maxRpmBarLabel7 = _T(""); m_sliderLabel0 = _T(""); m_sliderLabel1 = _T(""); m_sliderLabel2 = _T(""); m_sliderLabel3 = _T(""); m_sliderLabel4 = _T(""); m_sliderLabel5 = _T(""); m_sliderLabel6 = _T(""); m_sliderLabel7 = _T(""); //}}AFX_DATA_INIT // Note that LoadIcon does not require a subsequent DestroyIcon in Win32 m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); //It is possible to write arrays of controls in VC6, but it must be done entirely by hand //and breaks the Class Wizard when it is done. So, we will just stuff all the member variables //into the proper arrays. progressBars[0] = &m_bar0; progressBars[1] = &m_bar1; progressBars[2] = &m_bar2; progressBars[3] = &m_bar3; progressBars[4] = &m_bar4; progressBars[5] = &m_bar5; progressBars[6] = &m_bar6; progressBars[7] = &m_bar7; currentRPMs[0] = &m_currentRPM0; currentRPMs[1] = &m_currentRPM1; currentRPMs[2] = &m_currentRPM2; currentRPMs[3] = &m_currentRPM3; currentRPMs[4] = &m_currentRPM4; currentRPMs[5] = &m_currentRPM5; currentRPMs[6] = &m_currentRPM6; currentRPMs[7] = &m_currentRPM7; maxRPMs[0] = &m_maxRpmBarLabel0; maxRPMs[1] = &m_maxRpmBarLabel1; maxRPMs[2] = &m_maxRpmBarLabel2; maxRPMs[3] = &m_maxRpmBarLabel3; maxRPMs[4] = &m_maxRpmBarLabel4; maxRPMs[5] = &m_maxRpmBarLabel5; maxRPMs[6] = &m_maxRpmBarLabel6; maxRPMs[7] = &m_maxRpmBarLabel7; multBoxes[0] = &m_mult0; multBoxes[1] = &m_mult1; multBoxes[2] = &m_mult2; multBoxes[3] = &m_mult3; multBoxes[4] = &m_mult4; multBoxes[5] = &m_mult5; multBoxes[6] = &m_mult6; multBoxes[7] = &m_mult7; paintBoxes[0] = &m_paintBox0; paintBoxes[1] = &m_paintBox1; paintBoxes[2] = &m_paintBox2; paintBoxes[3] = &m_paintBox3; paintBoxes[4] = &m_paintBox4; paintBoxes[5] = &m_paintBox5; paintBoxes[6] = &m_paintBox6; paintBoxes[7] = &m_paintBox7; readings[0] = &m_reading0; readings[1] = &m_reading1; readings[2] = &m_reading2; readings[3] = &m_reading3; readings[4] = &m_reading4; readings[5] = &m_reading5; readings[6] = &m_reading6; readings[7] = &m_reading7; resolutions[0] = &m_resolution0; resolutions[1] = &m_resolution1; resolutions[2] = &m_resolution2; resolutions[3] = &m_resolution3; resolutions[4] = &m_resolution4; resolutions[5] = &m_resolution5; resolutions[6] = &m_resolution6; resolutions[7] = &m_resolution7; resetBtns[0] = &m_rst0; resetBtns[1] = &m_rst1; resetBtns[2] = &m_rst2; resetBtns[3] = &m_rst3; resetBtns[4] = &m_rst4; resetBtns[5] = &m_rst5; resetBtns[6] = &m_rst6; resetBtns[7] = &m_rst7; setBtns[0] = &m_set0; setBtns[1] = &m_set1; setBtns[2] = &m_set2; setBtns[3] = &m_set3; setBtns[4] = &m_set4; setBtns[5] = &m_set5; setBtns[6] = &m_set6; setBtns[7] = &m_set7; sliders[0] = &m_slider0; sliders[1] = &m_slider1; sliders[2] = &m_slider2; sliders[3] = &m_slider3; sliders[4] = &m_slider4; sliders[5] = &m_slider5; sliders[6] = &m_slider6; sliders[7] = &m_slider7; sliderLabels[0] = &m_sliderLabel0; sliderLabels[1] = &m_sliderLabel1; sliderLabels[2] = &m_sliderLabel2; sliderLabels[3] = &m_sliderLabel3; sliderLabels[4] = &m_sliderLabel4; sliderLabels[5] = &m_sliderLabel5; sliderLabels[6] = &m_sliderLabel6; sliderLabels[7] = &m_sliderLabel7; timerRunning = false; } void CSample1Dlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CSample1Dlg) DDX_Control(pDX, IDC_SET7, m_set7); DDX_Control(pDX, IDC_SET6, m_set6); DDX_Control(pDX, IDC_SET5, m_set5); DDX_Control(pDX, IDC_SET4, m_set4); DDX_Control(pDX, IDC_SET3, m_set3); DDX_Control(pDX, IDC_SET2, m_set2); DDX_Control(pDX, IDC_SET1, m_set1); DDX_Control(pDX, IDC_SET0, m_set0); DDX_Control(pDX, IDC_RPM_SLIDER7, m_slider7); DDX_Control(pDX, IDC_RPM_SLIDER6, m_slider6); DDX_Control(pDX, IDC_RPM_SLIDER5, m_slider5); DDX_Control(pDX, IDC_RPM_SLIDER4, m_slider4); DDX_Control(pDX, IDC_RPM_SLIDER3, m_slider3); DDX_Control(pDX, IDC_RPM_SLIDER2, m_slider2); DDX_Control(pDX, IDC_RPM_SLIDER1, m_slider1); DDX_Control(pDX, IDC_RPM_SLIDER0, m_slider0); DDX_Control(pDX, IDC_RPM_BAR7, m_bar7); DDX_Control(pDX, IDC_RPM_BAR6, m_bar6); DDX_Control(pDX, IDC_RPM_BAR5, m_bar5); DDX_Control(pDX, IDC_RPM_BAR4, m_bar4); DDX_Control(pDX, IDC_RPM_BAR3, m_bar3); DDX_Control(pDX, IDC_RPM_BAR2, m_bar2); DDX_Control(pDX, IDC_RPM_BAR1, m_bar1); DDX_Control(pDX, IDC_RPM_BAR0, m_bar0); DDX_Control(pDX, IDC_RESOLUTION7, m_resolution7); DDX_Control(pDX, IDC_RESOLUTION6, m_resolution6); DDX_Control(pDX, IDC_RESOLUTION5, m_resolution5); DDX_Control(pDX, IDC_RESOLUTION4, m_resolution4); DDX_Control(pDX, IDC_RESOLUTION3, m_resolution3); DDX_Control(pDX, IDC_RESOLUTION2, m_resolution2); DDX_Control(pDX, IDC_RESOLUTION1, m_resolution1); DDX_Control(pDX, IDC_RESOLUTION0, m_resolution0); DDX_Control(pDX, IDC_RESET7, m_rst7); DDX_Control(pDX, IDC_RESET6, m_rst6); DDX_Control(pDX, IDC_RESET5, m_rst5); DDX_Control(pDX, IDC_RESET4, m_rst4); DDX_Control(pDX, IDC_RESET3, m_rst3); DDX_Control(pDX, IDC_RESET2, m_rst2); DDX_Control(pDX, IDC_RESET1, m_rst1); DDX_Control(pDX, IDC_RESET0, m_rst0); DDX_Control(pDX, IDC_READING7, m_reading7); DDX_Control(pDX, IDC_READING6, m_reading6); DDX_Control(pDX, IDC_READING5, m_reading5); DDX_Control(pDX, IDC_READING4, m_reading4); DDX_Control(pDX, IDC_READING3, m_reading3); DDX_Control(pDX, IDC_READING2, m_reading2); DDX_Control(pDX, IDC_READING1, m_reading1); DDX_Control(pDX, IDC_READING0, m_reading0); DDX_Control(pDX, IDC_PAINT_BOX7, m_paintBox7); DDX_Control(pDX, IDC_PAINT_BOX6, m_paintBox6); DDX_Control(pDX, IDC_PAINT_BOX5, m_paintBox5); DDX_Control(pDX, IDC_PAINT_BOX4, m_paintBox4); DDX_Control(pDX, IDC_PAINT_BOX3, m_paintBox3); DDX_Control(pDX, IDC_PAINT_BOX2, m_paintBox2); DDX_Control(pDX, IDC_PAINT_BOX1, m_paintBox1); DDX_Control(pDX, IDC_PAINT_BOX0, m_paintBox0); DDX_Control(pDX, IDC_MULT0, m_mult0); DDX_Control(pDX, IDC_INIT_BTN, m_initBtn); DDX_Control(pDX, IDC_GO_BTN, m_goBtn); DDX_Control(pDX, IDC_ADDR, m_addr); DDX_Text(pDX, IDC_CURRENT_RPM0, m_currentRPM0); DDX_Text(pDX, IDC_CURRENT_RPM1, m_currentRPM1); DDX_Text(pDX, IDC_CURRENT_RPM2, m_currentRPM2); DDX_Text(pDX, IDC_CURRENT_RPM3, m_currentRPM3); DDX_Text(pDX, IDC_CURRENT_RPM4, m_currentRPM4); DDX_Text(pDX, IDC_CURRENT_RPM5, m_currentRPM5); DDX_Text(pDX, IDC_CURRENT_RPM6, m_currentRPM6); DDX_Text(pDX, IDC_CURRENT_RPM7, m_currentRPM7); DDX_Text(pDX, IDC_MAX_RPM_BAR_LABEL0, m_maxRpmBarLabel0); DDX_Text(pDX, IDC_MAX_RPM_BAR_LABEL1, m_maxRpmBarLabel1); DDX_Text(pDX, IDC_MAX_RPM_BAR_LABEL2, m_maxRpmBarLabel2); DDX_Text(pDX, IDC_MAX_RPM_BAR_LABEL3, m_maxRpmBarLabel3); DDX_Text(pDX, IDC_MAX_RPM_BAR_LABEL4, m_maxRpmBarLabel4); DDX_Text(pDX, IDC_MAX_RPM_BAR_LABEL5, m_maxRpmBarLabel5); DDX_Text(pDX, IDC_MAX_RPM_BAR_LABEL6, m_maxRpmBarLabel6); DDX_Text(pDX, IDC_MAX_RPM_BAR_LABEL7, m_maxRpmBarLabel7); DDX_Control(pDX, IDC_MULT1, m_mult1); DDX_Control(pDX, IDC_MULT2, m_mult2); DDX_Control(pDX, IDC_MULT3, m_mult3); DDX_Control(pDX, IDC_MULT4, m_mult4); DDX_Control(pDX, IDC_MULT5, m_mult5); DDX_Control(pDX, IDC_MULT6, m_mult6); DDX_Control(pDX, IDC_MULT7, m_mult7); DDX_Text(pDX, IDC_SLIDER_LABEL0, m_sliderLabel0); DDX_Text(pDX, IDC_SLIDER_LABEL1, m_sliderLabel1); DDX_Text(pDX, IDC_SLIDER_LABEL2, m_sliderLabel2); DDX_Text(pDX, IDC_SLIDER_LABEL3, m_sliderLabel3); DDX_Text(pDX, IDC_SLIDER_LABEL4, m_sliderLabel4); DDX_Text(pDX, IDC_SLIDER_LABEL5, m_sliderLabel5); DDX_Text(pDX, IDC_SLIDER_LABEL6, m_sliderLabel6); DDX_Text(pDX, IDC_SLIDER_LABEL7, m_sliderLabel7); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CSample1Dlg, CDialog) //{{AFX_MSG_MAP(CSample1Dlg) ON_WM_PAINT() ON_WM_QUERYDRAGICON() ON_BN_CLICKED(IDC_INIT_BTN, OnInitBtn) ON_BN_CLICKED(IDC_GO_BTN, OnGoBtn) ON_WM_TIMER() ON_BN_CLICKED(IDC_SET0, OnSet0) ON_BN_CLICKED(IDC_SET1, OnSet1) ON_BN_CLICKED(IDC_SET2, OnSet2) ON_BN_CLICKED(IDC_SET3, OnSet3) ON_BN_CLICKED(IDC_SET4, OnSet4) ON_BN_CLICKED(IDC_SET5, OnSet5) ON_BN_CLICKED(IDC_SET6, OnSet6) ON_BN_CLICKED(IDC_SET7, OnSet7) ON_BN_CLICKED(IDC_RESET0, OnReset0) ON_BN_CLICKED(IDC_RESET1, OnReset1) ON_BN_CLICKED(IDC_RESET2, OnReset2) ON_BN_CLICKED(IDC_RESET3, OnReset3) ON_BN_CLICKED(IDC_RESET4, OnReset4) ON_BN_CLICKED(IDC_RESET5, OnReset5) ON_BN_CLICKED(IDC_RESET6, OnReset6) ON_BN_CLICKED(IDC_RESET7, OnReset7) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CSample1Dlg message handlers BOOL CSample1Dlg::OnInitDialog() { CDialog::OnInitDialog(); // Set the icon for this dialog. The framework does this automatically // when the application's main window is not a dialog SetIcon(m_hIcon, TRUE); // Set big icon SetIcon(m_hIcon, FALSE); // Set small icon // TODO: Add extra initialization here m_addr.SetWindowText("300"); m_goBtn.EnableWindow(false); for (int count = 0; count < 8; count++) { resetBtns[count]->EnableWindow(false); setBtns[count]->EnableWindow(false); multBoxes[count]->SetCurSel(0); resolutions[count]->SetWindowText("1000"); sliders[count]->SetTicFreq(5); sliders[count]->SetPos(20); sliders[count] -> SetRange(1, 150, false); *sliderLabels[count] = "20"; *maxRPMs[count] = "20"; *currentRPMs[count] = "-"; readings[count]->SetWindowText("0"); previous_readings[count] = currentReadings[count] = 0; progressBars[count] -> SetRange(0, 20); currentRes[count] = 1000; } UpdateData(false); return TRUE; // return TRUE unless you set the focus to a control } // If you add a minimize button to your dialog, you will need the code below // to draw the icon. For MFC applications using the document/view model, // this is automatically done for you by the framework. void CSample1Dlg::OnPaint() { for (int count = 0; count < 8; count++) doPaintBox(count); if (IsIconic()) { CPaintDC dc(this); // device context for painting SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0); // Center icon in client rectangle int cxIcon = GetSystemMetrics(SM_CXICON); int cyIcon = GetSystemMetrics(SM_CYICON); CRect rect; GetClientRect(&rect); int x = (rect.Width() - cxIcon + 1) / 2; int y = (rect.Height() - cyIcon + 1) / 2; // Draw the icon dc.DrawIcon(x, y, m_hIcon); } else { CDialog::OnPaint(); } } // The system calls this to obtain the cursor to display while the user drags // the minimized window. HCURSOR CSample1Dlg::OnQueryDragIcon() { return (HCURSOR) m_hIcon; } void CSample1Dlg::OnInitBtn() { // TODO: Add your control notification handler code here CString address; char *buf; m_addr.GetWindowText(address); buf = address.GetBuffer(0); sscanf(buf, "%x", &baseAddr); address.ReleaseBuffer(-1); Init_7266(baseAddr); OutPortB(baseAddr + 0x14, 1); m_initBtn.EnableWindow(false); m_goBtn.EnableWindow(true); } BOOL CSample1Dlg::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult) { // TODO: Add your specialized code here and/or call the base class int controlType; int controlIndex; switch (wParam) //it's nice to know some things haven't changed since Windows 3.11 { case IDC_RPM_SLIDER0: controlIndex = 0; controlType = SLIDER; break; case IDC_RPM_SLIDER1: controlIndex = 1; controlType = SLIDER; break; case IDC_RPM_SLIDER2: controlIndex = 2; controlType = SLIDER; break; case IDC_RPM_SLIDER3: controlIndex = 3; controlType = SLIDER; break; case IDC_RPM_SLIDER4: controlIndex = 4; controlType = SLIDER; break; case IDC_RPM_SLIDER5: controlIndex = 5; controlType = SLIDER; break; case IDC_RPM_SLIDER6: controlIndex = 6; controlType = SLIDER; break; case IDC_RPM_SLIDER7: controlIndex = 7; controlType = SLIDER; break; } switch (controlType) { case SLIDER: UpdateData(true); sliderLabels[controlIndex]->Format("%d", sliders[controlIndex]->GetPos()); maxRPMs[controlIndex]-> Format("%d", sliders[controlIndex]->GetPos()); progressBars[controlIndex] -> SetRange(0, sliders[controlIndex] -> GetPos()); UpdateData(false); break; } return CDialog::OnNotify(wParam, lParam, pResult); } void CSample1Dlg::OnGoBtn() { // TODO: Add your control notification handler code here CString displayString; if (timerRunning == false) { for (int count = 0; count < 8; count++) { setBtns[count]->EnableWindow(true); resetBtns[count] ->EnableWindow(true); previous_readings[count] = Read_7266_OL(baseAddr + (count * 2)); currentReadings[count] = previous_readings[count]; displayString.Format("%d", previous_readings[count]); readings[count]->SetWindowText(displayString); } m_goBtn.SetWindowText("Stop"); timerRunning = true; SetTimer(0, TIMER_DELAY, NULL); } else { KillTimer(0); timerRunning = false; m_goBtn.SetWindowText("Go"); } } void CSample1Dlg::OnTimer(UINT nIDEvent) { // TODO: Add your message handler code here and/or call default bool change = false; CString readString; UpdateData(true); for (int count = 0; count < 8; count++) { previous_readings[count] = currentReadings[count]; currentReadings[count] = Read_7266_OL(baseAddr + (count * 2)); if (currentReadings[count] != previous_readings[count]) { change = true; readString.Format("%d", currentReadings[count]); readings[count] -> SetWindowText(readString); } } // if (change == true) Invalidate(false); CDialog::OnTimer(nIDEvent); } void CSample1Dlg::doPaintBox(int channel) { CDC *pDC; CBrush pBrush; CPen pPen; double rpm, angle; int maxRpm, resolution, mult; CString resString; pDC = paintBoxes[channel]-> GetDC(); maxRpm = sliders[channel] -> GetPos(); resolution = currentRes[channel]; mult = multBoxes[channel] -> GetCurSel(); switch (mult) { case 0: mult = 1; break; case 1: mult = 2; break; case 2: mult = 4; break; }; rpm = currentReadings[channel] - previous_readings[channel]; rpm = rpm / (resolution * mult); rpm = rpm * 60 / (TIMER_DELAY * .001); rpm = fabs(rpm); if (rpm != 0) { currentRPMs[channel]->Format("%.2f", rpm); } else { currentRPMs[channel]->Format("-"); } progressBars[channel]->SetPos(rpm); if (rpm >= maxRpm) { pBrush.CreateSolidBrush(RGB(0xFF, 0, 0)); } else { pBrush.CreateSolidBrush(RGB(0xFF, 0xFF, 0xFF)); } pDC -> SelectObject(&pBrush); pDC -> SelectStockObject(BLACK_PEN); pDC -> Ellipse(5, 5, 85, 85); pDC -> MoveTo(45, 45); pDC -> LineTo (45, 85); pDC -> MoveTo(45, 45); angle = currentReadings[channel]; angle = 2 * angle * PI; angle = angle / (resolution * mult) - 0.5 * PI; pPen.CreatePen(PS_SOLID, 0, RGB(0, 0xFF, 0)); pDC -> SelectObject(&pPen); pDC -> LineTo(45 - 40 * cos(angle), 45 - 40 * sin(angle)); UpdateData(false); } void CSample1Dlg::changeResolution(int channel) { CString resString; char *buf; int newRes; resolutions[channel] -> GetWindowText(resString); buf = resString.GetBuffer(0); sscanf(buf, "%d", &newRes); resString.ReleaseBuffer(-1); if (newRes > 0) currentRes[channel] = newRes; else { resString.Format("%d", currentRes[channel]); resolutions[channel] -> SetWindowText(resString); } } void CSample1Dlg::OnSet0() { // TODO: Add your control notification handler code here changeResolution(0); } void CSample1Dlg::OnSet1() { // TODO: Add your control notification handler code here changeResolution(1); } void CSample1Dlg::OnSet2() { // TODO: Add your control notification handler code here changeResolution(2); } void CSample1Dlg::OnSet3() { // TODO: Add your control notification handler code here changeResolution(3); } void CSample1Dlg::OnSet4() { // TODO: Add your control notification handler code here changeResolution(4); } void CSample1Dlg::OnSet5() { // TODO: Add your control notification handler code here changeResolution(5); } void CSample1Dlg::OnSet6() { // TODO: Add your control notification handler code here changeResolution(6); } void CSample1Dlg::OnSet7() { // TODO: Add your control notification handler code here changeResolution(7); } void CSample1Dlg::resetCount(int channel) { OutPortB(baseAddr + 1 + (2 * channel), Rst_CTR); } void Init_7266(unsigned short Addr) { unsigned long XCt; unsigned long YCt; for (int count = 0; count < 4; count++) { XCt = 0xFFFFFF; YCt = 0xFFFFFF; //Setup IOR reg OutPortB(Addr + 1, IOR + DisAB + LOL + ABGate + CYBW); //Setup RLD reg OutPortB(Addr + 1, RLD + Rst_BP + Rst_FLAGS); OutPortB(Addr + 0, 0x0); OutPortB(Addr + 2, 0x0); OutPortB(Addr + 1, RLD + Rst_E + Trf_PS0_PSC); OutPortB(Addr + 1, RLD + Rst_BP + Rst_CTR); //Setup IDR reg OutPortB(Addr + 1, IDR + EnIDX + NIDX + LIDX); //Setup CMR reg OutPortB(Addr + 1, CMR + BINCnt + ModN + QDX1); //Setup PR reg for modulo N counter to XCt OutPortB(Addr + 0, XCt); XCt >>= 8; OutPortB(Addr + 0, XCt); XCt >>= 8; OutPortB(Addr + 0, XCt); //Setup PR reg for modulo N counter to YCt OutPortB(Addr + 2, YCt); YCt >>= 8; OutPortB(Addr + 2, YCt); YCt >>= 8; OutPortB(Addr + 2, YCt); //Enable counters OutPortB(Addr + 1, IOR + EnAB); Addr += 4; } } int Read_7266_OL(unsigned short Addr) { union pos_tag { /* allows access of 32-bit integer as 4 bytes */ int l; struct byte_tag {char b0; char b1; char b2; char b3;} byte; } pos; OutPortB(Addr + 1, 0x10); /* reset address pointer */ OutPortB(Addr + 1, 0x01); /* command to latch counter */ pos.byte.b0 = InPortB(Addr); pos.byte.b1 = InPortB(Addr); pos.byte.b2 = InPortB(Addr); /* extend sign of position */ if (pos.byte.b2 < 0) pos.byte.b3 = -1; else pos.byte.b3 = 0; return pos.l; } void CSample1Dlg::OnReset0() { // TODO: Add your control notification handler code here resetCount(0); } void CSample1Dlg::OnReset1() { // TODO: Add your control notification handler code here resetCount(1); } void CSample1Dlg::OnReset2() { // TODO: Add your control notification handler code here resetCount(2); } void CSample1Dlg::OnReset3() { // TODO: Add your control notification handler code here resetCount(3); } void CSample1Dlg::OnReset4() { // TODO: Add your control notification handler code here resetCount(4); } void CSample1Dlg::OnReset5() { // TODO: Add your control notification handler code here resetCount(5); } void CSample1Dlg::OnReset6() { // TODO: Add your control notification handler code here resetCount(6); } void CSample1Dlg::OnReset7() { // TODO: Add your control notification handler code here resetCount(7); }