Display driver test (VC)

// DisplayTestDlg.cpp : implementation file
//

#include "stdafx.h"
#include "DisplayTest.h"
#include "DisplayTestDlg.h"
#include "./displaytestdlg.h"
#include "dwdptest.h"
#include "common.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#endif

int handle = 0;

 

CString idstring[GDD_MAX_HW_CID+1]=
{
  "GDD_ID_NONE",                               
  "PCF8548",                                
  "S6B0741",                               
  "LDS506",                               
  "S6B33B0",                              
  "S6B33B1",                               
  "S1D13713",                              
  "BU1594",                                 
  "CSM202B",                               
  "MB86S03_IMAGE_SENSOR",                  
  "MB86S03_COLOR_PROC",                    
  "SUB_S6B33B0",                         
  "SUB_S6B33B1",                           
  "HD66772",                             
  "HD66766R",                             
  "S44203A01",                             
  "L2F50032",                              
  "GDD_MAX_HW_CID"                          
};

// CAboutDlg dialog used for App About

class CAboutDlg : public CDialog
{
public:
 CAboutDlg();

// Dialog Data
 enum { IDD = IDD_ABOUTBOX };

 protected:
 virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support

// Implementation
protected:
 DECLARE_MESSAGE_MAP()
};

CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
}

void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
 CDialog::DoDataExchange(pDX);
}

BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
END_MESSAGE_MAP()


// CDisplayTestDlg dialog

 

CDisplayTestDlg::CDisplayTestDlg(CWnd* pParent /*=NULL*/)
 : CDialog(CDisplayTestDlg::IDD, pParent)
 , m_comport(0)
 , m_message(_T(""))
 , m_displayid(_T(""))
 , m_testimage(0)
 , m_defcontrast(0)
 , m_mincontrast(0)
 , m_maxcontrast(0)
 , m_contrastvalue(0)
 , m_lcdregister(0)
 , m_lcdvalue1(0)
 , m_lcdvalue2(0)
{
 m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CDisplayTestDlg::DoDataExchange(CDataExchange* pDX)
{
 CDialog::DoDataExchange(pDX);
 DDX_Text(pDX, IDC_COM, m_comport);
 DDX_Text(pDX, IDC_MESSAGE, m_message);
 DDX_Text(pDX, IDC_DISPLAYID, m_displayid);
 DDX_Text(pDX, IDC_EDTTESTIMAGE, m_testimage);
 DDX_Text(pDX, IDC_DEFCONTRAST, m_defcontrast);
 DDV_MinMaxUInt(pDX, m_defcontrast, 0, 255);
 DDX_Text(pDX, IDC_MINCONTRAST, m_mincontrast);
 DDV_MinMaxUInt(pDX, m_mincontrast, 0, 255);
 DDX_Text(pDX, IDC_MAXCONTRAST, m_maxcontrast);
 DDV_MinMaxUInt(pDX, m_maxcontrast, 0, 255);
 DDX_Text(pDX, IDC_CONTRASTVALUE, m_contrastvalue);
 DDV_MinMaxUInt(pDX, m_contrastvalue, 0, 255);
 DDX_Text(pDX, IDC_LCDREGISTER, m_lcdregister);
 DDX_Text(pDX, IDC_LCDVALUE1, m_lcdvalue1);
}

BEGIN_MESSAGE_MAP(CDisplayTestDlg, CDialog)
 ON_WM_SYSCOMMAND()
 ON_WM_PAINT()
 ON_WM_QUERYDRAGICON()
 //}}AFX_MSG_MAP
 ON_BN_CLICKED(IDC_CONNECT, OnBnClickedConnect)
 ON_BN_CLICKED(IDC_CHECKCONN, OnBnClickedCheckconn)
 ON_BN_CLICKED(IDC_DISCONNECT, OnBnClickedDisconnect)
 ON_BN_CLICKED(IDC_CLEARMESSAGE, OnBnClickedClearmessage)
 ON_BN_CLICKED(IDC_CMDDISPLAYID, OnBnClickedCmddisplayid)
 ON_NOTIFY(UDN_DELTAPOS, IDC_SPINCOM, OnDeltaposSpincom)
 ON_BN_CLICKED(IDC_TESTIMAGE, OnBnClickedTestimage)
 ON_BN_CLICKED(IDC_STANDBYON, OnBnClickedStandbyon)
 ON_BN_CLICKED(IDC_STANDBYOFF, OnBnClickedStandbyoff)
 ON_BN_CLICKED(IDC_SHUTDOWN, OnBnClickedShutdown)
 ON_BN_CLICKED(IDC_STARTREINIT, OnBnClickedStartreinit)
 ON_BN_CLICKED(IDC_STOPREINIT, OnBnClickedStopreinit)
 ON_BN_CLICKED(IDC_READCONTRAST, OnBnClickedReadcontrast)
 ON_BN_CLICKED(IDC_SETCONTRAST, OnBnClickedSetcontrast)
 ON_BN_CLICKED(IDC_WRITEREGISTER, OnBnClickedWriteregister)
END_MESSAGE_MAP()


// CDisplayTestDlg message handlers

BOOL CDisplayTestDlg::OnInitDialog()
{
 CDialog::OnInitDialog();

 // Add "About..." menu item to system menu.

 // IDM_ABOUTBOX must be in the system command range.
 ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
 ASSERT(IDM_ABOUTBOX < 0xF000);

 CMenu* pSysMenu = GetSystemMenu(FALSE);
 if (pSysMenu != NULL)
 {
  CString strAboutMenu;
  strAboutMenu.LoadString(IDS_ABOUTBOX);
  if (!strAboutMenu.IsEmpty())
  {
   pSysMenu->AppendMenu(MF_SEPARATOR);
   pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
  }
 }

 // 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_comport = 5;
 m_contrastvalue = 150;
 m_testimage = 9;

 CSpinButtonCtrl* pSpin = (CSpinButtonCtrl*) GetDlgItem(IDC_SPINCOM);
 pSpin->SetRange(0, 8);
 pSpin->SetPos(5);

 pSpin = (CSpinButtonCtrl*) GetDlgItem(IDC_SPINTESTIMAGE);
 pSpin->SetRange(1,300);
 pSpin->SetPos(9);

 pSpin = (CSpinButtonCtrl*) GetDlgItem(IDC_SPINCONTRAST);
 pSpin->SetRange(1, 255);
 pSpin->SetPos(150);
 UDACCEL uda;
 uda.nSec = 0;
 uda.nInc = 10;
 pSpin->SetAccel (1, &uda);

 UpdateData(FALSE);
 return TRUE;  // return TRUE  unless you set the focus to a control
}

void CDisplayTestDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
 if ((nID & 0xFFF0) == IDM_ABOUTBOX)
 {
  CAboutDlg dlgAbout;
  dlgAbout.DoModal();
 }
 else
 {
  CDialog::OnSysCommand(nID, lParam);
 }
}

