Shop OBEX P1 Docs P2 Docs Learn Events
DEMO: Easy HTML with the Spinneret — Parallax Forums

DEMO: Easy HTML with the Spinneret

Beau SchwabeBeau Schwabe Posts: 6,566
edited 2011-01-29 15:13 in Accessories
This demo heavily uses Timothy D. Swieter's WIZnet W5100 Indirect Driver as well as Roy ELtham's DHCP driver and his S-35390A RTC Driver.

There are several changes, but mostly just to clean up the user front end so that in my opinion, it's easier to manage.

- Originally there were two instances of the Indirect Driver that were called upon that really bugged me, especially since I knew only one was necessary.

- I pushed a lot of stuff that was in what I call the 'user interface' (COG 0) into the DHCP driver since I felt that's where it made the most sense for it's location.

- I added a PUB to the RTC driver that formats the time/date into a string

So, I really didn't add a bunch of NEW code, I just moved a few things around to make the user interface less intimidating (<- I hope that's the case anyway) by adding a couple of example DEMO's.

There are also checks implemented to help prevent Web-Server lockups due to malformed network traffic.

Enjoy!!


EDIT
DEMO1 - is just a basic bare bones way to communicate HTML script in a web server. It implements a dynamic HTML approach to update the current time from the on-board RTC.

DEMO2 - expands on DEMO1 by showing how to implement dynamic HTML buttons providing feedback to the Spinneret. I have implemented a PUB function called InStr(Start,String1Address,String2Address) which makes parsing the received data much easier.

Instr - Compares two strings, if one string is located within the other string, the value returned is the starting position within the LONGEST string that the SHORTER string can be found. If there is no match, the result is a -1. You may also specify a starting position within the longest string to begin a search.




Note: Both DEMO's do not require a micro SD card to operate.

Comments

  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-01-28 19:03
    Beau,

    Thanks for this! My Spinneret has been sitting on the bench since I got it, but other priorities have kept me from doing anything with it. Your code provided both the incentive and the on-ramp that I needed to get started.

    -Phil
  • Beau SchwabeBeau Schwabe Posts: 6,566
    edited 2011-01-28 19:49
    Thanks Phil,

    That was the intent... I suspected that there were many who know a little HTML, and know a little SPIN/PASM, but didn't want to try to mess too much with the other stuff.
  • Mike GMike G Posts: 2,702
    edited 2011-01-29 06:01
    I use the same InStr() concept in my HttpRequest object except I called it MatchPattern(source, pattern, matchCase, startIndex). MatchPattern returns the startling string position but it can also set string beginning and ending memory pointers. I use MatchPattern to parse the entire header so I can expose request values through getters and setters.

    @Beau, yours is probably more efficient. Anyway, I've been thinking for a while that I should abstract the string parsing from the HttpRequest and put it in its own object. Parsing strings is also handy when you're building and sending dynamic content.
  • Beau SchwabeBeau Schwabe Posts: 6,566
    edited 2011-01-29 15:13
    Mike G,

    I just modeled mine from visual basic, one of the differences is that it doesn't matter which string is assign to what... It figures out the longest string and assumes that the shortest string would be somewhere inside of the longest one. if it can't be found a -1 is returned.
Sign In or Register to comment.