PDA

View Full Version : Some Additions to fsrw (SD Card Routines)



QuattroRS4
01-12-2009, 10:58 PM
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

Oldbitcollector (Jeff)
01-12-2009, 11:17 PM
Nice! Definitely add to the OBEX.

OBC

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

Check out: Protoboard Introduction (http://jeffledger.googlepages.com/Protoboard_Introduction.pdf) , Propeller Cookbook 1.4 (http://ucontroller.com/Propeller%20Protoboard%20Designs%20for%20the%20Beg inner.pdf) & Software Index (http://forums.parallax.com/showthread.php?p=770318)
Updates to the Cookbook are now posted to: Propeller.warrantyvoid.us (http://propeller.warrantyvoid.us)
Got an SD card connected? - PropDOS (http://www.orrtech.net/propdos/)

mpark
01-13-2009, 12:11 AM
Are you taking requests? I could really use a seek capability (jump to arbitrary point in a file)...

QuattroRS4
01-13-2009, 12:48 AM
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

rokicki
01-13-2009, 01:27 AM
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 Jacobs
01-13-2009, 04:24 AM
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.

BradC
01-13-2009, 09:11 AM
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.

QuattroRS4
01-13-2009, 10:01 AM
OK all withdrawn ...

Rgds,
John Twomey

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

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

ElectricAye
01-13-2009, 10:45 AM
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? http://forums.parallax.com/images/smilies/cry.gif

rokicki
01-13-2009, 03:09 PM
Any way to get them back? I think we'd really love to see them.

QuattroRS4
01-13-2009, 04:48 PM
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 Jacobs
01-13-2009, 05:15 PM
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.

QuattroRS4
01-13-2009, 05:23 PM
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

ElectricAye
01-13-2009, 09:35 PM
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

http://forums.parallax.com/images/smilies/smile.gif