Displaying calculated numbers on Parallax parallel LCD
studebaker1925
Posts: 2
I am using the Parallax Experiment kit which comes with a parallel (not serial) LCD and the BS2. I am measuring resistance of a pot using the supplied 555 oscillator chip with the result stored as a Word variable (let's call it ResistanceValue). I view the result using DEBUG as a decimal (DEC) with 4 digits using DEBUG CRSRXY, 13, 2, DEC ResistanceValue, CLREOL. I would like to display this four digit value on the parallel LCD. I have no problem loading characters from a string (from the EEProm) such as "This is the resistance=" but have yet to work out how to add the number generated from the resistance.
:blank: Steve
:blank: Steve
Comments
This is not the most elegant method for converting an integer to a character byte array (string) but it works and should give you some ideas.
MsgNums DATA "0123456789" ' store number characters in array
...Extract_Digits_from_number:
R1=Number//1000
R2=R1//100
R3=R2//10
R4=R3
R3=R2/10
R2=R1/100
R1=Number/1000
...then
READ (MsgNums + R1), char ' read a character from MsgNums
GOSUB LCD_Out ' write character at next cursor location
READ (MsgNums + R2), char ' read a character from MsgNums
GOSUB LCD_Out ' write character at next cursor location
READ (MsgNums + R3), char ' read a character from MsgNums
GOSUB LCD_Out ' write character at next cursor location
READ (MsgNums + R4), char ' read a character from MsgNums
GOSUB LCD_Out ' write character at next cursor location
X=12345
X DIG 4 returns the 10^4 decimal digit (1 in this case)
X DIG 0 returns the 10^0 decimal digit (5 in this case)
add 48 to that and you have the numeric ascii code to send to the LCD
X DIG 4 + 48
You can loop through the digits and suppress leading zeros or turn them into spaces if you want.