Shop OBEX P1 Docs P2 Docs Learn Events
Some Additions to fsrw (SD Card Routines) — Parallax Forums

Some Additions to fsrw (SD Card Routines)

QuattroRS4QuattroRS4 Posts: 916
edited 2009-01-13 14:35 in Propeller 1
Hello all,
·········· Recently on a project I used fsrw (The SD Card routines)· but needed to add the following. I found them useful - perhaps you may also.


Added 'SDstr' to Simplify Writing of strings to SD Card. Use as follows -
sdfat.sdstr(string("Test String"))
sdfat.sdstr(string("Test String",13,10))
the latter example adds CR & LF.

Added 'SDdec' to simplify writing of decimal values to SD Card. Use as follows -
sdfat.sddec(25)
The above example writes 25 to SDCard.


Added 'SDhex' to Simplify Writing of Hexadecimal
values to SD Card'. Use as follows -
sdfat.sdhex(25)
The above example writes 19 to SD card.
·················································
Added 'SDbin' to Simplify Writing of Binary to SD Card. Use as follows -
sdfat.sdbin(254,8)
The above example writes 11111110 to SD card.

Comments added to Code Additions also.

If you have any comments· - Please do. If you think it is worth it I will update obex or pass on to Tomas Rokicki ·.. your call.

Regards,
·········· John Twomey

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
'Necessity is the mother of invention'

Those who can, do.Those who can’t, teach.

Post Edited (QuattroRS4) : 1/13/2009 9:35:37 AM GMT

