Move LCD Character - 27979
JBWolf
Posts: 405
Hello,
I am interested in figuring out the easiest way to move a character on the LCD so I can insert another.
LCD = Parallax 4x20 LCD pn# 27979
I am using the DS1620 digital thermometer to get temperature data.
The result given back from the DS1620 is a 3-digit decimal. A typical value would be "792", which equals 79.2 degrees.
I need to place the decimal for aesthetic reasons.
I have found 2 ways to approach this...
1) Try to move the 3rd character on the LCD one position to the right.
2) Divide the variable by 10 to place a decimal point.
Here is my first attempt:
This code does not create the desired effect and instead erases the 2nd character.... ie 792 becomes 7.2
I have looked through the 'fullduplexserial.spin' and also the LCD manual, but cannot find a way to place the cursor so it moves characters.
If there is not a way to move characters using fullduplexserial, I assume FLOAT is the best way?
I read the propeller manual regarding the FLOAT command, however I did not find enough information to apply it for my needs.
This will be my first time using FLOAT.
Can someone help me with dividing the 'degrees' variable by 10 to place a decimal in the proper place?
I am using multiple cogs and pointers... cog0 launches cog1 & cog2 then monitors input buttons, cog1 monitors the DS1620 temperature probe and moves results to a LONG variable, cog2 runs the LCD and displays the temperature data.
cog2 copies the temperature data to a local variable for display with Degrees := long[temperature]... it is this local 'Degrees' variable I would like to divide by 10.
I appreciate any help
I am interested in figuring out the easiest way to move a character on the LCD so I can insert another.
LCD = Parallax 4x20 LCD pn# 27979
I am using the DS1620 digital thermometer to get temperature data.
The result given back from the DS1620 is a 3-digit decimal. A typical value would be "792", which equals 79.2 degrees.
I need to place the decimal for aesthetic reasons.
I have found 2 ways to approach this...
1) Try to move the 3rd character on the LCD one position to the right.
2) Divide the variable by 10 to place a decimal point.
Here is my first attempt:
LCD.tx(17) ' No Cursor Mode LCD.tx(22) ' Turn ON BackLight LCD.tx(173) ' Move to Center of LCD Screen LCD.str(string("DegF =")) ' Display Text Repeat Degrees := long[temperature] LCD.tx(180) ' Move to end of Text LCD.dec(Degrees) ' Display Temperature Data LCD.tx(182) ' Move to Second digit of temp data to place decimal LCD.tx(46) ' ASCII Decimal waitcnt(clkfreq + cnt)
This code does not create the desired effect and instead erases the 2nd character.... ie 792 becomes 7.2
I have looked through the 'fullduplexserial.spin' and also the LCD manual, but cannot find a way to place the cursor so it moves characters.
If there is not a way to move characters using fullduplexserial, I assume FLOAT is the best way?
I read the propeller manual regarding the FLOAT command, however I did not find enough information to apply it for my needs.
This will be my first time using FLOAT.
Can someone help me with dividing the 'degrees' variable by 10 to place a decimal in the proper place?
I am using multiple cogs and pointers... cog0 launches cog1 & cog2 then monitors input buttons, cog1 monitors the DS1620 temperature probe and moves results to a LONG variable, cog2 runs the LCD and displays the temperature data.
cog2 copies the temperature data to a local variable for display with Degrees := long[temperature]... it is this local 'Degrees' variable I would like to divide by 10.
I appreciate any help
Comments
Which means if there isn't a way to back-space one position on the LCD and insert a character which pushes characters to the right... the only viable solution will be to divide by 10.
And what does // do?
Can you please explain the || and // for me?
I would like to understand for future references.
Thanks so much for the very fast (and super simple) resolution!
You need the absolute value in there, otherwise for negative numbers you get something like "-32.-5"
The temp probe is outside.... in Wisconsin, negatives are in the repertoire.
Notice the little trick at the end, too -- .hex is faster than .dec for single digits.
Yep!