remove last uses of 'u' prefix
This commit is contained in:
parent
b589dc2589
commit
88c22d5052
@ -357,6 +357,6 @@ const mp_obj_module_t mp_module_uasyncio = {
|
|||||||
.globals = (mp_obj_dict_t *)&mp_module_uasyncio_globals,
|
.globals = (mp_obj_dict_t *)&mp_module_uasyncio_globals,
|
||||||
};
|
};
|
||||||
|
|
||||||
MP_REGISTER_MODULE(MP_QSTR__uasyncio, mp_module_uasyncio);
|
MP_REGISTER_MODULE(MP_QSTR__asyncio, mp_module_uasyncio);
|
||||||
|
|
||||||
#endif // MICROPY_PY_UASYNCIO
|
#endif // MICROPY_PY_UASYNCIO
|
||||||
|
@ -330,6 +330,6 @@ const mp_obj_module_t mp_module_ubinascii = {
|
|||||||
.globals = (mp_obj_dict_t *)&mp_module_binascii_globals,
|
.globals = (mp_obj_dict_t *)&mp_module_binascii_globals,
|
||||||
};
|
};
|
||||||
|
|
||||||
MP_REGISTER_MODULE(MP_QSTR_ubinascii, mp_module_ubinascii);
|
MP_REGISTER_MODULE(MP_QSTR_binascii, mp_module_ubinascii);
|
||||||
|
|
||||||
#endif // MICROPY_PY_UBINASCII
|
#endif // MICROPY_PY_UBINASCII
|
||||||
|
@ -382,6 +382,6 @@ const mp_obj_module_t mp_module_uhashlib = {
|
|||||||
.globals = (mp_obj_dict_t *)&mp_module_uhashlib_globals,
|
.globals = (mp_obj_dict_t *)&mp_module_uhashlib_globals,
|
||||||
};
|
};
|
||||||
|
|
||||||
MP_REGISTER_MODULE(MP_QSTR_uhashlib, mp_module_uhashlib);
|
MP_REGISTER_MODULE(MP_QSTR_hashlib, mp_module_uhashlib);
|
||||||
|
|
||||||
#endif // MICROPY_PY_UHASHLIB
|
#endif // MICROPY_PY_UHASHLIB
|
||||||
|
@ -120,7 +120,7 @@ const mp_obj_module_t mp_module_uheapq = {
|
|||||||
.globals = (mp_obj_dict_t *)&mp_module_uheapq_globals,
|
.globals = (mp_obj_dict_t *)&mp_module_uheapq_globals,
|
||||||
};
|
};
|
||||||
|
|
||||||
MP_REGISTER_MODULE(MP_QSTR_uheapq, mp_module_uheapq);
|
MP_REGISTER_MODULE(MP_QSTR_heapq, mp_module_uheapq);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // MICROPY_PY_UHEAPQ
|
#endif // MICROPY_PY_UHEAPQ
|
||||||
|
@ -458,6 +458,6 @@ const mp_obj_module_t mp_module_ujson = {
|
|||||||
.globals = (mp_obj_dict_t *)&mp_module_ujson_globals,
|
.globals = (mp_obj_dict_t *)&mp_module_ujson_globals,
|
||||||
};
|
};
|
||||||
|
|
||||||
MP_REGISTER_MODULE(MP_QSTR_ujson, mp_module_ujson);
|
MP_REGISTER_MODULE(MP_QSTR_json, mp_module_ujson);
|
||||||
|
|
||||||
#endif // MICROPY_PY_UJSON
|
#endif // MICROPY_PY_UJSON
|
||||||
|
@ -181,6 +181,6 @@ const mp_obj_module_t mp_module_uos = {
|
|||||||
.globals = (mp_obj_dict_t *)&os_module_globals,
|
.globals = (mp_obj_dict_t *)&os_module_globals,
|
||||||
};
|
};
|
||||||
|
|
||||||
MP_REGISTER_MODULE(MP_QSTR_uos, mp_module_uos);
|
MP_REGISTER_MODULE(MP_QSTR_os, mp_module_uos);
|
||||||
|
|
||||||
#endif // MICROPY_PY_UOS
|
#endif // MICROPY_PY_UOS
|
||||||
|
@ -75,6 +75,6 @@ const mp_obj_module_t mp_module_uplatform = {
|
|||||||
.globals = (mp_obj_dict_t *)&modplatform_globals,
|
.globals = (mp_obj_dict_t *)&modplatform_globals,
|
||||||
};
|
};
|
||||||
|
|
||||||
MP_REGISTER_MODULE(MP_QSTR_uplatform, mp_module_uplatform);
|
MP_REGISTER_MODULE(MP_QSTR_platform, mp_module_uplatform);
|
||||||
|
|
||||||
#endif // MICROPY_PY_UPLATFORM
|
#endif // MICROPY_PY_UPLATFORM
|
||||||
|
@ -255,7 +255,7 @@ const mp_obj_module_t mp_module_urandom = {
|
|||||||
.globals = (mp_obj_dict_t *)&mp_module_urandom_globals,
|
.globals = (mp_obj_dict_t *)&mp_module_urandom_globals,
|
||||||
};
|
};
|
||||||
|
|
||||||
MP_REGISTER_MODULE(MP_QSTR_urandom, mp_module_urandom);
|
MP_REGISTER_MODULE(MP_QSTR_random, mp_module_urandom);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // MICROPY_PY_URANDOM
|
#endif // MICROPY_PY_URANDOM
|
||||||
|
@ -491,7 +491,7 @@ const mp_obj_module_t mp_module_ure = {
|
|||||||
.globals = (mp_obj_dict_t *)&mp_module_re_globals,
|
.globals = (mp_obj_dict_t *)&mp_module_re_globals,
|
||||||
};
|
};
|
||||||
|
|
||||||
MP_REGISTER_MODULE(MP_QSTR_ure, mp_module_ure);
|
MP_REGISTER_MODULE(MP_QSTR_re, mp_module_ure);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Source files #include'd here to make sure they're compiled in
|
// Source files #include'd here to make sure they're compiled in
|
||||||
|
@ -1,239 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of the MicroPython project, http://micropython.org/
|
|
||||||
*
|
|
||||||
* The MIT License (MIT)
|
|
||||||
*
|
|
||||||
* Copyright (c) 2014 Damien P. George
|
|
||||||
* Copyright (c) 2016-2017 Paul Sokolovsky
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
|
||||||
* in the Software without restriction, including without limitation the rights
|
|
||||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
* copies of the Software, and to permit persons to whom the Software is
|
|
||||||
* furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in
|
|
||||||
* all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
* THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include "py/objlist.h"
|
|
||||||
#include "py/runtime.h"
|
|
||||||
#include "py/smallint.h"
|
|
||||||
|
|
||||||
#include "supervisor/shared/translate/translate.h"
|
|
||||||
|
|
||||||
#if MICROPY_PY_UTIMEQ
|
|
||||||
|
|
||||||
#define MODULO MICROPY_PY_UTIME_TICKS_PERIOD
|
|
||||||
|
|
||||||
#define DEBUG 0
|
|
||||||
|
|
||||||
// the algorithm here is modelled on CPython's heapq.py
|
|
||||||
|
|
||||||
struct qentry {
|
|
||||||
mp_uint_t time;
|
|
||||||
mp_uint_t id;
|
|
||||||
mp_obj_t callback;
|
|
||||||
mp_obj_t args;
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef struct _mp_obj_utimeq_t {
|
|
||||||
mp_obj_base_t base;
|
|
||||||
mp_uint_t alloc;
|
|
||||||
mp_uint_t len;
|
|
||||||
struct qentry items[];
|
|
||||||
} mp_obj_utimeq_t;
|
|
||||||
|
|
||||||
STATIC mp_uint_t utimeq_id;
|
|
||||||
|
|
||||||
STATIC mp_obj_utimeq_t *utimeq_get_heap(mp_obj_t heap_in) {
|
|
||||||
return MP_OBJ_TO_PTR(heap_in);
|
|
||||||
}
|
|
||||||
|
|
||||||
STATIC bool time_less_than(struct qentry *item, struct qentry *parent) {
|
|
||||||
mp_uint_t item_tm = item->time;
|
|
||||||
mp_uint_t parent_tm = parent->time;
|
|
||||||
mp_uint_t res = parent_tm - item_tm;
|
|
||||||
if (res == 0) {
|
|
||||||
// TODO: This actually should use the same "ring" logic
|
|
||||||
// as for time, to avoid artifacts when id's overflow.
|
|
||||||
return item->id < parent->id;
|
|
||||||
}
|
|
||||||
if ((mp_int_t)res < 0) {
|
|
||||||
res += MODULO;
|
|
||||||
}
|
|
||||||
return res && res < (MODULO / 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
STATIC mp_obj_t utimeq_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
|
|
||||||
mp_arg_check_num(n_args, n_kw, 1, 1, false);
|
|
||||||
mp_uint_t alloc = mp_obj_get_int(args[0]);
|
|
||||||
mp_obj_utimeq_t *o = mp_obj_malloc_var(mp_obj_utimeq_t, struct qentry, alloc, type);
|
|
||||||
memset(o->items, 0, sizeof(*o->items) * alloc);
|
|
||||||
o->alloc = alloc;
|
|
||||||
o->len = 0;
|
|
||||||
return MP_OBJ_FROM_PTR(o);
|
|
||||||
}
|
|
||||||
|
|
||||||
STATIC void utimeq_heap_siftdown(mp_obj_utimeq_t *heap, mp_uint_t start_pos, mp_uint_t pos) {
|
|
||||||
struct qentry item = heap->items[pos];
|
|
||||||
while (pos > start_pos) {
|
|
||||||
mp_uint_t parent_pos = (pos - 1) >> 1;
|
|
||||||
struct qentry *parent = &heap->items[parent_pos];
|
|
||||||
bool lessthan = time_less_than(&item, parent);
|
|
||||||
if (lessthan) {
|
|
||||||
heap->items[pos] = *parent;
|
|
||||||
pos = parent_pos;
|
|
||||||
} else {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
heap->items[pos] = item;
|
|
||||||
}
|
|
||||||
|
|
||||||
STATIC void utimeq_heap_siftup(mp_obj_utimeq_t *heap, mp_uint_t pos) {
|
|
||||||
mp_uint_t start_pos = pos;
|
|
||||||
mp_uint_t end_pos = heap->len;
|
|
||||||
struct qentry item = heap->items[pos];
|
|
||||||
for (mp_uint_t child_pos = 2 * pos + 1; child_pos < end_pos; child_pos = 2 * pos + 1) {
|
|
||||||
// choose right child if it's <= left child
|
|
||||||
if (child_pos + 1 < end_pos) {
|
|
||||||
bool lessthan = time_less_than(&heap->items[child_pos], &heap->items[child_pos + 1]);
|
|
||||||
if (!lessthan) {
|
|
||||||
child_pos += 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// bubble up the smaller child
|
|
||||||
heap->items[pos] = heap->items[child_pos];
|
|
||||||
pos = child_pos;
|
|
||||||
}
|
|
||||||
heap->items[pos] = item;
|
|
||||||
utimeq_heap_siftdown(heap, start_pos, pos);
|
|
||||||
}
|
|
||||||
|
|
||||||
STATIC mp_obj_t mod_utimeq_heappush(size_t n_args, const mp_obj_t *args) {
|
|
||||||
(void)n_args;
|
|
||||||
mp_obj_t heap_in = args[0];
|
|
||||||
mp_obj_utimeq_t *heap = utimeq_get_heap(heap_in);
|
|
||||||
if (heap->len == heap->alloc) {
|
|
||||||
mp_raise_IndexError(MP_ERROR_TEXT("queue overflow"));
|
|
||||||
}
|
|
||||||
mp_uint_t l = heap->len;
|
|
||||||
heap->items[l].time = MP_OBJ_SMALL_INT_VALUE(args[1]);
|
|
||||||
heap->items[l].id = utimeq_id++;
|
|
||||||
heap->items[l].callback = args[2];
|
|
||||||
heap->items[l].args = args[3];
|
|
||||||
utimeq_heap_siftdown(heap, 0, heap->len);
|
|
||||||
heap->len++;
|
|
||||||
return mp_const_none;
|
|
||||||
}
|
|
||||||
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_utimeq_heappush_obj, 4, 4, mod_utimeq_heappush);
|
|
||||||
|
|
||||||
STATIC mp_obj_t mod_utimeq_heappop(mp_obj_t heap_in, mp_obj_t list_ref) {
|
|
||||||
mp_obj_utimeq_t *heap = utimeq_get_heap(heap_in);
|
|
||||||
if (heap->len == 0) {
|
|
||||||
mp_raise_IndexError(MP_ERROR_TEXT("empty heap"));
|
|
||||||
}
|
|
||||||
mp_obj_list_t *ret = MP_OBJ_TO_PTR(list_ref);
|
|
||||||
if (!mp_obj_is_type(list_ref, &mp_type_list) || ret->len < 3) {
|
|
||||||
mp_raise_TypeError(NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
struct qentry *item = &heap->items[0];
|
|
||||||
ret->items[0] = MP_OBJ_NEW_SMALL_INT(item->time);
|
|
||||||
ret->items[1] = item->callback;
|
|
||||||
ret->items[2] = item->args;
|
|
||||||
heap->len -= 1;
|
|
||||||
heap->items[0] = heap->items[heap->len];
|
|
||||||
heap->items[heap->len].callback = MP_OBJ_NULL; // so we don't retain a pointer
|
|
||||||
heap->items[heap->len].args = MP_OBJ_NULL;
|
|
||||||
if (heap->len) {
|
|
||||||
utimeq_heap_siftup(heap, 0);
|
|
||||||
}
|
|
||||||
return mp_const_none;
|
|
||||||
}
|
|
||||||
STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_utimeq_heappop_obj, mod_utimeq_heappop);
|
|
||||||
|
|
||||||
STATIC mp_obj_t mod_utimeq_peektime(mp_obj_t heap_in) {
|
|
||||||
mp_obj_utimeq_t *heap = utimeq_get_heap(heap_in);
|
|
||||||
if (heap->len == 0) {
|
|
||||||
mp_raise_IndexError(MP_ERROR_TEXT("empty heap"));
|
|
||||||
}
|
|
||||||
|
|
||||||
struct qentry *item = &heap->items[0];
|
|
||||||
return MP_OBJ_NEW_SMALL_INT(item->time);
|
|
||||||
}
|
|
||||||
STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_utimeq_peektime_obj, mod_utimeq_peektime);
|
|
||||||
|
|
||||||
#if DEBUG
|
|
||||||
STATIC mp_obj_t mod_utimeq_dump(mp_obj_t heap_in) {
|
|
||||||
mp_obj_utimeq_t *heap = utimeq_get_heap(heap_in);
|
|
||||||
for (int i = 0; i < heap->len; i++) {
|
|
||||||
printf(UINT_FMT "\t%p\t%p\n", heap->items[i].time,
|
|
||||||
MP_OBJ_TO_PTR(heap->items[i].callback), MP_OBJ_TO_PTR(heap->items[i].args));
|
|
||||||
}
|
|
||||||
return mp_const_none;
|
|
||||||
}
|
|
||||||
STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_utimeq_dump_obj, mod_utimeq_dump);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
STATIC mp_obj_t utimeq_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
|
|
||||||
mp_obj_utimeq_t *self = MP_OBJ_TO_PTR(self_in);
|
|
||||||
switch (op) {
|
|
||||||
case MP_UNARY_OP_BOOL:
|
|
||||||
return mp_obj_new_bool(self->len != 0);
|
|
||||||
case MP_UNARY_OP_LEN:
|
|
||||||
return MP_OBJ_NEW_SMALL_INT(self->len);
|
|
||||||
default:
|
|
||||||
return MP_OBJ_NULL; // op not supported
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
STATIC const mp_rom_map_elem_t utimeq_locals_dict_table[] = {
|
|
||||||
{ MP_ROM_QSTR(MP_QSTR_push), MP_ROM_PTR(&mod_utimeq_heappush_obj) },
|
|
||||||
{ MP_ROM_QSTR(MP_QSTR_pop), MP_ROM_PTR(&mod_utimeq_heappop_obj) },
|
|
||||||
{ MP_ROM_QSTR(MP_QSTR_peektime), MP_ROM_PTR(&mod_utimeq_peektime_obj) },
|
|
||||||
#if DEBUG
|
|
||||||
{ MP_ROM_QSTR(MP_QSTR_dump), MP_ROM_PTR(&mod_utimeq_dump_obj) },
|
|
||||||
#endif
|
|
||||||
};
|
|
||||||
|
|
||||||
STATIC MP_DEFINE_CONST_DICT(utimeq_locals_dict, utimeq_locals_dict_table);
|
|
||||||
|
|
||||||
STATIC const mp_obj_type_t utimeq_type = {
|
|
||||||
{ &mp_type_type },
|
|
||||||
.flags = MP_TYPE_FLAG_EXTENDED,
|
|
||||||
.name = MP_QSTR_utimeq,
|
|
||||||
.make_new = utimeq_make_new,
|
|
||||||
.locals_dict = (void *)&utimeq_locals_dict,
|
|
||||||
MP_TYPE_EXTENDED_FIELDS(
|
|
||||||
.unary_op = utimeq_unary_op,
|
|
||||||
),
|
|
||||||
};
|
|
||||||
|
|
||||||
STATIC const mp_rom_map_elem_t mp_module_utimeq_globals_table[] = {
|
|
||||||
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_utimeq) },
|
|
||||||
{ MP_ROM_QSTR(MP_QSTR_utimeq), MP_ROM_PTR(&utimeq_type) },
|
|
||||||
};
|
|
||||||
|
|
||||||
STATIC MP_DEFINE_CONST_DICT(mp_module_utimeq_globals, mp_module_utimeq_globals_table);
|
|
||||||
|
|
||||||
const mp_obj_module_t mp_module_utimeq = {
|
|
||||||
.base = { &mp_type_module },
|
|
||||||
.globals = (mp_obj_dict_t *)&mp_module_utimeq_globals,
|
|
||||||
};
|
|
||||||
|
|
||||||
MP_REGISTER_MODULE(MP_QSTR_utimeq, mp_module_utimeq);
|
|
||||||
|
|
||||||
#endif // MICROPY_PY_UTIMEQ
|
|
@ -230,7 +230,7 @@ const mp_obj_module_t mp_module_uzlib = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
MP_REGISTER_MODULE(MP_QSTR_uzlib, mp_module_uzlib);
|
MP_REGISTER_MODULE(MP_QSTR_zlib, mp_module_uzlib);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Source files #include'd here to make sure they're compiled in
|
// Source files #include'd here to make sure they're compiled in
|
||||||
|
@ -326,12 +326,12 @@ STATIC mp_obj_t extra_coverage(void) {
|
|||||||
size_t len = mp_repl_autocomplete("__n", 3, &mp_plat_print, &str);
|
size_t len = mp_repl_autocomplete("__n", 3, &mp_plat_print, &str);
|
||||||
mp_printf(&mp_plat_print, "%.*s\n", (int)len, str);
|
mp_printf(&mp_plat_print, "%.*s\n", (int)len, str);
|
||||||
|
|
||||||
len = mp_repl_autocomplete("i", 1, &mp_plat_print, &str);
|
len = mp_repl_autocomplete("im", 2, &mp_plat_print, &str);
|
||||||
mp_printf(&mp_plat_print, "%.*s\n", (int)len, str);
|
mp_printf(&mp_plat_print, "%.*s\n", (int)len, str);
|
||||||
mp_repl_autocomplete("import ", 7, &mp_plat_print, &str);
|
mp_repl_autocomplete("import ", 7, &mp_plat_print, &str);
|
||||||
len = mp_repl_autocomplete("import ut", 9, &mp_plat_print, &str);
|
len = mp_repl_autocomplete("import ti", 9, &mp_plat_print, &str);
|
||||||
mp_printf(&mp_plat_print, "%.*s\n", (int)len, str);
|
mp_printf(&mp_plat_print, "%.*s\n", (int)len, str);
|
||||||
mp_repl_autocomplete("import utime", 12, &mp_plat_print, &str);
|
mp_repl_autocomplete("import ra", 9, &mp_plat_print, &str);
|
||||||
|
|
||||||
mp_store_global(MP_QSTR_sys, mp_import_name(MP_QSTR_sys, mp_const_none, MP_OBJ_NEW_SMALL_INT(0)));
|
mp_store_global(MP_QSTR_sys, mp_import_name(MP_QSTR_sys, mp_const_none, MP_OBJ_NEW_SMALL_INT(0)));
|
||||||
mp_repl_autocomplete("sys.", 4, &mp_plat_print, &str);
|
mp_repl_autocomplete("sys.", 4, &mp_plat_print, &str);
|
||||||
|
@ -232,6 +232,6 @@ const mp_obj_module_t mp_module_time = {
|
|||||||
.globals = (mp_obj_dict_t *)&mp_module_time_globals,
|
.globals = (mp_obj_dict_t *)&mp_module_time_globals,
|
||||||
};
|
};
|
||||||
|
|
||||||
MP_REGISTER_MODULE(MP_QSTR_utime, mp_module_time);
|
MP_REGISTER_MODULE(MP_QSTR_time, mp_module_time);
|
||||||
|
|
||||||
#endif // MICROPY_PY_UTIME
|
#endif // MICROPY_PY_UTIME
|
||||||
|
@ -354,6 +354,6 @@ const mp_obj_module_t mp_module_uselect = {
|
|||||||
.globals = (mp_obj_dict_t *)&mp_module_select_globals,
|
.globals = (mp_obj_dict_t *)&mp_module_select_globals,
|
||||||
};
|
};
|
||||||
|
|
||||||
MP_REGISTER_MODULE(MP_QSTR_uselect, mp_module_uselect);
|
MP_REGISTER_MODULE(MP_QSTR_select, mp_module_uselect);
|
||||||
|
|
||||||
#endif // MICROPY_PY_USELECT_POSIX
|
#endif // MICROPY_PY_USELECT_POSIX
|
||||||
|
@ -245,6 +245,6 @@ const mp_obj_module_t mp_module_io = {
|
|||||||
.globals = (mp_obj_dict_t *)&mp_module_io_globals,
|
.globals = (mp_obj_dict_t *)&mp_module_io_globals,
|
||||||
};
|
};
|
||||||
|
|
||||||
MP_REGISTER_MODULE(MP_QSTR_uio, mp_module_io);
|
MP_REGISTER_MODULE(MP_QSTR_io, mp_module_io);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -282,6 +282,6 @@ const mp_obj_module_t mp_module_sys = {
|
|||||||
.globals = (mp_obj_dict_t *)&mp_module_sys_globals,
|
.globals = (mp_obj_dict_t *)&mp_module_sys_globals,
|
||||||
};
|
};
|
||||||
|
|
||||||
MP_REGISTER_MODULE(MP_QSTR_usys, mp_module_sys);
|
MP_REGISTER_MODULE(MP_QSTR_sys, mp_module_sys);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -105,11 +105,7 @@ const mp_obj_module_t mp_module_uerrno = {
|
|||||||
.globals = (mp_obj_dict_t *)&mp_module_uerrno_globals,
|
.globals = (mp_obj_dict_t *)&mp_module_uerrno_globals,
|
||||||
};
|
};
|
||||||
|
|
||||||
#if defined(MICROPY_UNIX_COVERAGE)
|
|
||||||
MP_REGISTER_MODULE(MP_QSTR_uerrno, mp_module_uerrno);
|
|
||||||
#else
|
|
||||||
MP_REGISTER_MODULE(MP_QSTR_errno, mp_module_uerrno);
|
MP_REGISTER_MODULE(MP_QSTR_errno, mp_module_uerrno);
|
||||||
#endif
|
|
||||||
|
|
||||||
qstr mp_errno_to_str(mp_obj_t errno_val) {
|
qstr mp_errno_to_str(mp_obj_t errno_val) {
|
||||||
// Otherwise, return the Exxxx string for that error code
|
// Otherwise, return the Exxxx string for that error code
|
||||||
|
1
py/py.mk
1
py/py.mk
@ -195,7 +195,6 @@ PY_EXTMOD_O_BASENAME = \
|
|||||||
extmod/modure.o \
|
extmod/modure.o \
|
||||||
extmod/moduzlib.o \
|
extmod/moduzlib.o \
|
||||||
extmod/moduheapq.o \
|
extmod/moduheapq.o \
|
||||||
extmod/modutimeq.o \
|
|
||||||
extmod/moduhashlib.o \
|
extmod/moduhashlib.o \
|
||||||
extmod/modubinascii.o \
|
extmod/modubinascii.o \
|
||||||
extmod/modurandom.o \
|
extmod/modurandom.o \
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
try:
|
try:
|
||||||
import uarray as array
|
|
||||||
except ImportError:
|
|
||||||
try:
|
|
||||||
import array
|
import array
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print("SKIP")
|
print("SKIP")
|
||||||
raise SystemExit
|
raise SystemExit
|
||||||
|
|
||||||
|
@ -1,10 +1,7 @@
|
|||||||
# test array + array
|
# test array + array
|
||||||
try:
|
try:
|
||||||
import uarray as array
|
|
||||||
except ImportError:
|
|
||||||
try:
|
|
||||||
import array
|
import array
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print("SKIP")
|
print("SKIP")
|
||||||
raise SystemExit
|
raise SystemExit
|
||||||
|
|
||||||
|
@ -1,10 +1,7 @@
|
|||||||
# test MicroPython-specific features of array.array
|
# test MicroPython-specific features of array.array
|
||||||
try:
|
try:
|
||||||
import uarray as array
|
|
||||||
except ImportError:
|
|
||||||
try:
|
|
||||||
import array
|
import array
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print("SKIP")
|
print("SKIP")
|
||||||
raise SystemExit
|
raise SystemExit
|
||||||
|
|
||||||
|
@ -1,10 +1,7 @@
|
|||||||
# test bytes + other
|
# test bytes + other
|
||||||
try:
|
try:
|
||||||
import uarray as array
|
|
||||||
except ImportError:
|
|
||||||
try:
|
|
||||||
import array
|
import array
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print("SKIP")
|
print("SKIP")
|
||||||
raise SystemExit
|
raise SystemExit
|
||||||
|
|
||||||
|
@ -1,10 +1,7 @@
|
|||||||
# test bytes + other
|
# test bytes + other
|
||||||
try:
|
try:
|
||||||
import uarray as array
|
|
||||||
except ImportError:
|
|
||||||
try:
|
|
||||||
import array
|
import array
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print("SKIP")
|
print("SKIP")
|
||||||
raise SystemExit
|
raise SystemExit
|
||||||
|
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
try:
|
try:
|
||||||
import uarray as array
|
|
||||||
except ImportError:
|
|
||||||
try:
|
|
||||||
import array
|
import array
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print("SKIP")
|
print("SKIP")
|
||||||
raise SystemExit
|
raise SystemExit
|
||||||
|
|
||||||
|
@ -1,48 +1,48 @@
|
|||||||
# test that fixed dictionaries cannot be modified
|
# test that fixed dictionaries cannot be modified
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import uerrno
|
import errno
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print("SKIP")
|
print("SKIP")
|
||||||
raise SystemExit
|
raise SystemExit
|
||||||
|
|
||||||
# Save a copy of uerrno.errorcode, so we can check later
|
# Save a copy of errno.errorcode, so we can check later
|
||||||
# that it hasn't been modified.
|
# that it hasn't been modified.
|
||||||
errorcode_copy = uerrno.errorcode.copy()
|
errorcode_copy = errno.errorcode.copy()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
uerrno.errorcode.popitem()
|
errno.errorcode.popitem()
|
||||||
except TypeError:
|
except TypeError:
|
||||||
print("TypeError")
|
print("TypeError")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
uerrno.errorcode.pop(0)
|
errno.errorcode.pop(0)
|
||||||
except TypeError:
|
except TypeError:
|
||||||
print("TypeError")
|
print("TypeError")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
uerrno.errorcode.setdefault(0, 0)
|
errno.errorcode.setdefault(0, 0)
|
||||||
except TypeError:
|
except TypeError:
|
||||||
print("TypeError")
|
print("TypeError")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
uerrno.errorcode.update([(1, 2)])
|
errno.errorcode.update([(1, 2)])
|
||||||
except TypeError:
|
except TypeError:
|
||||||
print("TypeError")
|
print("TypeError")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
del uerrno.errorcode[1]
|
del errno.errorcode[1]
|
||||||
except TypeError:
|
except TypeError:
|
||||||
print("TypeError")
|
print("TypeError")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
uerrno.errorcode[1] = 'foo'
|
errno.errorcode[1] = 'foo'
|
||||||
except TypeError:
|
except TypeError:
|
||||||
print("TypeError")
|
print("TypeError")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
uerrno.errorcode.clear()
|
errno.errorcode.clear()
|
||||||
except TypeError:
|
except TypeError:
|
||||||
print("TypeError")
|
print("TypeError")
|
||||||
|
|
||||||
assert uerrno.errorcode == errorcode_copy
|
assert errno.errorcode == errorcode_copy
|
||||||
|
@ -1,25 +1,25 @@
|
|||||||
# test errno's and uerrno module
|
# test errno's and errno module
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import uerrno
|
import errno
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print("SKIP")
|
print("SKIP")
|
||||||
raise SystemExit
|
raise SystemExit
|
||||||
|
|
||||||
# check that constants exist and are integers
|
# check that constants exist and are integers
|
||||||
print(type(uerrno.EIO))
|
print(type(errno.EIO))
|
||||||
|
|
||||||
# check that errors are rendered in a nice way
|
# check that errors are rendered in a nice way
|
||||||
msg = str(OSError(uerrno.EIO))
|
msg = str(OSError(errno.EIO))
|
||||||
print(msg[:7], msg[-5:])
|
print(msg[:7], msg[-5:])
|
||||||
msg = str(OSError(uerrno.EIO, "details"))
|
msg = str(OSError(errno.EIO, "details"))
|
||||||
print(msg[:7], msg[-14:])
|
print(msg[:7], msg[-14:])
|
||||||
msg = str(OSError(uerrno.EIO, "details", "more details"))
|
msg = str(OSError(errno.EIO, "details", "more details"))
|
||||||
print(msg[:1], msg[-28:])
|
print(msg[:1], msg[-28:])
|
||||||
|
|
||||||
# check that unknown errno is still rendered
|
# check that unknown errno is still rendered
|
||||||
print(str(OSError(9999)))
|
print(str(OSError(9999)))
|
||||||
|
|
||||||
# this tests a failed constant lookup in errno
|
# this tests a failed constant lookup in errno
|
||||||
errno = uerrno
|
errno = errno
|
||||||
print(errno.__name__)
|
print(errno.__name__)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import uio as io
|
import io
|
||||||
|
|
||||||
try:
|
try:
|
||||||
io.BytesIO
|
io.BytesIO
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
# Make sure that write operations on io.BytesIO don't
|
# Make sure that write operations on io.BytesIO don't
|
||||||
# change original object it was constructed from.
|
# change original object it was constructed from.
|
||||||
try:
|
import io
|
||||||
import uio as io
|
|
||||||
except ImportError:
|
|
||||||
import io
|
|
||||||
|
|
||||||
b = b"foobar"
|
b = b"foobar"
|
||||||
|
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
# Extended stream operations on io.BytesIO
|
# Extended stream operations on io.BytesIO
|
||||||
try:
|
import io
|
||||||
import uio as io
|
|
||||||
except ImportError:
|
|
||||||
import io
|
|
||||||
|
|
||||||
a = io.BytesIO(b"foobar")
|
a = io.BytesIO(b"foobar")
|
||||||
a.seek(10)
|
a.seek(10)
|
||||||
|
@ -1,7 +1,4 @@
|
|||||||
try:
|
import io
|
||||||
import uio as io
|
|
||||||
except ImportError:
|
|
||||||
import io
|
|
||||||
|
|
||||||
a = io.BytesIO(b"foobar")
|
a = io.BytesIO(b"foobar")
|
||||||
try:
|
try:
|
||||||
|
@ -1,7 +1,4 @@
|
|||||||
try:
|
import io
|
||||||
import uio as io
|
|
||||||
except:
|
|
||||||
import io
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
io.IOBase
|
io.IOBase
|
||||||
|
@ -1,7 +1,4 @@
|
|||||||
try:
|
import io
|
||||||
import uio as io
|
|
||||||
except ImportError:
|
|
||||||
import io
|
|
||||||
|
|
||||||
a = io.StringIO()
|
a = io.StringIO()
|
||||||
print("io.StringIO" in repr(a))
|
print("io.StringIO" in repr(a))
|
||||||
|
@ -1,7 +1,4 @@
|
|||||||
try:
|
import io
|
||||||
import uio as io
|
|
||||||
except ImportError:
|
|
||||||
import io
|
|
||||||
|
|
||||||
# test __enter__/__exit__
|
# test __enter__/__exit__
|
||||||
with io.StringIO() as b:
|
with io.StringIO() as b:
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
# This tests extended (MicroPython-specific) form of write:
|
# This tests extended (MicroPython-specific) form of write:
|
||||||
# write(buf, len) and write(buf, offset, len)
|
# write(buf, len) and write(buf, offset, len)
|
||||||
import uio
|
import io
|
||||||
|
|
||||||
try:
|
try:
|
||||||
uio.BytesIO
|
io.BytesIO
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
print("SKIP")
|
print("SKIP")
|
||||||
raise SystemExit
|
raise SystemExit
|
||||||
|
|
||||||
buf = uio.BytesIO()
|
buf = io.BytesIO()
|
||||||
|
|
||||||
buf.write(b"foo", 2)
|
buf.write(b"foo", 2)
|
||||||
print(buf.getvalue())
|
print(buf.getvalue())
|
||||||
|
@ -5,11 +5,8 @@ except:
|
|||||||
print("SKIP")
|
print("SKIP")
|
||||||
raise SystemExit
|
raise SystemExit
|
||||||
try:
|
try:
|
||||||
import uarray as array
|
|
||||||
except ImportError:
|
|
||||||
try:
|
|
||||||
import array
|
import array
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print("SKIP")
|
print("SKIP")
|
||||||
raise SystemExit
|
raise SystemExit
|
||||||
|
|
||||||
|
@ -7,11 +7,8 @@ except (NameError, TypeError):
|
|||||||
raise SystemExit
|
raise SystemExit
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import uarray as array
|
|
||||||
except ImportError:
|
|
||||||
try:
|
|
||||||
import array
|
import array
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print("SKIP")
|
print("SKIP")
|
||||||
raise SystemExit
|
raise SystemExit
|
||||||
|
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
try:
|
try:
|
||||||
import ustruct as struct
|
|
||||||
except:
|
|
||||||
try:
|
|
||||||
import struct
|
import struct
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print("SKIP")
|
print("SKIP")
|
||||||
raise SystemExit
|
raise SystemExit
|
||||||
|
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
try:
|
try:
|
||||||
import ustruct as struct
|
|
||||||
except:
|
|
||||||
try:
|
|
||||||
import struct
|
import struct
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print("SKIP")
|
print("SKIP")
|
||||||
raise SystemExit
|
raise SystemExit
|
||||||
|
|
||||||
|
@ -1,11 +1,8 @@
|
|||||||
# test ustruct with a count specified before the type
|
# test ustruct with a count specified before the type
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import ustruct as struct
|
|
||||||
except:
|
|
||||||
try:
|
|
||||||
import struct
|
import struct
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print("SKIP")
|
print("SKIP")
|
||||||
raise SystemExit
|
raise SystemExit
|
||||||
|
|
||||||
|
@ -1,11 +1,8 @@
|
|||||||
# test ustruct and endian specific things
|
# test ustruct and endian specific things
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import ustruct as struct
|
|
||||||
except:
|
|
||||||
try:
|
|
||||||
import struct
|
import struct
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print("SKIP")
|
print("SKIP")
|
||||||
raise SystemExit
|
raise SystemExit
|
||||||
|
|
||||||
|
@ -2,11 +2,8 @@ import skip_if
|
|||||||
skip_if.no_bigint()
|
skip_if.no_bigint()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import ustruct as struct
|
|
||||||
except:
|
|
||||||
try:
|
|
||||||
import struct
|
import struct
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print("SKIP")
|
print("SKIP")
|
||||||
raise SystemExit
|
raise SystemExit
|
||||||
|
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
# test sys.path
|
# test sys.path
|
||||||
|
|
||||||
try:
|
import sys
|
||||||
import usys as sys
|
|
||||||
except ImportError:
|
|
||||||
import sys
|
|
||||||
|
|
||||||
# check that this script was executed from a file of the same name
|
# check that this script was executed from a file of the same name
|
||||||
if "__file__" not in globals() or "sys_path.py" not in __file__:
|
if "__file__" not in globals() or "sys_path.py" not in __file__:
|
||||||
|
@ -1,10 +1,6 @@
|
|||||||
# test sys.tracebacklimit
|
# test sys.tracebacklimit
|
||||||
|
|
||||||
try:
|
try:
|
||||||
try:
|
|
||||||
import usys as sys
|
|
||||||
import uio as io
|
|
||||||
except ImportError:
|
|
||||||
import sys
|
import sys
|
||||||
import io
|
import io
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
@ -1,35 +1,35 @@
|
|||||||
Traceback (most recent call last):
|
Traceback (most recent call last):
|
||||||
File , line 62, in ftop
|
File , line 58, in ftop
|
||||||
File , line 57, in f3
|
File , line 53, in f3
|
||||||
File , line 53, in f2
|
File , line 49, in f2
|
||||||
File , line 49, in f1
|
File , line 45, in f1
|
||||||
File , line 45, in f0
|
File , line 41, in f0
|
||||||
ValueError: value
|
ValueError: value
|
||||||
|
|
||||||
limit 4
|
limit 4
|
||||||
Traceback (most recent call last):
|
Traceback (most recent call last):
|
||||||
File , line 62, in ftop
|
File , line 58, in ftop
|
||||||
File , line 57, in f3
|
File , line 53, in f3
|
||||||
File , line 53, in f2
|
File , line 49, in f2
|
||||||
File , line 49, in f1
|
File , line 45, in f1
|
||||||
ValueError: value
|
ValueError: value
|
||||||
|
|
||||||
limit 3
|
limit 3
|
||||||
Traceback (most recent call last):
|
Traceback (most recent call last):
|
||||||
File , line 62, in ftop
|
File , line 58, in ftop
|
||||||
File , line 57, in f3
|
File , line 53, in f3
|
||||||
File , line 53, in f2
|
File , line 49, in f2
|
||||||
ValueError: value
|
ValueError: value
|
||||||
|
|
||||||
limit 2
|
limit 2
|
||||||
Traceback (most recent call last):
|
Traceback (most recent call last):
|
||||||
File , line 62, in ftop
|
File , line 58, in ftop
|
||||||
File , line 57, in f3
|
File , line 53, in f3
|
||||||
ValueError: value
|
ValueError: value
|
||||||
|
|
||||||
limit 1
|
limit 1
|
||||||
Traceback (most recent call last):
|
Traceback (most recent call last):
|
||||||
File , line 62, in ftop
|
File , line 58, in ftop
|
||||||
ValueError: value
|
ValueError: value
|
||||||
|
|
||||||
limit 0
|
limit 0
|
||||||
|
@ -2,10 +2,7 @@ import ulab.numpy as np
|
|||||||
import displayio
|
import displayio
|
||||||
import bitmaptools
|
import bitmaptools
|
||||||
|
|
||||||
try:
|
import struct
|
||||||
import struct
|
|
||||||
except:
|
|
||||||
import ustruct as struct
|
|
||||||
|
|
||||||
base_header = b"BMFX\x02\x00\x00\x00\x00\x00F\x00\x00\x008\x00\x00\x00@\x01\x00\x00\xf0\x00\x00\x00\x01\x00\x10\x00\x03\x00\x00\x00\x00X\x02\x00\xd7\r\x00\x00\xd7\r\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xf8\x00\x00\xe0\x07\x00\x00\x1f\x00\x00\x00\x00\x00\x00\x00"
|
base_header = b"BMFX\x02\x00\x00\x00\x00\x00F\x00\x00\x008\x00\x00\x00@\x01\x00\x00\xf0\x00\x00\x00\x01\x00\x10\x00\x03\x00\x00\x00\x00X\x02\x00\xd7\r\x00\x00\xd7\r\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xf8\x00\x00\xe0\x07\x00\x00\x1f\x00\x00\x00\x00\x00\x00\x00"
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import uos
|
import os
|
||||||
|
|
||||||
uos.umount("/")
|
os.umount("/")
|
||||||
|
|
||||||
|
|
||||||
class RAMBlockDevice:
|
class RAMBlockDevice:
|
||||||
@ -32,8 +32,8 @@ class RAMBlockDevice:
|
|||||||
|
|
||||||
|
|
||||||
bdev = RAMBlockDevice(64)
|
bdev = RAMBlockDevice(64)
|
||||||
uos.VfsFat.mkfs(bdev)
|
os.VfsFat.mkfs(bdev)
|
||||||
uos.mount(uos.VfsFat(bdev), "/")
|
os.mount(os.VfsFat(bdev), "/")
|
||||||
|
|
||||||
content_good = b"""
|
content_good = b"""
|
||||||
# comment
|
# comment
|
||||||
@ -66,7 +66,7 @@ def run_test(key, content):
|
|||||||
f.write(content)
|
f.write(content)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
v = uos.getenv(key)
|
v = os.getenv(key)
|
||||||
print(key, repr(v))
|
print(key, repr(v))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(key, str(e))
|
print(key, str(e))
|
||||||
@ -82,7 +82,7 @@ for i in range(13):
|
|||||||
run_test(f"key{i}", content_good)
|
run_test(f"key{i}", content_good)
|
||||||
|
|
||||||
run_test(f"K", b"K = 7\r\n")
|
run_test(f"K", b"K = 7\r\n")
|
||||||
print(uos.getenv_int("K"))
|
print(os.getenv_int("K"))
|
||||||
|
|
||||||
# Test value without trailing newline
|
# Test value without trailing newline
|
||||||
run_test(f"noeol", b"noeol=3")
|
run_test(f"noeol", b"noeol=3")
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
try:
|
try:
|
||||||
import zlib
|
import zlib
|
||||||
except ImportError:
|
except ImportError:
|
||||||
try:
|
|
||||||
import zlib as zlib
|
|
||||||
except ImportError:
|
|
||||||
print("SKIP")
|
print("SKIP")
|
||||||
raise SystemExit
|
raise SystemExit
|
||||||
|
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
import uos
|
import os
|
||||||
|
|
||||||
uos.putenv('MICROPYINSPECT', '1')
|
os.putenv('MICROPYINSPECT', '1')
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
# test changing ps1/ps2
|
# test changing ps1/ps2
|
||||||
import usys
|
import sys
|
||||||
usys.ps1 = "PS1"
|
sys.ps1 = "PS1"
|
||||||
usys.ps2 = "PS2"
|
sys.ps2 = "PS2"
|
||||||
(1 +
|
(1 +
|
||||||
2)
|
2)
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
MicroPython \.\+ version
|
MicroPython \.\+ version
|
||||||
Use \.\+
|
Use \.\+
|
||||||
>>> # test changing ps1/ps2
|
>>> # test changing ps1/ps2
|
||||||
>>> import usys
|
>>> import sys
|
||||||
>>> usys.ps1 = "PS1"
|
>>> sys.ps1 = "PS1"
|
||||||
PS1usys.ps2 = "PS2"
|
PS1sys.ps2 = "PS2"
|
||||||
PS1(1 +
|
PS1(1 +
|
||||||
PS22)
|
PS22)
|
||||||
3
|
3
|
||||||
|
@ -1,89 +0,0 @@
|
|||||||
try:
|
|
||||||
import btree
|
|
||||||
import uio
|
|
||||||
import uerrno
|
|
||||||
except ImportError:
|
|
||||||
print("SKIP")
|
|
||||||
raise SystemExit
|
|
||||||
|
|
||||||
# f = open("_test.db", "w+b")
|
|
||||||
f = uio.BytesIO()
|
|
||||||
db = btree.open(f, pagesize=512)
|
|
||||||
|
|
||||||
db[b"foo3"] = b"bar3"
|
|
||||||
db[b"foo1"] = b"bar1"
|
|
||||||
db[b"foo2"] = b"bar2"
|
|
||||||
db[b"bar1"] = b"foo1"
|
|
||||||
|
|
||||||
dbstr = str(db)
|
|
||||||
print(dbstr[:7], dbstr[-1:])
|
|
||||||
|
|
||||||
print(db[b"foo2"])
|
|
||||||
try:
|
|
||||||
print(db[b"foo"])
|
|
||||||
except KeyError:
|
|
||||||
print("KeyError")
|
|
||||||
print(db.get(b"foo"))
|
|
||||||
print(db.get(b"foo", b"dflt"))
|
|
||||||
|
|
||||||
del db[b"foo2"]
|
|
||||||
try:
|
|
||||||
del db[b"foo"]
|
|
||||||
except KeyError:
|
|
||||||
print("KeyError")
|
|
||||||
|
|
||||||
for k, v in db.items():
|
|
||||||
print((k, v))
|
|
||||||
|
|
||||||
print("---")
|
|
||||||
for k, v in db.items(None, None):
|
|
||||||
print((k, v))
|
|
||||||
|
|
||||||
print("---")
|
|
||||||
for k, v in db.items(b"f"):
|
|
||||||
print((k, v))
|
|
||||||
|
|
||||||
print("---")
|
|
||||||
for k, v in db.items(b"f", b"foo3"):
|
|
||||||
print((k, v))
|
|
||||||
|
|
||||||
print("---")
|
|
||||||
for k, v in db.items(None, b"foo3"):
|
|
||||||
print((k, v))
|
|
||||||
|
|
||||||
print("---")
|
|
||||||
for k, v in db.items(b"f", b"foo3", btree.INCL):
|
|
||||||
print((k, v))
|
|
||||||
|
|
||||||
print("---")
|
|
||||||
for k, v in db.items(None, None, btree.DESC):
|
|
||||||
print((k, v))
|
|
||||||
|
|
||||||
print(db.seq(1, b"foo1"))
|
|
||||||
print(db.seq(1, b"qux"))
|
|
||||||
|
|
||||||
try:
|
|
||||||
db.seq(b"foo1")
|
|
||||||
except OSError as e:
|
|
||||||
print(e.errno == uerrno.EINVAL)
|
|
||||||
|
|
||||||
print(list(db.keys()))
|
|
||||||
print(list(db.values()))
|
|
||||||
|
|
||||||
for k in db:
|
|
||||||
print(k)
|
|
||||||
|
|
||||||
db.put(b"baz1", b"qux1")
|
|
||||||
|
|
||||||
print("foo1", "foo1" in db)
|
|
||||||
print("foo2", "foo2" in db)
|
|
||||||
print("baz1", "baz1" in db)
|
|
||||||
|
|
||||||
try:
|
|
||||||
print(db + db[b"foo1"])
|
|
||||||
except TypeError:
|
|
||||||
print("TypeError")
|
|
||||||
|
|
||||||
db.flush()
|
|
||||||
db.close()
|
|
||||||
f.close()
|
|
@ -1,40 +0,0 @@
|
|||||||
<btree >
|
|
||||||
b'bar2'
|
|
||||||
KeyError
|
|
||||||
None
|
|
||||||
b'dflt'
|
|
||||||
KeyError
|
|
||||||
(b'bar1', b'foo1')
|
|
||||||
(b'foo1', b'bar1')
|
|
||||||
(b'foo3', b'bar3')
|
|
||||||
---
|
|
||||||
(b'bar1', b'foo1')
|
|
||||||
(b'foo1', b'bar1')
|
|
||||||
(b'foo3', b'bar3')
|
|
||||||
---
|
|
||||||
(b'foo1', b'bar1')
|
|
||||||
(b'foo3', b'bar3')
|
|
||||||
---
|
|
||||||
(b'foo1', b'bar1')
|
|
||||||
---
|
|
||||||
(b'bar1', b'foo1')
|
|
||||||
(b'foo1', b'bar1')
|
|
||||||
---
|
|
||||||
(b'foo1', b'bar1')
|
|
||||||
(b'foo3', b'bar3')
|
|
||||||
---
|
|
||||||
(b'foo3', b'bar3')
|
|
||||||
(b'foo1', b'bar1')
|
|
||||||
(b'bar1', b'foo1')
|
|
||||||
(b'foo1', b'bar1')
|
|
||||||
None
|
|
||||||
True
|
|
||||||
[b'bar1', b'foo1', b'foo3']
|
|
||||||
[b'foo1', b'bar1', b'bar3']
|
|
||||||
b'bar1'
|
|
||||||
b'foo1'
|
|
||||||
b'foo3'
|
|
||||||
foo1 True
|
|
||||||
foo2 False
|
|
||||||
baz1 True
|
|
||||||
TypeError
|
|
@ -1,42 +0,0 @@
|
|||||||
# Test that errno's propagate correctly through btree module.
|
|
||||||
|
|
||||||
try:
|
|
||||||
import btree, uio, uerrno
|
|
||||||
|
|
||||||
uio.IOBase
|
|
||||||
except (ImportError, AttributeError):
|
|
||||||
print("SKIP")
|
|
||||||
raise SystemExit
|
|
||||||
|
|
||||||
|
|
||||||
class Device(uio.IOBase):
|
|
||||||
def __init__(self, read_ret=0, ioctl_ret=0):
|
|
||||||
self.read_ret = read_ret
|
|
||||||
self.ioctl_ret = ioctl_ret
|
|
||||||
|
|
||||||
def readinto(self, buf):
|
|
||||||
print("read", len(buf))
|
|
||||||
return self.read_ret
|
|
||||||
|
|
||||||
def ioctl(self, cmd, arg):
|
|
||||||
print("ioctl", cmd)
|
|
||||||
return self.ioctl_ret
|
|
||||||
|
|
||||||
|
|
||||||
# Invalid pagesize; errno comes from btree library
|
|
||||||
try:
|
|
||||||
db = btree.open(Device(), pagesize=511)
|
|
||||||
except OSError as er:
|
|
||||||
print("OSError", er.errno == uerrno.EINVAL)
|
|
||||||
|
|
||||||
# Valid pagesize, device returns error on read; errno comes from Device.readinto
|
|
||||||
try:
|
|
||||||
db = btree.open(Device(-1000), pagesize=512)
|
|
||||||
except OSError as er:
|
|
||||||
print(repr(er))
|
|
||||||
|
|
||||||
# Valid pagesize, device returns error on seek; errno comes from Device.ioctl
|
|
||||||
try:
|
|
||||||
db = btree.open(Device(0, -1001), pagesize=512)
|
|
||||||
except OSError as er:
|
|
||||||
print(repr(er))
|
|
@ -1,6 +0,0 @@
|
|||||||
OSError True
|
|
||||||
read 24
|
|
||||||
OSError(1000,)
|
|
||||||
read 24
|
|
||||||
ioctl 2
|
|
||||||
OSError(1001,)
|
|
@ -1,26 +0,0 @@
|
|||||||
# Test btree interaction with the garbage collector.
|
|
||||||
|
|
||||||
try:
|
|
||||||
import btree, uio, gc
|
|
||||||
except ImportError:
|
|
||||||
print("SKIP")
|
|
||||||
raise SystemExit
|
|
||||||
|
|
||||||
N = 80
|
|
||||||
|
|
||||||
# Create a BytesIO but don't keep a reference to it.
|
|
||||||
db = btree.open(uio.BytesIO(), pagesize=512)
|
|
||||||
|
|
||||||
# Overwrite lots of the Python stack to make sure no reference to the BytesIO remains.
|
|
||||||
x = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
|
|
||||||
|
|
||||||
# Write lots of key/value pairs, which fill up the DB and also allocate temporary heap
|
|
||||||
# memory due to the string addition, and do a GC collect to verify that the BytesIO
|
|
||||||
# is not collected.
|
|
||||||
for i in range(N):
|
|
||||||
db[b"thekey" + str(i)] = b"thelongvalue" + str(i)
|
|
||||||
print(db[b"thekey" + str(i)])
|
|
||||||
gc.collect()
|
|
||||||
|
|
||||||
# Reclaim memory allocated by the db object.
|
|
||||||
db.close()
|
|
@ -1,80 +0,0 @@
|
|||||||
b'thelongvalue0'
|
|
||||||
b'thelongvalue1'
|
|
||||||
b'thelongvalue2'
|
|
||||||
b'thelongvalue3'
|
|
||||||
b'thelongvalue4'
|
|
||||||
b'thelongvalue5'
|
|
||||||
b'thelongvalue6'
|
|
||||||
b'thelongvalue7'
|
|
||||||
b'thelongvalue8'
|
|
||||||
b'thelongvalue9'
|
|
||||||
b'thelongvalue10'
|
|
||||||
b'thelongvalue11'
|
|
||||||
b'thelongvalue12'
|
|
||||||
b'thelongvalue13'
|
|
||||||
b'thelongvalue14'
|
|
||||||
b'thelongvalue15'
|
|
||||||
b'thelongvalue16'
|
|
||||||
b'thelongvalue17'
|
|
||||||
b'thelongvalue18'
|
|
||||||
b'thelongvalue19'
|
|
||||||
b'thelongvalue20'
|
|
||||||
b'thelongvalue21'
|
|
||||||
b'thelongvalue22'
|
|
||||||
b'thelongvalue23'
|
|
||||||
b'thelongvalue24'
|
|
||||||
b'thelongvalue25'
|
|
||||||
b'thelongvalue26'
|
|
||||||
b'thelongvalue27'
|
|
||||||
b'thelongvalue28'
|
|
||||||
b'thelongvalue29'
|
|
||||||
b'thelongvalue30'
|
|
||||||
b'thelongvalue31'
|
|
||||||
b'thelongvalue32'
|
|
||||||
b'thelongvalue33'
|
|
||||||
b'thelongvalue34'
|
|
||||||
b'thelongvalue35'
|
|
||||||
b'thelongvalue36'
|
|
||||||
b'thelongvalue37'
|
|
||||||
b'thelongvalue38'
|
|
||||||
b'thelongvalue39'
|
|
||||||
b'thelongvalue40'
|
|
||||||
b'thelongvalue41'
|
|
||||||
b'thelongvalue42'
|
|
||||||
b'thelongvalue43'
|
|
||||||
b'thelongvalue44'
|
|
||||||
b'thelongvalue45'
|
|
||||||
b'thelongvalue46'
|
|
||||||
b'thelongvalue47'
|
|
||||||
b'thelongvalue48'
|
|
||||||
b'thelongvalue49'
|
|
||||||
b'thelongvalue50'
|
|
||||||
b'thelongvalue51'
|
|
||||||
b'thelongvalue52'
|
|
||||||
b'thelongvalue53'
|
|
||||||
b'thelongvalue54'
|
|
||||||
b'thelongvalue55'
|
|
||||||
b'thelongvalue56'
|
|
||||||
b'thelongvalue57'
|
|
||||||
b'thelongvalue58'
|
|
||||||
b'thelongvalue59'
|
|
||||||
b'thelongvalue60'
|
|
||||||
b'thelongvalue61'
|
|
||||||
b'thelongvalue62'
|
|
||||||
b'thelongvalue63'
|
|
||||||
b'thelongvalue64'
|
|
||||||
b'thelongvalue65'
|
|
||||||
b'thelongvalue66'
|
|
||||||
b'thelongvalue67'
|
|
||||||
b'thelongvalue68'
|
|
||||||
b'thelongvalue69'
|
|
||||||
b'thelongvalue70'
|
|
||||||
b'thelongvalue71'
|
|
||||||
b'thelongvalue72'
|
|
||||||
b'thelongvalue73'
|
|
||||||
b'thelongvalue74'
|
|
||||||
b'thelongvalue75'
|
|
||||||
b'thelongvalue76'
|
|
||||||
b'thelongvalue77'
|
|
||||||
b'thelongvalue78'
|
|
||||||
b'thelongvalue79'
|
|
@ -1,111 +0,0 @@
|
|||||||
try:
|
|
||||||
import framebuf
|
|
||||||
except ImportError:
|
|
||||||
print("SKIP")
|
|
||||||
raise SystemExit
|
|
||||||
|
|
||||||
w = 5
|
|
||||||
h = 16
|
|
||||||
size = w * h // 8
|
|
||||||
buf = bytearray(size)
|
|
||||||
maps = {
|
|
||||||
framebuf.MONO_VLSB: "MONO_VLSB",
|
|
||||||
framebuf.MONO_HLSB: "MONO_HLSB",
|
|
||||||
framebuf.MONO_HMSB: "MONO_HMSB",
|
|
||||||
}
|
|
||||||
|
|
||||||
for mapping in maps.keys():
|
|
||||||
for x in range(size):
|
|
||||||
buf[x] = 0
|
|
||||||
fbuf = framebuf.FrameBuffer(buf, w, h, mapping)
|
|
||||||
print(maps[mapping])
|
|
||||||
# access as buffer
|
|
||||||
print(memoryview(fbuf)[0])
|
|
||||||
|
|
||||||
# fill
|
|
||||||
fbuf.fill(1)
|
|
||||||
print(buf)
|
|
||||||
fbuf.fill(0)
|
|
||||||
print(buf)
|
|
||||||
|
|
||||||
# put pixel
|
|
||||||
fbuf.pixel(0, 0, 1)
|
|
||||||
fbuf.pixel(4, 0, 1)
|
|
||||||
fbuf.pixel(0, 15, 1)
|
|
||||||
fbuf.pixel(4, 15, 1)
|
|
||||||
print(buf)
|
|
||||||
|
|
||||||
# clear pixel
|
|
||||||
fbuf.pixel(4, 15, 0)
|
|
||||||
print(buf)
|
|
||||||
|
|
||||||
# get pixel
|
|
||||||
print(fbuf.pixel(0, 0), fbuf.pixel(1, 1))
|
|
||||||
|
|
||||||
# hline
|
|
||||||
fbuf.fill(0)
|
|
||||||
fbuf.hline(0, 1, w, 1)
|
|
||||||
print("hline", buf)
|
|
||||||
|
|
||||||
# vline
|
|
||||||
fbuf.fill(0)
|
|
||||||
fbuf.vline(1, 0, h, 1)
|
|
||||||
print("vline", buf)
|
|
||||||
|
|
||||||
# rect
|
|
||||||
fbuf.fill(0)
|
|
||||||
fbuf.rect(1, 1, 3, 3, 1)
|
|
||||||
print("rect", buf)
|
|
||||||
|
|
||||||
# fill rect
|
|
||||||
fbuf.fill(0)
|
|
||||||
fbuf.fill_rect(0, 0, 0, 3, 1) # zero width, no-operation
|
|
||||||
fbuf.fill_rect(1, 1, 3, 3, 1)
|
|
||||||
print("fill_rect", buf)
|
|
||||||
|
|
||||||
# line
|
|
||||||
fbuf.fill(0)
|
|
||||||
fbuf.line(1, 1, 3, 3, 1)
|
|
||||||
print("line", buf)
|
|
||||||
|
|
||||||
# line steep negative gradient
|
|
||||||
fbuf.fill(0)
|
|
||||||
fbuf.line(3, 3, 2, 1, 1)
|
|
||||||
print("line", buf)
|
|
||||||
|
|
||||||
# scroll
|
|
||||||
fbuf.fill(0)
|
|
||||||
fbuf.pixel(2, 7, 1)
|
|
||||||
fbuf.scroll(0, 1)
|
|
||||||
print(buf)
|
|
||||||
fbuf.scroll(0, -2)
|
|
||||||
print(buf)
|
|
||||||
fbuf.scroll(1, 0)
|
|
||||||
print(buf)
|
|
||||||
fbuf.scroll(-1, 0)
|
|
||||||
print(buf)
|
|
||||||
fbuf.scroll(2, 2)
|
|
||||||
print(buf)
|
|
||||||
|
|
||||||
# print text
|
|
||||||
fbuf.fill(0)
|
|
||||||
fbuf.text("hello", 0, 0, 1)
|
|
||||||
print(buf)
|
|
||||||
fbuf.text("hello", 0, 0, 0) # clear
|
|
||||||
print(buf)
|
|
||||||
|
|
||||||
# char out of font range set to chr(127)
|
|
||||||
fbuf.text(str(chr(31)), 0, 0)
|
|
||||||
print(buf)
|
|
||||||
print()
|
|
||||||
|
|
||||||
# test invalid constructor, and stride argument
|
|
||||||
try:
|
|
||||||
fbuf = framebuf.FrameBuffer(buf, w, h, -1, w)
|
|
||||||
except ValueError:
|
|
||||||
print("ValueError")
|
|
||||||
|
|
||||||
# test legacy constructor
|
|
||||||
fbuf = framebuf.FrameBuffer1(buf, w, h)
|
|
||||||
fbuf = framebuf.FrameBuffer1(buf, w, h, w)
|
|
||||||
print(framebuf.MVLSB == framebuf.MONO_VLSB)
|
|
@ -1,68 +0,0 @@
|
|||||||
MONO_VLSB
|
|
||||||
0
|
|
||||||
bytearray(b'\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff')
|
|
||||||
bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
|
|
||||||
bytearray(b'\x01\x00\x00\x00\x01\x80\x00\x00\x00\x80')
|
|
||||||
bytearray(b'\x01\x00\x00\x00\x01\x80\x00\x00\x00\x00')
|
|
||||||
1 0
|
|
||||||
hline bytearray(b'\x02\x02\x02\x02\x02\x00\x00\x00\x00\x00')
|
|
||||||
vline bytearray(b'\x00\xff\x00\x00\x00\x00\xff\x00\x00\x00')
|
|
||||||
rect bytearray(b'\x00\x0e\n\x0e\x00\x00\x00\x00\x00\x00')
|
|
||||||
fill_rect bytearray(b'\x00\x0e\x0e\x0e\x00\x00\x00\x00\x00\x00')
|
|
||||||
line bytearray(b'\x00\x02\x04\x08\x00\x00\x00\x00\x00\x00')
|
|
||||||
line bytearray(b'\x00\x00\x06\x08\x00\x00\x00\x00\x00\x00')
|
|
||||||
bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00')
|
|
||||||
bytearray(b'\x00\x00@\x00\x00\x00\x00\x00\x00\x00')
|
|
||||||
bytearray(b'\x00\x00\x00@\x00\x00\x00\x00\x00\x00')
|
|
||||||
bytearray(b'\x00\x00@\x00\x00\x00\x00\x00\x00\x00')
|
|
||||||
bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01')
|
|
||||||
bytearray(b'\x00\x7f\x7f\x04\x04\x00\x00\x00\x00\x00')
|
|
||||||
bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
|
|
||||||
bytearray(b'\xaaU\xaaU\xaa\x00\x00\x00\x00\x00')
|
|
||||||
|
|
||||||
MONO_HLSB
|
|
||||||
0
|
|
||||||
bytearray(b'\xf8\xf8\xf8\xf8\xf8\xf8\xf8\xf8\xf8\xf8')
|
|
||||||
bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
|
|
||||||
bytearray(b'\x88\x00\x00\x00\x00\x00\x00\x00\x00\x00')
|
|
||||||
bytearray(b'\x88\x00\x00\x00\x00\x00\x00\x00\x00\x00')
|
|
||||||
1 0
|
|
||||||
hline bytearray(b'\x00\xf8\x00\x00\x00\x00\x00\x00\x00\x00')
|
|
||||||
vline bytearray(b'@@@@@@@@@@')
|
|
||||||
rect bytearray(b'\x00pPp\x00\x00\x00\x00\x00\x00')
|
|
||||||
fill_rect bytearray(b'\x00ppp\x00\x00\x00\x00\x00\x00')
|
|
||||||
line bytearray(b'\x00@ \x10\x00\x00\x00\x00\x00\x00')
|
|
||||||
line bytearray(b'\x00 \x10\x00\x00\x00\x00\x00\x00')
|
|
||||||
bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00 \x00')
|
|
||||||
bytearray(b'\x00\x00\x00\x00\x00\x00 \x00\x00\x00')
|
|
||||||
bytearray(b'\x00\x00\x00\x00\x00\x00\x10\x00\x00\x00')
|
|
||||||
bytearray(b'\x00\x00\x00\x00\x00\x00 \x00\x00\x00')
|
|
||||||
bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00\x08\x00')
|
|
||||||
bytearray(b'``x````\x00\x00\x00')
|
|
||||||
bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
|
|
||||||
bytearray(b'P\xa8P\xa8P\xa8P\xa8\x00\x00')
|
|
||||||
|
|
||||||
MONO_HMSB
|
|
||||||
0
|
|
||||||
bytearray(b'\x1f\x1f\x1f\x1f\x1f\x1f\x1f\x1f\x1f\x1f')
|
|
||||||
bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
|
|
||||||
bytearray(b'\x11\x00\x00\x00\x00\x00\x00\x00\x00\x00')
|
|
||||||
bytearray(b'\x11\x00\x00\x00\x00\x00\x00\x00\x00\x00')
|
|
||||||
1 0
|
|
||||||
hline bytearray(b'\x00\x1f\x00\x00\x00\x00\x00\x00\x00\x00')
|
|
||||||
vline bytearray(b'\x02\x02\x02\x02\x02\x02\x02\x02\x02\x02')
|
|
||||||
rect bytearray(b'\x00\x0e\n\x0e\x00\x00\x00\x00\x00\x00')
|
|
||||||
fill_rect bytearray(b'\x00\x0e\x0e\x0e\x00\x00\x00\x00\x00\x00')
|
|
||||||
line bytearray(b'\x00\x02\x04\x08\x00\x00\x00\x00\x00\x00')
|
|
||||||
line bytearray(b'\x00\x04\x04\x08\x00\x00\x00\x00\x00\x00')
|
|
||||||
bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00\x04\x00')
|
|
||||||
bytearray(b'\x00\x00\x00\x00\x00\x00\x04\x00\x00\x00')
|
|
||||||
bytearray(b'\x00\x00\x00\x00\x00\x00\x08\x00\x00\x00')
|
|
||||||
bytearray(b'\x00\x00\x00\x00\x00\x00\x04\x00\x00\x00')
|
|
||||||
bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00\x10\x00')
|
|
||||||
bytearray(b'\x06\x06\x1e\x06\x06\x06\x06\x00\x00\x00')
|
|
||||||
bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
|
|
||||||
bytearray(b'\n\x15\n\x15\n\x15\n\x15\x00\x00')
|
|
||||||
|
|
||||||
ValueError
|
|
||||||
True
|
|
@ -1,66 +0,0 @@
|
|||||||
try:
|
|
||||||
import framebuf, usys
|
|
||||||
except ImportError:
|
|
||||||
print("SKIP")
|
|
||||||
raise SystemExit
|
|
||||||
|
|
||||||
# This test and its .exp file is based on a little-endian architecture.
|
|
||||||
if usys.byteorder != "little":
|
|
||||||
print("SKIP")
|
|
||||||
raise SystemExit
|
|
||||||
|
|
||||||
|
|
||||||
def printbuf():
|
|
||||||
print("--8<--")
|
|
||||||
for y in range(h):
|
|
||||||
print(buf[y * w * 2 : (y + 1) * w * 2])
|
|
||||||
print("-->8--")
|
|
||||||
|
|
||||||
|
|
||||||
w = 4
|
|
||||||
h = 5
|
|
||||||
buf = bytearray(w * h * 2)
|
|
||||||
fbuf = framebuf.FrameBuffer(buf, w, h, framebuf.RGB565)
|
|
||||||
|
|
||||||
# fill
|
|
||||||
fbuf.fill(0xFFFF)
|
|
||||||
printbuf()
|
|
||||||
fbuf.fill(0x0000)
|
|
||||||
printbuf()
|
|
||||||
|
|
||||||
# put pixel
|
|
||||||
fbuf.pixel(0, 0, 0xEEEE)
|
|
||||||
fbuf.pixel(3, 0, 0xEE00)
|
|
||||||
fbuf.pixel(0, 4, 0x00EE)
|
|
||||||
fbuf.pixel(3, 4, 0x0EE0)
|
|
||||||
printbuf()
|
|
||||||
|
|
||||||
# get pixel
|
|
||||||
print(fbuf.pixel(0, 4), fbuf.pixel(1, 1))
|
|
||||||
|
|
||||||
# scroll
|
|
||||||
fbuf.fill(0x0000)
|
|
||||||
fbuf.pixel(2, 2, 0xFFFF)
|
|
||||||
printbuf()
|
|
||||||
fbuf.scroll(0, 1)
|
|
||||||
printbuf()
|
|
||||||
fbuf.scroll(1, 0)
|
|
||||||
printbuf()
|
|
||||||
fbuf.scroll(-1, -2)
|
|
||||||
printbuf()
|
|
||||||
|
|
||||||
w2 = 2
|
|
||||||
h2 = 3
|
|
||||||
buf2 = bytearray(w2 * h2 * 2)
|
|
||||||
fbuf2 = framebuf.FrameBuffer(buf2, w2, h2, framebuf.RGB565)
|
|
||||||
|
|
||||||
fbuf2.fill(0x0000)
|
|
||||||
fbuf2.pixel(0, 0, 0x0EE0)
|
|
||||||
fbuf2.pixel(0, 2, 0xEE00)
|
|
||||||
fbuf2.pixel(1, 0, 0x00EE)
|
|
||||||
fbuf2.pixel(1, 2, 0xE00E)
|
|
||||||
fbuf.fill(0xFFFF)
|
|
||||||
fbuf.blit(fbuf2, 3, 3, 0x0000)
|
|
||||||
fbuf.blit(fbuf2, -1, -1, 0x0000)
|
|
||||||
fbuf.blit(fbuf2, 16, 16, 0x0000)
|
|
||||||
printbuf()
|
|
@ -1,57 +0,0 @@
|
|||||||
--8<--
|
|
||||||
bytearray(b'\xff\xff\xff\xff\xff\xff\xff\xff')
|
|
||||||
bytearray(b'\xff\xff\xff\xff\xff\xff\xff\xff')
|
|
||||||
bytearray(b'\xff\xff\xff\xff\xff\xff\xff\xff')
|
|
||||||
bytearray(b'\xff\xff\xff\xff\xff\xff\xff\xff')
|
|
||||||
bytearray(b'\xff\xff\xff\xff\xff\xff\xff\xff')
|
|
||||||
-->8--
|
|
||||||
--8<--
|
|
||||||
bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00')
|
|
||||||
bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00')
|
|
||||||
bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00')
|
|
||||||
bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00')
|
|
||||||
bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00')
|
|
||||||
-->8--
|
|
||||||
--8<--
|
|
||||||
bytearray(b'\xee\xee\x00\x00\x00\x00\x00\xee')
|
|
||||||
bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00')
|
|
||||||
bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00')
|
|
||||||
bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00')
|
|
||||||
bytearray(b'\xee\x00\x00\x00\x00\x00\xe0\x0e')
|
|
||||||
-->8--
|
|
||||||
238 0
|
|
||||||
--8<--
|
|
||||||
bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00')
|
|
||||||
bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00')
|
|
||||||
bytearray(b'\x00\x00\x00\x00\xff\xff\x00\x00')
|
|
||||||
bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00')
|
|
||||||
bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00')
|
|
||||||
-->8--
|
|
||||||
--8<--
|
|
||||||
bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00')
|
|
||||||
bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00')
|
|
||||||
bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00')
|
|
||||||
bytearray(b'\x00\x00\x00\x00\xff\xff\x00\x00')
|
|
||||||
bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00')
|
|
||||||
-->8--
|
|
||||||
--8<--
|
|
||||||
bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00')
|
|
||||||
bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00')
|
|
||||||
bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00')
|
|
||||||
bytearray(b'\x00\x00\x00\x00\x00\x00\xff\xff')
|
|
||||||
bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00')
|
|
||||||
-->8--
|
|
||||||
--8<--
|
|
||||||
bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00')
|
|
||||||
bytearray(b'\x00\x00\x00\x00\xff\xff\x00\x00')
|
|
||||||
bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00')
|
|
||||||
bytearray(b'\x00\x00\x00\x00\x00\x00\xff\xff')
|
|
||||||
bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00')
|
|
||||||
-->8--
|
|
||||||
--8<--
|
|
||||||
bytearray(b'\xff\xff\xff\xff\xff\xff\xff\xff')
|
|
||||||
bytearray(b'\x0e\xe0\xff\xff\xff\xff\xff\xff')
|
|
||||||
bytearray(b'\xff\xff\xff\xff\xff\xff\xff\xff')
|
|
||||||
bytearray(b'\xff\xff\xff\xff\xff\xff\xe0\x0e')
|
|
||||||
bytearray(b'\xff\xff\xff\xff\xff\xff\xff\xff')
|
|
||||||
-->8--
|
|
@ -1,64 +0,0 @@
|
|||||||
try:
|
|
||||||
import framebuf
|
|
||||||
except ImportError:
|
|
||||||
print("SKIP")
|
|
||||||
raise SystemExit
|
|
||||||
|
|
||||||
|
|
||||||
def printbuf():
|
|
||||||
print("--8<--")
|
|
||||||
for y in range(h):
|
|
||||||
for x in range(w):
|
|
||||||
print("%u" % ((buf[(x + y * w) // 4] >> ((x & 3) << 1)) & 3), end="")
|
|
||||||
print()
|
|
||||||
print("-->8--")
|
|
||||||
|
|
||||||
|
|
||||||
w = 8
|
|
||||||
h = 5
|
|
||||||
buf = bytearray(w * h // 4)
|
|
||||||
fbuf = framebuf.FrameBuffer(buf, w, h, framebuf.GS2_HMSB)
|
|
||||||
|
|
||||||
# fill
|
|
||||||
fbuf.fill(3)
|
|
||||||
printbuf()
|
|
||||||
fbuf.fill(0)
|
|
||||||
printbuf()
|
|
||||||
|
|
||||||
# put pixel
|
|
||||||
fbuf.pixel(0, 0, 1)
|
|
||||||
fbuf.pixel(3, 0, 2)
|
|
||||||
fbuf.pixel(0, 4, 3)
|
|
||||||
fbuf.pixel(3, 4, 2)
|
|
||||||
printbuf()
|
|
||||||
|
|
||||||
# get pixel
|
|
||||||
print(fbuf.pixel(0, 4), fbuf.pixel(1, 1))
|
|
||||||
|
|
||||||
# scroll
|
|
||||||
fbuf.fill(0)
|
|
||||||
fbuf.pixel(2, 2, 3)
|
|
||||||
printbuf()
|
|
||||||
fbuf.scroll(0, 1)
|
|
||||||
printbuf()
|
|
||||||
fbuf.scroll(1, 0)
|
|
||||||
printbuf()
|
|
||||||
fbuf.scroll(-1, -2)
|
|
||||||
printbuf()
|
|
||||||
|
|
||||||
w2 = 2
|
|
||||||
h2 = 3
|
|
||||||
buf2 = bytearray(w2 * h2 // 4)
|
|
||||||
fbuf2 = framebuf.FrameBuffer(buf2, w2, h2, framebuf.GS2_HMSB)
|
|
||||||
|
|
||||||
# blit
|
|
||||||
fbuf2.fill(0)
|
|
||||||
fbuf2.pixel(0, 0, 1)
|
|
||||||
fbuf2.pixel(0, 2, 2)
|
|
||||||
fbuf2.pixel(1, 0, 1)
|
|
||||||
fbuf2.pixel(1, 2, 2)
|
|
||||||
fbuf.fill(3)
|
|
||||||
fbuf.blit(fbuf2, 3, 3, 0)
|
|
||||||
fbuf.blit(fbuf2, -1, -1, 0)
|
|
||||||
fbuf.blit(fbuf2, 16, 16, 0)
|
|
||||||
printbuf()
|
|
@ -1,57 +0,0 @@
|
|||||||
--8<--
|
|
||||||
33333333
|
|
||||||
33333333
|
|
||||||
33333333
|
|
||||||
33333333
|
|
||||||
33333333
|
|
||||||
-->8--
|
|
||||||
--8<--
|
|
||||||
00000000
|
|
||||||
00000000
|
|
||||||
00000000
|
|
||||||
00000000
|
|
||||||
00000000
|
|
||||||
-->8--
|
|
||||||
--8<--
|
|
||||||
10020000
|
|
||||||
00000000
|
|
||||||
00000000
|
|
||||||
00000000
|
|
||||||
30020000
|
|
||||||
-->8--
|
|
||||||
3 0
|
|
||||||
--8<--
|
|
||||||
00000000
|
|
||||||
00000000
|
|
||||||
00300000
|
|
||||||
00000000
|
|
||||||
00000000
|
|
||||||
-->8--
|
|
||||||
--8<--
|
|
||||||
00000000
|
|
||||||
00000000
|
|
||||||
00000000
|
|
||||||
00300000
|
|
||||||
00000000
|
|
||||||
-->8--
|
|
||||||
--8<--
|
|
||||||
00000000
|
|
||||||
00000000
|
|
||||||
00000000
|
|
||||||
00030000
|
|
||||||
00000000
|
|
||||||
-->8--
|
|
||||||
--8<--
|
|
||||||
00000000
|
|
||||||
00300000
|
|
||||||
00000000
|
|
||||||
00030000
|
|
||||||
00000000
|
|
||||||
-->8--
|
|
||||||
--8<--
|
|
||||||
33333333
|
|
||||||
23333333
|
|
||||||
33333333
|
|
||||||
33311333
|
|
||||||
33333333
|
|
||||||
-->8--
|
|
@ -1,55 +0,0 @@
|
|||||||
try:
|
|
||||||
import framebuf
|
|
||||||
except ImportError:
|
|
||||||
print("SKIP")
|
|
||||||
raise SystemExit
|
|
||||||
|
|
||||||
|
|
||||||
def printbuf():
|
|
||||||
print("--8<--")
|
|
||||||
for y in range(h):
|
|
||||||
print(buf[y * w // 2 : (y + 1) * w // 2])
|
|
||||||
print("-->8--")
|
|
||||||
|
|
||||||
|
|
||||||
w = 16
|
|
||||||
h = 8
|
|
||||||
buf = bytearray(w * h // 2)
|
|
||||||
fbuf = framebuf.FrameBuffer(buf, w, h, framebuf.GS4_HMSB)
|
|
||||||
|
|
||||||
# fill
|
|
||||||
fbuf.fill(0x0F)
|
|
||||||
printbuf()
|
|
||||||
fbuf.fill(0xA0)
|
|
||||||
printbuf()
|
|
||||||
|
|
||||||
# put pixel
|
|
||||||
fbuf.pixel(0, 0, 0x01)
|
|
||||||
printbuf()
|
|
||||||
fbuf.pixel(w - 1, 0, 0x02)
|
|
||||||
printbuf()
|
|
||||||
fbuf.pixel(w - 1, h - 1, 0x03)
|
|
||||||
printbuf()
|
|
||||||
fbuf.pixel(0, h - 1, 0x04)
|
|
||||||
printbuf()
|
|
||||||
|
|
||||||
# get pixel
|
|
||||||
print(fbuf.pixel(0, 0), fbuf.pixel(w - 1, 0), fbuf.pixel(w - 1, h - 1), fbuf.pixel(0, h - 1))
|
|
||||||
print(fbuf.pixel(1, 0), fbuf.pixel(w - 2, 0), fbuf.pixel(w - 2, h - 1), fbuf.pixel(1, h - 1))
|
|
||||||
|
|
||||||
# fill rect
|
|
||||||
fbuf.fill_rect(0, 0, w, h, 0x0F)
|
|
||||||
printbuf()
|
|
||||||
fbuf.fill_rect(0, 0, w, h, 0xF0)
|
|
||||||
fbuf.fill_rect(1, 0, w // 2 + 1, 1, 0xF1)
|
|
||||||
printbuf()
|
|
||||||
fbuf.fill_rect(1, 0, w // 2 + 1, 1, 0x10)
|
|
||||||
fbuf.fill_rect(1, 0, w // 2, 1, 0xF1)
|
|
||||||
printbuf()
|
|
||||||
fbuf.fill_rect(1, 0, w // 2, 1, 0x10)
|
|
||||||
fbuf.fill_rect(0, h - 4, w // 2 + 1, 4, 0xAF)
|
|
||||||
printbuf()
|
|
||||||
fbuf.fill_rect(0, h - 4, w // 2 + 1, 4, 0xB0)
|
|
||||||
fbuf.fill_rect(0, h - 4, w // 2, 4, 0xAF)
|
|
||||||
printbuf()
|
|
||||||
fbuf.fill_rect(0, h - 4, w // 2, 4, 0xB0)
|
|
@ -1,112 +0,0 @@
|
|||||||
--8<--
|
|
||||||
bytearray(b'\xff\xff\xff\xff\xff\xff\xff\xff')
|
|
||||||
bytearray(b'\xff\xff\xff\xff\xff\xff\xff\xff')
|
|
||||||
bytearray(b'\xff\xff\xff\xff\xff\xff\xff\xff')
|
|
||||||
bytearray(b'\xff\xff\xff\xff\xff\xff\xff\xff')
|
|
||||||
bytearray(b'\xff\xff\xff\xff\xff\xff\xff\xff')
|
|
||||||
bytearray(b'\xff\xff\xff\xff\xff\xff\xff\xff')
|
|
||||||
bytearray(b'\xff\xff\xff\xff\xff\xff\xff\xff')
|
|
||||||
bytearray(b'\xff\xff\xff\xff\xff\xff\xff\xff')
|
|
||||||
-->8--
|
|
||||||
--8<--
|
|
||||||
bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00')
|
|
||||||
bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00')
|
|
||||||
bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00')
|
|
||||||
bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00')
|
|
||||||
bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00')
|
|
||||||
bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00')
|
|
||||||
bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00')
|
|
||||||
bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00')
|
|
||||||
-->8--
|
|
||||||
--8<--
|
|
||||||
bytearray(b'\x10\x00\x00\x00\x00\x00\x00\x00')
|
|
||||||
bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00')
|
|
||||||
bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00')
|
|
||||||
bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00')
|
|
||||||
bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00')
|
|
||||||
bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00')
|
|
||||||
bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00')
|
|
||||||
bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00')
|
|
||||||
-->8--
|
|
||||||
--8<--
|
|
||||||
bytearray(b'\x10\x00\x00\x00\x00\x00\x00\x02')
|
|
||||||
bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00')
|
|
||||||
bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00')
|
|
||||||
bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00')
|
|
||||||
bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00')
|
|
||||||
bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00')
|
|
||||||
bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00')
|
|
||||||
bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00')
|
|
||||||
-->8--
|
|
||||||
--8<--
|
|
||||||
bytearray(b'\x10\x00\x00\x00\x00\x00\x00\x02')
|
|
||||||
bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00')
|
|
||||||
bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00')
|
|
||||||
bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00')
|
|
||||||
bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00')
|
|
||||||
bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00')
|
|
||||||
bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00')
|
|
||||||
bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x03')
|
|
||||||
-->8--
|
|
||||||
--8<--
|
|
||||||
bytearray(b'\x10\x00\x00\x00\x00\x00\x00\x02')
|
|
||||||
bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00')
|
|
||||||
bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00')
|
|
||||||
bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00')
|
|
||||||
bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00')
|
|
||||||
bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00')
|
|
||||||
bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00')
|
|
||||||
bytearray(b'@\x00\x00\x00\x00\x00\x00\x03')
|
|
||||||
-->8--
|
|
||||||
1 2 3 4
|
|
||||||
0 0 0 0
|
|
||||||
--8<--
|
|
||||||
bytearray(b'\xff\xff\xff\xff\xff\xff\xff\xff')
|
|
||||||
bytearray(b'\xff\xff\xff\xff\xff\xff\xff\xff')
|
|
||||||
bytearray(b'\xff\xff\xff\xff\xff\xff\xff\xff')
|
|
||||||
bytearray(b'\xff\xff\xff\xff\xff\xff\xff\xff')
|
|
||||||
bytearray(b'\xff\xff\xff\xff\xff\xff\xff\xff')
|
|
||||||
bytearray(b'\xff\xff\xff\xff\xff\xff\xff\xff')
|
|
||||||
bytearray(b'\xff\xff\xff\xff\xff\xff\xff\xff')
|
|
||||||
bytearray(b'\xff\xff\xff\xff\xff\xff\xff\xff')
|
|
||||||
-->8--
|
|
||||||
--8<--
|
|
||||||
bytearray(b'\x01\x11\x11\x11\x11\x00\x00\x00')
|
|
||||||
bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00')
|
|
||||||
bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00')
|
|
||||||
bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00')
|
|
||||||
bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00')
|
|
||||||
bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00')
|
|
||||||
bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00')
|
|
||||||
bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00')
|
|
||||||
-->8--
|
|
||||||
--8<--
|
|
||||||
bytearray(b'\x01\x11\x11\x11\x10\x00\x00\x00')
|
|
||||||
bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00')
|
|
||||||
bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00')
|
|
||||||
bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00')
|
|
||||||
bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00')
|
|
||||||
bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00')
|
|
||||||
bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00')
|
|
||||||
bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00')
|
|
||||||
-->8--
|
|
||||||
--8<--
|
|
||||||
bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00')
|
|
||||||
bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00')
|
|
||||||
bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00')
|
|
||||||
bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00')
|
|
||||||
bytearray(b'\xff\xff\xff\xff\xf0\x00\x00\x00')
|
|
||||||
bytearray(b'\xff\xff\xff\xff\xf0\x00\x00\x00')
|
|
||||||
bytearray(b'\xff\xff\xff\xff\xf0\x00\x00\x00')
|
|
||||||
bytearray(b'\xff\xff\xff\xff\xf0\x00\x00\x00')
|
|
||||||
-->8--
|
|
||||||
--8<--
|
|
||||||
bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00')
|
|
||||||
bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00')
|
|
||||||
bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00')
|
|
||||||
bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00')
|
|
||||||
bytearray(b'\xff\xff\xff\xff\x00\x00\x00\x00')
|
|
||||||
bytearray(b'\xff\xff\xff\xff\x00\x00\x00\x00')
|
|
||||||
bytearray(b'\xff\xff\xff\xff\x00\x00\x00\x00')
|
|
||||||
bytearray(b'\xff\xff\xff\xff\x00\x00\x00\x00')
|
|
||||||
-->8--
|
|
@ -1,34 +0,0 @@
|
|||||||
try:
|
|
||||||
import framebuf
|
|
||||||
except ImportError:
|
|
||||||
print("SKIP")
|
|
||||||
raise SystemExit
|
|
||||||
|
|
||||||
|
|
||||||
def printbuf():
|
|
||||||
print("--8<--")
|
|
||||||
for y in range(h):
|
|
||||||
for x in range(w):
|
|
||||||
print("%02x" % buf[(x + y * w)], end="")
|
|
||||||
print()
|
|
||||||
print("-->8--")
|
|
||||||
|
|
||||||
|
|
||||||
w = 8
|
|
||||||
h = 5
|
|
||||||
buf = bytearray(w * h)
|
|
||||||
fbuf = framebuf.FrameBuffer(buf, w, h, framebuf.GS8)
|
|
||||||
|
|
||||||
# fill
|
|
||||||
fbuf.fill(0x55)
|
|
||||||
printbuf()
|
|
||||||
|
|
||||||
# put pixel
|
|
||||||
fbuf.pixel(0, 0, 0x11)
|
|
||||||
fbuf.pixel(w - 1, 0, 0x22)
|
|
||||||
fbuf.pixel(0, h - 1, 0x33)
|
|
||||||
fbuf.pixel(w - 1, h - 1, 0xFF)
|
|
||||||
printbuf()
|
|
||||||
|
|
||||||
# get pixel
|
|
||||||
print(hex(fbuf.pixel(0, h - 1)), hex(fbuf.pixel(1, 1)))
|
|
@ -1,15 +0,0 @@
|
|||||||
--8<--
|
|
||||||
5555555555555555
|
|
||||||
5555555555555555
|
|
||||||
5555555555555555
|
|
||||||
5555555555555555
|
|
||||||
5555555555555555
|
|
||||||
-->8--
|
|
||||||
--8<--
|
|
||||||
1155555555555522
|
|
||||||
5555555555555555
|
|
||||||
5555555555555555
|
|
||||||
5555555555555555
|
|
||||||
33555555555555ff
|
|
||||||
-->8--
|
|
||||||
0x33 0x55
|
|
@ -1,35 +0,0 @@
|
|||||||
# Test blit between different color spaces
|
|
||||||
try:
|
|
||||||
import framebuf, usys
|
|
||||||
except ImportError:
|
|
||||||
print("SKIP")
|
|
||||||
raise SystemExit
|
|
||||||
|
|
||||||
# Monochrome glyph/icon
|
|
||||||
w = 8
|
|
||||||
h = 8
|
|
||||||
cbuf = bytearray(w * h // 8)
|
|
||||||
fbc = framebuf.FrameBuffer(cbuf, w, h, framebuf.MONO_HLSB)
|
|
||||||
fbc.line(0, 0, 7, 7, 1)
|
|
||||||
|
|
||||||
# RGB565 destination
|
|
||||||
wd = 16
|
|
||||||
hd = 16
|
|
||||||
dest = bytearray(wd * hd * 2)
|
|
||||||
fbd = framebuf.FrameBuffer(dest, wd, hd, framebuf.RGB565)
|
|
||||||
|
|
||||||
wp = 2
|
|
||||||
bg = 0x1234
|
|
||||||
fg = 0xF800
|
|
||||||
pal = bytearray(wp * 2)
|
|
||||||
palette = framebuf.FrameBuffer(pal, wp, 1, framebuf.RGB565)
|
|
||||||
palette.pixel(0, 0, bg)
|
|
||||||
palette.pixel(1, 0, fg)
|
|
||||||
|
|
||||||
fbd.blit(fbc, 0, 0, -1, palette)
|
|
||||||
|
|
||||||
print(fbd.pixel(0, 0) == fg)
|
|
||||||
print(fbd.pixel(7, 7) == fg)
|
|
||||||
print(fbd.pixel(8, 8) == 0) # Outside blit
|
|
||||||
print(fbd.pixel(0, 1) == bg)
|
|
||||||
print(fbd.pixel(1, 0) == bg)
|
|
@ -1,5 +0,0 @@
|
|||||||
True
|
|
||||||
True
|
|
||||||
True
|
|
||||||
True
|
|
||||||
True
|
|
@ -1,51 +0,0 @@
|
|||||||
# test subclassing framebuf.FrameBuffer
|
|
||||||
|
|
||||||
try:
|
|
||||||
import framebuf, usys
|
|
||||||
except ImportError:
|
|
||||||
print("SKIP")
|
|
||||||
raise SystemExit
|
|
||||||
|
|
||||||
# This test and its .exp file is based on a little-endian architecture.
|
|
||||||
if usys.byteorder != "little":
|
|
||||||
print("SKIP")
|
|
||||||
raise SystemExit
|
|
||||||
|
|
||||||
|
|
||||||
class FB(framebuf.FrameBuffer):
|
|
||||||
def __init__(self, n):
|
|
||||||
self.n = n
|
|
||||||
super().__init__(bytearray(2 * n * n), n, n, framebuf.RGB565)
|
|
||||||
|
|
||||||
def foo(self):
|
|
||||||
self.hline(0, 2, self.n, 0x0304)
|
|
||||||
|
|
||||||
|
|
||||||
fb = FB(n=3)
|
|
||||||
fb.pixel(0, 0, 0x0102)
|
|
||||||
fb.foo()
|
|
||||||
print(bytes(fb))
|
|
||||||
|
|
||||||
# Test that blitting a subclass works.
|
|
||||||
fb2 = framebuf.FrameBuffer(bytearray(2 * 3 * 3), 3, 3, framebuf.RGB565)
|
|
||||||
fb.fill(0)
|
|
||||||
fb.pixel(0, 0, 0x0506)
|
|
||||||
fb.pixel(2, 2, 0x0708)
|
|
||||||
fb2.blit(fb, 0, 0)
|
|
||||||
print(bytes(fb2))
|
|
||||||
|
|
||||||
|
|
||||||
# Test that blitting something that isn't a subclass fails with TypeError.
|
|
||||||
class NotAFrameBuf:
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
try:
|
|
||||||
fb.blit(NotAFrameBuf(), 0, 0)
|
|
||||||
except TypeError:
|
|
||||||
print("TypeError")
|
|
||||||
|
|
||||||
try:
|
|
||||||
fb.blit(None, 0, 0)
|
|
||||||
except TypeError:
|
|
||||||
print("TypeError")
|
|
@ -1,4 +0,0 @@
|
|||||||
b'\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04\x03\x04\x03\x04\x03'
|
|
||||||
b'\x06\x05\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x08\x07'
|
|
||||||
TypeError
|
|
||||||
TypeError
|
|
@ -1,5 +1,5 @@
|
|||||||
try:
|
try:
|
||||||
from utime import ticks_diff, ticks_add
|
from time import ticks_diff, ticks_add
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print("SKIP")
|
print("SKIP")
|
||||||
raise SystemExit
|
raise SystemExit
|
||||||
|
@ -1,23 +1,23 @@
|
|||||||
try:
|
try:
|
||||||
import utime
|
import time
|
||||||
|
|
||||||
utime.sleep_ms, utime.sleep_us, utime.ticks_diff, utime.ticks_ms, utime.ticks_us, utime.ticks_cpu
|
time.sleep_ms, time.sleep_us, time.ticks_diff, time.ticks_ms, time.ticks_us, time.ticks_cpu
|
||||||
except (ImportError, AttributeError):
|
except (ImportError, AttributeError):
|
||||||
print("SKIP")
|
print("SKIP")
|
||||||
raise SystemExit
|
raise SystemExit
|
||||||
|
|
||||||
utime.sleep_ms(1)
|
time.sleep_ms(1)
|
||||||
utime.sleep_us(1)
|
time.sleep_us(1)
|
||||||
|
|
||||||
t0 = utime.ticks_ms()
|
t0 = time.ticks_ms()
|
||||||
t1 = utime.ticks_ms()
|
t1 = time.ticks_ms()
|
||||||
print(0 <= utime.ticks_diff(t1, t0) <= 1)
|
print(0 <= time.ticks_diff(t1, t0) <= 1)
|
||||||
|
|
||||||
t0 = utime.ticks_us()
|
t0 = time.ticks_us()
|
||||||
t1 = utime.ticks_us()
|
t1 = time.ticks_us()
|
||||||
print(0 <= utime.ticks_diff(t1, t0) <= 500)
|
print(0 <= time.ticks_diff(t1, t0) <= 500)
|
||||||
|
|
||||||
# ticks_cpu may not be implemented, at least make sure it doesn't decrease
|
# ticks_cpu may not be implemented, at least make sre it doesn't decrease
|
||||||
t0 = utime.ticks_cpu()
|
t0 = time.ticks_cpu()
|
||||||
t1 = utime.ticks_cpu()
|
t1 = time.ticks_cpu()
|
||||||
print(utime.ticks_diff(t1, t0) >= 0)
|
print(time.ticks_diff(t1, t0) >= 0)
|
||||||
|
@ -1,11 +1,8 @@
|
|||||||
# Test that tasks return their value correctly to the caller
|
# Test that tasks return their value correctly to the caller
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import uasyncio as asyncio
|
|
||||||
except ImportError:
|
|
||||||
try:
|
|
||||||
import asyncio
|
import asyncio
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print("SKIP")
|
print("SKIP")
|
||||||
raise SystemExit
|
raise SystemExit
|
||||||
|
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
try:
|
try:
|
||||||
import uasyncio as asyncio
|
|
||||||
except ImportError:
|
|
||||||
try:
|
|
||||||
import asyncio
|
import asyncio
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print("SKIP")
|
print("SKIP")
|
||||||
raise SystemExit
|
raise SystemExit
|
||||||
|
|
||||||
@ -19,10 +16,10 @@ except AttributeError:
|
|||||||
raise SystemExit
|
raise SystemExit
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import utime
|
import time
|
||||||
|
|
||||||
ticks = utime.ticks_ms
|
ticks = time.ticks_ms
|
||||||
ticks_diff = utime.ticks_diff
|
ticks_diff = time.ticks_diff
|
||||||
except:
|
except:
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
try:
|
try:
|
||||||
import uasyncio as asyncio
|
|
||||||
except ImportError:
|
|
||||||
try:
|
|
||||||
import asyncio
|
import asyncio
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print("SKIP")
|
print("SKIP")
|
||||||
raise SystemExit
|
raise SystemExit
|
||||||
|
|
||||||
|
@ -2,11 +2,8 @@
|
|||||||
# That tasks which continuously cancel each other don't take over the scheduler
|
# That tasks which continuously cancel each other don't take over the scheduler
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import uasyncio as asyncio
|
|
||||||
except ImportError:
|
|
||||||
try:
|
|
||||||
import asyncio
|
import asyncio
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print("SKIP")
|
print("SKIP")
|
||||||
raise SystemExit
|
raise SystemExit
|
||||||
|
|
||||||
|
@ -2,11 +2,8 @@
|
|||||||
# That tasks which keeps being cancelled by multiple other tasks gets a chance to run
|
# That tasks which keeps being cancelled by multiple other tasks gets a chance to run
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import uasyncio as asyncio
|
|
||||||
except ImportError:
|
|
||||||
try:
|
|
||||||
import asyncio
|
import asyncio
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print("SKIP")
|
print("SKIP")
|
||||||
raise SystemExit
|
raise SystemExit
|
||||||
|
|
||||||
|
@ -1,11 +1,8 @@
|
|||||||
# Test a task cancelling itself (currently unsupported)
|
# Test a task cancelling itself (currently unsupported)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import uasyncio as asyncio
|
|
||||||
except ImportError:
|
|
||||||
try:
|
|
||||||
import asyncio
|
import asyncio
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print("SKIP")
|
print("SKIP")
|
||||||
raise SystemExit
|
raise SystemExit
|
||||||
|
|
||||||
|
@ -1,11 +1,8 @@
|
|||||||
# Test cancelling a task
|
# Test cancelling a task
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import uasyncio as asyncio
|
|
||||||
except ImportError:
|
|
||||||
try:
|
|
||||||
import asyncio
|
import asyncio
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print("SKIP")
|
print("SKIP")
|
||||||
raise SystemExit
|
raise SystemExit
|
||||||
|
|
||||||
|
@ -1,11 +1,8 @@
|
|||||||
# Test cancelling a task that is waiting on a task that just finishes.
|
# Test cancelling a task that is waiting on a task that just finishes.
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import uasyncio as asyncio
|
|
||||||
except ImportError:
|
|
||||||
try:
|
|
||||||
import asyncio
|
import asyncio
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print("SKIP")
|
print("SKIP")
|
||||||
raise SystemExit
|
raise SystemExit
|
||||||
|
|
||||||
|
@ -1,11 +1,8 @@
|
|||||||
# Test current_task() function
|
# Test current_task() function
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import uasyncio as asyncio
|
|
||||||
except ImportError:
|
|
||||||
try:
|
|
||||||
import asyncio
|
import asyncio
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print("SKIP")
|
print("SKIP")
|
||||||
raise SystemExit
|
raise SystemExit
|
||||||
|
|
||||||
|
@ -1,11 +1,8 @@
|
|||||||
# Test Event class
|
# Test Event class
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import uasyncio as asyncio
|
|
||||||
except ImportError:
|
|
||||||
try:
|
|
||||||
import asyncio
|
import asyncio
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print("SKIP")
|
print("SKIP")
|
||||||
raise SystemExit
|
raise SystemExit
|
||||||
|
|
||||||
|
@ -2,11 +2,8 @@
|
|||||||
# That tasks which continuously wait on events don't take over the scheduler
|
# That tasks which continuously wait on events don't take over the scheduler
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import uasyncio as asyncio
|
|
||||||
except ImportError:
|
|
||||||
try:
|
|
||||||
import asyncio
|
import asyncio
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print("SKIP")
|
print("SKIP")
|
||||||
raise SystemExit
|
raise SystemExit
|
||||||
|
|
||||||
|
@ -1,11 +1,8 @@
|
|||||||
# Test general exception handling
|
# Test general exception handling
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import uasyncio as asyncio
|
|
||||||
except ImportError:
|
|
||||||
try:
|
|
||||||
import asyncio
|
import asyncio
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print("SKIP")
|
print("SKIP")
|
||||||
raise SystemExit
|
raise SystemExit
|
||||||
|
|
||||||
|
@ -1,11 +1,8 @@
|
|||||||
# Test fairness of scheduler
|
# Test fairness of scheduler
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import uasyncio as asyncio
|
|
||||||
except ImportError:
|
|
||||||
try:
|
|
||||||
import asyncio
|
import asyncio
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print("SKIP")
|
print("SKIP")
|
||||||
raise SystemExit
|
raise SystemExit
|
||||||
|
|
||||||
|
@ -1,11 +1,8 @@
|
|||||||
# test uasyncio.gather() function
|
# test asyncio.gather() function
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import uasyncio as asyncio
|
|
||||||
except ImportError:
|
|
||||||
try:
|
|
||||||
import asyncio
|
import asyncio
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print("SKIP")
|
print("SKIP")
|
||||||
raise SystemExit
|
raise SystemExit
|
||||||
|
|
||||||
|
@ -1,11 +1,8 @@
|
|||||||
# Test uasyncio.gather() function, features that are not implemented.
|
# Test asyncio.gather() function, featres that are not implemented.
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import uasyncio as asyncio
|
|
||||||
except ImportError:
|
|
||||||
try:
|
|
||||||
import asyncio
|
import asyncio
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print("SKIP")
|
print("SKIP")
|
||||||
raise SystemExit
|
raise SystemExit
|
||||||
|
|
||||||
|
@ -1,11 +1,8 @@
|
|||||||
# Test get_event_loop()
|
# Test get_event_loop()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import uasyncio as asyncio
|
|
||||||
except ImportError:
|
|
||||||
try:
|
|
||||||
import asyncio
|
import asyncio
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print("SKIP")
|
print("SKIP")
|
||||||
raise SystemExit
|
raise SystemExit
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# test that basic scheduling of tasks, and uasyncio.sleep_ms, does not use the heap
|
# test that basic scheduling of tasks, and asyncio.sleep_ms, does not use the heap
|
||||||
|
|
||||||
import micropython
|
import micropython
|
||||||
|
|
||||||
@ -13,11 +13,8 @@ except RuntimeError:
|
|||||||
raise SystemExit
|
raise SystemExit
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import uasyncio as asyncio
|
|
||||||
except ImportError:
|
|
||||||
try:
|
|
||||||
import asyncio
|
import asyncio
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print("SKIP")
|
print("SKIP")
|
||||||
raise SystemExit
|
raise SystemExit
|
||||||
|
|
||||||
|
@ -1,11 +1,8 @@
|
|||||||
# Test Lock class
|
# Test Lock class
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import uasyncio as asyncio
|
|
||||||
except ImportError:
|
|
||||||
try:
|
|
||||||
import asyncio
|
import asyncio
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print("SKIP")
|
print("SKIP")
|
||||||
raise SystemExit
|
raise SystemExit
|
||||||
|
|
||||||
|
@ -1,11 +1,8 @@
|
|||||||
# Test that locks work when cancelling multiple waiters on the lock
|
# Test that locks work when cancelling multiple waiters on the lock
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import uasyncio as asyncio
|
|
||||||
except ImportError:
|
|
||||||
try:
|
|
||||||
import asyncio
|
import asyncio
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print("SKIP")
|
print("SKIP")
|
||||||
raise SystemExit
|
raise SystemExit
|
||||||
|
|
||||||
|
@ -1,11 +1,8 @@
|
|||||||
# Test Loop.stop() to stop the event loop
|
# Test Loop.stop() to stop the event loop
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import uasyncio as asyncio
|
|
||||||
except ImportError:
|
|
||||||
try:
|
|
||||||
import asyncio
|
import asyncio
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print("SKIP")
|
print("SKIP")
|
||||||
raise SystemExit
|
raise SystemExit
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
# - wait_for_ms
|
# - wait_for_ms
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import utime, uasyncio
|
import time, asyncio
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print("SKIP")
|
print("SKIP")
|
||||||
raise SystemExit
|
raise SystemExit
|
||||||
@ -11,27 +11,27 @@ except ImportError:
|
|||||||
|
|
||||||
async def task(id, t):
|
async def task(id, t):
|
||||||
print("task start", id)
|
print("task start", id)
|
||||||
await uasyncio.sleep_ms(t)
|
await asyncio.sleep_ms(t)
|
||||||
print("task end", id)
|
print("task end", id)
|
||||||
return id * 2
|
return id * 2
|
||||||
|
|
||||||
|
|
||||||
async def main():
|
async def main():
|
||||||
# Simple sleep_ms
|
# Simple sleep_ms
|
||||||
t0 = utime.ticks_ms()
|
t0 = time.ticks_ms()
|
||||||
await uasyncio.sleep_ms(1)
|
await asyncio.sleep_ms(1)
|
||||||
print(utime.ticks_diff(utime.ticks_ms(), t0) < 100)
|
print(time.ticks_diff(time.ticks_ms(), t0) < 100)
|
||||||
|
|
||||||
# When task finished before the timeout
|
# When task finished before the timeout
|
||||||
print(await uasyncio.wait_for_ms(task(1, 5), 50))
|
print(await asyncio.wait_for_ms(task(1, 5), 50))
|
||||||
|
|
||||||
# When timeout passes and task is cancelled
|
# When timeout passes and task is cancelled
|
||||||
try:
|
try:
|
||||||
print(await uasyncio.wait_for_ms(task(2, 50), 5))
|
print(await asyncio.wait_for_ms(task(2, 50), 5))
|
||||||
except uasyncio.TimeoutError:
|
except asyncio.TimeoutError:
|
||||||
print("timeout")
|
print("timeout")
|
||||||
|
|
||||||
print("finish")
|
print("finish")
|
||||||
|
|
||||||
|
|
||||||
uasyncio.run(main())
|
asyncio.run(main())
|
||||||
|
@ -1,11 +1,8 @@
|
|||||||
# Test Loop.new_event_loop()
|
# Test Loop.new_event_loop()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import uasyncio as asyncio
|
|
||||||
except ImportError:
|
|
||||||
try:
|
|
||||||
import asyncio
|
import asyncio
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print("SKIP")
|
print("SKIP")
|
||||||
raise SystemExit
|
raise SystemExit
|
||||||
|
|
||||||
|
@ -1,11 +1,8 @@
|
|||||||
# Test that tasks return their value correctly to the caller
|
# Test that tasks return their value correctly to the caller
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import uasyncio as asyncio
|
|
||||||
except ImportError:
|
|
||||||
try:
|
|
||||||
import asyncio
|
import asyncio
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print("SKIP")
|
print("SKIP")
|
||||||
raise SystemExit
|
raise SystemExit
|
||||||
|
|
||||||
|
@ -1,11 +1,8 @@
|
|||||||
# Test the Task.done() method
|
# Test the Task.done() method
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import uasyncio as asyncio
|
|
||||||
except ImportError:
|
|
||||||
try:
|
|
||||||
import asyncio
|
import asyncio
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print("SKIP")
|
print("SKIP")
|
||||||
raise SystemExit
|
raise SystemExit
|
||||||
|
|
||||||
|
@ -8,11 +8,8 @@
|
|||||||
# raising.
|
# raising.
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import uasyncio as asyncio
|
|
||||||
except ImportError:
|
|
||||||
try:
|
|
||||||
import asyncio
|
import asyncio
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print("SKIP")
|
print("SKIP")
|
||||||
raise SystemExit
|
raise SystemExit
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
# Test Event class
|
# Test Event class
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import uasyncio as asyncio
|
import asyncio
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print("SKIP")
|
print("SKIP")
|
||||||
raise SystemExit
|
raise SystemExit
|
||||||
@ -11,6 +11,7 @@ import micropython
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
micropython.schedule
|
micropython.schedule
|
||||||
|
asyncio.ThreadSafeFlag
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
print("SKIP")
|
print("SKIP")
|
||||||
raise SystemExit
|
raise SystemExit
|
||||||
@ -18,7 +19,7 @@ except AttributeError:
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
# Unix port can't select/poll on user-defined types.
|
# Unix port can't select/poll on user-defined types.
|
||||||
import uselect as select
|
import select
|
||||||
|
|
||||||
poller = select.poll()
|
poller = select.poll()
|
||||||
poller.register(asyncio.ThreadSafeFlag())
|
poller.register(asyncio.ThreadSafeFlag())
|
||||||
|
@ -1,11 +1,8 @@
|
|||||||
# Test asyncio.wait_for
|
# Test asyncio.wait_for
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import uasyncio as asyncio
|
|
||||||
except ImportError:
|
|
||||||
try:
|
|
||||||
import asyncio
|
import asyncio
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print("SKIP")
|
print("SKIP")
|
||||||
raise SystemExit
|
raise SystemExit
|
||||||
|
|
||||||
|
@ -1,11 +1,8 @@
|
|||||||
# Test asyncio.wait_for, with forwarding cancellation
|
# Test asyncio.wait_for, with forwarding cancellation
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import uasyncio as asyncio
|
|
||||||
except ImportError:
|
|
||||||
try:
|
|
||||||
import asyncio
|
import asyncio
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print("SKIP")
|
print("SKIP")
|
||||||
raise SystemExit
|
raise SystemExit
|
||||||
|
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user