Skip to content

Add fast seek support and turn on auto brightness by default #1519

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions extmod/vfs_fat_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion lib/oofatfs/ffconf.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
/* This option switches f_mkfs() function. (0:Disable or 1:Enable) */


#define _USE_FASTSEEK 0
#define _USE_FASTSEEK 1
/* This option switches fast seek function. (0:Disable or 1:Enable) */


Expand Down
1 change: 1 addition & 0 deletions ports/atmel-samd/boards/hallowing_m0_express/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ void board_init(void) {
display_init_sequence,
sizeof(display_init_sequence),
&pin_PA00);
common_hal_displayio_display_set_auto_brightness(display, true);
}

bool board_requests_safe_mode(void) {
Expand Down
1 change: 1 addition & 0 deletions ports/atmel-samd/boards/pyportal/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ void board_init(void) {
display_init_sequence,
sizeof(display_init_sequence),
&pin_PB31);
common_hal_displayio_display_set_auto_brightness(display, true);
}

bool board_requests_safe_mode(void) {
Expand Down