Our new official repo is on github
LCD Smartie version 5.6 is released!
Download it now: https://github.com/LCD-Smartie/LCDSmartie/releases

SparkFun 20x4 Serial Enabled LCD Display Driver

Announcements of new plugins or updates.

Moderators: _X7JAY7X_, caesar, IFR, mattcro, limbo

Post Reply
rfryar
Posts: 36
Joined: July 17th, 2007, 2:12 pm
Contact:

SparkFun 20x4 Serial Enabled LCD Display Driver

Post by rfryar »

Updated 7/26/2007:
New version 1.1 now supports all size screens Spark Fun sells and custom characters!


Version 1.1 - Second Release:
SparkFunLCD.dll should be placed in the 'displays' subdirectory of the LCD
Smartie installation directory. It requires that the Visual 2005 redistributable
package is installed on the executing computer. If necessary, this package can
be downloaded there
http://www.microsoft.com/downloads/deta ... laylang=en

Website to download, etc: http://lcdsmartie.fryar.org/serlcd.php

Please feel free to give me feedback and comments!

Rick
You do not have the required permissions to view the files attached to this post.
Last edited by rfryar on August 10th, 2007, 3:33 am, edited 4 times in total.

mattcro
Forum Supporter
Posts: 590
Joined: March 8th, 2006, 1:58 pm
Location: Scotland

Post by mattcro »

You might be able to set custom characters by sending the command byte 254 (decimal) followed by a Character Generator RAM address (64 + offset) instead of a Display Data RAM address like 128+offset.

For example: 254,65,byte1,byte2,byte3....byte8 should set the 2nd custom char slot to the pattern specified by byte1-8 as per HD44780 datasheet.

I don't know if it will actually work but it's worth a try!

rfryar
Posts: 36
Joined: July 17th, 2007, 2:12 pm
Contact:

Custom Chars

Post by rfryar »

Thanks that got me on the right track at least.. Now the Bars work correctly, however it is strange as I need to pad 12 more characters at the end of the 8 data characters before the LCD goes back into standard character entry mode.

So right now I would say custom characters are 70% functional in the current debug release of my display driver.

Thanks for the help!

Rick

rfryar
Posts: 36
Joined: July 17th, 2007, 2:12 pm
Contact:

New Website

Post by rfryar »

Just wanted to say that I have set up a website for my drivers and plug-in development: http://lcdsmartie.fryar.org/

Rick Fryar
rickf@mindless.com

mattcro
Forum Supporter
Posts: 590
Joined: March 8th, 2006, 1:58 pm
Location: Scotland

Post by mattcro »

Rick,
Have you noticed that when you open the Smartie config window, the parameter string for this SparkFun driver is truncated to just the com port? For example, if you specify "COM1,9600,5,1", it works fine. But then if you re-open the config window, the parameter string is truncated to "COM1".

I used the same parameter parsing code for my PJRC LCD driver development and find this truncation occurs. I eventually tracked it down to the fact that the strtok() function modifies the input string by replacing each instance of the separator with a null. This makes Smartie think the parameter string contains only the text preceding the first separator character.

My quick workaround is to process a copy of the parameter string in order to leave the original (pointer passed from Smartie to DISPLAYDLL_Init) intact.

rfryar
Posts: 36
Joined: July 17th, 2007, 2:12 pm
Contact:

Post by rfryar »

Yes I did notice that and I also have tried to use the strcpy function to fix but I still got the truncation issue on my end. :(

Did you just do a strcpy and then strtok the copy? This did not work for me for some reason.

Thanks.

Rick

mattcro
Forum Supporter
Posts: 590
Joined: March 8th, 2006, 1:58 pm
Location: Scotland

Post by mattcro »

It seems to work OK for me - I just did a strcpy into a new char array. The parameter string in the Smartie setup window doesn't get truncated any more. I just had a look at Enrico74's code and I guess that it has the same issue, being the template for your driver.

My code:

Code: Select all

DLL_EXPORT(char *) DISPLAYDLL_Init(LCDS_BYTE size_x,LCDS_BYTE size_y,char *startup_parameters,LCDS_BOOL *ok)
{
	*ok = 0;  //assume failure until we have passed all checks

	//strtok modifies the input string, so need to copy it to a temp variable
	char params_temp[40];
	strcpy(params_temp, startup_parameters);
	char comport[40];
	strcpy(comport,"COM1");
	int baud = 9600;

	//Parse startup params
	const char separators[]=",";
	char *token = strtok(params_temp,separators);
	int  idx=0;
	while (NULL!=token)
	{
		switch (idx)
		{
			case 0: strcpy(comport,token); break;
			case 1: baud=atoi(token); break;
			default: break;
		}
		token=strtok(NULL,separators);
		++idx;
	}
...
There must be a small amount of buffering or write-behind in the serial port write handling. I've noticed that if there are only a few characters changing on the display (like CPU usage percent), the update is a bit erratic as if several Smartie writes are being bunched up into one serial port write. If there is a lot of scrolling or a perf graph, the update is fairly regular.

Post Reply