Some Additions to fsrw (SD Card Routines)
QuattroRS4
Posts: 916
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
·········· 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
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
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
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
After opening a file:
Redirect character I/O to the file system (fs) driver.
Now anything that uses character I/O will operate on the SD card.
Eg. write a string and some numbers:
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:
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:
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.
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.
Rgds,
John Twomey
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
'Necessity is the mother of invention'
Those who can, do.Those who can’t, teach.
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?
Regards,
John Twomey
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
'Necessity is the mother of invention'
Those who can, do.Those who can’t, teach.
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.
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
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