added setPPLines(), sendNibble(), and sendByte() VFD functions
git-svn-id: svn://anubis/misc/parport-2x20vfd@111 bd8a9e45-a331-0410-811e-c64571078777
This commit is contained in:
parent
3f8b4d0b5a
commit
dcba2c00fe
28
VFD.cc
28
VFD.cc
@ -69,3 +69,31 @@ void VFD::disconnect()
|
|||||||
m_ppfd = -1;
|
m_ppfd = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void VFD::setPPLines(unsigned char bits)
|
||||||
|
{
|
||||||
|
if (m_ppfd >= 0)
|
||||||
|
{
|
||||||
|
ioctl(m_ppfd, PPWDATA, &bits);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void VFD::sendNibble(unsigned char rs, unsigned char dat)
|
||||||
|
{
|
||||||
|
setPPLines( (rs << PP_OFFSET_RS)
|
||||||
|
| (E_DISABLE << PP_OFFSET_E)
|
||||||
|
| (RW_WRITE << PP_OFFSET_RW)
|
||||||
|
| ((dat & 0xF) << PP_OFFSET_DATA) );
|
||||||
|
usleep(1);
|
||||||
|
setPPLines( (rs << PP_OFFSET_RS)
|
||||||
|
| (E_ENABLE << PP_OFFSET_E)
|
||||||
|
| (RW_WRITE << PP_OFFSET_RW)
|
||||||
|
| ((dat & 0xF) << PP_OFFSET_DATA) );
|
||||||
|
usleep(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void VFD::sendByte(unsigned char rs, unsigned char dat)
|
||||||
|
{
|
||||||
|
sendNibble(rs, (dat >> 4) & 0xF);
|
||||||
|
sendNibble(rs, dat & 0xF);
|
||||||
|
}
|
||||||
|
17
VFD.h
17
VFD.h
@ -32,17 +32,26 @@
|
|||||||
class VFD
|
class VFD
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
VFD();
|
||||||
|
bool connect(const std::string & parport = "/dev/parport0");
|
||||||
|
void disconnect();
|
||||||
|
|
||||||
|
protected:
|
||||||
static const unsigned char RW_WRITE = 0;
|
static const unsigned char RW_WRITE = 0;
|
||||||
static const unsigned char RW_READ = 1;
|
static const unsigned char RW_READ = 1;
|
||||||
static const unsigned char E_ENABLE = 0;
|
static const unsigned char E_ENABLE = 0;
|
||||||
static const unsigned char E_DISABLE = 1;
|
static const unsigned char E_DISABLE = 1;
|
||||||
static const unsigned char RS_COMMAND = 0;
|
static const unsigned char RS_COMMAND = 0;
|
||||||
static const unsigned char RS_DATA = 1;
|
static const unsigned char RS_DATA = 1;
|
||||||
VFD();
|
static const unsigned char PP_OFFSET_RS = 0;
|
||||||
bool connect(const std::string & parport = "/dev/parport0");
|
static const unsigned char PP_OFFSET_RW = 1;
|
||||||
void disconnect();
|
static const unsigned char PP_OFFSET_E = 2;
|
||||||
|
static const unsigned char PP_OFFSET_DATA = 3;
|
||||||
|
|
||||||
|
void sendByte(unsigned char rs, unsigned char dat);
|
||||||
|
void sendNibble(unsigned char rs, unsigned char dat);
|
||||||
|
void setPPLines(unsigned char bits);
|
||||||
|
|
||||||
protected:
|
|
||||||
int m_ppfd; /* parallel port file descriptor */
|
int m_ppfd; /* parallel port file descriptor */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user