DPC Module:DPC under Windows

From LEXWiKi

(Difference between revisions)
Jump to: navigation, search
(How to use the DEMO application)
(Sample code Introduction)
Line 60: Line 60:
== Sample code Introduction ==
== Sample code Introduction ==
-
===Open COM Port Device===
+
===Define SMBus regester===
-
In Sample code /LCD_CTLDlg.cpp lin 157
+
#define SMBUSPORT 0x0500
-
if(m_SerialPort.InitPort(this,nPort,9600,'N',8,1,EV_RXFLAG|EV_RXCHAR,512)) //Set LCM to 9600.n.8.1
+
#define HST_STS SMBUSPORT+0x00
-
{
+
#define HST_CNT SMBUSPORT+0x02
-
m_SerialPort.StartMonitoring(); //Open Com port monitoring
+
#define HST_CMD SMBUSPORT+0x03
-
m_bSerialPortOpened=TRUE; //Set COM port open
+
#define XMIT_SLVA SMBUSPORT+0x04
-
}
+
#define HST_D0 SMBUSPORT+0x05
 +
#define bSize 1
 +
#define SADD 0xb0
 +
#define PWMFeq 0x01
 +
#define PWMDuty 0x02
-
===Close COM Port Device===
+
===Set Frequency data===
-
In Sample code /LCD_CTLDlg.cpp lin 171
+
DWORD dwPortVal;
-
m_SerialPort.ClosePort(); //Set COM port close
+
bool bResult;
-
m_bSerialPortOpened=FALSE;
+
bResult = InitializeWinIo();
 +
 +
if (bResult){
 +
SetPortVal(HST_STS, 0xFE, bSize); //start
 +
Sleep(20);
 +
SetPortVal(XMIT_SLVA, SADD, bSize); //set
 +
Sleep(20);
 +
SetPortVal(HST_CMD, PWMFeq, bSize); //set frequency
 +
Sleep(20);
 +
GetPortVal(HST_STS, &dwPortVal, bSize);
 +
Sleep(20);
 +
dwPortVal = dwPortVal & 0x01;
 +
if (dwPortVal == 0){
 +
SetPortVal(HST_D0, fvalue, bSize); //write data into frequency
 +
Sleep(20);
 +
SetPortVal(HST_CNT, 0x48, bSize); //stop
 +
Sleep(20);
 +
ShutdownWinIo();
 +
}
 +
else
 +
ShutdownWinIo();
 +
}
 +
