Did os, _pixelbuf, _pew
This commit is contained in:
parent
d750096bef
commit
09530e5dc3
|
@ -34,33 +34,33 @@
|
|||
#include "shared-module/_pew/PewPew.h"
|
||||
#include "supervisor/shared/translate.h"
|
||||
|
||||
|
||||
//| .. currentmodule:: _pew
|
||||
//| class PewPew:
|
||||
//| """.. currentmodule:: _pew
|
||||
//|
|
||||
//| :class:`PewPew` -- LED matrix and button driver
|
||||
//| ===============================================
|
||||
//| :class:`PewPew` -- LED matrix and button driver
|
||||
//| ===============================================
|
||||
//|
|
||||
//| This is an internal module to be used by the ``pew.py`` library from
|
||||
//| https://github.com/pewpew-game/pew-pewpew-standalone-10.x to handle the
|
||||
//| LED matrix display and buttons on the ``pewpew10`` board.
|
||||
//| This is an internal module to be used by the ``pew.py`` library from
|
||||
//| https://github.com/pewpew-game/pew-pewpew-standalone-10.x to handle the
|
||||
//| LED matrix display and buttons on the ``pewpew10`` board.
|
||||
//|
|
||||
//| Usage::
|
||||
//| Usage::
|
||||
//|
|
||||
//| This singleton class is instantiated by the ``pew`` library, and
|
||||
//| used internally by it. All user-visible interactions are done through
|
||||
//| that library.
|
||||
//| This singleton class is instantiated by the ``pew`` library, and
|
||||
//| used internally by it. All user-visible interactions are done through
|
||||
//| that library."""
|
||||
//|
|
||||
|
||||
//| .. class:: PewPew(buffer, rows, cols, buttons)
|
||||
//| def __init__(self, buffer: Any, rows: Any, cols: Any, buttons: Any):
|
||||
//| """Initializes matrix scanning routines.
|
||||
//|
|
||||
//| Initializes matrix scanning routines.
|
||||
//|
|
||||
//| The ``buffer`` is a 64 byte long ``bytearray`` that stores what should
|
||||
//| be displayed on the matrix. ``rows`` and ``cols`` are both lists of
|
||||
//| eight ``DigitalInputOutput`` objects that are connected to the matrix
|
||||
//| rows and columns. ``buttons`` is a ``DigitalInputOutput`` object that
|
||||
//| is connected to the common side of all buttons (the other sides of the
|
||||
//| buttons are connected to rows of the matrix).
|
||||
//| The ``buffer`` is a 64 byte long ``bytearray`` that stores what should
|
||||
//| be displayed on the matrix. ``rows`` and ``cols`` are both lists of
|
||||
//| eight ``DigitalInputOutput`` objects that are connected to the matrix
|
||||
//| rows and columns. ``buttons`` is a ``DigitalInputOutput`` object that
|
||||
//| is connected to the common side of all buttons (the other sides of the
|
||||
//| buttons are connected to rows of the matrix)."""
|
||||
//| ...
|
||||
//|
|
||||
STATIC mp_obj_t pewpew_make_new(const mp_obj_type_t *type, size_t n_args,
|
||||
const mp_obj_t *pos_args, mp_map_t *kw_args) {
|
||||
|
|
|
@ -41,7 +41,7 @@ STATIC mp_obj_t get_pressed(void) {
|
|||
STATIC MP_DEFINE_CONST_FUN_OBJ_0(get_pressed_obj, get_pressed);
|
||||
|
||||
|
||||
//| :mod:`_pew` --- LED matrix driver
|
||||
//| """:mod:`_pew` --- LED matrix driver
|
||||
//| ==================================
|
||||
//|
|
||||
//| .. module:: _pew
|
||||
|
@ -51,7 +51,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_0(get_pressed_obj, get_pressed);
|
|||
//| .. toctree::
|
||||
//| :maxdepth: 3
|
||||
//|
|
||||
//| PewPew
|
||||
//| PewPew"""
|
||||
//|
|
||||
STATIC const mp_rom_map_elem_t pew_module_globals_table[] = {
|
||||
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR__pew) },
|
||||
|
|
|
@ -44,31 +44,32 @@ extern const int32_t colorwheel(float pos);
|
|||
|
||||
static void parse_byteorder(mp_obj_t byteorder_obj, pixelbuf_byteorder_details_t* parsed);
|
||||
|
||||
//| .. currentmodule:: pixelbuf
|
||||
//| class PixelBuf:
|
||||
//| """.. currentmodule:: pixelbuf
|
||||
//|
|
||||
//| :class:`PixelBuf` -- A fast RGB[W] pixel buffer for LED and similar devices
|
||||
//| ===========================================================================
|
||||
//| :class:`PixelBuf` -- A fast RGB[W] pixel buffer for LED and similar devices
|
||||
//| ===========================================================================
|
||||
//|
|
||||
//| :class:`~_pixelbuf.PixelBuf` implements an RGB[W] bytearray abstraction.
|
||||
//| :class:`~_pixelbuf.PixelBuf` implements an RGB[W] bytearray abstraction."""
|
||||
//|
|
||||
//| .. class:: PixelBuf(size, *, byteorder="BGR", brightness=0, auto_write=False, header=b"", trailer=b"")
|
||||
//| def __init__(self, size: int, *, byteorder: str = "BGR", brightness: float = 0, auto_write: bool = False, header: bytes = b"", trailer: bytes = b""):
|
||||
//| """Create a PixelBuf object of the specified size, byteorder, and bits per pixel.
|
||||
//|
|
||||
//| Create a PixelBuf object of the specified size, byteorder, and bits per pixel.
|
||||
//| When brightness is less than 1.0, a second buffer will be used to store the color values
|
||||
//| before they are adjusted for brightness.
|
||||
//|
|
||||
//| When brightness is less than 1.0, a second buffer will be used to store the color values
|
||||
//| before they are adjusted for brightness.
|
||||
//| When ``P`` (pwm duration) is present as the 4th character of the byteorder
|
||||
//| string, the 4th value in the tuple/list for a pixel is the individual pixel
|
||||
//| brightness (0.0-1.0) and will enable a Dotstar compatible 1st byte in the
|
||||
//| output buffer (``buf``).
|
||||
//|
|
||||
//| When ``P`` (pwm duration) is present as the 4th character of the byteorder
|
||||
//| string, the 4th value in the tuple/list for a pixel is the individual pixel
|
||||
//| brightness (0.0-1.0) and will enable a Dotstar compatible 1st byte in the
|
||||
//| output buffer (``buf``).
|
||||
//|
|
||||
//| :param ~int size: Number of pixelsx
|
||||
//| :param ~str byteorder: Byte order string (such as "BGR" or "PBGR")
|
||||
//| :param ~float brightness: Brightness (0 to 1.0, default 1.0)
|
||||
//| :param ~bool auto_write: Whether to automatically write pixels (Default False)
|
||||
//| :param bytes header: Sequence of bytes to always send before pixel values.
|
||||
//| :param bytes trailer: Sequence of bytes to always send after pixel values.
|
||||
//| :param ~int size: Number of pixelsx
|
||||
//| :param ~str byteorder: Byte order string (such as "BGR" or "PBGR")
|
||||
//| :param ~float brightness: Brightness (0 to 1.0, default 1.0)
|
||||
//| :param ~bool auto_write: Whether to automatically write pixels (Default False)
|
||||
//| :param bytes header: Sequence of bytes to always send before pixel values.
|
||||
//| :param bytes trailer: Sequence of bytes to always send after pixel values."""
|
||||
//| ...
|
||||
//|
|
||||
STATIC mp_obj_t pixelbuf_pixelbuf_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
|
||||
mp_arg_check_num(n_args, kw_args, 1, MP_OBJ_FUN_ARGS_MAX, true);
|
||||
|
@ -156,9 +157,8 @@ static void parse_byteorder(mp_obj_t byteorder_obj, pixelbuf_byteorder_details_t
|
|||
}
|
||||
}
|
||||
|
||||
//| .. attribute:: bpp
|
||||
//|
|
||||
//| The number of bytes per pixel in the buffer (read-only)
|
||||
//| bpp: Any = ...
|
||||
//| """The number of bytes per pixel in the buffer (read-only)"""
|
||||
//|
|
||||
STATIC mp_obj_t pixelbuf_pixelbuf_obj_get_bpp(mp_obj_t self_in) {
|
||||
return MP_OBJ_NEW_SMALL_INT(common_hal__pixelbuf_pixelbuf_get_bpp(self_in));
|
||||
|
@ -173,12 +173,11 @@ const mp_obj_property_t pixelbuf_pixelbuf_bpp_obj = {
|
|||
};
|
||||
|
||||
|
||||
//| .. attribute:: brightness
|
||||
//|
|
||||
//| Float value between 0 and 1. Output brightness.
|
||||
//| brightness: Any = ...
|
||||
//| """Float value between 0 and 1. Output brightness.
|
||||
//|
|
||||
//| When brightness is less than 1.0, a second buffer will be used to store the color values
|
||||
//| before they are adjusted for brightness.
|
||||
//| before they are adjusted for brightness."""
|
||||
//|
|
||||
STATIC mp_obj_t pixelbuf_pixelbuf_obj_get_brightness(mp_obj_t self_in) {
|
||||
return mp_obj_new_float(common_hal__pixelbuf_pixelbuf_get_brightness(self_in));
|
||||
|
@ -205,9 +204,8 @@ const mp_obj_property_t pixelbuf_pixelbuf_brightness_obj = {
|
|||
(mp_obj_t)&mp_const_none_obj},
|
||||
};
|
||||
|
||||
//| .. attribute:: auto_write
|
||||
//|
|
||||
//| Whether to automatically write the pixels after each update.
|
||||
//| auto_write: Any = ...
|
||||
//| """Whether to automatically write the pixels after each update."""
|
||||
//|
|
||||
STATIC mp_obj_t pixelbuf_pixelbuf_obj_get_auto_write(mp_obj_t self_in) {
|
||||
return mp_obj_new_bool(common_hal__pixelbuf_pixelbuf_get_auto_write(self_in));
|
||||
|
@ -228,9 +226,8 @@ const mp_obj_property_t pixelbuf_pixelbuf_auto_write_obj = {
|
|||
(mp_obj_t)&mp_const_none_obj},
|
||||
};
|
||||
|
||||
//| .. attribute:: byteorder
|
||||
//|
|
||||
//| byteorder string for the buffer (read-only)
|
||||
//| byteorder: Any = ...
|
||||
//| """byteorder string for the buffer (read-only)"""
|
||||
//|
|
||||
STATIC mp_obj_t pixelbuf_pixelbuf_obj_get_byteorder(mp_obj_t self_in) {
|
||||
return common_hal__pixelbuf_pixelbuf_get_byteorder_string(self_in);
|
||||
|
@ -253,10 +250,10 @@ STATIC mp_obj_t pixelbuf_pixelbuf_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
|
|||
}
|
||||
}
|
||||
|
||||
//| .. method:: show()
|
||||
//|
|
||||
//| Transmits the color data to the pixels so that they are shown. This is done automatically
|
||||
//| when `auto_write` is True.
|
||||
//| def show(self, ) -> Any:
|
||||
//| """Transmits the color data to the pixels so that they are shown. This is done automatically
|
||||
//| when `auto_write` is True."""
|
||||
//| ...
|
||||
//|
|
||||
|
||||
STATIC mp_obj_t pixelbuf_pixelbuf_show(mp_obj_t self_in) {
|
||||
|
@ -265,9 +262,9 @@ STATIC mp_obj_t pixelbuf_pixelbuf_show(mp_obj_t self_in) {
|
|||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_1(pixelbuf_pixelbuf_show_obj, pixelbuf_pixelbuf_show);
|
||||
|
||||
//| .. function:: fill(color)
|
||||
//|
|
||||
//| Fills the given pixelbuf with the given color.
|
||||
//| def fill(color: Any) -> Any:
|
||||
//| """Fills the given pixelbuf with the given color."""
|
||||
//| ...
|
||||
//|
|
||||
|
||||
STATIC mp_obj_t pixelbuf_pixelbuf_fill(mp_obj_t self_in, mp_obj_t value) {
|
||||
|
@ -277,17 +274,16 @@ STATIC mp_obj_t pixelbuf_pixelbuf_fill(mp_obj_t self_in, mp_obj_t value) {
|
|||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_2(pixelbuf_pixelbuf_fill_obj, pixelbuf_pixelbuf_fill);
|
||||
|
||||
|
||||
//| .. method:: __getitem__(index)
|
||||
//| def __getitem__(self, index: Any) -> Any:
|
||||
//| """Returns the pixel value at the given index as a tuple of (Red, Green, Blue[, White]) values
|
||||
//| between 0 and 255."""
|
||||
//| ...
|
||||
//|
|
||||
//| Returns the pixel value at the given index as a tuple of (Red, Green, Blue[, White]) values
|
||||
//| between 0 and 255.
|
||||
//|
|
||||
//| .. method:: __setitem__(index, value)
|
||||
//|
|
||||
//| Sets the pixel value at the given index. Value can either be a tuple of (Red, Green, Blue
|
||||
//| [, White]) values between 0 and 255 or an integer where the red, green and blue values are
|
||||
//| packed into the lower three bytes (0xRRGGBB).
|
||||
//| def __setitem__(self, index: Any, value: Any) -> Any:
|
||||
//| """Sets the pixel value at the given index. Value can either be a tuple of (Red, Green, Blue
|
||||
//| [, White]) values between 0 and 255 or an integer where the red, green and blue values are
|
||||
//| packed into the lower three bytes (0xRRGGBB)."""
|
||||
//| ...
|
||||
//|
|
||||
STATIC mp_obj_t pixelbuf_pixelbuf_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value) {
|
||||
if (value == MP_OBJ_NULL) {
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
#include "shared-bindings/_pixelbuf/PixelBuf.h"
|
||||
|
||||
|
||||
//| :mod:`_pixelbuf` --- Fast RGB(W) pixel buffer and helpers
|
||||
//| """:mod:`_pixelbuf` --- Fast RGB(W) pixel buffer and helpers
|
||||
//| ===========================================================
|
||||
|
||||
//| .. module:: _pixelbuf
|
||||
|
@ -50,13 +50,13 @@
|
|||
//| .. toctree::
|
||||
//| :maxdepth: 3
|
||||
//|
|
||||
//| PixelBuf
|
||||
|
||||
|
||||
//| .. function:: wheel(n)
|
||||
//| PixelBuf"""
|
||||
//|
|
||||
//| C implementation of the common wheel() function found in many examples.
|
||||
//| Returns the colorwheel RGB value as an integer value for n (usable in :py:class:`PixelBuf`, neopixel, and dotstar).
|
||||
|
||||
//| def wheel(n: Any) -> Any:
|
||||
//| """C implementation of the common wheel() function found in many examples.
|
||||
//| Returns the colorwheel RGB value as an integer value for n (usable in :py:class:`PixelBuf`, neopixel, and dotstar)."""
|
||||
//| ...
|
||||
//|
|
||||
|
||||
STATIC mp_obj_t pixelbuf_wheel(mp_obj_t n) {
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
#include "py/runtime.h"
|
||||
#include "shared-bindings/os/__init__.h"
|
||||
|
||||
//| :mod:`os` --- functions that an OS normally provides
|
||||
//| """:mod:`os` --- functions that an OS normally provides
|
||||
//| ========================================================
|
||||
//|
|
||||
//| .. module:: os
|
||||
|
@ -46,22 +46,22 @@
|
|||
//|
|
||||
//| The `os` module is a strict subset of the CPython `cpython:os` module. So,
|
||||
//| code written in CircuitPython will work in CPython but not necessarily the
|
||||
//| other way around.
|
||||
//| other way around."""
|
||||
//|
|
||||
|
||||
//| .. function:: uname()
|
||||
//|
|
||||
//| Returns a named tuple of operating specific and CircuitPython port
|
||||
//| specific information.
|
||||
//| def uname() -> Any:
|
||||
//| """Returns a named tuple of operating specific and CircuitPython port
|
||||
//| specific information."""
|
||||
//| ...
|
||||
//|
|
||||
STATIC mp_obj_t os_uname(void) {
|
||||
return common_hal_os_uname();
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_0(os_uname_obj, os_uname);
|
||||
|
||||
//| .. function:: chdir(path)
|
||||
//|
|
||||
//| Change current directory.
|
||||
//| def chdir(path: Any) -> Any:
|
||||
//| """Change current directory."""
|
||||
//| ...
|
||||
//|
|
||||
mp_obj_t os_chdir(mp_obj_t path_in) {
|
||||
const char *path = mp_obj_str_get_str(path_in);
|
||||
|
@ -70,18 +70,18 @@ mp_obj_t os_chdir(mp_obj_t path_in) {
|
|||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(os_chdir_obj, os_chdir);
|
||||
|
||||
//| .. function:: getcwd()
|
||||
//|
|
||||
//| Get the current directory.
|
||||
//| def getcwd() -> Any:
|
||||
//| """Get the current directory."""
|
||||
//| ...
|
||||
//|
|
||||
mp_obj_t os_getcwd(void) {
|
||||
return common_hal_os_getcwd();
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_0(os_getcwd_obj, os_getcwd);
|
||||
|
||||
//| .. function:: listdir([dir])
|
||||
//|
|
||||
//| With no argument, list the current directory. Otherwise list the given directory.
|
||||
//| def listdir(dir: Any) -> Any:
|
||||
//| """With no argument, list the current directory. Otherwise list the given directory."""
|
||||
//| ...
|
||||
//|
|
||||
mp_obj_t os_listdir(size_t n_args, const mp_obj_t *args) {
|
||||
const char* path;
|
||||
|
@ -94,9 +94,9 @@ mp_obj_t os_listdir(size_t n_args, const mp_obj_t *args) {
|
|||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(os_listdir_obj, 0, 1, os_listdir);
|
||||
|
||||
//| .. function:: mkdir(path)
|
||||
//|
|
||||
//| Create a new directory.
|
||||
//| def mkdir(path: Any) -> Any:
|
||||
//| """Create a new directory."""
|
||||
//| ...
|
||||
//|
|
||||
mp_obj_t os_mkdir(mp_obj_t path_in) {
|
||||
const char *path = mp_obj_str_get_str(path_in);
|
||||
|
@ -105,9 +105,9 @@ mp_obj_t os_mkdir(mp_obj_t path_in) {
|
|||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(os_mkdir_obj, os_mkdir);
|
||||
|
||||
//| .. function:: remove(path)
|
||||
//|
|
||||
//| Remove a file.
|
||||
//| def remove(path: Any) -> Any:
|
||||
//| """Remove a file."""
|
||||
//| ...
|
||||
//|
|
||||
mp_obj_t os_remove(mp_obj_t path_in) {
|
||||
const char *path = mp_obj_str_get_str(path_in);
|
||||
|
@ -116,9 +116,9 @@ mp_obj_t os_remove(mp_obj_t path_in) {
|
|||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(os_remove_obj, os_remove);
|
||||
|
||||
//| .. function:: rmdir(path)
|
||||
//|
|
||||
//| Remove a directory.
|
||||
//| def rmdir(path: Any) -> Any:
|
||||
//| """Remove a directory."""
|
||||
//| ...
|
||||
//|
|
||||
mp_obj_t os_rename(mp_obj_t old_path_in, mp_obj_t new_path_in) {
|
||||
const char *old_path = mp_obj_str_get_str(old_path_in);
|
||||
|
@ -128,9 +128,9 @@ mp_obj_t os_rename(mp_obj_t old_path_in, mp_obj_t new_path_in) {
|
|||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_2(os_rename_obj, os_rename);
|
||||
|
||||
//| .. function:: rename(old_path, new_path)
|
||||
//|
|
||||
//| Rename a file.
|
||||
//| def rename(old_path: Any, new_path: Any) -> Any:
|
||||
//| """Rename a file."""
|
||||
//| ...
|
||||
//|
|
||||
mp_obj_t os_rmdir(mp_obj_t path_in) {
|
||||
const char *path = mp_obj_str_get_str(path_in);
|
||||
|
@ -139,14 +139,14 @@ mp_obj_t os_rmdir(mp_obj_t path_in) {
|
|||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(os_rmdir_obj, os_rmdir);
|
||||
|
||||
//| .. function:: stat(path)
|
||||
//| def stat(path: Any) -> Any:
|
||||
//| """Get the status of a file or directory.
|
||||
//|
|
||||
//| Get the status of a file or directory.
|
||||
//|
|
||||
//| .. note:: On builds without long integers, the number of seconds
|
||||
//| for contemporary dates will not fit in a small integer.
|
||||
//| So the time fields return 946684800,
|
||||
//| which is the number of seconds corresponding to 1999-12-31.
|
||||
//| .. note:: On builds without long integers, the number of seconds
|
||||
//| for contemporary dates will not fit in a small integer.
|
||||
//| So the time fields return 946684800,
|
||||
//| which is the number of seconds corresponding to 1999-12-31."""
|
||||
//| ...
|
||||
//|
|
||||
mp_obj_t os_stat(mp_obj_t path_in) {
|
||||
const char *path = mp_obj_str_get_str(path_in);
|
||||
|
@ -154,26 +154,26 @@ mp_obj_t os_stat(mp_obj_t path_in) {
|
|||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(os_stat_obj, os_stat);
|
||||
|
||||
//| .. function:: statvfs(path)
|
||||
//| def statvfs(path: Any) -> Any:
|
||||
//| """Get the status of a fileystem.
|
||||
//|
|
||||
//| Get the status of a fileystem.
|
||||
//| Returns a tuple with the filesystem information in the following order:
|
||||
//|
|
||||
//| Returns a tuple with the filesystem information in the following order:
|
||||
//| * ``f_bsize`` -- file system block size
|
||||
//| * ``f_frsize`` -- fragment size
|
||||
//| * ``f_blocks`` -- size of fs in f_frsize units
|
||||
//| * ``f_bfree`` -- number of free blocks
|
||||
//| * ``f_bavail`` -- number of free blocks for unpriviliged users
|
||||
//| * ``f_files`` -- number of inodes
|
||||
//| * ``f_ffree`` -- number of free inodes
|
||||
//| * ``f_favail`` -- number of free inodes for unpriviliged users
|
||||
//| * ``f_flag`` -- mount flags
|
||||
//| * ``f_namemax`` -- maximum filename length
|
||||
//|
|
||||
//| * ``f_bsize`` -- file system block size
|
||||
//| * ``f_frsize`` -- fragment size
|
||||
//| * ``f_blocks`` -- size of fs in f_frsize units
|
||||
//| * ``f_bfree`` -- number of free blocks
|
||||
//| * ``f_bavail`` -- number of free blocks for unpriviliged users
|
||||
//| * ``f_files`` -- number of inodes
|
||||
//| * ``f_ffree`` -- number of free inodes
|
||||
//| * ``f_favail`` -- number of free inodes for unpriviliged users
|
||||
//| * ``f_flag`` -- mount flags
|
||||
//| * ``f_namemax`` -- maximum filename length
|
||||
//|
|
||||
//| Parameters related to inodes: ``f_files``, ``f_ffree``, ``f_avail``
|
||||
//| and the ``f_flags`` parameter may return ``0`` as they can be unavailable
|
||||
//| in a port-specific implementation.
|
||||
//| Parameters related to inodes: ``f_files``, ``f_ffree``, ``f_avail``
|
||||
//| and the ``f_flags`` parameter may return ``0`` as they can be unavailable
|
||||
//| in a port-specific implementation."""
|
||||
//| ...
|
||||
//|
|
||||
mp_obj_t os_statvfs(mp_obj_t path_in) {
|
||||
const char *path = mp_obj_str_get_str(path_in);
|
||||
|
@ -181,9 +181,9 @@ mp_obj_t os_statvfs(mp_obj_t path_in) {
|
|||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(os_statvfs_obj, os_statvfs);
|
||||
|
||||
//| .. function:: sync()
|
||||
//|
|
||||
//| Sync all filesystems.
|
||||
//| def sync() -> Any:
|
||||
//| """Sync all filesystems."""
|
||||
//| ...
|
||||
//|
|
||||
STATIC mp_obj_t os_sync(void) {
|
||||
for (mp_vfs_mount_t *vfs = MP_STATE_VM(vfs_mount_table); vfs != NULL; vfs = vfs->next) {
|
||||
|
@ -194,10 +194,10 @@ STATIC mp_obj_t os_sync(void) {
|
|||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_0(os_sync_obj, os_sync);
|
||||
|
||||
//| .. function:: urandom(size)
|
||||
//|
|
||||
//| Returns a string of *size* random bytes based on a hardware True Random
|
||||
//| Number Generator. When not available, it will raise a NotImplementedError.
|
||||
//| def urandom(size: Any) -> Any:
|
||||
//| """Returns a string of *size* random bytes based on a hardware True Random
|
||||
//| Number Generator. When not available, it will raise a NotImplementedError."""
|
||||
//| ...
|
||||
//|
|
||||
STATIC mp_obj_t os_urandom(mp_obj_t size_in) {
|
||||
mp_int_t size = mp_obj_get_int(size_in);
|
||||
|
@ -229,9 +229,9 @@ STATIC const mp_rom_map_elem_t os_module_globals_table[] = {
|
|||
|
||||
{ MP_ROM_QSTR(MP_QSTR_urandom), MP_ROM_PTR(&os_urandom_obj) },
|
||||
|
||||
//| .. data:: sep
|
||||
//| """.. data:: sep
|
||||
//|
|
||||
//| Separator used to delineate path components such as folder and file names.
|
||||
//| Separator used to delineate path components such as folder and file names."""
|
||||
//|
|
||||
{ MP_ROM_QSTR(MP_QSTR_sep), MP_ROM_QSTR(MP_QSTR__slash_) },
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue