VGA_TEXT_DEMO mods to display decimal digits
Richard S.
Posts: 70
I am reposting this message since I forgot the 'subject' previously.· Also I made a few corrections.
I have been twiddling with VGA_TEXT_DEMO.SPIN and VGA_TEXT.SPIN files.· My goal is to be able to display 3.4 digit number (3 digits to the left of the decimal preceded by spaces and·+/- sign·where appropriate,·and 4 digits to the right of the decimal point padded with zeros where appropriate· i.e. "·97.0035").· What a job!· I like the screen colors, character size, and small size of the program.··My·number to print would be a·LONG (32 bit) eventually coming·from the ENCODER.SPIN program.· I have not yet made the leap·of transfering ENCODER output to the VGA_TEXT display.· I am trying to get numbers to display properly first.
I have·included my edited RFS_VGA_TEXT_DEMO.SPIN and RFS_VGA_TEXT.SPIN files.· Note that if j = 0 the VGA_TEXT·adds an extra 0 on the display...I have not been able to solve this problem.· If j =·1, the problem resolves.· The extra zero is not present if j = -j.· I also have not figured out how to pad 0's between the decimal point and numbers to the·right of the decimal point.
Is there any easier way to do this?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Richard in Michigan
I have been twiddling with VGA_TEXT_DEMO.SPIN and VGA_TEXT.SPIN files.· My goal is to be able to display 3.4 digit number (3 digits to the left of the decimal preceded by spaces and·+/- sign·where appropriate,·and 4 digits to the right of the decimal point padded with zeros where appropriate· i.e. "·97.0035").· What a job!· I like the screen colors, character size, and small size of the program.··My·number to print would be a·LONG (32 bit) eventually coming·from the ENCODER.SPIN program.· I have not yet made the leap·of transfering ENCODER output to the VGA_TEXT display.· I am trying to get numbers to display properly first.
I have·included my edited RFS_VGA_TEXT_DEMO.SPIN and RFS_VGA_TEXT.SPIN files.· Note that if j = 0 the VGA_TEXT·adds an extra 0 on the display...I have not been able to solve this problem.· If j =·1, the problem resolves.· The extra zero is not present if j = -j.· I also have not figured out how to pad 0's between the decimal point and numbers to the·right of the decimal point.
Is there any easier way to do this?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Richard in Michigan
Comments
I will grind on this for awhile!·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Richard in Michigan
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Paul Baker
Propeller Applications Engineer
Parallax, Inc.
In the
'PUB decFixed(value,width,numPlaces) | i, j, p, f, a, b, c, d'
line there are several unused variables...are they left over from some other project or am I missing something?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Richard in Michigan
The variables "a" through "d" are used as the string buffer for the result. There have to be 4 variables with "a" as the first one (to make 16 bytes).
Mike
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Stan Dobrowski
RE: variables a, b, c, and d. I assume that the 'method' variables (longs - 4 bytes each) are allocated sequentially in memory as 16 bytes of buffer space (not zero terminated as in zstring). Then one references the first variable, @a, then index into the space??
Hello Stan...
Thanx for your integer to string contribution. I am studying it to understand more of how all this is done. It looks like one could fiddle with the comma routine to get number of decimals plus addition of decimal point. Padding out the decimal places with zeros will take some work, however. I may work on that a bit.
I have had fun changing the color palatte at the end of the vga_text.spin file. All kinds of color schemes can be created. I like the dark blue background the best with a yellow, green, or white foreground. I also made the general screen black with red foreground characters (see first entry in the table).
' fore back
' RGB RGB
palette byte %%300, %%000 '0 red / black
byte %%330, %%001 '1 yellow / dark blue
byte %%333, %%001 '2 white / dark blue
byte %%000, %%333 '3 black / white
byte %%033, %%011 '4 cyan / dark cyan
byte %%030, %%001 '5 green / dark blue
byte %%033, %%001 '6 cyan / dark blue
byte %%330, %%001 '7 yellow / dark blue
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Richard in Michigan
Yes, the local variables are allocated sequentially. If you look at the code, I assign the address of "a" to a pointer variable "p", then use that from then on.
Mike
I do understand. Your patience is much appreciated!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Richard in Michigan
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Stan Dobrowski
Thanx again for your comments.· I find your routine very instructive.· If you come across the decimal formatter program I would very much like to see it.· Mike's routine and several others from the PROP page such as Simple_numbers.spin, have been very helpful!· Now to get some of this to work collectively.
I do have a question.· In a programs such as VGA_TEXT_DEMO.spin that calls (through OBJ) VGA_TEXT.spin which in turn calls (through OBJ) VGA.spin....does each of these programs start in there own cog? or are they lumped together into one large program.· It is not clear to me since none of the three seem specifically call a cog function.
Mike's routine:···I have added documentation and include it for review and critiquing.··
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Richard in Michigan
Thanks for adding the extra comments. For the record, I'm not a Parallax employee.
If you're curious, I could have figured out the number of spaces needed when I found the first non-zero digit, but it would make the logic a lot more complicated. It's simpler to just produce the variable length string and later add any needed leading blanks.
I have succeeded in printing fixed decimal place numbers with sign and appropriate space padding, even retaining zeros in the decimal places!!· Your help has been invaluable.· If one runs the rfs_vga_text_demo.spin you can see different things happening including a negative number counting up slowly through 0.0 and beyond.
Mike, I took your program, made some adjustments using Stans approach and have come up a working model.
I use VGA_TEXT_DEMO.spin as the integer input, VGA_TEXT.spin as the integer to ASCII converter plus ASCII string printer, and VGA.spin to run the video.· I chopped out unnecessary routines in the VGA_TEXT.spin program.· The compiled version only takes 446 longs.
Next is to connect the ENCODER.spin
I have posted my working models for those interested.
This will be my last post to this thread.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Richard in Michigan