Shop OBEX P1 Docs P2 Docs Learn Events
Dynamic Stripchart Image Generator — Parallax Forums

Dynamic Stripchart Image Generator

Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
edited 2011-03-18 12:44 in Accessories
Continuing my quest to create dynamic image content with the Spinneret, I've come up with an object that produces strip charts, like this one:
attachment.php?attachmentid=79154&d=1299739438

The image is a bitmap (.bmp). This format was chosen because it's paletted and does not require an image-compression algorithm to produce. The following aspects of the stripchart are programmable:
  • Width (up to 496 active pixels, 512 pixels total)
  • Height
  • Horizontal scaling
  • Paper color
  • Grid spacing and color
  • Pen color
The image is generated one line at a time, starting from the bottom (the natural order for .bmp images) and requires only enough buffer space for one line. That way, a 256- x 400-pixel stripchart image that would normally require 51.2K bytes of RAM to draw in situ needs just a 128-byte line buffer (plus some auxiliary variables) to produce and ship off to the HTTP client for display on a webpage.

Here's a link to my SpinneretCAM web server with another stripchart example:

That image is produced with using the following code snippets:
  cht.new(201, 400, 20, 16, $eeffee, $aaffaa, $ff0000, -$1_0000, $1_0000, @cht_buffer) 'Create chart specs.
  repeat i from 0 to 800
    cht.add_datum(sin(i << 5))    'Fill the chart with data.
...

  cht.begin 'Begin a new          'Generate a chart, and send it to the client.
  repeat while i := cht.block
    server.array(i, cht.block_size)
  server.end_custom_content
Typically, the chart would not be filled with data all at once, but one datum at a time at scheduled intervals, with the excess scrolling off the bottom. Such data often represent time sequences such as line voltage, temperature, windspeed, humidity, etc.

The objects in the attached archive are autodocument-ready and can be uploaded to read in document format here:

-Phil

Comments

  • D.PD.P Posts: 790
    edited 2011-03-10 00:44
    All I can say is extremely cool and thanks for all you do on this forum.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-03-13 09:57
    The stripcharts are now live and updating continuously (every five minutes). You can see them here:

    Here's a photo of the Spinneret server that creates them, with a TSL230 light-to-frequency sensor and a DS1620 temperature sensor:

    attachment.php?attachmentid=79251&d=1300035236

    The two sensors are multiplexed, as described in this thread:

    I've got it sitting in my living room next to a window. You should be able to tell when I turned the room lights on in the evening and then off when I hit the sack.

    -Phil
    695 x 419 - 77K
  • Mike GMike G Posts: 2,702
    edited 2011-03-13 11:09
    Hey Phil, I'm getting a timeout.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-03-13 11:20
    Oh, sorry about that. I had the NAT misconfigured in my firewall and, of course, hadn't tested it this time with my external website's reflector script. Try it now.

    -Phil
  • Mike GMike G Posts: 2,702
    edited 2011-03-13 12:12
    Still getting a timeout
    http://phipi.homelinux.org:4567
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-03-13 12:30
    Oh, drat! It locked up; so I had to reset it, which means the data that it collected got lost. Anyway, here's what was there before it locked up:

    attachment.php?attachmentid=79252&d=1300044580

    Now you'll have to wait an hour or so before any interesting trends appear.

    -Phil
    536 x 578 - 17K
  • Mike GMike G Posts: 2,702
    edited 2011-03-13 18:47
    That is damn cool Phil.
  • mindrobotsmindrobots Posts: 6,506
    edited 2011-03-13 19:23
    BRAVO!!

    This is excellent. Time to put my local environment online.

    Rick
  • LtechLtech Posts: 370
    edited 2011-03-14 00:57
    Push to facebook and put some heartbeat monitoring ....
    Connecting " virtual" and "physical" life ?

    Great !

    I need it for remote monitoring server temp/power rooms and racks
  • TumblerTumbler Posts: 323
    edited 2011-03-15 09:04
    Nice work Phil,
    Seems you are working on a GD2 processor :)
    Now it needs some compression (to jpeg or so)
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-03-15 09:28
    Yes, Ive considered a more generalized graphics generator. The idea would be to accept GD-like commands to create a display list, and then cycle through the display list once for each row of the image as it's being generated. The objective is to keep from having to generate a complete image in the Prop's limited RAM first.

    As to compression, LZW-GIF is probably the best candidate for crisp graphic images (as opposed to photos), since it's lossless. However, it does require a large chunk of memory for its string table, so I don't know how viable it is for the Prop.

    -Phil
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-03-18 12:44
    I've updated the object in the top post. Now the grid lines scroll with the plot, and you can choose to add minor grid lines:

    attachment.php?attachmentid=79404&d=1300477050

    The Spinneret has been moved out to my shop, which has forced-air electric heat. You can see when the heater comes on. BTW, it's not really that hot in here. (I'm not that old!) The ambient near the temp sensor is about 10 degrees warmer than the overall air temperature. The W5100 puts out a bit of heat; the Prop, not so much.

    -Phil
    539 x 581 - 16K
Sign In or Register to comment.