Comments

  • Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
    edited 2009-01-12 16:17
    Nice! Definitely add to the OBEX.

    OBC

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    New to the Propeller?

    Check out: Protoboard Introduction , Propeller Cookbook 1.4 & Software Index
    Updates to the Cookbook are now posted to: Propeller.warrantyvoid.us
    Got an SD card connected? - PropDOS
  • mparkmpark Posts: 1,305
    edited 2009-01-12 17:11
    Are you taking requests? I could really use a seek capability (jump to arbitrary point in a file)...
  • QuattroRS4QuattroRS4 Posts: 916
    edited 2009-01-12 17:48
    Suggested Obex submission attached - Pending Tomas Rokicki's approval I suppose . Suggestion / Comments Welcome .

    Included is very simple Vga Demo called 'sdrw_VGA_Demo.spin' to demonstrate the added features - this demo uses 'VGA_1024x768_Tile_Driver_With_Cursor.spin'. - Just to be different

    Attached also is a copy of the file - from the SDCard..

    Regards,
    John

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    'Necessity is the mother of invention'

    Those who can, do.Those who can’t, teach.

    Post Edited (QuattroRS4) : 1/13/2009 9:37:13 AM GMT
  • rokickirokicki Posts: 1,000
    edited 2009-01-12 18:27
    Howdy!

    I'll take a look tonight.

    One goal of the fsrw however was to keep the memory consumption as small as possible. So I'm not really in
    favor of adding too many utility routines.

    (If *only* the compiler would omit unused routines; I would be *so* much happier and then we could put the
    entire world in there.)

    But these are almost certainly tiny. Thanks for the contributions!

    -tom
  • Carl JacobsCarl Jacobs Posts: 41
    edited 2009-01-12 21:24
    JDForth has had this functionality and more for quite some time now, eg:
    After opening a file:
    Redirect character I/O to the file system (fs) driver.
    fs.I/O
    


    Now anything that uses character I/O will operate on the SD card.
    Eg. write a string and some numbers:
    ." Hello World." CRLF
    1000 . 1000 $. 1000 %. \ write out 1000 in decimal, hex and binary
    


    It can also be used with other words which eventually call the character I/O words.
    Eg. Dump the contents of RAM to a file:
    0 32768 DUMP
    


    When you're done, restore the character I/O routines back to nomal:
    Which could be a dedicated driver in another COG, or an inline bit-bash simple serial driver:
    I/O  -or-  ss.I/O
    


    What's really nice about this is that it's quite easy to know what's going to go to the SD card
    because you can easily use the serial port to do your testing by commenting out the first fs.I/O.

    JDForth optimises out any unused words, so there's no reason not to fill the source files with handy funcitons.

    Regards,

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Carl Jacobs


    JDForth - Forth to Spin Compiler http://www.jacobsdesign.com.au/software/jdforth/jdforth.php
    Includes: FAT16 support for SD cards. Bit-bash Serial at 2M baud. 32-bit floating point maths.·Fib(28) in 0.86 seconds. ~3x faster than spin, ~40% larger than spin.
  • BradCBradC Posts: 2,601
    edited 2009-01-13 02:11
    rokicki said...

    (If *only* the compiler would omit unused routines; I would be *so* much happier and then we could put the
    entire world in there.)

    bstc does this. I saved 24 longs on a project I was playing with using fsrw by enabling unused method removal.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Cardinal Fang! Fetch the comfy chair.
  • QuattroRS4QuattroRS4 Posts: 916
    edited 2009-01-13 03:01
    OK all withdrawn ...

    Rgds,
    John Twomey

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    'Necessity is the mother of invention'

    Those who can, do.Those who can’t, teach.
  • ElectricAyeElectricAye Posts: 4,561
    edited 2009-01-13 03:45
    QuattroRS4 said...
    OK all withdrawn ...

    Rgds,
    John Twomey

    HUH??? Withdrawn??? You mean.... like.... you took it all away....???

    Hey, wait a second. I was just getting ready to say something like "Man, I'm kissing your feet for doing this..."

    Wha happened? cry.gif
  • rokickirokicki Posts: 1,000
    edited 2009-01-13 08:09
    Any way to get them back? I think we'd really love to see them.
  • QuattroRS4QuattroRS4 Posts: 916
    edited 2009-01-13 09:48
    Reinstated ... I was of the impression that similar was already posted so I didn't want to upset the balance or add more variations .... and perhaps change the main focus by increasing code size - even though additions were minimal. Sorry for any any misunderstaning..

    Regards,
    John Twomey

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    'Necessity is the mother of invention'

    Those who can, do.Those who can’t, teach.
  • Carl JacobsCarl Jacobs Posts: 41
    edited 2009-01-13 10:15
    I'm sorry if you thought my post implied that the work had already been done.

    What I was really trying to imply, is that these features are of value which is why I included them in JDForth.
    My variation gives the functionality you described in the Forth language, but it is still of great value to have it in Spin!

    Regards,

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Carl Jacobs


    JDForth - Forth to Spin Compiler http://www.jacobsdesign.com.au/software/jdforth/jdforth.php
    Includes: FAT16 support for SD cards. Bit-bash Serial at 2M baud. 32-bit floating point maths.·Fib(28) in 0.86 seconds. ~3x faster than spin, ~40% larger than spin.
  • QuattroRS4QuattroRS4 Posts: 916
    edited 2009-01-13 10:23
    Carl,
    No problem ... I didn't want to add another version if aforementioned was already done - to me there is nothing worse than having multiple variations of the same .. perhaps there is some value in the additions for users.

    Regards,
    John Twomey

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    'Necessity is the mother of invention'

    Those who can, do.Those who can’t, teach.

    Post Edited (QuattroRS4) : 1/13/2009 12:35:43 PM GMT
  • ElectricAyeElectricAye Posts: 4,561
    edited 2009-01-13 14:35
    John,

    Man, I am kissing your feet for doing this!

    My only caveat might be to check with rokicki or post in the OBEX under a different name so that we can all keep version numbers straight, etc. As far as I know, there's not yet been any kind of formal method for managing the OBEX so things like this are incorporated in an orderly manner that is duly documented.


    Thanks again!
    Mark

    smile.gif
Sign In or Register to comment.