Shop OBEX P1 Docs P2 Docs Learn Events
Displaying both line plots and text to a monitor (VGA or Composite TV? Or Other?) — Parallax Forums

Displaying both line plots and text to a monitor (VGA or Composite TV? Or Other?)

Hey guys,
I am wanting to use the propeller to display some information to a monitor (line plots and text). I have been playing around with misc. VGA libraries and they seem to be pretty limited on what they can do?
I stumbled across some topics of people claiming to be able to do this, but the topic seems to be outdated and the library is no longer there. I am pretty new to messing with VGA, but it seems you can either do all text, or all plotting, but not both? Also, I came across the graphics_demo in the library, but I was not able to get this to work with VGA, am I missing something?

Is VGA the best rout or should I be using composite TV? I have accomplished similar things with 4D systems displays but they are pretty expensive... so figured if I could accomplish something similar with the VGA or TV then that would be good. Thanks and any help is greatly appreciated!

Comments

  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2016-02-01 02:15
    Many years ago I adapted the graphics driver and added scalable fonts to it etc. I mainly use this on my small Pixie boards that plug directly into the back of a VGA monitor and connect together in an RS485/422 network. Have a look back at that thread here and here.

    99837.jpg
    82603.jpg
  • ElectrodudeElectrodude Posts: 1,657
    edited 2016-02-01 02:39
    I would recommend one of the 16x16 VGA tile drivers that come with Propeller Tool. If you've experimented with them, you already know how to do text. For your plots, you can point portions of the tile space into a large buffer, and use graphics.spin to draw graphics into that buffer.

    The first attachment is an example (that hopefully works) that I wrote almost two years ago. It's pretty messy. It uses the regular old VGA.spin. It should be pretty easy to get it to work with vga_1280x1024_tile_driver_with_cursor.spin or vga_1024x768_tile_driver_with_cursor.spin.

    The magic part is this:
      'init tile screen
      repeat dx from minx to maxx
        repeat dy from miny to maxy
          screen[dy*vga_hc+dx]:=display_base>>6 + (dy-miny)+(dx-minx)*gr_y_tiles + (17<<10)            'base>>6 + index + color<<10
    

    Where minx, maxx, miny, and maxy are the left, right, top, and bottom bounds (in tiles from the top left) of your plot, gr_y_tiles is how wide the plot is in tiles ( = maxy - miny + 1), and vga_hc is how wide the screen is in tiles.

    The second attachment is a completely untested (but compileable) program that should output a 1280x1024 signal with both graphics and text. It uses 3 cogs for VGA and 1 for graphics, though, leaving only 4 for the rest of your application. Since I didn't test it, there might be some off-by-one errors causing the graphics zone to wrap around the screen or something, but hopefully it works well enough for you to understand the basic principle.


    EDIT: Peter Jakacki does it again with his Tachyon Forth...

    But my method lets you have up to 64 different sets of 4 color palletes that can be assigned individually to each 16x16 tile, and truly combines text and graphics, and doesn't just draw text onto a graphics buffer (which uses less RAM than making everything graphics, like PJ's second example), and doesn't just do ASCII art.
  • jmgjmg Posts: 15,173
    Mahonroy wrote: »
    ... I am pretty new to messing with VGA, but it seems you can either do all text, or all plotting, but not both?

    You could also look at FTDI Eve parts (Direct LCD, not VGA)

    VGA Text only is common. because that covers many applications, and it needs less system memory.
    The P1 only has 32K of system memory, which is light for VGA.

    What sort of lines do you need to plot, to what resolution and colours ?
    How much Text do you need at the same time ?


    I've seen Bar graphs used to give analog style information and they can pack better than poly-lines.

    Top end VGA operation can be done with devices like SSD1963, which has > 1MB display buffer on-chip.

  • jmg wrote: »
    Mahonroy wrote: »
    ... I am pretty new to messing with VGA, but it seems you can either do all text, or all plotting, but not both?

    You could also look at FTDI Eve parts (Direct LCD, not VGA)

    VGA Text only is common. because that covers many applications, and it needs less system memory.
    The P1 only has 32K of system memory, which is light for VGA.

    What sort of lines do you need to plot, to what resolution and colours ?
    How much Text do you need at the same time ?


    I've seen Bar graphs used to give analog style information and they can pack better than poly-lines.

    Top end VGA operation can be done with devices like SSD1963, which has > 1MB display buffer on-chip.

    Except the great thing about the Propeller is that you can do this, albeit at a possibly lower resolution, all in one chip.

    Good point about bar graphs. With a tile driver, you could make 16 different bar graph tiles, for different fill levels, and fill the bar chart appropriately with them.


    I've had this plan that I've been wanting to try for a long time for drawing mostly empty plots. Initially, the plot area would be initialized to all point to the same empty tile, and a modified graphics.spin would automatically allocate tiles as they were drawn on. This would allow you to get bigger graphs, as long as they're sparse enough.
  • jmgjmg Posts: 15,173
    Except the great thing about the Propeller is that you can do this, albeit at a possibly lower resolution, all in one chip.
    Yes, that lower resolution is usually the kicker.

    I've looked at a mid-ground solution of external SPI SRAM, (Prop does all the timing) where Microchip and OnSemi have Quad SPI 1MB in TSSOP8, and a couple of topologies seem possible.
    Two QSPI parts, as either 4 bpp or 8bpp, and 4bpp with a HC257 offers a gain in write bandwidth. (8bpp limits write windows to blanking times.)
    One issue here, is both vendors parts specs to a frustrating 20MHz, at 2.5V~5.5V, this hints that 25-30MHz is ok at 3.3V, but it would be nice if they spec'd that !

    This gives full raster RAM, so any mix of Characters and lines is possible. No tile caveats.

  • Thanks a lot for your replies so far!
    I would recommend one of the 16x16 VGA tile drivers that come with Propeller Tool. If you've experimented with them, you already know how to do text. For your plots, you can point portions of the tile space into a large buffer, and use graphics.spin to draw graphics into that buffer.

    The first attachment is an example (that hopefully works) that I wrote almost two years ago. It's pretty messy. It uses the regular old VGA.spin. It should be pretty easy to get it to work with vga_1280x1024_tile_driver_with_cursor.spin or vga_1024x768_tile_driver_with_cursor.spin.

    The magic part is this:
      'init tile screen
      repeat dx from minx to maxx
        repeat dy from miny to maxy
          screen[dy*vga_hc+dx]:=display_base>>6 + (dy-miny)+(dx-minx)*gr_y_tiles + (17<<10)            'base>>6 + index + color<<10
    

    Where minx, maxx, miny, and maxy are the left, right, top, and bottom bounds (in tiles from the top left) of your plot, gr_y_tiles is how wide the plot is in tiles ( = maxy - miny + 1), and vga_hc is how wide the screen is in tiles.

    The second attachment is a completely untested (but compileable) program that should output a 1280x1024 signal with both graphics and text. It uses 3 cogs for VGA and 1 for graphics, though, leaving only 4 for the rest of your application. Since I didn't test it, there might be some off-by-one errors causing the graphics zone to wrap around the screen or something, but hopefully it works well enough for you to understand the basic principle.


    EDIT: Peter Jakacki does it again with his Tachyon Forth...

    But my method lets you have up to 64 different sets of 4 color palletes that can be assigned individually to each 16x16 tile, and truly combines text and graphics, and doesn't just draw text onto a graphics buffer (which uses less RAM than making everything graphics, like PJ's second example), and doesn't just do ASCII art.

    I did not see an attachment, did you forget to upload it? Also, I found a 1280x1024 tile driver, and a 1600x1200 tile driver.... but could not find a 1024x768 tile driver.
  • jmg wrote: »
    Mahonroy wrote: »
    ... I am pretty new to messing with VGA, but it seems you can either do all text, or all plotting, but not both?

    You could also look at FTDI Eve parts (Direct LCD, not VGA)

    VGA Text only is common. because that covers many applications, and it needs less system memory.
    The P1 only has 32K of system memory, which is light for VGA.

    What sort of lines do you need to plot, to what resolution and colours ?
    How much Text do you need at the same time ?


    I've seen Bar graphs used to give analog style information and they can pack better than poly-lines.

    Top end VGA operation can be done with devices like SSD1963, which has > 1MB display buffer on-chip.

    I am shooting for the top 2/3 of the screen to be text, and the bottom 1/3 of the screen to be a plotted graph. I suppose the graph resolution would be good enough at 640x480 (or in this case 640x160). I need to be able to update specific points on the graph is the thing.
  • ElectrodudeElectrodude Posts: 1,657
    edited 2016-02-01 19:49
    (deleted) How do you post attachments?
  • ElectrodudeElectrodude Posts: 1,657
    edited 2016-02-01 19:59
    Mahonroy wrote: »
    Thanks a lot for your replies so far!
    I would recommend one of the 16x16 VGA tile drivers that come with Propeller Tool. If you've experimented with them, you already know how to do text. For your plots, you can point portions of the tile space into a large buffer, and use graphics.spin to draw graphics into that buffer.

    The first attachment is an example (that hopefully works) that I wrote almost two years ago. It's pretty messy. It uses the regular old VGA.spin. It should be pretty easy to get it to work with vga_1280x1024_tile_driver_with_cursor.spin or vga_1024x768_tile_driver_with_cursor.spin.

    The magic part is this:
      'init tile screen
      repeat dx from minx to maxx
        repeat dy from miny to maxy
          screen[dy*vga_hc+dx]:=display_base>>6 + (dy-miny)+(dx-minx)*gr_y_tiles + (17<<10)            'base>>6 + index + color<<10
    

    Where minx, maxx, miny, and maxy are the left, right, top, and bottom bounds (in tiles from the top left) of your plot, gr_y_tiles is how wide the plot is in tiles ( = maxy - miny + 1), and vga_hc is how wide the screen is in tiles.

    The second attachment is a completely untested (but compileable) program that should output a 1280x1024 signal with both graphics and text. It uses 3 cogs for VGA and 1 for graphics, though, leaving only 4 for the rest of your application. Since I didn't test it, there might be some off-by-one errors causing the graphics zone to wrap around the screen or something, but hopefully it works well enough for you to understand the basic principle.


    EDIT: Peter Jakacki does it again with his Tachyon Forth...

    But my method lets you have up to 64 different sets of 4 color palletes that can be assigned individually to each 16x16 tile, and truly combines text and graphics, and doesn't just draw text onto a graphics buffer (which uses less RAM than making everything graphics, like PJ's second example), and doesn't just do ASCII art.

    I did not see an attachment, did you forget to upload it? Also, I found a 1280x1024 tile driver, and a 1600x1200 tile driver.... but could not find a 1024x768 tile driver.

    Sorry about that...

    About the 1024x768 driver: From digging around my Propeller libraries, it would seem that Rayman wrote it. Its tile format is a bit different. For most other prop VGA tile drivers, the tile format is (color >> 6) | (tileptr << 10), but for this one it would seem to be (color & $3F) | (tileptr & $FFC0). That would mean that the graphics zone loop should be (only the last line changed):
      'init tile screen
      repeat dx from minx to maxx
        repeat dy from miny to maxy
          screen[dy*vga_hc+dx]:=(display_base + (dy-miny)+(dx-minx)*gr_y_tiles) << 6) & $FFC0 + (17 & $3F)
    

    I have attached the two Spin files I tried to attach above, as well as the 1024x768 driver (which uses 2 cogs with no cursor).
  • jmgjmg Posts: 15,173
    Mahonroy wrote: »
    I am shooting for the top 2/3 of the screen to be text, and the bottom 1/3 of the screen to be a plotted graph. I suppose the graph resolution would be good enough at 640x480 (or in this case 640x160). I need to be able to update specific points on the graph is the thing.
    If you want multiple graph line freedom and 640 in X, then you could store the pixel image of that area in RAM, for 160 hi that's 12800 bytes monochrome.

    Another approach : The P1 can time to 1 Sysclk, so you could do 160 lines of single-dot or Bar graph (ie vertical chart recorder like) with higher than 640 X precision, Monitor limited.

    Each Dot would have a minimum width set by SW delays.

  • The code I posted was broken (didn't even compile). I'll post a tested 1024x768 version soon.
  • Did you want double buffered graphics? It would halve your display area, but you'd be able to redraw stuff without the display flickering. It won't really be practical, so I'm going to remove it from the demo I'm about to give you.
  • ElectrodudeElectrodude Posts: 1,657
    edited 2016-02-02 00:32
    Here's a demo that does 320x240 single buffered 4 color graphics on a 1024x768 display. Download both files into the same folder and run VGA_gr_and_text_1024x768.spin. The rest of the display is used for text. It uses 19200 bytes ((20 tiles)*(15 tiles)*(64 bytes per tile)) to do this. It also uses 6144 bytes for the tile map. That means that 25344 out of 32768 bytes (77.3%) of hubram is used for graphics buffers. That leaves only 13568 bytes for everything else. My demo, counting code, buffers, and all, has 1764 unused bytes, which isn't exactly a ton.

    If you used VGA.spin, you'd be stuck with about only 640x480 total resolution (for both graphics and text), but would be able to use most of it for graphics since the screen would be smaller.
  • RaymanRayman Posts: 14,648
    Here's a way to show a lot of data in high resolution:
    http://forums.parallax.com/discussion/106118
  • Is there more than 1 line on the plot?
  • Here's a demo that does 320x240 single buffered 4 color graphics on a 1024x768 display. Download both files into the same folder and run VGA_gr_and_text_1024x768.spin. The rest of the display is used for text. It uses 19200 bytes ((20 tiles)*(15 tiles)*(64 bytes per tile)) to do this. It also uses 6144 bytes for the tile map. That means that 25344 out of 32768 bytes (77.3%) of hubram is used for graphics buffers. That leaves only 13568 bytes for everything else. My demo, counting code, buffers, and all, has 1764 unused bytes, which isn't exactly a ton.

    If you used VGA.spin, you'd be stuck with about only 640x480 total resolution (for both graphics and text), but would be able to use most of it for graphics since the screen would be smaller.
    This is great, thanks for taking the time to upload it... this looks to be just what I was looking for. I'll definitely update this with what I come up with.
  • MahonroyMahonroy Posts: 175
    edited 2016-02-19 01:24
    Here's a demo that does 320x240 single buffered 4 color graphics on a 1024x768 display. Download both files into the same folder and run VGA_gr_and_text_1024x768.spin. The rest of the display is used for text. It uses 19200 bytes ((20 tiles)*(15 tiles)*(64 bytes per tile)) to do this. It also uses 6144 bytes for the tile map. That means that 25344 out of 32768 bytes (77.3%) of hubram is used for graphics buffers. That leaves only 13568 bytes for everything else. My demo, counting code, buffers, and all, has 1764 unused bytes, which isn't exactly a ton.

    If you used VGA.spin, you'd be stuck with about only 640x480 total resolution (for both graphics and text), but would be able to use most of it for graphics since the screen would be smaller.

    I have been playing around with this trying to understand how its working... and I apologize for my ignorance... but how do you change text colors? (Or text background color - basically inverse the text/background) Every attempt I have tried using the print function for a color select and I get a bunch of jumbled characters on the screen.
Sign In or Register to comment.