Text onto LCD display

General discussion on mikroPascal PRO for PIC.
Post Reply
Author
Message
lewjoubert
Posts: 68
Joined: 12 Apr 2006 11:55
Location: Gold Coast Australia
Contact:

Text onto LCD display

#1 Post by lewjoubert » 07 Jul 2015 12:47

Hope someone can help... if possible.
I need to read a byte from EEprom and display the equivalent ASCII characters on a LCD.
EG: Stored in EEprom, ABCDEFGHIJKLMNOP (16 chars),stored as hex values.
I read the values from EEprom addresses OK and store them in Bytes.
I then use the ByteToStr function to what I would expect to convert these values to the string representations of the byte value.
When I display these converted values on the LCD, I get the decimal values displayed!?
Example, 0x4C in EEprom gets displayed as 76.
I have 'played' with various ideas, Ord(), Chr(), altering the variables to store the data between array and string etc., but still no luck.
Hopefully I have explained accurately what I am attempting to achieve - HELP :?
DISCLAIMER: Content reflects the thoughts & opinions of my goldfish neighbour's mad dog; don't quote me on that; don't quote me on anything; hand wash only, tumble dry on low heat; do not bend or fold.

hadv
Posts: 116
Joined: 29 Mar 2013 12:55

Re: Text onto LCD display

#2 Post by hadv » 07 Jul 2015 12:54

What do you mean when you write "stored as hex values"? Do you use two bytes for each character?

ByteToStr will output the numerical representation of the byte.
Assuming your bytes are already in the valid ascii-range, like your example 0x4C, you can just use Lcd_Chr.

janni
Posts: 5373
Joined: 18 Feb 2006 13:17
Contact:

Re: Text onto LCD display

#3 Post by janni » 07 Jul 2015 13:50

lewjoubert wrote:I have 'played' with various ideas, Ord(), Chr()...
Formally, when storing chars in EEPROM and then reading and sending them to LCD one indeed should use these functions

Code: Select all

var ch:char;

EEPROM_Write(addr, ord(ch));
...
ch:=chr(EEPROM_Read(addr));
Lcd_Chr(row, column, ord(ch));
In practice, as there's no difference in mP between char and byte (character is always stored as its ordinal value), one may skip the formal type changes.

lewjoubert
Posts: 68
Joined: 12 Apr 2006 11:55
Location: Gold Coast Australia
Contact:

Re: Text onto LCD display

#4 Post by lewjoubert » 08 Jul 2015 01:53

Thanks for assistance Jani, problem solved.
Ended up with this (skeleton code):-

NOTE: 2 Line 16 character LCD

var
w1-16, z1-16 : char;
txt2:string[16];
....
z1-16 := EEPROM_Read(addresses 1- 16);
w1-16:= ord(z1-16);
txt2 := chr(w1)+chr(w2)+chr(w3)...+chr(w16)
LCD_Out(2,1,' ');
LCD_Out(2,1,txt2);
:lol: :D
DISCLAIMER: Content reflects the thoughts & opinions of my goldfish neighbour's mad dog; don't quote me on that; don't quote me on anything; hand wash only, tumble dry on low heat; do not bend or fold.

Post Reply

Return to “mikroPascal PRO for PIC General”