// 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 CDisplayTestDlg::OnPaint()
{
 if (IsIconic())
 {
  CPaintDC dc(this); // device context for painting

  SendMessage(WM_ICONERASEBKGND, reinterpret_cast<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 function to obtain the cursor to display while the user drags
//  the minimized window.
HCURSOR CDisplayTestDlg::OnQueryDragIcon()
{
 return static_cast<HCURSOR>(m_hIcon);
}

void CDisplayTestDlg::OnBnClickedConnect()
{
 // TODO: Add your control notification handler code here
    if (DWD_set_com_port(m_comport, &handle)==FALSE)
   {
       printmessage("Connection failed/r/n");
    return;
    }
    if (DWD_set_v24_mode(dwd_at_hash_on, handle)==FALSE)
    {
    printmessage("Connection failed/r/n");
       return;
    }
 printmessage("Connection OK/r/n");
}

void CDisplayTestDlg::OnBnClickedCheckconn()
{
 // TODO: Add your control notification handler code here
  if (DWD_check_comm_link(handle)==TRUE)
  {
     printmessage("Connection OK/r/n");
  }
  else
  {
     printmessage("Connection failed/r/n");
  }


}

void CDisplayTestDlg::OnBnClickedDisconnect()
{
 // TODO: Add your control notification handler code here
        if (DWD_close_com_port(handle)==TRUE)
      printmessage("Disconnection OK/r/n");
        else
     printmessage("Disconnection failed/r/n");

}

void CDisplayTestDlg::OnBnClickedClearmessage()
{
 // TODO: Add your control notification handler code here
     m_message = "";
  UpdateData(FALSE);
 
}

void CDisplayTestDlg::printmessage(CString str)
{
 static byte count;
 if (count ==5)
 {
      m_message = "";
   count = 1;
 }
 else
 {
  count = count + 1;
 }
 m_message = m_message + str;
    UpdateData(FALSE);
}

 

void CDisplayTestDlg::OnBnClickedCmddisplayid()
{
 // TODO: Add your control notification handler code here
    unsigned int input[255], output[255];
    unsigned short len;
    unsigned int id;
 char tempstr[5];
 memset(tempstr, 0, 5);

    m_displayid = "";
    UpdateData(FALSE);

    input[0]=250;  
    len=2 * sizeof(unsigned int);
    DWD_gdd_generic(atctst_gdd_get_main_sub_hw_id, 4, (unsigned char*)input, &len, (unsigned char*)output, 0);

 if (output[0] == dwd_ok)
 {
  id=output[1];
     sprintf(tempstr, "--%d", id);
  if (id >=0 && id<=GDD_MAX_HW_CID)
  {
   m_displayid = idstring[id] + tempstr;
   UpdateData(FALSE);
  }
  else
   m_displayid = tempstr;
 }
 else
  printmessage("Read Display ID error/r/n");
}

void CDisplayTestDlg::OnDeltaposSpincom(NMHDR *pNMHDR, LRESULT *pResult)
{
 LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
 // TODO: Add your control notification handler code here
 *pResult = 0;
}

void CDisplayTestDlg::OnBnClickedTestimage()
{
 // TODO: Add your control notification handler code here
    unsigned int input[255], output[255];
    unsigned short len;

 UpdateData(TRUE);
    input[0] = 250;//hw_id;
    input[1] = m_testimage;
    len=4;
    DWD_gdd_generic(atctst_gdd_lcd_test_image_start, 2 * sizeof(int32), (unsigned char*)input, &len, (unsigned char*)output, 0);

 if (output[0] != dwd_ok)
 {
  printmessage("Test image failed/r/n");
 }
}

void CDisplayTestDlg::OnBnClickedStandbyon()
{
 // TODO: Add your control notification handler code here
    unsigned int input[255], output[255];
    unsigned short len;

    input[0] = 250;//hw_id;
    input[1] = 0;
    len=4;
    DWD_gdd_generic(atctst_gdd_lcd_set_power_save_mode, 2*sizeof(int32), (unsigned char*)input, &len, (unsigned char*)output, 0);

 if (output[0] != dwd_ok)
 {
  printmessage("Set LCD standby on failed/r/n");
 }
}

void CDisplayTestDlg::OnBnClickedStandbyoff()
{
 // TODO: Add your control notification handler code here
    unsigned int input[255], output[255];
    unsigned short len;

    input[0] = 250;//hw_id;
    input[1] = 1;   
    len=4;
    DWD_gdd_generic(atctst_gdd_lcd_set_power_save_mode, 2*sizeof(int32), (unsigned char*)input, &len, (unsigned char*)output, 0);
 if (output[0] != dwd_ok)
 {
  printmessage("Set LCD standby off failed/r/n");
 }


}

void CDisplayTestDlg::OnBnClickedShutdown()
{
 // TODO: Add your control notification handler code here
    unsigned int input[255], output[255];
    unsigned short len;

    input[0] = 250;//hw_id;
    len=4;
    DWD_gdd_generic(atctst_gdd_lcd_shutdown, sizeof(int32), (unsigned char*)input, &len, (unsigned char*)output, 0);
 if (output[0] != dwd_ok)
 {
  printmessage("Set LCD shut down failed/r/n");
 }

}

void CDisplayTestDlg::OnBnClickedStartreinit()
{
 // TODO: Add your control notification handler code here
    unsigned int input[255], output[255];
    unsigned short len;

    input[0]=1;    //start
    len = 4;

   DWD_gdd_generic(301, 4, (unsigned char*)input, &len, (unsigned char*)output, 0);
 if (output[0] != dwd_ok)
 {
  printmessage("Start reinit failed/r/n");
 }
}

void CDisplayTestDlg::OnBnClickedStopreinit()
{
 // TODO: Add your control notification handler code here
    unsigned int input[255], output[255];
    unsigned short len;

    input[0]=0;    //stop
    len = 4;

   DWD_gdd_generic(301, 4, (unsigned char*)input, &len, (unsigned char*)output, 0);
 if (output[0] != dwd_ok)
 {
  printmessage("Stop reinit failed/r/n");
 }
}

void CDisplayTestDlg::OnEnChangeEdit2()
{
 // TODO:  If this is a RICHEDIT control, the control will not
 // send this notification unless you override the CDialog::OnInitDialog()
 // function and call CRichEditCtrl().SetEventMask()
 // with the ENM_CHANGE flag ORed into the mask.

 // TODO:  Add your control notification handler code here
}

void CDisplayTestDlg::OnBnClickedReadcontrast()
{
 // TODO: Add your control notification handler code here
    unsigned int input[255], output[255];
    unsigned short len;

    input[0] = 250;//hw_id;
    len=4*4;
    DWD_gdd_generic(atctst_gdd_lcd_get_contrast_limits, 1 * sizeof(int32), (unsigned char*)input, &len, (unsigned char*)output, 0);

 if (output[0] == dwd_ok)
 {
        m_defcontrast = output[1];
  m_mincontrast = output[2];
  m_maxcontrast = output[3];
  UpdateData(FALSE);
 }
    else
 {
        m_defcontrast = 0;
  m_mincontrast =0;
  m_maxcontrast =0;
        printmessage("Get contrast limits failed/r/n");
 }
}

void CDisplayTestDlg::OnBnClickedSetcontrast()
{
 // TODO: Add your control notification handler code here
 UpdateData(TRUE);
    unsigned int input[255], output[255];
    unsigned short len;

    input[0] = 250;//hw_id;
    input[1] =m_contrastvalue;

    len=4;
    DWD_gdd_generic(atctst_gdd_lcd_set_contrast, 2 * sizeof(int32), (unsigned char*)input, &len, (unsigned char*)output, 0);

}


void CDisplayTestDlg::OnBnClickedWriteregister()
{
 // TODO: Add your control notification handler code here
#if 0
    unsigned int input[255], output[255];
    unsigned short len;

 UpdateData(TRUE);
    input[0]=250;
   
   /* if (m_lcdregister =="")  //How to judge this item is empty
    {
      ::MessageBox(NULL,"Please input register!", TitleMsg, 0);
      return;
    }*/


    input[1] =m_lcdregister;

    if (m_lcdvalue1 ==0)
       DWD_gdd_generic(atctst_gdd_llc_txi, 8, (unsigned char*)input, &len, (unsigned char*)output, 0);
    else
    {
       input[1]=0x0100 | (0xff & input[1]);
       input[2]=m_lcdvalue1;

       DWD_gdd_generic(atctst_gdd_llc_txi, 12, (unsigned char*)input, &len, (unsigned char*)output, 0);
    }
#endif
   // if (dwd_ok!=output[0])
     //  printmessage( "Write register failed/r/n");

}

 

 

// DisplayTestDlg.h : header file
//

#pragma once


// CDisplayTestDlg dialog
class CDisplayTestDlg : public CDialog
{
// Construction
public:
 CDisplayTestDlg(CWnd* pParent = NULL); // standard constructor

// Dialog Data
 enum { IDD = IDD_DISPLAYTEST_DIALOG };

 protected:
 virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support


// Implementation
protected:
 HICON m_hIcon;

 // Generated message map functions
 virtual BOOL OnInitDialog();
 afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
 afx_msg void OnPaint();
 afx_msg HCURSOR OnQueryDragIcon();
 DECLARE_MESSAGE_MAP()
public:
 BYTE m_comport;
 afx_msg void OnBnClickedConnect();
 afx_msg void OnBnClickedCheckconn();
 afx_msg void OnBnClickedDisconnect();
 CString m_message;
 afx_msg void OnBnClickedClearmessage();

private:
 void printmessage(CString str);
public:
 CString m_displayid;
 afx_msg void OnBnClickedCmddisplayid();
 afx_msg void OnDeltaposSpincom(NMHDR *pNMHDR, LRESULT *pResult);
 UINT m_testimage;
 afx_msg void OnBnClickedTestimage();
 afx_msg void OnBnClickedStandbyon();
 afx_msg void OnBnClickedStandbyoff();
 afx_msg void OnBnClickedShutdown();
 afx_msg void OnBnClickedStartreinit();
 afx_msg void OnBnClickedStopreinit();
 afx_msg void OnEnChangeEdit2();
 UINT m_defcontrast;
 UINT m_mincontrast;
 UINT m_maxcontrast;
 afx_msg void OnBnClickedReadcontrast();
 UINT m_contrastvalue;
 afx_msg void OnBnClickedSetcontrast();
 afx_msg void OnBnClickedButton11();
 afx_msg void OnBnClickedWriteregister();
 UINT m_lcdregister;
 UINT m_lcdvalue1;
 UINT m_lcdvalue2;
};

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值