summaryrefslogtreecommitdiff
path: root/extmod
diff options
context:
space:
mode:
authorKattni <kattni@adafruit.com>2019-02-04 17:56:40 -0500
committerGitHub <noreply@github.com>2019-02-04 17:56:40 -0500
commit9bcc38e995648493fe35ad63a18bd65d63f64c21 (patch)
tree977ccc7335abd9db4e62c71ed73394e427fe72f0 /extmod
parent3d0757102977bcebadfd530949a84fb224e0cfcb (diff)
parentb249243a9f8d6ed246b0b873fe606066a6d712ed (diff)
Merge pull request #1519 from tannewt/speed_debug4.0.0-beta.2
Add fast seek support and turn on auto brightness by default
Diffstat (limited to 'extmod')
-rw-r--r--extmod/vfs_fat_file.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/extmod/vfs_fat_file.c b/extmod/vfs_fat_file.c
index 75fa2fbd4..1b2bb27f8 100644
--- a/extmod/vfs_fat_file.c
+++ b/extmod/vfs_fat_file.c
@@ -197,6 +197,23 @@ STATIC mp_obj_t file_open(fs_user_mount_t *vfs, const mp_obj_type_t *type, mp_ar
m_del_obj(pyb_file_obj_t, o);
mp_raise_OSError(fresult_to_errno_table[res]);
}
+ // If we're reading, turn on fast seek.
+ if (mode == FA_READ) {
+ // one call to determine how much space we need.
+ DWORD temp_table[2];
+ temp_table[0] = 2;
+ o->fp.cltbl = temp_table;
+ f_lseek(&o->fp, CREATE_LINKMAP);
+ DWORD size = (temp_table[0] + 1) * 2;
+ o->fp.cltbl = m_malloc_maybe(size * sizeof(DWORD), false);
+ if (o->fp.cltbl != NULL) {
+ o->fp.cltbl[0] = size;
+ res = f_lseek(&o->fp, CREATE_LINKMAP);
+ if (res != FR_OK) {
+ o->fp.cltbl = NULL;
+ }
+ }
+ }
// for 'a' mode, we must begin at the end of the file
if ((mode & FA_OPEN_ALWAYS) != 0) {