📄 dlgshengfang.cpp
字号:
// Dlgshengfang.cpp : implementation file
//
#include "stdafx.h"
#include "Agsi.h"
#include "Common.h"
#include "shengfangagsi.h"
#include "Dlgshengfang.h"
#define simrunhead
#include "psrun.h"
#include "psrun.cpp"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
int kin;
char kc[100];
char at24cio;
extern DWORD port1;
/////////////////////////////////////////////////////////////////////////////
// CDlgshengfang dialog
static void PeriUpdate (void);
static void PeriKill (AGSIDLGD *pM);
static void PeriDisp (AGSIMENU *pM);
static CDlgshengfang * pDlgshengfang;
// must not use 'const' here !
// iOpen Hwnd Dlg Proc. Rect: -1 := default Update Kill
AGSIDLGD PeriDlg = { 0, NULL, NULL, { -1, -1, -1, -1, }, PeriUpdate, PeriKill };
// The following line specifies the menu entry in the peripheral pull down menu.
// The '&' and the following character in the sting specifies the keyboard shortcut. <Alt+3> in this case.
// nDelim *szText *fp nID nDlgId *pDlg;
AGSIMENU PeriMenu = { 1, "AT24C01" , PeriDisp, 0, IDD_DLGSHENGFANG, &PeriDlg }; // Peripheral Dialog
static DWORD tl3; // Current values
static DWORD tl3p; // Previous values
static void PeriUpdate (void) // Update Function
{
//return;//
if (pDlgshengfang) pDlgshengfang->Update();
}
static void PeriKill (AGSIDLGD *pM) // Kill Function
{
if (pDlgshengfang == NULL) return;
pDlgshengfang->SendMessage (WM_CLOSE);
pDlgshengfang = NULL;
pM->iOpen = 0;
pM->hw = NULL;
}
static void PeriDisp (AGSIMENU *pM)
{
if (pM->pDlg->hw != NULL) // created
{
PeriKill (pM->pDlg);
}
else // close
{
pDlgshengfang = new CDlgshengfang (pM, NULL); // modeless construction
if (pDlgshengfang != NULL) // construction was Ok.
{
pM->pDlg->hw = pDlgshengfang->m_hWnd; // Dialog handle
}
}
}
CDlgshengfang::CDlgshengfang (AGSIMENU *pMen, CWnd *pWnd)
{
pM = pMen; // save DYM-Descriptor locally.
Create (IDD_DLGSHENGFANG, pWnd);
pDlgshengfang = this;
}
//CDlgshengfang::CDlgshengfang(CWnd* pParent /*=NULL*/)
// : CDialog(CDlgshengfang::IDD, pParent)
//{
// //{{AFX_DATA_INIT(CDlgshengfang)
// // NOTE: the ClassWizard will add member initialization here
// //}}AFX_DATA_INIT
//}
void CDlgshengfang::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDlgshengfang)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
void CDlgshengfang::Update (void)
{ /* Update Dialog Contents */
CString str;
// DWORD port1;
int l;
char c[100];
GetDlgItemText(IDC_KEY,str);
l=strlen(str);
if(l)
{
kin=str[0]-0x30;
if((kin<=9)&&(kin>=0))
{
at24xx[0]=kin;
}
c[0]=kin;
c[1]=0;
SetDlgItemText (IDC_SK, c);
// str.Format("%d",kin);
// SetDlgItemText (IDC_SK1,str);
SetDlgItemText (IDC_KEY,"");
}
Agsi.ReadSFR(TL3, &tl3, &tl3p, 0xFF);
str.Format("%d",tl3p);
SetDlgItemText (IDC_TL3, str); // Status
Agsi.ReadVTR(PORT1, &port1);
if((port1&0x1)!=(filv[at24xxrb]&0x8))
{
if(port1&0x1)
{
filv[at24xxrb]|=8;
}
else
{
filv[at24xxrb]&=0xf7;
}
}
if((port1&0x2)!=(filv[at24xxrb]&0x4))
{
if(port1&0x2)
{
filv[at24xxrb]|=4;
}
else
{
filv[at24xxrb]&=0xfb;
}
}
getat24xx();
if((port1&0x1)!=(filv[at24xxrb]&0x8))
{
if(filv[at24xxrb]&0x8)
{
port1|=1;
}
else
{
port1&=0xfe;
}
Agsi.WriteVTR(PORT1, port1);
}
if((port1&0x2)!=(filv[at24xxrb]&0x4))
{
if(filv[at24xxrb]&0x4)
{
port1|=2;
}
else
{
port1&=0xfd;
}
Agsi.WriteVTR(PORT1, port1);
}
if(port1&0x1)
{
SetDlgItemText (IDC_SCL,"1"); // Status
}
else
{
SetDlgItemText (IDC_SCL,"0"); // Status
}
if(port1&0x2)
{
SetDlgItemText (IDC_SDA,"1"); // Status
}
else
{
SetDlgItemText (IDC_SDA,"0"); // Status
}
str.Format("%x",at24xx[0]);
SetDlgItemText (IDC_SK1, str); // Status
str.Format("%x",opat24xx);
SetDlgItemText (IDC_Status, str); // Status
str.Format("%x",at24xxold);
SetDlgItemText (IDC_Ioold, str); // Status
str.Format("%x",at24xxdat);
SetDlgItemText (IDC_Datin, str); // Status
str.Format("%x",at24xxclk);
SetDlgItemText (IDC_Clkcnt, str); // Status
str.Format("%x",at24xxaddress);
SetDlgItemText (IDC_Address, str); // Status
}
BEGIN_MESSAGE_MAP(CDlgshengfang, CDialog)
//{{AFX_MSG_MAP(CDlgshengfang)
ON_WM_CLOSE()
ON_WM_CHAR()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDlgshengfang message handlers
BOOL CDlgshengfang::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
if (PeriDlg.rc.left != -1) {
SetWindowPos(NULL, /* placement order - not used */
PeriDlg.rc.left, /* left */
PeriDlg.rc.top, /* top */
0, /* width - not used */
0, /* height - not used */
SWP_NOSIZE | SWP_NOZORDER); /* flags */
}
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CDlgshengfang::OnClose()
{
// TODO: Add your message handler code here and/or call default
GetWindowRect (&pM->pDlg->rc); // save Window position
pM->pDlg->hw = NULL; // clear m_hWnd
DestroyWindow(); //--- modeless
CDialog::OnClose();
}
void CDlgshengfang::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
// TODO: Add your message handler code here and/or call default
CString str;
str.Format("%d",nChar);
SetDlgItemText (IDC_SK, str); /* Status */
kin=nChar;
CDialog::OnChar(nChar, nRepCnt, nFlags);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -