seems to be working better with a full initialization routine

git-svn-id: svn://anubis/misc/parport-2x20vfd@116 bd8a9e45-a331-0410-811e-c64571078777
This commit is contained in:
josh 2009-06-19 03:04:34 +00:00
parent 14214f7a99
commit 06e9aec1e0
2 changed files with 25 additions and 11 deletions

31
VFD.cc
View File

@ -56,8 +56,28 @@ bool VFD::connect(const std::string & parport)
else
{
usleep(INIT_DELAY);
sendNibble(0, 0x8); /* set 8-bit mode (sync) */
sendNibble(0, 0x8); /* set 8-bit mode (sync) */
sendNibble(0, 0x8); /* set 8-bit mode (sync) */
sendNibble(0, 0x2); /* set 4-bit mode */
sendByte(1, 0); /* set brightness */
usleep(2);
sendByte(0, 0x8);
usleep(2);
sendByte(0, 0x1);
usleep(DISPLAY_CLEAR_DELAY);
sendByte(0, 0x0C);
usleep(2);
sendByte(0, 0x6);
usleep(2);
return true;
}
@ -93,7 +113,7 @@ void VFD::sendNibble(unsigned char rs, unsigned char dat)
| (E_DISABLE << PP_OFFSET_E)
| (RW_WRITE << PP_OFFSET_RW)
| ((dat & 0xF) << PP_OFFSET_DATA) );
usleep(1);
// usleep(1000);
setPPLines( (rs << PP_OFFSET_RS)
| (E_ENABLE << PP_OFFSET_E)
| (RW_WRITE << PP_OFFSET_RW)
@ -104,13 +124,6 @@ void VFD::sendNibble(unsigned char rs, unsigned char dat)
| (RW_WRITE << PP_OFFSET_RW)
| ((dat & 0xF) << PP_OFFSET_DATA) );
usleep(1);
#if 0
setPPLines( (rs << PP_OFFSET_RS)
| (E_DISABLE << PP_OFFSET_E)
| (RW_WRITE << PP_OFFSET_RW)
| ((dat & 0xF) << PP_OFFSET_DATA) );
usleep(1000);
#endif
}
void VFD::sendByte(unsigned char rs, unsigned char dat)
@ -122,7 +135,7 @@ void VFD::sendByte(unsigned char rs, unsigned char dat)
void VFD::displayClear()
{
sendByte(0, 0x1);
usleep(INIT_DELAY);
usleep(DISPLAY_CLEAR_DELAY);
}
void VFD::cursorHome()

3
VFD.h
View File

@ -71,7 +71,8 @@ class VFD
static const unsigned char PP_OFFSET_RW = 1;
static const unsigned char PP_OFFSET_E = 2;
static const unsigned char PP_OFFSET_DATA = 3;
static const int INIT_DELAY = 10000;
static const int INIT_DELAY = 10 * 1000;
static const int DISPLAY_CLEAR_DELAY = 2300;
void sendByte(unsigned char rs, unsigned char dat);
void sendNibble(unsigned char rs, unsigned char dat);