C++ and the LCD function.
Moderator: Guido Körber
C++ and the LCD function.
Hy, sorry that I took so long to start the project I was working on. (had to relocate from Canada) Anyway ...
I got my LCD working, it works with the included VBLCD Example.
But my software is done with C++, so I'm trying to understand how to write a Report 4 to the IOW40.
Could you give me an example in C++ on how to turn-on the LCD and clear it? From this, I can do the rest.
Best Regards, WilliamK
I got my LCD working, it works with the included VBLCD Example.
But my software is done with C++, so I'm trying to understand how to write a Report 4 to the IOW40.
Could you give me an example in C++ on how to turn-on the LCD and clear it? From this, I can do the rest.
Best Regards, WilliamK
I added following to the iowklass.h to get access to the Display
For clear you have to choose the right command code and give them to the LCD_Cmd methode off your iow class
Code: Select all
ULONG LCD_Enable()
{
ULONG bytes;
char data[7];
data[0] = 0x04;
data[1] = 0x01;
bytes = IowKitWrite(m_devHandle, 1, data, 8);
return bytes;
}
ULONG LCD_Disable()
{
ULONG bytes;
char data[7];
data[0] = 0x04;
data[1] = 0x00;
bytes = IowKitWrite(m_devHandle, 1, data, 8);
return bytes;
}
ULONG LCD_Init()
{
ULONG bytes;
char data[7];
data[0] = 0x05;
data[1] = 0x03;
data[2] = 0x28 | 0x10; // for 2*16 display
data[3] = 0x01;
data[4] = 0x0F;
bytes = IowKitWrite(m_devHandle, 1, data, 8);
return bytes;
}
ULONG LCD_Cmd(int cmd)
{
ULONG bytes;
char data[7];
data[0] = 0x05;
data[1] = 0x01;
data[2] = cmd;
bytes = IowKitWrite(m_devHandle, 1, data, 8);
return bytes;
}
ULONG LCD_Set_Addr(int addr)
{
ULONG bytes;
char data[7];
data[0] = 0x05;
data[1] = 0x01;
data[2] = (0x80 | addr);
bytes = IowKitWrite(m_devHandle, 1, data, 8);
return bytes;
}
ULONG LCD_String(char *string)
{
ULONG bytes;
char data[7];
int nchars=0;
int nnow=0;
int ncurr=0;
data[0]=0x05;
nchars = strlen(string);
while (ncurr < nchars)
{
if ((ncurr+6)>nchars)
{
nnow = nchars - ncurr;
}
else
{
nnow = 6;
}
data[1] = (0x80 | nnow);
for (int x=0; x<nnow; x++)
{
data[x+2] = string[x+ncurr];
}
bytes = IowKitWrite(m_devHandle, 1, data, 8);
ncurr = ncurr +6;
}
return bytes;
}
If I'm not wrong, the datasheet of the LCD I got has some basic graphics. Anyway, is not a must for my project.
I just tested and your code works like a charm.
My other problem is how I will manage a data-entry pot.
http://www.codemercs.com/phpBB2/viewtopic.php?t=23
If it won't work, I just use some +/- knobs...
Wk
I just tested and your code works like a charm.
My other problem is how I will manage a data-entry pot.
http://www.codemercs.com/phpBB2/viewtopic.php?t=23
If it won't work, I just use some +/- knobs...
Wk
I just read that you can have 8 user-built characters.
http://www.repairfaq.org/filipg/LINK/F_LCD_HD44780.html
Wk
http://www.repairfaq.org/filipg/LINK/F_LCD_HD44780.html
Wk
-
- Site Admin
- Posts: 2856
- Joined: Tue Nov 25, 2003 10:25 pm
- Location: Germany/Berlin
- Contact:
-
- Site Admin
- Posts: 2856
- Joined: Tue Nov 25, 2003 10:25 pm
- Location: Germany/Berlin
- Contact:
This depends on the contrast setting of the LCD, but it is perfectly normal behaviour and there is nothing you can do to prevent this. Until the LCD controller gets initialized this is what it does.williamk wrote:Ahhh, just one small problem. When I plug the USB cable to the IOW40, the LCD starts with a series of squares. Is there a way to make it init BLANK? Do "I" have to put something on the board to make that? Otherwise it will look strange...
-
- Posts: 543
- Joined: Mon Dec 01, 2003 6:09 pm
You will have to initialize the LCD with some commands.williamk wrote:Ahhh, just one small problem. When I plug the USB cable to the IOW40, the LCD starts with a series of squares. Is there a way to make it init BLANK? Do "I" have to put something on the board to make that? Otherwise it will look strange...
Wk
Is there a way to add on the driver an option to init on plug? It is a big deal, as most users will just leave the USB connected until they run the software.Guido Körber wrote:This depends on the contrast setting of the LCD, but it is perfectly normal behaviour and there is nothing you can do to prevent this. Until the LCD controller gets initialized this is what it does.williamk wrote:Ahhh, just one small problem. When I plug the USB cable to the IOW40, the LCD starts with a series of squares. Is there a way to make it init BLANK? Do "I" have to put something on the board to make that? Otherwise it will look strange...
Maybe I will just add an On/Off knob on my project, that's all...
Wk
-
- Site Admin
- Posts: 2856
- Joined: Tue Nov 25, 2003 10:25 pm
- Location: Germany/Berlin
- Contact:
If you want to write a new Windows driver...williamk wrote:Is there a way to add on the driver an option to init on plug? It is a big deal, as most users will just leave the USB connected until they run the software.
IO-Warrior uses the HID drivers of the system. They know nothing about an LCd connected to the IO-Warrior, they don't even know anything about IO-Warrior.
What you could do though is write an application that runs in the background and waits for the device to get plugged in.
But the other thing you can do is play with the contract setting pot for the LCD to see if you can reduce the intensity of the squares. Usually the squares are not very prominent if the setting is done properly.
-
- Site Admin
- Posts: 2856
- Joined: Tue Nov 25, 2003 10:25 pm
- Location: Germany/Berlin
- Contact:
If you make sure that the voltage drop across your transistor (or whatever you use to switch the supply voltage) is low enough you can do that. You should switch the +5V end of the power, switching ground is more critical as this is the comman reference and if that changes you can get errors.williamk wrote:BTW: Can't I use the same ON port that lights the backlite to open the 5+V or Ground to the LCD? So it stays OFF until you send the LCD-ON command? If I said something stupid, ignore me ...
Wk