added VFD::write(), VFD destructor, and driver code
git-svn-id: svn://anubis/misc/parport-2x20vfd@113 bd8a9e45-a331-0410-811e-c64571078777
This commit is contained in:
parent
2fdd2b821b
commit
c0c55edfec
14
VFD.cc
14
VFD.cc
@ -23,6 +23,12 @@ VFD::VFD()
|
||||
m_ppfd = -1;
|
||||
}
|
||||
|
||||
VFD::~VFD()
|
||||
{
|
||||
if (m_ppfd >= 0)
|
||||
disconnect();
|
||||
}
|
||||
|
||||
bool VFD::connect(const std::string & parport)
|
||||
{
|
||||
const int mode = IEEE1284_MODE_BYTE;
|
||||
@ -152,3 +158,11 @@ void VFD::writeData(unsigned char data)
|
||||
{
|
||||
sendByte(1, data);
|
||||
}
|
||||
|
||||
void VFD::write(const std::string & str)
|
||||
{
|
||||
for (const char * chr = str.c_str(); *chr; chr++)
|
||||
{
|
||||
writeData(*chr);
|
||||
}
|
||||
}
|
||||
|
4
VFD.h
4
VFD.h
@ -38,8 +38,11 @@ class VFD
|
||||
static const unsigned char RIGHT = 1;
|
||||
static const unsigned char OFF = 0;
|
||||
static const unsigned char ON = 1;
|
||||
static const unsigned char ADDRESS_LINE1 = 0x80;
|
||||
static const unsigned char ADDRESS_LINE2 = 0xC0;
|
||||
|
||||
VFD();
|
||||
~VFD();
|
||||
bool connect(const std::string & parport = "/dev/parport0");
|
||||
void disconnect();
|
||||
|
||||
@ -55,6 +58,7 @@ class VFD
|
||||
void setCGAddress(unsigned char address);
|
||||
void setAddress(unsigned char address);
|
||||
void writeData(unsigned char data);
|
||||
void write(const std::string & str);
|
||||
|
||||
protected:
|
||||
static const unsigned char RW_WRITE = 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user