{"id":15102316,"url":"https://github.com/microsoft/pxt-filesystem","last_synced_at":"2025-09-27T00:31:19.349Z","repository":{"id":65976066,"uuid":"72689845","full_name":"microsoft/pxt-filesystem","owner":"microsoft","description":"File system - beta","archived":true,"fork":false,"pushed_at":"2020-05-07T20:50:23.000Z","size":73,"stargazers_count":28,"open_issues_count":11,"forks_count":18,"subscribers_count":13,"default_branch":"master","last_synced_at":"2024-09-21T07:04:11.865Z","etag":null,"topics":["makefile","microbit"],"latest_commit_sha":null,"homepage":"https://pxt.microbit.org/pkg/microsoft/pxt-filesystem","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/microsoft.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-11-02T23:21:39.000Z","updated_at":"2023-11-16T18:00:12.000Z","dependencies_parsed_at":"2023-02-19T18:55:20.503Z","dependency_job_id":null,"html_url":"https://github.com/microsoft/pxt-filesystem","commit_stats":null,"previous_names":[],"tags_count":27,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microsoft%2Fpxt-filesystem","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microsoft%2Fpxt-filesystem/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microsoft%2Fpxt-filesystem/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microsoft%2Fpxt-filesystem/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/microsoft","download_url":"https://codeload.github.com/microsoft/pxt-filesystem/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219871828,"owners_count":16554457,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["makefile","microbit"],"created_at":"2024-09-25T19:00:38.840Z","updated_at":"2025-09-27T00:31:14.073Z","avatar_url":"https://github.com/microsoft.png","language":"TypeScript","readme":"# File system driver [![Build Status](https://travis-ci.org/Microsoft/pxt-filesystem.svg?branch=master)](https://travis-ci.org/Microsoft/pxt-filesystem)\n\nTo use this package, go to https://makecode.microbit.org, click ``Extensions`` and search for **filesystem**.\n\n### ~ hint\n\nDEPRECATED - This package is no longer maintained or supported.\n\n### ~\n\n## Usage\n\nThe package allows to read and write files to the @boardname@ flash.\n\n### ~hint\n\nThe entire file system content is ERASED when a new .hex file is download onto the @boardname@.\n\n### ~\n\n### Writing data\n\n* append text and a new line character\n\n```blocks\nfiles.appendLine(\"data.txt\", \"Hello\");\n```\n\n* append text to the file\n\n```blocks\nfiles.appendString(\"data.txt\", \"Hello\");\n```\n\n* append a number (as text) to the file\n\n```blocks\nfiles.appendNumber(\"data.txt\", 42);\n```\n\n### Reading data\n\n* send the content of a file to serial\n\n```blocks\nfiles.readToSerial(\"data.txt\");\n```\n\n### Settings\n\nThe package allows to save and load number settings based on the file system\n\n* save setting value\n\n```blocks\nfiles.settingsSaveNumber(\"calibrated\", 1)\n```\n\n* read setting value\n\n```blocks\nlet calibrated = files.settingsReadNumber(\"calibrated\");\n```\n\n### File class\n\nThe ``File`` class allows to keep a file instance open, manipulate the pointer position and read from the file.\n\n\n* open, flush or close the file\n\n```blocks\nlet f = files.open(\"data.txt\");\nf.flush();\nf.close();\n```\n\n* write strings or buffers\n```blocks\nlet f = files.open(\"data.txt\");\nf.writeString(\"yay\");\n```\n\n* read data\n```blocks\nlet f = files.open(\"data.txt\");\nlet buf = f.readBuffer(64);\nlet c = f.read();\n```\n\n* set the cursor position\n\n```blocks\nlet f = files.open(\"data.txt\");\nf.setPosition(42);\nlet pos = f.position();\n```\n\n## Example: Writing accelerometer data\n\nThe following program allows to collect accelerometer data and save it in a ``data.csv`` file. \nWhen the user presses button ``A``, the @boardname@ pauses for 3 seconds, then starts collecting 720 acceleration samples.\nEach sample is written to the file in a format that can be important by spreadsheet programs (CSV).\n\n```blocks\nlet file = \"data.csv\";\ninput.onButtonPressed(Button.A, () =\u003e {    \n    basic.pause(3000);\n    files.remove(file);\n    files.appendLine(file, \"Time\\tAcceleration\");\n    for (let i = 0; i \u003c 100; ++i) {\n        let t = input.runningTime();\n        let ay = input.acceleration(Dimension.Y);\n        files.appendLine(file, t + \"\\t\" + ay);\n        control.waitMicros(20);\n    }\n});\ninput.onButtonPressed(Button.B, () =\u003e {\n    files.readToSerial(file);\n    basic.showString(\":)\")\n})\n```\n\n## Supported targets\n\n* for PXT/ microbit\n* for PXT/ calliope\n\n## License\n\nMIT\n\n## Code of Conduct\n\nThis project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmicrosoft%2Fpxt-filesystem","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmicrosoft%2Fpxt-filesystem","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmicrosoft%2Fpxt-filesystem/lists"}