frmtest.cpp

来自「在PXA270开发平台上」· C++ 代码 · 共 82 行

CPP
82
字号
#include "frmtest.h"#include <stdio.h>#include <fcntl.h>#include <unistd.h>#define LED_DEV		"/dev/emdoor_8led"/*  *  Constructs a frmtest which is a child of 'parent', with the  *  name 'name' and widget flags set to 'f'  * *  The dialog will by default be modeless, unless you set 'modal' to *  TRUE to construct a modal dialog. */frmtest::frmtest( QWidget* parent,  const char* name, bool modal, WFlags fl )    : Formtest( parent, name, modal, fl ){    DispTimer=new QTimer(this);    connect ( btnOpen, SIGNAL(clicked()), this, SLOT(OpenDevice()));    connect ( btnClose,SIGNAL(clicked()), this, SLOT(CloseDevice()));    connect ( btnExit,SIGNAL(clicked()), this, SLOT(close()));    connect (btnDisplay, SIGNAL(clicked()), this,SLOT(Display()));    connect (btnStop, SIGNAL(clicked()), this,SLOT(StopDisplay()));    connect ( DispTimer, SIGNAL(timeout()),this,SLOT(DisplayTimer()));    fd=-1;    led=0xff;    flag=FALSE;    }/*   *  Destroys the object and frees any allocated resources */frmtest::~frmtest(){    if(fd>0)    {	::close(fd);	fd=-1;    }    // no need to delete child widgets, Qt does it all for us}void frmtest::OpenDevice(){    if(fd<0)	fd = ::open(LED_DEV, O_RDWR);    else	qDebug("The Device is opened!!");    }void frmtest::CloseDevice(){    if(fd>0)    {	::close(fd);	fd=-1;    }    	}void frmtest::Display(){    DispTimer->start(500);}void frmtest::StopDisplay(){    DispTimer->stop();}void frmtest::DisplayTimer(){    flag=!flag;    if(flag==TRUE)	led=0xff;    else	led=0x0;    if(fd>0)	write(fd, &led, 1);}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?