「App:Library:LVGL:docs:Overview:File system」の版間の差分
(ページの作成:「https://docs.lvgl.io/8.2/overview/style.html __NOTOC__ {| class="wikitable" !英文 !自動翻訳 |- | | |} :戻る : Previous」) |
(→API) |
||
(同じ利用者による、間の5版が非表示) | |||
1行目: | 1行目: | ||
− | https://docs.lvgl.io/8.2/overview/ | + | https://docs.lvgl.io/8.2/overview/file-system.html |
__NOTOC__ | __NOTOC__ | ||
+ | = File system = | ||
{| class="wikitable" | {| class="wikitable" | ||
!英文 | !英文 | ||
6行目: | 7行目: | ||
|- | |- | ||
| | | | ||
+ | LVGL has a 'File system' abstraction module that enables you to attach any type of file system. | ||
+ | |||
+ | A file system is identified by an assigned drive letter. | ||
+ | |||
+ | For example, if an SD card is associated with the letter <code style="color: #bb0000;">'S'</code>, a file can be reached using <code style="color: #bb0000;">"S:path/to/file.txt"</code>. | ||
+ | |LVGLには'File system'抽象化モジュールがあり、任意の種類のファイルシステムをアタッチすることができます。 | ||
+ | ファイルシステムは、ドライブレターで識別されます。 | ||
+ | |||
+ | 例えば、SDカードに<code style="color: #bb0000;">'S'</code>という文字が割り当てられている場合、<code style="color: #bb0000;">"S:path/to/file.txt"</code>でファイルにアクセスすることができる。 | ||
+ | |} | ||
+ | :[[App:Library:LVGL:docs:Overview#File_system|戻る : Previous]] | ||
+ | |||
+ | |||
+ | == Ready to use drivers == | ||
+ | {| class="wikitable" | ||
+ | !英文 | ||
+ | !自動翻訳 | ||
+ | |- | ||
+ | | | ||
+ | The lv_fs_if repository contains prepared drivers using POSIX, standard C and the FATFS API. | ||
+ | |||
+ | See its README for the details. | ||
+ | |lv_fs_ifリポジトリには、POSIX、標準C、FATFS APIを使用したドライバが用意されています。 | ||
+ | 詳しくはREADMEをご覧ください。 | ||
+ | |} | ||
+ | :[[App:Library:LVGL:docs:Overview#File_system|戻る : Previous]] | ||
+ | |||
+ | |||
+ | == Adding a driver == | ||
+ | === Registering a driver === | ||
+ | {| class="wikitable" | ||
+ | !英文 | ||
+ | !自動翻訳 | ||
+ | |- | ||
+ | | | ||
+ | To add a driver, a <code style="color: #bb0000;">lv_fs_drv_t</code> needs to be initialized like below. | ||
+ | |||
+ | The <code style="color: #bb0000;">lv_fs_drv_t</code> needs to be static, global or dynamically allocated and not a local variable. | ||
+ | <syntaxhighlight lang="C++" style="border:1px dashed gray;"> | ||
+ | static lv_fs_drv_t drv; /*Needs to be static or global*/ | ||
+ | lv_fs_drv_init(&drv); /*Basic initialization*/ | ||
+ | |||
+ | drv.letter = 'S'; /*An uppercase letter to identify the drive */ | ||
+ | drv.cache_size = my_cahce_size; /*Cache size for reading in bytes. 0 to not cache.*/ | ||
+ | |||
+ | drv.ready_cb = my_ready_cb; /*Callback to tell if the drive is ready to use */ | ||
+ | drv.open_cb = my_open_cb; /*Callback to open a file */ | ||
+ | drv.close_cb = my_close_cb; /*Callback to close a file */ | ||
+ | drv.read_cb = my_read_cb; /*Callback to read a file */ | ||
+ | drv.write_cb = my_write_cb; /*Callback to write a file */ | ||
+ | drv.seek_cb = my_seek_cb; /*Callback to seek in a file (Move cursor) */ | ||
+ | drv.tell_cb = my_tell_cb; /*Callback to tell the cursor position */ | ||
+ | |||
+ | drv.dir_open_cb = my_dir_open_cb; /*Callback to open directory to read its content */ | ||
+ | drv.dir_read_cb = my_dir_read_cb; /*Callback to read a directory's content */ | ||
+ | drv.dir_close_cb = my_dir_close_cb; /*Callback to close a directory */ | ||
+ | |||
+ | drv.user_data = my_user_data; /*Any custom data if required*/ | ||
+ | |||
+ | lv_fs_drv_register(&drv); /*Finally register the drive*/ | ||
+ | </syntaxhighlight> | ||
+ | Any of the callbacks can be <code style="color: #bb0000;">NULL</code> to indicate that operation is not supported. | ||
+ | |ドライバを追加するには、以下のように<code style="color: #bb0000;">lv_fs_drv_t</code> を初期化する必要があります。 | ||
+ | <code style="color: #bb0000;">lv_fs_drv_t</code> は、ローカル変数ではなく、スタティック、グローバル、またはダイナミックにアロケートされたものである必要があります。<syntaxhighlight lang="C++" style="border:1px dashed gray;"> | ||
+ | static lv_fs_drv_t drv; /*Needs to be static or global*/ | ||
+ | lv_fs_drv_init(&drv); /*Basic initialization*/ | ||
+ | |||
+ | drv.letter = 'S'; /*An uppercase letter to identify the drive */ | ||
+ | drv.cache_size = my_cahce_size; /*Cache size for reading in bytes. 0 to not cache.*/ | ||
+ | |||
+ | drv.ready_cb = my_ready_cb; /*Callback to tell if the drive is ready to use */ | ||
+ | drv.open_cb = my_open_cb; /*Callback to open a file */ | ||
+ | drv.close_cb = my_close_cb; /*Callback to close a file */ | ||
+ | drv.read_cb = my_read_cb; /*Callback to read a file */ | ||
+ | drv.write_cb = my_write_cb; /*Callback to write a file */ | ||
+ | drv.seek_cb = my_seek_cb; /*Callback to seek in a file (Move cursor) */ | ||
+ | drv.tell_cb = my_tell_cb; /*Callback to tell the cursor position */ | ||
+ | |||
+ | drv.dir_open_cb = my_dir_open_cb; /*Callback to open directory to read its content */ | ||
+ | drv.dir_read_cb = my_dir_read_cb; /*Callback to read a directory's content */ | ||
+ | drv.dir_close_cb = my_dir_close_cb; /*Callback to close a directory */ | ||
+ | |||
+ | drv.user_data = my_user_data; /*Any custom data if required*/ | ||
+ | |||
+ | lv_fs_drv_register(&drv); /*Finally register the drive*/ | ||
+ | </syntaxhighlight> | ||
+ | コールバックのいずれかを<code style="color: #bb0000;">NULL</code>にすることで、操作がサポートされていないことを示すことができる。 | ||
+ | |} | ||
+ | :[[App:Library:LVGL:docs:Overview#File_system|戻る : Previous]] | ||
+ | |||
+ | |||
+ | === Implementing the callbacks === | ||
+ | ==== Open callback ==== | ||
+ | {| class="wikitable" | ||
+ | !英文 | ||
+ | !自動翻訳 | ||
+ | |- | ||
+ | | | ||
+ | The prototype of <code style="color: #bb0000;">open_cb</code> looks like this: | ||
+ | void * (*open_cb)(lv_fs_drv_t * drv, const char * path, lv_fs_mode_t mode); | ||
+ | <code style="color: #bb0000;">path</code> is the path after the drive letter (e.g. "S:path/to/file.txt" -> "path/to/file.txt"). | ||
+ | |||
+ | <code style="color: #bb0000;">mode</code> can be <code style="color: #bb0000;">LV_FS_MODE_WR</code> or <code style="color: #bb0000;">LV_FS_MODE_RD</code> to open for writes or reads. | ||
+ | |||
+ | The return value is a pointer to a ''file object'' that describes the opened file or <code style="color: #bb0000;">NULL</code> if there were any issues (e.g. the file wasn't found). | ||
+ | |||
+ | The returned file object will be passed to other file system related callbacks. (see below) | ||
+ | |<code style="color: #bb0000;">open_cb</code>のプロトタイプは以下のようなものです。 | ||
+ | void * (*open_cb)(lv_fs_drv_t * drv, const char * path, lv_fs_mode_t mode); | ||
+ | <code style="color: #bb0000;">path</code> はドライブレターの後のパスです (例: "S:path/to/file.txt" -> "path/to/file.txt"). | ||
+ | |||
+ | <code style="color: #bb0000;">mode</code> には <code style="color: #bb0000;">LV_FS_MODE_WR</code> または <code style="color: #bb0000;">LV_FS_MODE_RD</code> を指定し、書き込みまたは読み出し用にオープンすることができます。 | ||
+ | |||
+ | 戻り値は、オープンしたファイルを記述したファイルオブジェクトへのポインタ、または何らかの問題(ファイルが見つからなかったなど)があった場合は<code style="color: #bb0000;">NULL</code> です。 | ||
+ | |||
+ | 返されたファイルオブジェクトは、他のファイルシステム関連のコールバック関数に渡されます。(下記参照) | ||
+ | |} | ||
+ | :[[App:Library:LVGL:docs:Overview#File_system|戻る : Previous]] | ||
+ | |||
+ | |||
+ | === Other callbacks === | ||
+ | {| class="wikitable" | ||
+ | !英文 | ||
+ | !自動翻訳 | ||
+ | |- | ||
+ | | | ||
+ | The other callbacks are quite similar. | ||
+ | |||
+ | For example looks like this: | ||
+ | <syntaxhighlight lang="C++" style="border:1px dashed gray;"> | ||
+ | lv_fs_res_t (*write_cb)(lv_fs_drv_t * drv, void * file_p, const void * buf, uint32_t btw, uint32_t * bw); | ||
+ | </syntaxhighlight> | ||
+ | For <code style="color: #bb0000;">file_p</code>, LVGL passes the return value of <code style="color: #bb0000;">open_cb</code>, | ||
+ | |||
+ | <code style="color: #bb0000;">buf</code> is the data to write, | ||
+ | |||
+ | <code style="color: #bb0000;">btw</code> is the Bytes To Write, | ||
+ | |||
+ | <code style="color: #bb0000;">bw</code> is the actually written bytes. | ||
+ | |||
+ | For a template of these callbacks see lv_fs_template.c. | ||
+ | |他のコールバックは非常によく似ています。 | ||
+ | 例えば<code style="color: #bb0000;">write_cb</code> は以下のような感じです。<syntaxhighlight lang="C++" style="border:1px dashed gray;"> | ||
+ | lv_fs_res_t (*write_cb)(lv_fs_drv_t * drv, void * file_p, const void * buf, uint32_t btw, uint32_t * bw); | ||
+ | </syntaxhighlight> | ||
+ | <code style="color: #bb0000;">file_p</code>には、LVGLは<code style="color: #bb0000;">open_cb</code>の戻り値を渡し、 | ||
+ | |||
+ | <code style="color: #bb0000;">buf</code>は書き込むデータ、 | ||
+ | |||
+ | <code style="color: #bb0000;">btw</code> は書き込むバイト数、 | ||
+ | |||
+ | <code style="color: #bb0000;">bw</code>は実際に書き込んだバイト数です。 | ||
+ | |||
+ | これらのコールバックのテンプレートは,lv_fs_template.cを参照してください. | ||
+ | |} | ||
+ | :[[App:Library:LVGL:docs:Overview#File_system|戻る : Previous]] | ||
+ | |||
+ | |||
+ | == Usage example == | ||
+ | {| class="wikitable" | ||
+ | !英文 | ||
+ | !自動翻訳 | ||
+ | |- | ||
+ | | | ||
+ | The example below shows how to read from a file: | ||
+ | <syntaxhighlight lang="C++" style="border:1px dashed gray;"> | ||
+ | lv_fs_file_t f; | ||
+ | lv_fs_res_t res; | ||
+ | res = lv_fs_open(&f, "S:folder/file.txt", LV_FS_MODE_RD); | ||
+ | if(res != LV_FS_RES_OK) my_error_handling(); | ||
+ | |||
+ | uint32_t read_num; | ||
+ | uint8_t buf[8]; | ||
+ | res = lv_fs_read(&f, buf, 8, &read_num); | ||
+ | if(res != LV_FS_RES_OK || read_num != 8) my_error_handling(); | ||
+ | |||
+ | lv_fs_close(&f); | ||
+ | </syntaxhighlight> | ||
+ | ''The mode in <code style="color: #bb0000;">lv_fs_open</code> can be <code style="color: #bb0000;">LV_FS_MODE_WR</code> to open for writes only or <code style="color: #bb0000;">LV_FS_MODE_RD | LV_FS_MODE_WR</code> for both'' | ||
+ | |||
+ | This example shows how to read a directory's content. | ||
+ | |||
+ | It's up to the driver how to mark directories in the result but it can be a good practice to insert a <code style="color: #bb0000;">'/'</code> in front of each directory name. | ||
+ | <syntaxhighlight lang="C++" style="border:1px dashed gray;"> | ||
+ | lv_fs_dir_t dir; | ||
+ | lv_fs_res_t res; | ||
+ | res = lv_fs_dir_open(&dir, "S:/folder"); | ||
+ | if(res != LV_FS_RES_OK) my_error_handling(); | ||
+ | |||
+ | char fn[256]; | ||
+ | while(1) { | ||
+ | res = lv_fs_dir_read(&dir, fn); | ||
+ | if(res != LV_FS_RES_OK) { | ||
+ | my_error_handling(); | ||
+ | break; | ||
+ | } | ||
+ | |||
+ | /*fn is empty, if not more files to read*/ | ||
+ | if(strlen(fn) == 0) { | ||
+ | break; | ||
+ | } | ||
+ | |||
+ | printf("%s\n", fn); | ||
+ | } | ||
+ | |||
+ | lv_fs_dir_close(&dir); | ||
+ | </syntaxhighlight> | ||
+ | |以下の例では、ファイルから読み取る方法を示しています。 | ||
+ | <syntaxhighlight lang="C++" style="border:1px dashed gray;"> | ||
+ | lv_fs_file_t f; | ||
+ | lv_fs_res_t res; | ||
+ | res = lv_fs_open(&f, "S:folder/file.txt", LV_FS_MODE_RD); | ||
+ | if(res != LV_FS_RES_OK) my_error_handling(); | ||
+ | |||
+ | uint32_t read_num; | ||
+ | uint8_t buf[8]; | ||
+ | res = lv_fs_read(&f, buf, 8, &read_num); | ||
+ | if(res != LV_FS_RES_OK || read_num != 8) my_error_handling(); | ||
+ | |||
+ | lv_fs_close(&f); | ||
+ | </syntaxhighlight> | ||
+ | ''<code style="color: #bb0000;">lv_fs_open</code>'' のモードは,書き込み専用なら''<code style="color: #bb0000;">LV_FS_MODE_WR</code>'' ,両方なら''<code style="color: #bb0000;">LV_FS_MODE_RD | LV_FS_MODE_WR</code>''を指定することができます。 | ||
+ | |||
+ | この例は、ディレクトリの内容を読み取る方法を示しています。 | ||
+ | |||
+ | 結果の中でディレクトリをどのようにマークするかはドライバ次第ですが、各ディレクトリ名の前に<code style="color: #bb0000;">'/'</code>を挿入するのは良い習慣と言えるでしょう。<syntaxhighlight lang="C++" style="border:1px dashed gray;"> | ||
+ | lv_fs_dir_t dir; | ||
+ | lv_fs_res_t res; | ||
+ | res = lv_fs_dir_open(&dir, "S:/folder"); | ||
+ | if(res != LV_FS_RES_OK) my_error_handling(); | ||
+ | |||
+ | char fn[256]; | ||
+ | while(1) { | ||
+ | res = lv_fs_dir_read(&dir, fn); | ||
+ | if(res != LV_FS_RES_OK) { | ||
+ | my_error_handling(); | ||
+ | break; | ||
+ | } | ||
+ | |||
+ | /*fn is empty, if not more files to read*/ | ||
+ | if(strlen(fn) == 0) { | ||
+ | break; | ||
+ | } | ||
+ | |||
+ | printf("%s\n", fn); | ||
+ | } | ||
+ | |||
+ | lv_fs_dir_close(&dir); | ||
+ | </syntaxhighlight> | ||
+ | |} | ||
+ | :[[App:Library:LVGL:docs:Overview#File_system|戻る : Previous]] | ||
+ | |||
+ | |||
+ | == Use drives for images == | ||
+ | {| class="wikitable" | ||
+ | !英文 | ||
+ | !自動翻訳 | ||
+ | |- | ||
| | | | ||
+ | Image objects can be opened from files too (besides variables stored in the compiled program). | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | To use files in image widgets the following callbacks are required: | ||
+ | |||
+ | * open | ||
+ | * close | ||
+ | * read | ||
+ | * seek | ||
+ | * tell | ||
+ | |画像オブジェクトはファイルからも開くことができます(コンパイルされたプログラムに格納されている変数を除く)。 | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | 画像ウィジェットでファイルを使用するには、次のコールバックが必要です。 | ||
+ | |||
+ | * open | ||
+ | * close | ||
+ | * read | ||
+ | * seek | ||
+ | * tell | ||
|} | |} | ||
+ | :[[App:Library:LVGL:docs:Overview#File_system|戻る : Previous]] | ||
+ | |||
+ | |||
+ | == API == | ||
+ | {| class="wikitable" | ||
+ | !英文 | ||
+ | !自動翻訳 | ||
+ | |- | ||
+ | | | ||
+ | '''Typedefs''' | ||
+ | |||
+ | <span style="background-color:#e7f2fa;color:#2980b9;">typedef uint8_t lv_fs_res_t </span> | ||
+ | : | ||
+ | |||
+ | <span style="background-color:#e7f2fa;color:#2980b9;">typedef uint8_t lv_fs_mode_t </span> | ||
+ | : | ||
+ | |||
+ | <span style="background-color:#e7f2fa;color:#2980b9;">typedef struct _lv_fs_drv_t lv_fs_drv_t </span> | ||
+ | : | ||
+ | |||
+ | '''Enums''' | ||
+ | |||
+ | <span style="background-color:#e7f2fa;color:#2980b9;">enum [anonymous] </span> | ||
+ | : Errors in the file system module. | ||
+ | : '''''Values:''''' | ||
+ | : <span style="background-color: #eeeeee;">enumerator LV_FS_RES_OK </span> | ||
+ | :: | ||
+ | : <span style="background-color: #eeeeee;">enumerator LV_FS_RES_HW_ERR </span> | ||
+ | :: | ||
+ | : <span style="background-color: #eeeeee;">enumerator LV_FS_RES_FS_ERR </span> | ||
+ | :: | ||
+ | : <span style="background-color: #eeeeee;">enumerator LV_FS_RES_NOT_EX </span> | ||
+ | :: | ||
+ | : <span style="background-color: #eeeeee;">enumerator LV_FS_RES_FULL </span> | ||
+ | :: | ||
+ | : <span style="background-color: #eeeeee;">enumerator LV_FS_RES_LOCKED </span> | ||
+ | :: | ||
+ | : <span style="background-color: #eeeeee;">enumerator LV_FS_RES_DENIED </span> | ||
+ | :: | ||
+ | : <span style="background-color: #eeeeee;">enumerator LV_FS_RES_BUSY </span> | ||
+ | :: | ||
+ | : <span style="background-color: #eeeeee;">enumerator LV_FS_RES_TOUT </span> | ||
+ | :: | ||
+ | : <span style="background-color: #eeeeee;">enumerator LV_FS_RES_NOT_IMP </span> | ||
+ | :: | ||
+ | : <span style="background-color: #eeeeee;">enumerator LV_FS_RES_OUT_OF_MEM </span> | ||
+ | :: | ||
+ | : <span style="background-color: #eeeeee;">enumerator LV_FS_RES_INV_PARAM </span> | ||
+ | :: | ||
+ | : <span style="background-color: #eeeeee;">enumerator LV_FS_RES_UNKNOWN </span> | ||
+ | :: | ||
+ | |||
+ | <span style="background-color:#e7f2fa;color:#2980b9;">enum [anonymous] </span> | ||
+ | : File open mode. | ||
+ | : '''''Values:''''' | ||
+ | : <span style="background-color: #eeeeee;">enumerator LV_FS_MODE_WR </span> | ||
+ | :: | ||
+ | : <span style="background-color: #eeeeee;">enumerator LV_FS_MODE_RD </span> | ||
+ | :: | ||
+ | |||
+ | <span style="background-color:#e7f2fa;color:#2980b9;">enum lv_fs_whence_t </span> | ||
+ | : Seek modes. | ||
+ | : '''''Values:''''' | ||
+ | : <span style="background-color: #eeeeee;">enumerator LV_FS_SEEK_SET </span> | ||
+ | :: Set the position from absolutely (from the start of file) | ||
+ | : <span style="background-color: #eeeeee;">enumerator LV_FS_SEEK_CUR </span> | ||
+ | :: Set the position from the current position | ||
+ | : <span style="background-color: #eeeeee;">enumerator LV_FS_SEEK_END </span> | ||
+ | :: Set the position from the end of the file | ||
+ | |'''Typedefs''' | ||
+ | |||
+ | <span style="background-color:#e7f2fa;color:#2980b9;">typedef uint8_t lv_fs_res_t </span> | ||
+ | : | ||
+ | |||
+ | <span style="background-color:#e7f2fa;color:#2980b9;">typedef uint8_t lv_fs_mode_t </span> | ||
+ | : | ||
+ | |||
+ | <span style="background-color:#e7f2fa;color:#2980b9;">typedef struct _lv_fs_drv_t lv_fs_drv_t </span> | ||
+ | : | ||
+ | '''Enums''' | ||
+ | <span style="background-color:#e7f2fa;color:#2980b9;">enum [anonymous] </span> | ||
+ | : ファイルシステムモジュールのエラー。 | ||
+ | :'''''Values:''''' | ||
+ | :<span style="background-color: #eeeeee;">enumerator LV_FS_RES_OK </span> | ||
+ | :: | ||
+ | :<span style="background-color: #eeeeee;">enumerator LV_FS_RES_HW_ERR </span> | ||
+ | :: | ||
+ | :<span style="background-color: #eeeeee;">enumerator LV_FS_RES_FS_ERR </span> | ||
+ | :: | ||
+ | :<span style="background-color: #eeeeee;">enumerator LV_FS_RES_NOT_EX </span> | ||
+ | :: | ||
+ | :<span style="background-color: #eeeeee;">enumerator LV_FS_RES_FULL </span> | ||
+ | :: | ||
+ | :<span style="background-color: #eeeeee;">enumerator LV_FS_RES_LOCKED </span> | ||
+ | :: | ||
+ | :<span style="background-color: #eeeeee;">enumerator LV_FS_RES_DENIED </span> | ||
+ | :: | ||
+ | :<span style="background-color: #eeeeee;">enumerator LV_FS_RES_BUSY </span> | ||
+ | :: | ||
+ | :<span style="background-color: #eeeeee;">enumerator LV_FS_RES_TOUT </span> | ||
+ | :: | ||
+ | :<span style="background-color: #eeeeee;">enumerator LV_FS_RES_NOT_IMP </span> | ||
+ | :: | ||
+ | :<span style="background-color: #eeeeee;">enumerator LV_FS_RES_OUT_OF_MEM </span> | ||
+ | :: | ||
+ | :<span style="background-color: #eeeeee;">enumerator LV_FS_RES_INV_PARAM </span> | ||
+ | :: | ||
+ | :<span style="background-color: #eeeeee;">enumerator LV_FS_RES_UNKNOWN </span> | ||
+ | :: | ||
+ | <span style="background-color:#e7f2fa;color:#2980b9;">enum [anonymous] </span> | ||
+ | : File open mode. | ||
+ | :'''''Values:''''' | ||
+ | :<span style="background-color: #eeeeee;">enumerator LV_FS_MODE_WR </span> | ||
+ | :: | ||
+ | :<span style="background-color: #eeeeee;">enumerator LV_FS_MODE_RD </span> | ||
+ | :: | ||
+ | <span style="background-color:#e7f2fa;color:#2980b9;">enum lv_fs_whence_t </span> | ||
+ | : シークモード。 | ||
+ | :'''''Values:''''' | ||
+ | :<span style="background-color: #eeeeee;">enumerator LV_FS_SEEK_SET </span> | ||
+ | :: 位置を絶対位置 (ファイルの先頭から) から設定 | ||
+ | :<span style="background-color: #eeeeee;">enumerator LV_FS_SEEK_CUR </span> | ||
+ | :: 現在の位置からの位置を設定します | ||
+ | :<span style="background-color: #eeeeee;">enumerator LV_FS_SEEK_END </span> | ||
+ | :: ファイルの末尾からの位置を設定する | ||
+ | |- | ||
+ | | | ||
+ | '''Functions''' | ||
+ | <span style="background-color:#e7f2fa;color:#2980b9;">void _lv_fs_init(void) </span> | ||
+ | : Initialize the File system interface | ||
+ | <span style="background-color:#e7f2fa;color:#2980b9;">void lv_fs_drv_init(lv_fs_drv_t *drv) </span> | ||
+ | : Initialize a file system driver with default values. | ||
+ | : It is used to surly have known values in the fields ant not memory junk. | ||
+ | : After it you can set the fields. | ||
+ | : | ||
+ | :'''Parameters''' | ||
+ | :: '''drv''' -- pointer to driver variable to initialize | ||
+ | <span style="background-color:#e7f2fa;color:#2980b9;">void lv_fs_drv_register(lv_fs_drv_t *drv) </span> | ||
+ | : Add a new drive | ||
+ | : '''Parameters''' | ||
+ | :: '''drv''' -- pointer to an lv_fs_drv_t structure which is inited with the corresponding function pointers. | ||
+ | :: Only pointer is saved, so the driver should be static or dynamically allocated. | ||
+ | <span style="background-color:#e7f2fa;color:#2980b9;">lv_fs_drv_t *lv_fs_get_drv(char letter) </span> | ||
+ | : Give a pointer to a driver from its letter | ||
+ | : '''Parameters''' | ||
+ | :: '''letter''' -- the driver letter | ||
+ | : '''Returns''' | ||
+ | :: pointer to a driver or NULL if not found | ||
+ | <span style="background-color:#e7f2fa;color:#2980b9;">bool lv_fs_is_ready(char letter) </span> | ||
+ | : Test if a drive is ready or not. If the <code style="color: #bb0000;">ready</code> function was not initialized <code style="color: #bb0000;">true</code> will be returned. | ||
+ | : '''Parameters''' | ||
+ | :: '''letter''' -- letter of the drive | ||
+ | : '''Returns''' | ||
+ | :: '''true''': drive is ready; false: drive is not ready | ||
+ | |||
+ | <span style="background-color:#e7f2fa;color:#2980b9;">lv_fs_res_t lv_fs_open(lv_fs_file_t *file_p, const char *path, lv_fs_mode_t mode) </span> | ||
+ | : Open a file | ||
+ | : '''Parameters''' | ||
+ | ::* '''file_p''' -- pointer to a lv_fs_file_t variable | ||
+ | |||
+ | ::* '''path''' -- path to the file beginning with the driver letter (e.g. S:/folder/file.txt) | ||
+ | ::* '''mode''' -- read: FS_MODE_RD, write: FS_MODE_WR, both: FS_MODE_RD | FS_MODE_WR | ||
+ | : '''Returns''' | ||
+ | :: LV_FS_RES_OK or any error from lv_fs_res_t enum | ||
+ | |||
+ | <span style="background-color:#e7f2fa;color:#2980b9;">lv_fs_res_t lv_fs_close(lv_fs_file_t *file_p) </span> | ||
+ | : Close an already opened file | ||
+ | : '''Parameters''' | ||
+ | :: '''file_p''' -- pointer to a lv_fs_file_t variable | ||
+ | : '''Returns''' | ||
+ | :: LV_FS_RES_OK or any error from lv_fs_res_t enum | ||
+ | |||
+ | <span style="background-color:#e7f2fa;color:#2980b9;">lv_fs_res_t lv_fs_read(lv_fs_file_t *file_p, void *buf, uint32_t btr, uint32_t *br) </span> | ||
+ | : Read from a file | ||
+ | : '''Parameters''' | ||
+ | ::* '''file_p''' -- pointer to a lv_fs_file_t variable | ||
+ | ::* '''buf''' -- pointer to a buffer where the read bytes are stored | ||
+ | ::* '''btr''' -- Bytes To Read | ||
+ | ::* '''br''' -- the number of real read bytes (Bytes Read). NULL if unused. | ||
+ | : '''Returns''' | ||
+ | :: LV_FS_RES_OK or any error from lv_fs_res_t enum | ||
+ | |||
+ | <span style="background-color:#e7f2fa;color:#2980b9;">lv_fs_res_t lv_fs_write(lv_fs_file_t *file_p, const void *buf, uint32_t btw, uint32_t *bw) </span> | ||
+ | : Write into a file | ||
+ | : '''Parameters''' | ||
+ | ::* '''file_p''' -- pointer to a lv_fs_file_t variable | ||
+ | ::* '''buf''' -- pointer to a buffer with the bytes to write | ||
+ | ::* '''btr''' -- Bytes To Write | ||
+ | ::* '''br''' -- the number of real written bytes (Bytes Written). NULL if unused. | ||
+ | : '''Returns''' | ||
+ | :: LV_FS_RES_OK or any error from lv_fs_res_t enum | ||
+ | |||
+ | <span style="background-color:#e7f2fa;color:#2980b9;">lv_fs_res_t lv_fs_seek(lv_fs_file_t *file_p, uint32_t pos, lv_fs_whence_t whence) </span> | ||
+ | : Set the position of the 'cursor' (read write pointer) in a file | ||
+ | : '''Parameters''' | ||
+ | ::* '''file_p''' -- pointer to a lv_fs_file_t variable | ||
+ | ::* '''pos''' -- the new position expressed in bytes index (0: start of file) | ||
+ | ::* '''whence''' -- tells from where set the position. See @lv_fs_whence_t | ||
+ | : '''Returns''' | ||
+ | :: LV_FS_RES_OK or any error from lv_fs_res_t enum | ||
+ | |||
+ | <span style="background-color:#e7f2fa;color:#2980b9;">lv_fs_res_t lv_fs_tell(lv_fs_file_t *file_p, uint32_t *pos) </span> | ||
+ | : Give the position of the read write pointer | ||
+ | : '''Parameters''' | ||
+ | ::* '''file_p''' -- pointer to a lv_fs_file_t variable | ||
+ | ::* '''pos_p''' -- pointer to store the position of the read write pointer | ||
+ | : '''Returns''' | ||
+ | :: LV_FS_RES_OK or any error from 'fs_res_t' | ||
+ | |||
+ | <span style="background-color:#e7f2fa;color:#2980b9;">lv_fs_res_t lv_fs_dir_open(lv_fs_dir_t *rddir_p, const char *path) </span> | ||
+ | : Initialize a 'fs_dir_t' variable for directory reading | ||
+ | : '''Parameters''' | ||
+ | ::* '''rddir_p''' -- pointer to a 'lv_fs_dir_t' variable | ||
+ | ::* '''path''' -- path to a directory | ||
+ | : '''Returns''' | ||
+ | :: LV_FS_RES_OK or any error from lv_fs_res_t enum | ||
+ | |||
+ | <span style="background-color:#e7f2fa;color:#2980b9;">lv_fs_res_t lv_fs_dir_read(lv_fs_dir_t *rddir_p, char *fn) </span> | ||
+ | : Read the next filename form a directory. The name of the directories will begin with '/' | ||
+ | : '''Parameters''' | ||
+ | ::* '''rddir_p''' -- pointer to an initialized 'fs_dir_t' variable | ||
+ | ::* '''fn''' -- pointer to a buffer to store the filename | ||
+ | : '''Returns''' | ||
+ | :: LV_FS_RES_OK or any error from lv_fs_res_t enum | ||
+ | |||
+ | <span style="background-color:#e7f2fa;color:#2980b9;">lv_fs_res_t lv_fs_dir_close(lv_fs_dir_t *rddir_p) </span> | ||
+ | : Close the directory reading | ||
+ | : '''Parameters''' | ||
+ | :: '''rddir_p''' -- pointer to an initialized 'fs_dir_t' variable | ||
+ | : '''Returns''' | ||
+ | :: LV_FS_RES_OK or any error from lv_fs_res_t enum | ||
+ | |||
+ | <span style="background-color:#e7f2fa;color:#2980b9;">char *lv_fs_get_letters(char *buf) </span> | ||
+ | : Fill a buffer with the letters of existing drivers | ||
+ | : '''Parameters''' | ||
+ | :: '''buf''' -- buffer to store the letters ('\0' added after the last letter) | ||
+ | : '''Returns''' | ||
+ | :: the buffer | ||
+ | |||
+ | <span style="background-color:#e7f2fa;color:#2980b9;">const char *lv_fs_get_ext(const char *fn) </span> | ||
+ | : Return with the extension of the filename | ||
+ | : '''Parameters''' | ||
+ | :: '''fn''' -- string with a filename | ||
+ | : '''Returns''' | ||
+ | :: pointer to the beginning extension or empty string if no extension | ||
+ | |||
+ | <span style="background-color:#e7f2fa;color:#2980b9;">char *lv_fs_up(char *path) </span> | ||
+ | : Step up one level | ||
+ | : '''Parameters''' | ||
+ | :: '''path''' -- pointer to a file name | ||
+ | : '''Returns''' | ||
+ | :: the truncated file name | ||
+ | |||
+ | <span style="background-color:#e7f2fa;color:#2980b9;">const char *lv_fs_get_last(const char *path) </span> | ||
+ | : Get the last element of a path (e.g. U:/folder/file -> file) | ||
+ | : '''Parameters''' | ||
+ | :: '''path''' -- pointer to a file name | ||
+ | : '''Returns''' | ||
+ | :: pointer to the beginning of the last element in the path | ||
+ | |||
+ | <span style="background-color:#e7f2fa;color:#2980b9;">struct _lv_fs_drv_t </span> | ||
+ | : '''Public Members''' | ||
+ | : <span style="background-color: #eeeeee;">char letter </span> | ||
+ | :: | ||
+ | : <span style="background-color: #eeeeee;">uint16_t cache_size </span> | ||
+ | :: | ||
+ | : <span style="background-color: #eeeeee;">bool (*ready_cb)(struct _lv_fs_drv_t *drv) </span> | ||
+ | :: | ||
+ | : <span style="background-color: #eeeeee;">void *(*open_cb)(struct _lv_fs_drv_t *drv, const char *path, lv_fs_mode_t mode) </span> | ||
+ | :: | ||
+ | : <span style="background-color: #eeeeee;">lv_fs_res_t (*close_cb)(struct _lv_fs_drv_t *drv, void *file_p) </span> | ||
+ | :: | ||
+ | : <span style="background-color: #eeeeee;">lv_fs_res_t (*read_cb)(struct _lv_fs_drv_t *drv, void *file_p, void *buf, uint32_t btr, uint32_t *br) </span> | ||
+ | :: | ||
+ | : <span style="background-color: #eeeeee;">lv_fs_res_t (*write_cb)(struct _lv_fs_drv_t *drv, void *file_p, const void *buf, uint32_t btw, uint32_t *bw) </span> | ||
+ | :: | ||
+ | : <span style="background-color: #eeeeee;">lv_fs_res_t (*seek_cb)(struct _lv_fs_drv_t *drv, void *file_p, uint32_t pos, lv_fs_whence_t whence) </span> | ||
+ | :: | ||
+ | : <span style="background-color: #eeeeee;">lv_fs_res_t (*tell_cb)(struct _lv_fs_drv_t *drv, void *file_p, uint32_t *pos_p) </span> | ||
+ | :: | ||
+ | : | ||
+ | : <span style="background-color: #eeeeee;">void *(*dir_open_cb)(struct _lv_fs_drv_t *drv, const char *path) </span> | ||
+ | :: | ||
+ | : <span style="background-color: #eeeeee;">lv_fs_res_t (*dir_read_cb)(struct _lv_fs_drv_t *drv, void *rddir_p, char *fn) </span> | ||
+ | :: | ||
+ | : <span style="background-color: #eeeeee;">lv_fs_res_t (*dir_close_cb)(struct _lv_fs_drv_t *drv, void *rddir_p) </span> | ||
+ | :: | ||
+ | : <span style="background-color: #eeeeee;">void *user_data </span> | ||
+ | :: Custom file user data | ||
+ | |||
+ | <span style="background-color:#e7f2fa;color:#2980b9;">struct lv_fs_file_cache_t </span> | ||
+ | : '''Public Members''' | ||
+ | : <span style="background-color: #eeeeee;">uint32_t start </span> | ||
+ | :: | ||
+ | : <span style="background-color: #eeeeee;">uint32_t end </span> | ||
+ | :: | ||
+ | : <span style="background-color: #eeeeee;">uint32_t file_position </span> | ||
+ | :: | ||
+ | : <span style="background-color: #eeeeee;">void *buffer </span> | ||
+ | :: | ||
+ | |||
+ | <span style="background-color:#e7f2fa;color:#2980b9;">struct lv_fs_file_t </span> | ||
+ | : '''Public Members''' | ||
+ | : <span style="background-color: #eeeeee;">void *file_d </span> | ||
+ | :: | ||
+ | : <span style="background-color: #eeeeee;">lv_fs_drv_t *drv </span> | ||
+ | :: | ||
+ | : <span style="background-color: #eeeeee;">lv_fs_file_cache_t *cache </span> | ||
+ | :: | ||
+ | |||
+ | <span style="background-color:#e7f2fa;color:#2980b9;">struct lv_fs_dir_t </span> | ||
+ | : '''Public Members''' | ||
+ | : <span style="background-color: #eeeeee;">void *dir_d </span> | ||
+ | :: | ||
+ | : <span style="background-color: #eeeeee;">lv_fs_drv_t *drv</span> | ||
+ | |'''Functions''' | ||
+ | |||
+ | <span style="background-color:#e7f2fa;color:#2980b9;">void _lv_fs_init(void) </span> | ||
+ | : ファイル・システム・インタフェースの初期化 | ||
+ | |||
+ | <span style="background-color:#e7f2fa;color:#2980b9;">void lv_fs_drv_init(lv_fs_drv_t *drv) </span> | ||
+ | : ファイルシステムドライバーを既定値で初期化します。 これは、メモリのジャンクではなく、フィールドの既知の値を持つために使用されます。 その後、フィールドを設定できます。 | ||
+ | : | ||
+ | :'''Parameters''' | ||
+ | ::'''drv''' -- 初期化するドライバ変数へのポインタ | ||
+ | |||
+ | <span style="background-color:#e7f2fa;color:#2980b9;">void lv_fs_drv_register(lv_fs_drv_t *drv) </span> | ||
+ | : 新しいドライブを追加する | ||
+ | :'''Parameters''' | ||
+ | ::'''drv''' -- lv_fs_drv_t構造体へのポインタで、対応する関数ポインタで初期化される。 ポインターのみが保存されるため、ドライバーは静的または動的に割り当てられる必要があります。 | ||
+ | |||
+ | <span style="background-color:#e7f2fa;color:#2980b9;">lv_fs_drv_t *lv_fs_get_drv(char letter) </span> | ||
+ | : 文字からドライバーへのポインターを指定します。 | ||
+ | :'''Parameters''' | ||
+ | ::'''letter''' -- 運転手の手紙 | ||
+ | :'''Returns''' | ||
+ | :: ドライバへのポインタ、見つからない場合はNULL | ||
+ | |||
+ | <span style="background-color:#e7f2fa;color:#2980b9;">bool lv_fs_is_ready(char letter) </span> | ||
+ | : ドライブの準備ができているかどうかをテストします。<code style="color: #bb0000;">ready</code> 関数が初期化されていない場合は、 <code style="color: #bb0000;">true</code> が返されます。 | ||
+ | :'''Parameters''' | ||
+ | ::'''letter''' -- ドライブの文字 | ||
+ | :'''Returns''' | ||
+ | ::'''true''':ドライブの準備ができました;false:ドライブの準備ができていません | ||
+ | |||
+ | <span style="background-color:#e7f2fa;color:#2980b9;">lv_fs_res_t lv_fs_open(lv_fs_file_t *file_p, const char *path, lv_fs_mode_t mode) </span> | ||
+ | : ファイルを開く | ||
+ | :'''Parameters''' | ||
+ | ::*'''file_p''' -- lv_fs_file_t変数へのポインタ | ||
+ | |||
+ | ::*'''path''' -- ドライバー文字で始まるファイルへのパス (例: S:/folder/file.txt) | ||
+ | ::*'''mode''' -- read: FS_MODE_RD, write: FS_MODE_WR, both: FS_MODE_RD | FS_MODE_WR | ||
+ | :'''Returns''' | ||
+ | :: LV_FS_RES_OKまたはlv_fs_res_tenumからのエラー | ||
+ | |||
+ | <span style="background-color:#e7f2fa;color:#2980b9;">lv_fs_res_t lv_fs_close(lv_fs_file_t *file_p) </span> | ||
+ | : 既に開いているファイルを閉じる | ||
+ | :'''Parameters''' | ||
+ | ::'''file_p''' -- lv_fs_file_t変数へのポインタ | ||
+ | :'''Returns''' | ||
+ | :: LV_FS_RES_OK または lv_fs_res_t enumからのエラー | ||
+ | |||
+ | <span style="background-color:#e7f2fa;color:#2980b9;">lv_fs_res_t lv_fs_read(lv_fs_file_t *file_p, void *buf, uint32_t btr, uint32_t *br) </span> | ||
+ | : ファイルから読み取る | ||
+ | :'''Parameters''' | ||
+ | ::*'''file_p''' -- lv_fs_file_t変数へのポインタ | ||
+ | ::*'''buf''' -- 読み込んだバイトを格納するバッファへのポインタ | ||
+ | ::*'''btr''' -- 読み取るバイト数 | ||
+ | ::*'''br''' -- 実際の読み取りバイト数(Bytes Read)。 未使用の場合はNULL。 | ||
+ | :'''Returns''' | ||
+ | :: LV_FS_RES_OKまたはlv_fs_res_tenumからのエラー | ||
+ | |||
+ | <span style="background-color:#e7f2fa;color:#2980b9;">lv_fs_res_t lv_fs_write(lv_fs_file_t *file_p, const void *buf, uint32_t btw, uint32_t *bw) </span> | ||
+ | : ファイルに書き込む | ||
+ | :'''Parameters''' | ||
+ | ::*'''file_p''' -- lv_fs_file_t変数へのポインター | ||
+ | ::*'''buf''' -- 書き込むバイトを含むバッファへのポインタ | ||
+ | ::* '''btr''' -- 書き込むバイト数 | ||
+ | ::*'''br''' -- 実際に書き込まれたバイト数(書き込まれたバイト数)。 未使用の場合はNULL。 | ||
+ | :'''Returns''' | ||
+ | :: LV_FS_RES_OKまたはlv_fs_res_tenumからのエラー | ||
+ | |||
+ | <span style="background-color:#e7f2fa;color:#2980b9;">lv_fs_res_t lv_fs_seek(lv_fs_file_t *file_p, uint32_t pos, lv_fs_whence_t whence) </span> | ||
+ | : ファイル内の「カーソル」(読み取り/書き込みポインター)の位置を設定します | ||
+ | :'''Parameters''' | ||
+ | ::*'''file_p''' -- lv_fs_file_t変数へのポインター | ||
+ | ::*'''pos''' --バイトインデックスで表される新しい位置(0:ファイルの先頭) | ||
+ | ::*'''whence''' -- 位置を設定した場所を示します。 @lv_fs_whence_tを参照してください | ||
+ | :'''Returns''' | ||
+ | :: LV_FS_RES_OKまたはlv_fs_res_tenumからのエラー | ||
+ | |||
+ | <span style="background-color:#e7f2fa;color:#2980b9;">lv_fs_res_t lv_fs_tell(lv_fs_file_t *file_p, uint32_t *pos) </span> | ||
+ | : 読み取り/書き込みポインタの位置を指定します | ||
+ | :'''Parameters''' | ||
+ | ::*'''file_p''' -- lv_fs_file_t変数へのポインター | ||
+ | ::*'''pos_p''' -- 読み取り/書き込みポインタの位置を格納するポインタ | ||
+ | :'''Returns''' | ||
+ | :: LV_FS_RES_OKまたは「fs_res_t」からのエラー | ||
+ | |||
+ | <span style="background-color:#e7f2fa;color:#2980b9;">lv_fs_res_t lv_fs_dir_open(lv_fs_dir_t *rddir_p, const char *path) </span> | ||
+ | : ディレクトリ読み取り用に「fs_dir_t」変数を初期化します | ||
+ | :'''Parameters''' | ||
+ | ::*'''rddir_p''' -- 'lv_fs_dir_t'変数へのポインター | ||
+ | ::*'''path''' -- ディレクトリへのパス | ||
+ | :'''Returns''' | ||
+ | :: LV_FS_RES_OKまたはlv_fs_res_tenumからのエラー | ||
+ | |||
+ | <span style="background-color:#e7f2fa;color:#2980b9;">lv_fs_res_t lv_fs_dir_read(lv_fs_dir_t *rddir_p, char *fn) </span> | ||
+ | : ディレクトリから次のファイル名を読み取ります。 ディレクトリの名前は「/」で始まります | ||
+ | :'''Parameters''' | ||
+ | ::*'''rddir_p''' -- 初期化された'fs_dir_t'変数へのポインタ | ||
+ | ::*'''fn''' -- ファイル名を格納するためのバッファへのポインタ | ||
+ | :'''Returns''' | ||
+ | :: LV_FS_RES_OKまたはlv_fs_res_tenumからのエラー | ||
+ | |||
+ | <span style="background-color:#e7f2fa;color:#2980b9;">lv_fs_res_t lv_fs_dir_close(lv_fs_dir_t *rddir_p) </span> | ||
+ | : ディレクトリの読み取りを閉じる | ||
+ | :'''Parameters''' | ||
+ | ::'''rddir_p''' -- 初期化された'fs_dir_t'変数へのポインタ | ||
+ | :'''Returns''' | ||
+ | :: LV_FS_RES_OKまたはlv_fs_res_tenumからのエラー | ||
+ | |||
+ | <span style="background-color:#e7f2fa;color:#2980b9;">char *lv_fs_get_letters(char *buf) </span> | ||
+ | : 既存のドライバーの文字でバッファーを埋めます | ||
+ | :'''Parameters''' | ||
+ | ::'''buf''' -- 文字を格納するためのバッファ(最後の文字の後に「\ 0」が追加されます) | ||
+ | :'''Returns''' | ||
+ | :: バッファ | ||
+ | |||
+ | <span style="background-color:#e7f2fa;color:#2980b9;">const char *lv_fs_get_ext(const char *fn) </span> | ||
+ | : ファイル名の拡張子を付けて返す | ||
+ | :'''Parameters''' | ||
+ | ::'''fn''' -- ファイル名のある文字列 | ||
+ | :'''Returns''' | ||
+ | :: 開始拡張子へのポインタ、または拡張子がない場合は空の文字列 | ||
+ | |||
+ | <span style="background-color:#e7f2fa;color:#2980b9;">char *lv_fs_up(char *path) </span> | ||
+ | : 1レベルステップアップ | ||
+ | :'''Parameters''' | ||
+ | ::'''path''' -- ファイル名へのポインタ | ||
+ | :'''Returns''' | ||
+ | :: 切り捨てられたファイル名 | ||
+ | |||
+ | <span style="background-color:#e7f2fa;color:#2980b9;">const char *lv_fs_get_last(const char *path) </span> | ||
+ | : パスの最後の要素を取得します(例: U:/folder/file -> file) | ||
+ | :'''Parameters''' | ||
+ | ::'''path''' -- ファイル名へのポインタ | ||
+ | :'''Returns''' | ||
+ | :: パスの最後の要素の先頭へのポインタ | ||
+ | |||
+ | <span style="background-color:#e7f2fa;color:#2980b9;">struct _lv_fs_drv_t </span> | ||
+ | :'''Public Members''' | ||
+ | :<span style="background-color: #eeeeee;">char letter </span> | ||
+ | :: | ||
+ | :<span style="background-color: #eeeeee;">uint16_t cache_size </span> | ||
+ | :: | ||
+ | :<span style="background-color: #eeeeee;">bool (*ready_cb)(struct _lv_fs_drv_t *drv) </span> | ||
+ | :: | ||
+ | :<span style="background-color: #eeeeee;">void *(*open_cb)(struct _lv_fs_drv_t *drv, const char *path, lv_fs_mode_t mode) </span> | ||
+ | :: | ||
+ | :<span style="background-color: #eeeeee;">lv_fs_res_t (*close_cb)(struct _lv_fs_drv_t *drv, void *file_p) </span> | ||
+ | :: | ||
+ | :<span style="background-color: #eeeeee;">lv_fs_res_t (*read_cb)(struct _lv_fs_drv_t *drv, void *file_p, void *buf, uint32_t btr, uint32_t *br) </span> | ||
+ | :: | ||
+ | :<span style="background-color: #eeeeee;">lv_fs_res_t (*write_cb)(struct _lv_fs_drv_t *drv, void *file_p, const void *buf, uint32_t btw, uint32_t *bw) </span> | ||
+ | :: | ||
+ | :<span style="background-color: #eeeeee;">lv_fs_res_t (*seek_cb)(struct _lv_fs_drv_t *drv, void *file_p, uint32_t pos, lv_fs_whence_t whence) </span> | ||
+ | :: | ||
+ | :<span style="background-color: #eeeeee;">lv_fs_res_t (*tell_cb)(struct _lv_fs_drv_t *drv, void *file_p, uint32_t *pos_p) </span> | ||
+ | :: | ||
+ | : | ||
+ | :<span style="background-color: #eeeeee;">void *(*dir_open_cb)(struct _lv_fs_drv_t *drv, const char *path) </span> | ||
+ | :: | ||
+ | :<span style="background-color: #eeeeee;">lv_fs_res_t (*dir_read_cb)(struct _lv_fs_drv_t *drv, void *rddir_p, char *fn) </span> | ||
+ | :: | ||
+ | :<span style="background-color: #eeeeee;">lv_fs_res_t (*dir_close_cb)(struct _lv_fs_drv_t *drv, void *rddir_p) </span> | ||
+ | :: | ||
+ | :<span style="background-color: #eeeeee;">void *user_data </span> | ||
+ | :: カスタムファイルのユーザーデータ | ||
+ | |||
+ | <span style="background-color:#e7f2fa;color:#2980b9;">struct lv_fs_file_cache_t </span> | ||
+ | :'''Public Members''' | ||
+ | :<span style="background-color: #eeeeee;">uint32_t start </span> | ||
+ | :: | ||
+ | :<span style="background-color: #eeeeee;">uint32_t end </span> | ||
+ | :: | ||
+ | :<span style="background-color: #eeeeee;">uint32_t file_position </span> | ||
+ | :: | ||
+ | :<span style="background-color: #eeeeee;">void *buffer </span> | ||
+ | :: | ||
+ | |||
+ | <span style="background-color:#e7f2fa;color:#2980b9;">struct lv_fs_file_t </span> | ||
+ | :'''Public Members''' | ||
+ | :<span style="background-color: #eeeeee;">void *file_d </span> | ||
+ | :: | ||
+ | :<span style="background-color: #eeeeee;">lv_fs_drv_t *drv </span> | ||
+ | :: | ||
+ | :<span style="background-color: #eeeeee;">lv_fs_file_cache_t *cache </span> | ||
+ | :: | ||
+ | |||
+ | <span style="background-color:#e7f2fa;color:#2980b9;">struct lv_fs_dir_t </span> | ||
+ | :'''Public Members''' | ||
+ | :<span style="background-color: #eeeeee;">void *dir_d </span> | ||
+ | :: | ||
+ | :<span style="background-color: #eeeeee;">lv_fs_drv_t *drv</span> | ||
+ | |} | ||
− | + | [[App:Library:LVGL#Overview|戻る : Previous]] |
2022年7月2日 (土) 10:53時点における最新版
https://docs.lvgl.io/8.2/overview/file-system.html
File system
英文 | 自動翻訳 |
---|---|
LVGL has a 'File system' abstraction module that enables you to attach any type of file system. A file system is identified by an assigned drive letter. For example, if an SD card is associated with the letter |
LVGLには'File system'抽象化モジュールがあり、任意の種類のファイルシステムをアタッチすることができます。
ファイルシステムは、ドライブレターで識別されます。 例えば、SDカードに |
Ready to use drivers
英文 | 自動翻訳 |
---|---|
The lv_fs_if repository contains prepared drivers using POSIX, standard C and the FATFS API. See its README for the details. |
lv_fs_ifリポジトリには、POSIX、標準C、FATFS APIを使用したドライバが用意されています。
詳しくはREADMEをご覧ください。 |
Adding a driver
Registering a driver
英文 | 自動翻訳 |
---|---|
To add a driver, a The static lv_fs_drv_t drv; /*Needs to be static or global*/
lv_fs_drv_init(&drv); /*Basic initialization*/
drv.letter = 'S'; /*An uppercase letter to identify the drive */
drv.cache_size = my_cahce_size; /*Cache size for reading in bytes. 0 to not cache.*/
drv.ready_cb = my_ready_cb; /*Callback to tell if the drive is ready to use */
drv.open_cb = my_open_cb; /*Callback to open a file */
drv.close_cb = my_close_cb; /*Callback to close a file */
drv.read_cb = my_read_cb; /*Callback to read a file */
drv.write_cb = my_write_cb; /*Callback to write a file */
drv.seek_cb = my_seek_cb; /*Callback to seek in a file (Move cursor) */
drv.tell_cb = my_tell_cb; /*Callback to tell the cursor position */
drv.dir_open_cb = my_dir_open_cb; /*Callback to open directory to read its content */
drv.dir_read_cb = my_dir_read_cb; /*Callback to read a directory's content */
drv.dir_close_cb = my_dir_close_cb; /*Callback to close a directory */
drv.user_data = my_user_data; /*Any custom data if required*/
lv_fs_drv_register(&drv); /*Finally register the drive*/
Any of the callbacks can be |
ドライバを追加するには、以下のようにlv_fs_drv_t を初期化する必要があります。
lv_fs_drv_t は、ローカル変数ではなく、スタティック、グローバル、またはダイナミックにアロケートされたものである必要があります。 static lv_fs_drv_t drv; /*Needs to be static or global*/
lv_fs_drv_init(&drv); /*Basic initialization*/
drv.letter = 'S'; /*An uppercase letter to identify the drive */
drv.cache_size = my_cahce_size; /*Cache size for reading in bytes. 0 to not cache.*/
drv.ready_cb = my_ready_cb; /*Callback to tell if the drive is ready to use */
drv.open_cb = my_open_cb; /*Callback to open a file */
drv.close_cb = my_close_cb; /*Callback to close a file */
drv.read_cb = my_read_cb; /*Callback to read a file */
drv.write_cb = my_write_cb; /*Callback to write a file */
drv.seek_cb = my_seek_cb; /*Callback to seek in a file (Move cursor) */
drv.tell_cb = my_tell_cb; /*Callback to tell the cursor position */
drv.dir_open_cb = my_dir_open_cb; /*Callback to open directory to read its content */
drv.dir_read_cb = my_dir_read_cb; /*Callback to read a directory's content */
drv.dir_close_cb = my_dir_close_cb; /*Callback to close a directory */
drv.user_data = my_user_data; /*Any custom data if required*/
lv_fs_drv_register(&drv); /*Finally register the drive*/
コールバックのいずれかを |
Implementing the callbacks
Open callback
英文 | 自動翻訳 |
---|---|
The prototype of void * (*open_cb)(lv_fs_drv_t * drv, const char * path, lv_fs_mode_t mode);
The return value is a pointer to a file object that describes the opened file or The returned file object will be passed to other file system related callbacks. (see below) |
open_cb のプロトタイプは以下のようなものです。
void * (*open_cb)(lv_fs_drv_t * drv, const char * path, lv_fs_mode_t mode);
戻り値は、オープンしたファイルを記述したファイルオブジェクトへのポインタ、または何らかの問題(ファイルが見つからなかったなど)があった場合は 返されたファイルオブジェクトは、他のファイルシステム関連のコールバック関数に渡されます。(下記参照) |
Other callbacks
英文 | 自動翻訳 |
---|---|
The other callbacks are quite similar. For example looks like this: lv_fs_res_t (*write_cb)(lv_fs_drv_t * drv, void * file_p, const void * buf, uint32_t btw, uint32_t * bw);
For
For a template of these callbacks see lv_fs_template.c. |
他のコールバックは非常によく似ています。
例えばwrite_cb は以下のような感じです。 lv_fs_res_t (*write_cb)(lv_fs_drv_t * drv, void * file_p, const void * buf, uint32_t btw, uint32_t * bw);
これらのコールバックのテンプレートは,lv_fs_template.cを参照してください. |
Usage example
英文 | 自動翻訳 |
---|---|
The example below shows how to read from a file: lv_fs_file_t f;
lv_fs_res_t res;
res = lv_fs_open(&f, "S:folder/file.txt", LV_FS_MODE_RD);
if(res != LV_FS_RES_OK) my_error_handling();
uint32_t read_num;
uint8_t buf[8];
res = lv_fs_read(&f, buf, 8, &read_num);
if(res != LV_FS_RES_OK || read_num != 8) my_error_handling();
lv_fs_close(&f);
The mode in This example shows how to read a directory's content. It's up to the driver how to mark directories in the result but it can be a good practice to insert a lv_fs_dir_t dir;
lv_fs_res_t res;
res = lv_fs_dir_open(&dir, "S:/folder");
if(res != LV_FS_RES_OK) my_error_handling();
char fn[256];
while(1) {
res = lv_fs_dir_read(&dir, fn);
if(res != LV_FS_RES_OK) {
my_error_handling();
break;
}
/*fn is empty, if not more files to read*/
if(strlen(fn) == 0) {
break;
}
printf("%s\n", fn);
}
lv_fs_dir_close(&dir);
|
以下の例では、ファイルから読み取る方法を示しています。
lv_fs_file_t f;
lv_fs_res_t res;
res = lv_fs_open(&f, "S:folder/file.txt", LV_FS_MODE_RD);
if(res != LV_FS_RES_OK) my_error_handling();
uint32_t read_num;
uint8_t buf[8];
res = lv_fs_read(&f, buf, 8, &read_num);
if(res != LV_FS_RES_OK || read_num != 8) my_error_handling();
lv_fs_close(&f);
この例は、ディレクトリの内容を読み取る方法を示しています。 結果の中でディレクトリをどのようにマークするかはドライバ次第ですが、各ディレクトリ名の前に'/' を挿入するのは良い習慣と言えるでしょう。 lv_fs_dir_t dir;
lv_fs_res_t res;
res = lv_fs_dir_open(&dir, "S:/folder");
if(res != LV_FS_RES_OK) my_error_handling();
char fn[256];
while(1) {
res = lv_fs_dir_read(&dir, fn);
if(res != LV_FS_RES_OK) {
my_error_handling();
break;
}
/*fn is empty, if not more files to read*/
if(strlen(fn) == 0) {
break;
}
printf("%s\n", fn);
}
lv_fs_dir_close(&dir);
|
Use drives for images
英文 | 自動翻訳 |
---|---|
Image objects can be opened from files too (besides variables stored in the compiled program).
|
画像オブジェクトはファイルからも開くことができます(コンパイルされたプログラムに格納されている変数を除く)。
|
API
英文 | 自動翻訳 |
---|---|
Typedefs typedef uint8_t lv_fs_res_t typedef uint8_t lv_fs_mode_t typedef struct _lv_fs_drv_t lv_fs_drv_t Enums enum [anonymous]
enum [anonymous]
enum lv_fs_whence_t
|
Typedefs
typedef uint8_t lv_fs_res_t typedef uint8_t lv_fs_mode_t typedef struct _lv_fs_drv_t lv_fs_drv_t Enums enum [anonymous]
enum [anonymous]
enum lv_fs_whence_t
|
Functions void _lv_fs_init(void)
void lv_fs_drv_init(lv_fs_drv_t *drv)
void lv_fs_drv_register(lv_fs_drv_t *drv)
lv_fs_drv_t *lv_fs_get_drv(char letter)
bool lv_fs_is_ready(char letter)
lv_fs_res_t lv_fs_open(lv_fs_file_t *file_p, const char *path, lv_fs_mode_t mode)
lv_fs_res_t lv_fs_close(lv_fs_file_t *file_p)
lv_fs_res_t lv_fs_read(lv_fs_file_t *file_p, void *buf, uint32_t btr, uint32_t *br)
lv_fs_res_t lv_fs_write(lv_fs_file_t *file_p, const void *buf, uint32_t btw, uint32_t *bw)
lv_fs_res_t lv_fs_seek(lv_fs_file_t *file_p, uint32_t pos, lv_fs_whence_t whence)
lv_fs_res_t lv_fs_tell(lv_fs_file_t *file_p, uint32_t *pos)
lv_fs_res_t lv_fs_dir_open(lv_fs_dir_t *rddir_p, const char *path)
lv_fs_res_t lv_fs_dir_read(lv_fs_dir_t *rddir_p, char *fn)
lv_fs_res_t lv_fs_dir_close(lv_fs_dir_t *rddir_p)
char *lv_fs_get_letters(char *buf)
const char *lv_fs_get_ext(const char *fn)
char *lv_fs_up(char *path)
const char *lv_fs_get_last(const char *path)
struct _lv_fs_drv_t
struct lv_fs_file_cache_t
struct lv_fs_file_t
struct lv_fs_dir_t
|
Functions
void _lv_fs_init(void)
void lv_fs_drv_init(lv_fs_drv_t *drv)
void lv_fs_drv_register(lv_fs_drv_t *drv)
lv_fs_drv_t *lv_fs_get_drv(char letter)
bool lv_fs_is_ready(char letter)
lv_fs_res_t lv_fs_open(lv_fs_file_t *file_p, const char *path, lv_fs_mode_t mode)
lv_fs_res_t lv_fs_close(lv_fs_file_t *file_p)
lv_fs_res_t lv_fs_read(lv_fs_file_t *file_p, void *buf, uint32_t btr, uint32_t *br)
lv_fs_res_t lv_fs_write(lv_fs_file_t *file_p, const void *buf, uint32_t btw, uint32_t *bw)
lv_fs_res_t lv_fs_seek(lv_fs_file_t *file_p, uint32_t pos, lv_fs_whence_t whence)
lv_fs_res_t lv_fs_tell(lv_fs_file_t *file_p, uint32_t *pos)
lv_fs_res_t lv_fs_dir_open(lv_fs_dir_t *rddir_p, const char *path)
lv_fs_res_t lv_fs_dir_read(lv_fs_dir_t *rddir_p, char *fn)
lv_fs_res_t lv_fs_dir_close(lv_fs_dir_t *rddir_p)
char *lv_fs_get_letters(char *buf)
const char *lv_fs_get_ext(const char *fn)
char *lv_fs_up(char *path)
const char *lv_fs_get_last(const char *path)
struct _lv_fs_drv_t
struct lv_fs_file_cache_t
struct lv_fs_file_t
struct lv_fs_dir_t
|