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:
parent
6c72574c16
commit
14214f7a99
5
Makefile
5
Makefile
@ -1,8 +1,9 @@
|
|||||||
|
|
||||||
TARGET := driver
|
TARGET := driver
|
||||||
SRCS := $(wildcard *.cc)
|
SRCS := $(wildcard *.cc)
|
||||||
|
HEADERS := $(wildcard *.h)
|
||||||
|
|
||||||
all: $(TARGET)
|
all: $(TARGET)
|
||||||
|
|
||||||
$(TARGET): $(SRCS)
|
$(TARGET): $(SRCS) $(HEADERS)
|
||||||
$(CXX) -o $@ $(CXXFLAGS) $(LDFLAGS) $^
|
$(CXX) -o $@ $(CXXFLAGS) $(LDFLAGS) $(SRCS)
|
||||||
|
21
VFD.cc
21
VFD.cc
@ -89,11 +89,6 @@ void VFD::setPPLines(unsigned char bits)
|
|||||||
|
|
||||||
void VFD::sendNibble(unsigned char rs, unsigned char dat)
|
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)
|
setPPLines( (rs << PP_OFFSET_RS)
|
||||||
| (E_DISABLE << PP_OFFSET_E)
|
| (E_DISABLE << PP_OFFSET_E)
|
||||||
| (RW_WRITE << PP_OFFSET_RW)
|
| (RW_WRITE << PP_OFFSET_RW)
|
||||||
@ -104,6 +99,18 @@ void VFD::sendNibble(unsigned char rs, unsigned char dat)
|
|||||||
| (RW_WRITE << PP_OFFSET_RW)
|
| (RW_WRITE << PP_OFFSET_RW)
|
||||||
| ((dat & 0xF) << PP_OFFSET_DATA) );
|
| ((dat & 0xF) << PP_OFFSET_DATA) );
|
||||||
usleep(1);
|
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)
|
void VFD::sendByte(unsigned char rs, unsigned char dat)
|
||||||
@ -159,7 +166,7 @@ void VFD::setAddress(unsigned char address)
|
|||||||
sendByte(0, 0x80 | (address & 0x7F));
|
sendByte(0, 0x80 | (address & 0x7F));
|
||||||
}
|
}
|
||||||
|
|
||||||
void VFD::writeData(unsigned char data)
|
void VFD::writeByte(unsigned char data)
|
||||||
{
|
{
|
||||||
sendByte(1, data);
|
sendByte(1, data);
|
||||||
}
|
}
|
||||||
@ -168,6 +175,6 @@ void VFD::write(const std::string & str)
|
|||||||
{
|
{
|
||||||
for (const char * chr = str.c_str(); *chr; chr++)
|
for (const char * chr = str.c_str(); *chr; chr++)
|
||||||
{
|
{
|
||||||
writeData(*chr);
|
writeByte(*chr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
10
VFD.h
10
VFD.h
@ -38,8 +38,8 @@ class VFD
|
|||||||
static const unsigned char RIGHT = 1;
|
static const unsigned char RIGHT = 1;
|
||||||
static const unsigned char OFF = 0;
|
static const unsigned char OFF = 0;
|
||||||
static const unsigned char ON = 1;
|
static const unsigned char ON = 1;
|
||||||
static const unsigned char ADDRESS_LINE1 = 0x80;
|
static const unsigned char ADDRESS_LINE1 = 0x00;
|
||||||
static const unsigned char ADDRESS_LINE2 = 0xC0;
|
static const unsigned char ADDRESS_LINE2 = 0x40;
|
||||||
|
|
||||||
VFD();
|
VFD();
|
||||||
~VFD();
|
~VFD();
|
||||||
@ -57,14 +57,14 @@ class VFD
|
|||||||
unsigned char direction); /* LEFT|RIGHT */
|
unsigned char direction); /* LEFT|RIGHT */
|
||||||
void setCGAddress(unsigned char address);
|
void setCGAddress(unsigned char address);
|
||||||
void setAddress(unsigned char address);
|
void setAddress(unsigned char address);
|
||||||
void writeData(unsigned char data);
|
void writeByte(unsigned char data);
|
||||||
void write(const std::string & str);
|
void write(const std::string & str);
|
||||||
|
|
||||||
protected:
|
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_DISABLE = 0;
|
||||||
static const unsigned char E_DISABLE = 1;
|
static const unsigned char E_ENABLE = 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;
|
||||||
static const unsigned char PP_OFFSET_RS = 0;
|
static const unsigned char PP_OFFSET_RS = 0;
|
||||||
|
15
driver.cc
15
driver.cc
@ -6,14 +6,23 @@ using namespace std;
|
|||||||
|
|
||||||
int main(int argc, char ** argv)
|
int main(int argc, char ** argv)
|
||||||
{
|
{
|
||||||
cout << "Working on VFD module" << endl;
|
|
||||||
|
|
||||||
VFD vfd;
|
VFD vfd;
|
||||||
|
|
||||||
vfd.connect();
|
vfd.connect();
|
||||||
vfd.setDisplay(1, 0, 0);
|
vfd.setDisplay(1, 0, 0);
|
||||||
|
vfd.displayClear();
|
||||||
|
|
||||||
vfd.setAddress(VFD::ADDRESS_LINE1);
|
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();
|
vfd.disconnect();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user