View Full Version : Unsolved SD Card Folder Asscess

10-15-2011, 02:54 PM

SD card driver that I am using is Kye's as described in an006. I want to be able to navigate into folders from the root directory and back again.

Lets say I have a folder with no sub-folders in the root directory called Drills.

Why wont the code: sd.changeDirectory("\Drills") assess the folder Drills for me.

10-15-2011, 03:04 PM


10-16-2011, 03:27 PM
Is is possible to read a single number back from a file using this driver.
I have a 8digit number which I need to extract all digits one at the time? Is this possible?

Tried using fat.fileseek(0) to navigate to file position. But cant read digit back.

Mike Green
10-16-2011, 03:51 PM
You could use readByte or readData with a byte count of 1. That will get you an ASCII digit at a time. You'll have to do any conversion of the characters of the number to a numeric value. Typically, you'd use a routine like this to do the conversion of one or more digits.
PUB convertDigits( count )
' Process count ASCII digits from left to right converting to
' a numeric value which is returned as the value of convertDigits.
' No checking is done that the characters found starting at the
' current file position are actually digits. That could be added.
repeat count
result := result * 10 + fat.readByte - "0"

10-16-2011, 06:21 PM
So if I had the following digits, 456323, in a file and I wanted digit 1 only, id open the file and do the following:

fat.fileSeek(0) 'Move to position 0
count:=fat.readByte 'Assign count equal byte at that position
convertDigits 'Call convert Digits Routine
value:=result 'Assign value equal the result
dec(value) 'To display on VGA

Should this give me the 1st digit in decimal form value then? As it does not seem to work.

Mike Green
10-16-2011, 07:18 PM
No. Did you read the comments at the beginning of the routine I posted? Did you understand them?

To read just one digit, you could try

dec( convertDigits(1) )