display not working again, need more investigation into why it stopped :(

git-svn-id: svn://anubis/misc/parport-2x20vfd@115 bd8a9e45-a331-0410-811e-c64571078777
This commit is contained in:
josh 2009-05-04 01:50:07 +00:00
parent 6c72574c16
commit 14214f7a99
4 changed files with 34 additions and 17 deletions

View File

@ -1,8 +1,9 @@
TARGET := driver
SRCS := $(wildcard *.cc)
HEADERS := $(wildcard *.h)
all: $(TARGET)
$(TARGET): $(SRCS)
$(CXX) -o $@ $(CXXFLAGS) $(LDFLAGS) $^
$(TARGET): $(SRCS) $(HEADERS)
$(CXX) -o $@ $(CXXFLAGS) $(LDFLAGS) $(SRCS)

21
VFD.cc
View File

@ -89,11 +89,6 @@ void VFD::setPPLines(unsigned char bits)
void VFD::sendNibble(unsigned char rs, unsigned char dat)
{
setPPLines( (rs << PP_OFFSET_RS)
| (E_ENABLE << PP_OFFSET_E)
| (RW_WRITE << PP_OFFSET_RW)
| ((dat & 0xF) << PP_OFFSET_DATA) );
usleep(1);
setPPLines( (rs << PP_OFFSET_RS)
| (E_DISABLE << PP_OFFSET_E)
| (RW_WRITE << PP_OFFSET_RW)
@ -104,6 +99,18 @@ void VFD::sendNibble(unsigned char rs, unsigned char dat)
| (RW_WRITE << PP_OFFSET_RW)
| ((dat & 0xF) << PP_OFFSET_DATA) );
usleep(1);
setPPLines( (rs << PP_OFFSET_RS)
| (E_DISABLE << PP_OFFSET_E)
| (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)
@ -159,7 +166,7 @@ void VFD::setAddress(unsigned char address)
sendByte(0, 0x80 | (address & 0x7F));
}
void VFD::writeData(unsigned char data)
void VFD::writeByte(unsigned char data)
{
sendByte(1, data);
}
@ -168,6 +175,6 @@ void VFD::write(const std::string & str)
{
for (const char * chr = str.c_str(); *chr; chr++)
{
writeData(*chr);
writeByte(*chr);
}
}

10
VFD.h
View File

@ -38,8 +38,8 @@ 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;
static const unsigned char ADDRESS_LINE1 = 0x00;
static const unsigned char ADDRESS_LINE2 = 0x40;
VFD();
~VFD();
@ -57,14 +57,14 @@ class VFD
unsigned char direction); /* LEFT|RIGHT */
void setCGAddress(unsigned char address);
void setAddress(unsigned char address);
void writeData(unsigned char data);
void writeByte(unsigned char data);
void write(const std::string & str);
protected:
static const unsigned char RW_WRITE = 0;
static const unsigned char RW_READ = 1;
static const unsigned char E_ENABLE = 0;
static const unsigned char E_DISABLE = 1;
static const unsigned char E_DISABLE = 0;
static const unsigned char E_ENABLE = 1;
static const unsigned char RS_COMMAND = 0;
static const unsigned char RS_DATA = 1;
static const unsigned char PP_OFFSET_RS = 0;

View File

@ -6,14 +6,23 @@ using namespace std;
int main(int argc, char ** argv)
{
cout << "Working on VFD module" << endl;
VFD vfd;
vfd.connect();
vfd.setDisplay(1, 0, 0);
vfd.displayClear();
vfd.setAddress(VFD::ADDRESS_LINE1);
vfd.write("Hi there!");
for (int i = 1; i < argc; i++)
{
for (const char * chr = argv[i]; *chr; chr++)
{
if (*chr == '\n')
vfd.setAddress(VFD::ADDRESS_LINE2);
vfd.writeByte(*chr);
}
}
vfd.disconnect();
return 0;