summaryrefslogtreecommitdiff
path: root/shared-bindings
diff options
context:
space:
mode:
authorDan Halbert <halbert@halwitz.org>2018-04-02 19:19:43 -0400
committerDan Halbert <halbert@halwitz.org>2018-04-02 19:19:43 -0400
commit435e894fa0ec5e9ce82b7bdef308413c6731e06a (patch)
treeaf8d62363157a6ba969684538e012871a88224c6 /shared-bindings
parentd005b123267ab4ac2f0471c730b762cc3e94232c (diff)
parent98c7d70fe406d66d80c3c9cc888602f96cf444c4 (diff)
Merge branch 'master' into 3.0_hid
Diffstat (limited to 'shared-bindings')
-rw-r--r--shared-bindings/gamepad/GamePad.c7
-rw-r--r--shared-bindings/help.c2
-rw-r--r--shared-bindings/storage/__init__.c53
-rw-r--r--shared-bindings/storage/__init__.h1
4 files changed, 62 insertions, 1 deletions
diff --git a/shared-bindings/gamepad/GamePad.c b/shared-bindings/gamepad/GamePad.c
index a03b9318d..d80d1fcf6 100644
--- a/shared-bindings/gamepad/GamePad.c
+++ b/shared-bindings/gamepad/GamePad.c
@@ -27,6 +27,7 @@
#include "py/runtime.h"
#include "py/mphal.h"
#include "shared-module/gamepad/GamePad.h"
+#include "shared-bindings/digitalio/DigitalInOut.h"
#include "GamePad.h"
@@ -96,6 +97,12 @@ STATIC mp_obj_t gamepad_make_new(const mp_obj_type_t *type, size_t n_args,
gamepad_singleton = m_new_obj(gamepad_obj_t);
gamepad_singleton->base.type = &gamepad_type;
}
+ for (size_t i = 0; i < n_args; ++i) {
+ if (!MP_OBJ_IS_TYPE(args[i], &digitalio_digitalinout_type)) {
+ nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError,
+ "Expected a %q", digitalio_digitalinout_type.name));
+ }
+ }
gamepad_init(n_args, args);
return MP_OBJ_FROM_PTR(gamepad_singleton);
}
diff --git a/shared-bindings/help.c b/shared-bindings/help.c
index cdd9a4a93..d8ffc13dd 100644
--- a/shared-bindings/help.c
+++ b/shared-bindings/help.c
@@ -35,7 +35,7 @@
//| prints general port information.
//|
-const char *circuitpython_help_text =
+const char circuitpython_help_text[] =
"Welcome to Adafruit CircuitPython " MICROPY_GIT_TAG "!\r\n"
"\r\n"
"Please visit learn.adafruit.com/category/circuitpython for project guides.\r\n"
diff --git a/shared-bindings/storage/__init__.c b/shared-bindings/storage/__init__.c
index 6f6a30da6..734cabcc1 100644
--- a/shared-bindings/storage/__init__.c
+++ b/shared-bindings/storage/__init__.c
@@ -122,12 +122,22 @@ mp_obj_t storage_remount(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_a
}
MP_DEFINE_CONST_FUN_OBJ_KW(storage_remount_obj, 1, storage_remount);
+//| .. function:: getmount(mount_path)
+//|
+//| Retrieves the mount object associated with the mount path
+//|
+mp_obj_t storage_getmount(const mp_obj_t mnt_in) {
+ return common_hal_storage_getmount(mp_obj_str_get_str(mnt_in));
+}
+MP_DEFINE_CONST_FUN_OBJ_1(storage_getmount_obj, storage_getmount);
+
STATIC const mp_rom_map_elem_t storage_module_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_storage) },
{ MP_ROM_QSTR(MP_QSTR_mount), MP_ROM_PTR(&storage_mount_obj) },
{ MP_ROM_QSTR(MP_QSTR_umount), MP_ROM_PTR(&storage_umount_obj) },
{ MP_ROM_QSTR(MP_QSTR_remount), MP_ROM_PTR(&storage_remount_obj) },
+ { MP_ROM_QSTR(MP_QSTR_getmount), MP_ROM_PTR(&storage_getmount_obj) },
//| .. class:: VfsFat(block_device)
//|
@@ -135,6 +145,49 @@ STATIC const mp_rom_map_elem_t storage_module_globals_table[] = {
//|
//| :param block_device: Block device the the filesystem lives on
//|
+ //| .. attribute:: label
+ //|
+ //| The filesystem label, up to 11 case-insensitive bytes. Note that
+ //| this property can only be set when the device is writable by the
+ //| microcontroller.
+ //|
+ //| .. method:: mkfs
+ //|
+ //| Format the block device, deleting any data that may have been there
+ //|
+ //| .. method:: open(path, mode)
+ //|
+ //| Like builtin ``open()``
+ //|
+ //| .. method:: ilistdir([path])
+ //|
+ //| Return an iterator whose values describe files and folders within
+ //| ``path``
+ //|
+ //| .. method:: mkdir(path)
+ //|
+ //| Like `os.mkdir`
+ //|
+ //| .. method:: rmdir(path)
+ //|
+ //| Like `os.rmdir`
+ //|
+ //| .. method:: stat(path)
+ //|
+ //| Like `os.stat`
+ //|
+ //| .. method:: statvfs(path)
+ //|
+ //| Like `os.statvfs`
+ //|
+ //| .. method:: mount(readonly, mkfs)
+ //|
+ //| Don't call this directly, call `storage.mount`.
+ //|
+ //| .. method:: umount
+ //|
+ //| Don't call this directly, call `storage.umount`.
+ //|
{ MP_ROM_QSTR(MP_QSTR_VfsFat), MP_ROM_PTR(&mp_fat_vfs_type) },
};
diff --git a/shared-bindings/storage/__init__.h b/shared-bindings/storage/__init__.h
index 574b5ff8d..76b9ae854 100644
--- a/shared-bindings/storage/__init__.h
+++ b/shared-bindings/storage/__init__.h
@@ -34,5 +34,6 @@ void common_hal_storage_mount(mp_obj_t vfs_obj, const char* path, bool readonly)
void common_hal_storage_umount_path(const char* path);
void common_hal_storage_umount_object(mp_obj_t vfs_obj);
void common_hal_storage_remount(const char* path, bool readonly);
+mp_obj_t common_hal_storage_getmount(const char* path);
#endif // MICROPY_INCLUDED_SHARED_BINDINGS_STORAGE___INIT___H