ShutdownWinIo();
-
===Send the UP line message to LCM Device===
+
===Set Duty data===
-
In Sample code /LCD_CTLDlg.cpp lin 183
+
UpdateData(TRUE);
-
if(!m_bSerialPortOpened) return; //check the com port was open
+
DWORD dwPortVal;
-
UpdateData(TRUE);
+
bool bResult;
-
char szSend[30] = {0x1b, 0x51, 0x41}; //0x1b , 0x51 ,0x41 for LCM send UPline command
+
bResult = InitializeWinIo();
-
sprintf(szSend+3, "%s\r", m_Sendmsg);
+
-
m_SerialPort.WriteToPort(szSend); //Write command and message to LCM device
+
if (bResult){
-
 
+
SetPortVal(HST_STS, 0xFE, bSize); //start
-
===Send the LOW line message to LCM Device===
+
Sleep(20);
-
In Sample code /LCD_CTLDlg.cpp lin 215
+
SetPortVal(XMIT_SLVA, SADD, bSize); //set
-
UpdateData();
+
Sleep(20);
-
char szSend[30] = {0x1b, 0x51, 0x42}; //0x1b , 0x51 ,0x42 for LCM send LOWline command
+
SetPortVal(HST_CMD, PWMDuty, bSize); //set duty
-
sprintf(szSend+3, "%s\r", m_Sendmsg2);
+
Sleep(20);
-
m_SerialPort.WriteToPort(szSend); //Write command and message to LCM device
+
GetPortVal(HST_STS, &dwPortVal, bSize);
-
 
+
Sleep(20);
-
===LCM Command list===
+
dwPortVal = dwPortVal & 0x01;
-
Please check the page6 in spec file ,you can download form [ftp://ftp.lex.com.tw/Engineer/SoftSupport/AP_Module/LCM_release/SCS02002R0LEW--ENGLISH.pdf LCM-Spec]
+
if (dwPortVal == 0){
 +
if (inverter == false)
 +
SetPortVal(HST_D0, dvalue * 10 , bSize); //write data into data
 +
else if (inverter == true)
 +
SetPortVal(HST_D0, (10 - dvalue) * 10 , bSize);
 +
Sleep(20);
 +
SetPortVal(HST_CNT, 0x48, bSize); //stop
 +
Sleep(20);
 +
ShutdownWinIo();
 +
}
 +
else
 +
ShutdownWinIo();
 +
}
 +
ShutdownWinIo();

Revision as of 15:33, 6 April 2009

Contents

DPC Module Spec

The Sample code source you can download form

Source file: DPCv2.4wSrc.rar

Binary file: DPC_v2.4w.rar

How to use the DEMO application

Image:DPC_AP_1.jpg

1. When double click "DPC v2.4w.exe",it will hide and show in the notification area.

Image:DPC_AP_2.jpg

2. Panel selection

3. Confirm the panel which selected

4. If you choose to save panel , you need not to select panel again next time.

5. If you install DPC v2.4w , it will autorun when start Windows XP.

6. If you don't want to use DPC anymore , you can uninstall it.

7. Brightness control , you can choose : 10,20,30,40,50,60,70,80,90,100.

8. Show the brightness data which you choose.

9. When click the LightOff button , the panel will become darkest.

10. Record mouse position for go to 10 when LightOff. If click the button , 13 will show , you can click anywhere which you want for light on.

11. Record hotkey for go to 10 when LightOff. If click the button , The Record Hot Key window will show.

12. When click minimized , DPC will hide and show in the notification area.


Image:DPC_AP_3.jpg

13. The light on mouse position and hotkay can not use together , after you record hotkey , you can't use the position anymore.

Image:DPC_AP_4.jpg

14. First key of hotkey

15. Second key of hotkey

16. Third key hotkey

17. Confirm the hotkey which you entered

18. Show hotkey which you set.

19. Hotkey will show here.

Image:DPC_AP_5.jpg

20. If you want to exit DPC , you should click right button of mouse on the icon and choose exit.

Sample code Introduction

Define SMBus regester

#define SMBUSPORT		0x0500
#define	HST_STS			SMBUSPORT+0x00
#define	HST_CNT			SMBUSPORT+0x02
#define	HST_CMD			SMBUSPORT+0x03
#define	XMIT_SLVA		SMBUSPORT+0x04
#define	HST_D0			SMBUSPORT+0x05
#define bSize			1
#define SADD			0xb0
#define PWMFeq			0x01
#define PWMDuty			0x02

Set Frequency data

DWORD dwPortVal;
bool bResult;
bResult = InitializeWinIo();

if (bResult){
     SetPortVal(HST_STS, 0xFE, bSize); //start
     Sleep(20);
     SetPortVal(XMIT_SLVA, SADD, bSize); //set
     Sleep(20);
     SetPortVal(HST_CMD, PWMFeq, bSize); //set frequency
     Sleep(20);
     GetPortVal(HST_STS, &dwPortVal, bSize);
     Sleep(20);
     dwPortVal = dwPortVal & 0x01;
     if (dwPortVal == 0){
          SetPortVal(HST_D0, fvalue, bSize); //write data into frequency
          Sleep(20);
          SetPortVal(HST_CNT, 0x48, bSize); //stop
          Sleep(20);
          ShutdownWinIo();
     }
     else
          ShutdownWinIo();
}
ShutdownWinIo();

Set Duty data

UpdateData(TRUE);
DWORD dwPortVal;
bool bResult;
bResult = InitializeWinIo();

if (bResult){
     SetPortVal(HST_STS, 0xFE, bSize); //start
     Sleep(20);
     SetPortVal(XMIT_SLVA, SADD, bSize); //set 
     Sleep(20);
     SetPortVal(HST_CMD, PWMDuty, bSize); //set duty
     Sleep(20);
     GetPortVal(HST_STS, &dwPortVal, bSize);
     Sleep(20);
     dwPortVal = dwPortVal & 0x01;
     if (dwPortVal == 0){
          if (inverter == false)
               SetPortVal(HST_D0, dvalue * 10 , bSize); //write data into data
          else if (inverter == true)
               SetPortVal(HST_D0, (10 - dvalue) * 10 , bSize); 
          Sleep(20);
   	   SetPortVal(HST_CNT, 0x48, bSize); //stop
          Sleep(20);
          ShutdownWinIo();
     }
     else
          ShutdownWinIo();
}
ShutdownWinIo();
Personal tools