Propeller VGA Demo: Text color and graphics
Beau Schwabe
Posts: 6,568
Here is a little something I have been putting together... It still needs some code optimization, but feel free to play around with it.
It uses the 'VGA_512x384_Bitmap' object that Chip put out awhile ago to allow you to include graphics as well as text.
Simple Spin Demo program:
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
Post Edited (Beau Schwabe (Parallax)) : 9/26/2006 3:56:22 AM GMT
It uses the 'VGA_512x384_Bitmap' object that Chip put out awhile ago to allow you to include graphics as well as text.
[b]COMMAND Summary[/b] [b]PUB[/b] Sine(Ang)|Arg1_ ' Input = 13-bit angle ranging from 0 to 8191 [b]PUB[/b] Cosine(Ang)|Arg1_ ' Input = 13-bit angle ranging from 0 to 8191 [b]PUB[/b] ArcSine(Ang)|Arg1_ ' Input = signed 16-bit value ranging from $FFFF0001 ('-1') to $0000FFFF ('1') [b]PUB[/b] ArcCosine(Ang)|Arg1_,sign ' Input = signed 16-bit value ranging from $FFFF0001 ('-1') to $0000FFFF ('1') [b]PUB[/b] plot(x,y)| Arg2_,Arg3_,Arg4_ 'Sets pixel value at location x,y [b]PUB[/b] point(x,y)| Arg2_ , Arg3_,Arg4_ 'Reads pixel value at location x,y [b]PUB[/b] character(offX,offY,chr)|Arg3_,Arg4_,Arg5_ 'Place a text character from the ROM table at offset location offsetX,offsetY [b]PUB[/b] line (px,py,dx,dy)| Arg4_,Arg5_,Arg6_,Arg7_,Arg8_ 'Draws line from px,py to dx,dy [b]PUB[/b] box(x1,y1,x2,y2)| Arg4_,Arg5_,Arg6_,Arg7_,Arg8_ 'Draws a box from opposite corners x1,y1 and x2,y2 [b]PUB[/b] color(tile,cval) 'Set Color tiles on VGA screen [b]PUB[/b] pointcolor(pc) 'Sets pixel color "1" or "0" [b]PUB[/b] Text(offX,offY,Address)|chr,i 'Place a text string from the ROM table at offset location offsetX,offsetY [b]PUB[/b] shape(x,y,sizeX,sizeY,sides,rotation)|angle,sx1,sy1,sx2,sy2 'Draws a shape with center located at x,y [b]PUB[/b] deg(angle) 'translate deg(0-360) ---> to ---> 13-bit angle(0-8192) [b]PUB[/b] bit13(angle) 'translate 13-bit angle(0-8192) ---> to ---> deg(0-360) [b]PUB[/b] SimpleNum(x,y,DecimalNumber,DecimalPoint)|sign,DecimalIndex,TempNum,spacing,DecimalFlag,Digit 'Crude decimal number printing
Simple Spin Demo program:
[b]CON[/b] [b]_clkmode[/b] = [b]xtal[/b]1 + [b]pll[/b]16x [b]_xinfreq[/b] = 5_000_000 '512x384 tiles = gr#tiles [b]OBJ[/b] gr : "vga graphics ASM" [b]PUB[/b] MainLoop|h,i,deg,x,y,mask,ii,char gr.start gr.pointcolor(1) [b]repeat[/b] i [b]from[/b] 0 to tiles - 1 'init tile colors to white on black 'gr.color(i,$FF00) gr.color(i,$FF<<8+i) 'init tile colors "Nice view" gr.text(0,0,[b]string[/b]("Parallax VGA text [b]and[/b] graphics")) gr.SimpleNum(464,32,123,3) gr.box(30,50,80,100) 'draw a box 'or 'gr.shape(55,75,71,71,4,gr.deg(45)) 'draw a box [b]repeat[/b] i [b]from[/b] 3 to 15 gr.shape(256,192,300,300,i,gr.deg(90)) 'i = 3 triangle 'i = 4 square 'i = 5 pentagon 'i = 6 hexagon 'i = 7 heptagon 'i = 8 octagon 'i = 9 nonagon 'i = 10 decagon 'i = 11 hendecagon 'i = 12 didecqgon 'i = 13 tridecagon 'i = 14 tetradecagon 'i = 15 pentadecagon [b]repeat[/b] [b]repeat[/b] i [b]from[/b] 0 to 359 gr.pointcolor(1) gr.shape(256,192,145,145,3,gr.deg(i)) gr.shape(256,192,70,70,4,gr.deg(359-i*2)) gr.shape(256,192,30,30,5,gr.deg(i*3)) [b]repeat[/b] 4000 gr.pointcolor(0) gr.shape(256,192,145,145,3,gr.deg(i)) gr.shape(256,192,70,70,4,gr.deg(359-i*2)) gr.shape(256,192,30,30,5,gr.deg(i*3))
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
Post Edited (Beau Schwabe (Parallax)) : 9/26/2006 3:56:22 AM GMT
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
In my first post on this thread, I state that this object uses the 'VGA_512x384_Bitmap' object that Chip released.
The reason there is not a 640x480 or higher is purely because of memory limitations.· For a screen resolution of
512 x 384 , this requires 6144 longs and leaves 2048 longs for your program space.· If the screen resolution were
640 x 480, it would require 9600 longs.· This exceeds the capacity of the Propeller by 1408 longs.
Longs = ( {Screen max X} / 32 ) * {Screen max Y}
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
There is already a graphics driver for TV output. I'm not sure I understand your request.
Look at the 'Graphics_Demo.spin' program located where you installed the Propeller IDE under Examples--> Library
The 'Graphics_Demo.spin' uses an object called 'Graphics.spin' located in the Propeller IDE installation directory.
Essentially both graphics objects (VGA and TV) work the same, with the main difference being features that one graphics
engine has that the other does not. The "core" assembly command dispatch program for the VGA graphics was actually
copied from 'Graphics.spin', so you should see similarities between the two.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
I have a question about the graphics for VGA. Graphing a set of data, line-graph style, would be helpful for a project I am working on. There was a thread a while ago that showed how to do this for with TV output (2 months ago?). I can't find the thread, but seems to me it showed code that graphed sound waves, or something like that, on a TV.
Does anyone remember that thread? And, could this VGA graphics routine be used to do something similar on a VGA output?
Thanks,
Jim C
Since 'plot' and 'line' commands are available with the VGA graphics, it would be just a matter of getting the XY dataset you wanted to graph within the Propeller.
There are several ways to do this, either by hard programming, or by setting up a com between PC and Propeller, etc.
As far as the thread you mention, I don't recall, but there is a "microphone to VGA" demo already available that converts sound waves and displayes them on a VGA monitor.
http://forums.parallax.com/showthread.php?p=590649
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
Post Edited (Beau Schwabe (Parallax)) : 10/2/2006 4:42:41 AM GMT
Yes, that's the thread I was thinging about. (I guess it was a VGA monitor, not a TV.) I'll see if I can get something working, using Chip's program and your new drivers.
Thanks.
Jim C
This should work ok since the "microphone to VGA" uses the same "VGA_512x384_Bitmap" object. If you look at the assembly 'plot' routine in the "microphone to VGA"
object verses the "vga graphics ASM" object's "Pixel_Core" routine you will notice some similarities, however there is a slight difference in the way the pixel position is
calculated between the two. I based my assembly code from the example Chip gives in the "vga_512x384_bitmap_demo". I quite literally took the Spin code that he had...
...and converted it to assembly.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
many thanks for that helpful VGA-grafik Demo.
That's what I'm looking for. Drawing lines and write text together on VGA.
I think that is the main reason to choose the PROPELLER. The people want the grafik possibilities on a Mikrocontroller.
But in the grafik you need also some Text!
I have two questions:
1. Is there a possibility to write smaller text ?
2. Can I write lines with different colors at the same screen ?
Regards
MC-Bernd
Attached is the newest version of the VGA graphics... As this object evolves as I go, and as I need a particular function from it when making another demo, I will
(for now) keep this open ended before I post it to the object exchange library.
1) "Is there a possibility to write smaller text ?"
··· When I have some time, I will add a method for creating or using a custom font.· Be it a standard 8x8 or something else.
2) "Can I write lines with different colors at the same screen ?"
··· You·can, but they must fall within a tile.· Each tile has two colors·you can·assign, a foreground (lines, text, etc.) and a background.· With·the color command,
··· the·color value is·represented as a WORD ($FFFF).· The Upper BYTE represents the foreground color, and the Lower BYTE represents the background color.
Here is a list of the current VGA graphics commands:
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
I assumed that the reason this program wont run in a plain VGA (640x480) is because memory limitations and because is running in the graphics mode?.
There is also another program xModemVGA_Bmp.spin that seems to run in the text mode and uses the 512x384 and still does not runs in my plain VGA (640x480).
There is a program VGA_Hires_Text that gives you 3 choices (1024x768, 800x600 and 640x480).
If I select the 640x480, the program runs just fine.
My question is:
Why· the 512x384 resolution does not work in the plain VGA (640x480)?
Please somebody help me on this?
I am slowly lifting the hood on this VGA graphics driver set. So far, things are working OK: It works as expected on one of my VGA monitors, and I've changed the demo to draw lines, boxes, pixels, etc. However, when hooking up to a different monitor at work, I'm getting some strange results.
The problem is a triangular smeared out region that runs horizontally across the screen, about in the middle of the screen. The smearing-out forms a long narrow triangle that's approx. 50 pixels (Parallax sized) on the left side of the screen, narrowing to about half that on the right side of the screen. The colors in the smeared out long triangle include those from the rest of the screen.
Several things were tried in an attempt to get at a solution. Screen resolution was changed to no avail. Then, upon randomly messing around with parameters in the "VGA 512x384 2-Color Bitmap Driver v1.0" driver, a partial solution was found. When changing the "pixel rate" parameter from 35 to 40, the screen straightens out, and the weird triangle is gone. But instead, there is now a message in the middle of the screen (presumable from the monitor itself) that says "OUT OF RANGE".
It is a "Hansol" monitor, of no particular quality. Modes tried were:
1024 x 768: 60, 70 and 75 Hz
640 x 480: 60, 70 and 75 Hz
Any ideas?
Thanks,
Jim C
(Still learning about video....)
Jim C
I have not tried this new object yet due to the lack of the display device. But, wanted to ask, when putting out new at x,y via the ::Text(), does that screen location have to be "cleared" before putting out new text on the same coords?
with regular text mode, we should be fine. In Gx mode however, one needs to clear the area - am I correct in that understanding?
thanks
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
ALIBE - Artificial LIfe BEing. In search of building autonoumous land robot
http://ALIBE.crosscity.com/
http://fstop.crosscity.com/
http://icar.crosscity.com/
·
Yes, that is correct. Only the pixel that is "ON"·will be written... use the boxfill command·or reprint the old text with the pointcolor command·set to "0" to clear previous data.
Use the clear command to clear the entire screen.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
Post Edited (Beau Schwabe (Parallax)) : 10/23/2006 4:27:29 PM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
ALIBE - Artificial LIfe BEing. In search of building autonoumous land robot
http://ALIBE.crosscity.com/
http://fstop.crosscity.com/
http://icar.crosscity.com/
·
I haven't implemented it, but there is a sync indicator that signals each time the VGA screen is redrawn. This is provided within the VGA_512x384_Bitmap object.
If you throttle your redraws based on the VGA screen refresh you should eliminate most if not all of the flicker.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.