summaryrefslogtreecommitdiff
path: root/shared-module
diff options
context:
space:
mode:
authorsommersoft <sommersoft@gmail.com>2018-04-06 01:58:29 +0000
committersommersoft <sommersoft@gmail.com>2018-04-06 01:58:29 +0000
commitcc644032ea81783de0e1e15b90dac2ce7913011b (patch)
treef859d54e7b8830b96cf9965dcb54c2f2daaaa21a /shared-module
parentd1974e0038f18ed2ffc59f0f198d998070f4c618 (diff)
parent6ee573c7c9e4912de8c518df73af81dd8c2fd935 (diff)
Merge branch 'super_status' of https://github.com/sommersoft/circuitpython into super_status
Diffstat (limited to 'shared-module')
-rw-r--r--shared-module/_stage/Layer.c2
-rw-r--r--shared-module/_stage/Layer.h2
-rw-r--r--shared-module/_stage/Text.c2
-rw-r--r--shared-module/_stage/Text.h2
-rw-r--r--shared-module/_stage/__init__.c9
-rw-r--r--shared-module/_stage/__init__.h2
-rw-r--r--shared-module/storage/__init__.c18
-rw-r--r--shared-module/struct/__init__.c2
8 files changed, 19 insertions, 20 deletions
diff --git a/shared-module/_stage/Layer.c b/shared-module/_stage/Layer.c
index 4c9c46d7c..d958f0d19 100644
--- a/shared-module/_stage/Layer.c
+++ b/shared-module/_stage/Layer.c
@@ -29,7 +29,7 @@
// Get the color of the pixel on the layer.
-uint16_t get_layer_pixel(layer_obj_t *layer, int16_t x, uint16_t y) {
+uint16_t get_layer_pixel(layer_obj_t *layer, uint16_t x, uint16_t y) {
// Shift by the layer's position offset.
x -= layer->x;
diff --git a/shared-module/_stage/Layer.h b/shared-module/_stage/Layer.h
index c46f71349..17d101263 100644
--- a/shared-module/_stage/Layer.h
+++ b/shared-module/_stage/Layer.h
@@ -43,6 +43,6 @@ typedef struct {
uint8_t rotation;
} layer_obj_t;
-uint16_t get_layer_pixel(layer_obj_t *layer, int16_t x, uint16_t y);
+uint16_t get_layer_pixel(layer_obj_t *layer, uint16_t x, uint16_t y);
#endif // MICROPY_INCLUDED_SHARED_MODULE__STAGE_LAYER
diff --git a/shared-module/_stage/Text.c b/shared-module/_stage/Text.c
index 307f9bbfa..df5bf8008 100644
--- a/shared-module/_stage/Text.c
+++ b/shared-module/_stage/Text.c
@@ -29,7 +29,7 @@
// Get the color of the pixel on the text.
-uint16_t get_text_pixel(text_obj_t *text, int16_t x, uint16_t y) {
+uint16_t get_text_pixel(text_obj_t *text, uint16_t x, uint16_t y) {
// Shift by the text's position offset.
x -= text->x;
diff --git a/shared-module/_stage/Text.h b/shared-module/_stage/Text.h
index bc111e49c..b263fc710 100644
--- a/shared-module/_stage/Text.h
+++ b/shared-module/_stage/Text.h
@@ -41,6 +41,6 @@ typedef struct {
uint8_t width, height;
} text_obj_t;
-uint16_t get_text_pixel(text_obj_t *text, int16_t x, uint16_t y);
+uint16_t get_text_pixel(text_obj_t *text, uint16_t x, uint16_t y);
#endif // MICROPY_INCLUDED_SHARED_MODULE__STAGE_TEXT
diff --git a/shared-module/_stage/__init__.c b/shared-module/_stage/__init__.c
index 1931b8940..86f5ee795 100644
--- a/shared-module/_stage/__init__.c
+++ b/shared-module/_stage/__init__.c
@@ -31,17 +31,14 @@
#include "shared-bindings/_stage/Text.h"
-bool render_stage(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1,
+bool render_stage(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1,
mp_obj_t *layers, size_t layers_size,
uint16_t *buffer, size_t buffer_size,
busio_spi_obj_t *spi) {
- // TODO(deshipu): Do a collision check of each layer with the
- // rectangle, and only process the layers that overlap with it.
-
size_t index = 0;
- for (uint8_t y = y0; y < y1; ++y) {
- for (uint8_t x = x0; x < x1; ++x) {
+ for (uint16_t y = y0; y < y1; ++y) {
+ for (uint16_t x = x0; x < x1; ++x) {
for (size_t layer = 0; layer < layers_size; ++layer) {
uint16_t c = TRANSPARENT;
layer_obj_t *obj = MP_OBJ_TO_PTR(layers[layer]);
diff --git a/shared-module/_stage/__init__.h b/shared-module/_stage/__init__.h
index 326c72559..d56a26940 100644
--- a/shared-module/_stage/__init__.h
+++ b/shared-module/_stage/__init__.h
@@ -34,7 +34,7 @@
#define TRANSPARENT (0x1ff8)
-bool render_stage(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1,
+bool render_stage(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1,
mp_obj_t *layers, size_t layers_size,
uint16_t *buffer, size_t buffer_size,
busio_spi_obj_t *spi);
diff --git a/shared-module/storage/__init__.c b/shared-module/storage/__init__.c
index 97a049bac..5b0bbe01e 100644
--- a/shared-module/storage/__init__.c
+++ b/shared-module/storage/__init__.c
@@ -109,19 +109,19 @@ void common_hal_storage_umount_object(mp_obj_t vfs_obj) {
mp_vfs_proxy_call(vfs, MP_QSTR_umount, 0, NULL);
}
-void common_hal_storage_umount_path(const char* mount_path) {
- // remove vfs from the mount table
- mp_obj_t *vfs_obj = NULL;
+STATIC mp_obj_t storage_object_from_path(const char* mount_path) {
for (mp_vfs_mount_t **vfsp = &MP_STATE_VM(vfs_mount_table); *vfsp != NULL; vfsp = &(*vfsp)->next) {
if (strcmp(mount_path, (*vfsp)->str) == 0) {
- vfs_obj = (*vfsp)->obj;
- break;
+ return (*vfsp)->obj;
}
}
+ mp_raise_OSError(MP_EINVAL);
+}
- if (vfs_obj == NULL) {
- mp_raise_OSError(MP_EINVAL);
- }
+void common_hal_storage_umount_path(const char* mount_path) {
+ common_hal_storage_umount_object(storage_object_from_path(mount_path));
+}
- common_hal_storage_umount_object(vfs_obj);
+mp_obj_t common_hal_storage_getmount(const char *mount_path) {
+ return storage_object_from_path(mount_path);
}
diff --git a/shared-module/struct/__init__.c b/shared-module/struct/__init__.c
index e944f7738..eac41c9c3 100644
--- a/shared-module/struct/__init__.c
+++ b/shared-module/struct/__init__.c
@@ -33,9 +33,11 @@
#include "py/parsenum.h"
void struct_validate_format(char fmt) {
+#if MICROPY_NONSTANDARD_TYPECODES
if( fmt == 'S' || fmt == 'O') {
mp_raise_RuntimeError("'S' and 'O' are not supported format types");
}
+#endif
}
char get_fmt_type(const char **fmt) {