[ADDED] Allow map certain characters to lcd memory location

Please add any feature requests for Flowcode version 7 here

Moderator: Benj

Post Reply
EtsDriver
Posts: 444
Joined: Tue Apr 15, 2014 4:19 pm
Location: Kajaani, Finland
Has thanked: 345 times
Been thanked: 227 times

[ADDED] Allow map certain characters to lcd memory location

Post by EtsDriver »

Hi!

I just was wondering could the LCD component be customized in a way that it would support certain custom memory locations to be nordic characters? Like in finnish we have ä and ö everywhere and even sometimes we visit sweden with this åÅ, and i use lcd acsii 0,1 and to store those, and when im creating code, i have to always put "PRINT ASCII(0)" to certain positions...

If this could automated this somehow that we tell LCD that if the print string has "ä" or "Ä" (ascii 132/142) character, use lcd memory location specified to it.

Or if users could directly write from software to the lcd RAM (custom characters) so if this "ä" or "Ä" character is found from printString, print this chracter ä =(9,0,14,1,15,17,15,0), or in the "ö" or "Ö" case use ö=(9,0,14,17,17,17,14,0) and with "å" or "Å" use å= (4,0,14,1,15,17,15,0) ?

Here is snippet of code how it was once done on older atmel dev board that we used on school..

Code: Select all

void LCD_print (char buf[])	
{

	int i;
	LCD_control = 0x01;				// Clear the display
	_delay_ms(10);
	
	for(i=0;i<strlen(buf);i++) 		// Print the buffer to lcd display
	{	
				if ((buf[i] == 'ä')|(buf[i] == 'Ä'))		// If the character is ä or Ä
		{
			LCD_data = 0xE1;		// printing the ä to the display (on this display, the E1 is the adress of little ä)
			_delay_ms(1);
		}		
		
		else if ((buf[i] == 'ö')|(buf[i] == 'Ö'))	// If the character on ö or Ö
		{
			LCD_data = 0xE3;		// printing ö to the lcd display (on this display, the E3 is the location of little ö)
			_delay_ms(1);
		}
		
		else
		{
			LCD_data = buf[i];		// Printing the characters to LCD display
			_delay_ms(1);
		}
	}
}
Writing bit tired so hope you can get a clue what im talking about... :)
Ill just keep the good work up!

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Allow users to map certain characters to lcd memory loca

Post by Benj »

Certainly sounds possible. I'll have a quick go and see how easy it would be to pull off.

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Allow users to map certain characters to lcd memory loca

Post by Benj »

Hello,

Right try this for size. I have hopefully added some functionality without adding any extra overhead to the component code unless you specifically want to use this map function.

The "Remap Characters" property sets how many mapped characters there can be in the program. The default is 0 in which case the functionality is switched off, a value greater then 0 will switch on the functionality and specify the maximum number of character remaps.

The RemapCharacter macro allows you to assign the re-mapped characters. For example with the Remap Characters property set to 1 you can do this following macro call to allow ASCII 'ä' characters to be replaced with custom character 1.

RemapCharacter (0, 'ä', 1)

I'm not sure if the extended ASCII 'ä' as shown above will work with the compiler, you might have to use the decimal version of 132.
http://www.asciitable.com/

Multiple characters can also be mapped to the same output character as per your example code.

RemapCharacter (0, 'ä', 0xE1)
RemapCharacter (1, 'Ä', 0xE1)
RemapCharacter (2, 'ö', 0xE3)
RemapCharacter (3, 'Ö', 0xE3)

Here is the new component, it's currently only available as the LCD (Generic) component.

Simply copy the file into your "Flowcode 7/components" folder and restart Flowcode.
LCD.fcpx
(7.65 KiB) Downloaded 328 times
Let me know how you get on and if this works ok for you then I'll add the new code to the other LCD components.

Simulation of the remap is also now functional though please note the extended ASCII characters will probably not line up correctly with the LCD's in built extended characters.
LCD_Remap.jpg
LCD_Remap.jpg (47.35 KiB) Viewed 5987 times
This might be a great addition to work along side the string translator component. As well as changing the language of the strings you can change the mapping of characters as needed for the language.
http://www.matrixtsl.com/wikiv7/index.p ... a9e35a75bf

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Allow users to map certain characters to lcd memory loca

Post by Benj »

I wonder if we can do anything to allow custom & remapped characters for graphical LCDs? I'll think on it.

EtsDriver
Posts: 444
Joined: Tue Apr 15, 2014 4:19 pm
Location: Kajaani, Finland
Has thanked: 345 times
Been thanked: 227 times

Re: Allow users to map certain characters to lcd memory loca

Post by EtsDriver »

The GLCD is pretty nicely working with the bitmap drawer, could that code be repurposed somehow? Like user draws their custom character to sizes (like 0,1,2 sizes) they want and if flowcode detects that in the string, it checks the font size item, it will draw the bitmap according to its memory content?

This could come up bit memory heavy if using many different custom characters and many different sizes are used, but sometimes the little bits matter on the other parts of the code... :) The memory gets freed somewhere else when the code doesnt need to split all the strings to million tiny pieces when custom characters are used more.
Ill just keep the good work up!

User avatar
Jan Lichtenbelt
Posts: 797
Joined: Tue Feb 17, 2009 8:35 pm
Location: Haren GN, the Netherlands
Has thanked: 128 times
Been thanked: 264 times
Contact:

Re: Allow users to map certain characters to lcd memory loca

Post by Jan Lichtenbelt »


Post Reply