From 47899a1ab8756c3850bb275f3756544da0e7b050 Mon Sep 17 00:00:00 2001 From: Damien George Date: Sun, 4 Sep 2016 16:39:28 +1000 Subject: extmod/modframebuf: Include font from stmhal directory explicitly. So that users of framebuf don't need to have stmhal directory in their path. (Eventually the font can be moved elsewhere.) --- extmod/modframebuf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'extmod') diff --git a/extmod/modframebuf.c b/extmod/modframebuf.c index 84f1246fb..569b75e1c 100644 --- a/extmod/modframebuf.c +++ b/extmod/modframebuf.c @@ -33,7 +33,7 @@ #if MICROPY_PY_FRAMEBUF -#include "font_petme128_8x8.h" +#include "stmhal/font_petme128_8x8.h" // 1-bit frame buffer, each byte is a column of 8 pixels typedef struct _mp_obj_framebuf1_t { -- cgit v1.2.3 From 1bc5cb4312cae9702ab5fe5412b16156a08b8280 Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Sun, 4 Sep 2016 14:44:12 +0300 Subject: extmod/moduzlib: Support wbits arg to DecompIO. --- extmod/moduzlib.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'extmod') diff --git a/extmod/moduzlib.c b/extmod/moduzlib.c index dbf513527..65cbc5eb0 100644 --- a/extmod/moduzlib.c +++ b/extmod/moduzlib.c @@ -67,17 +67,31 @@ STATIC unsigned char read_src_stream(TINF_DATA *data) { return c; } -#define DICT_SIZE 32768 - STATIC mp_obj_t decompio_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_arg_check_num(n_args, n_kw, 1, 2, false); mp_obj_decompio_t *o = m_new_obj(mp_obj_decompio_t); o->base.type = type; memset(&o->decomp, 0, sizeof(o->decomp)); - uzlib_uncompress_init(&o->decomp, m_new(byte, DICT_SIZE), DICT_SIZE); o->decomp.readSource = read_src_stream; o->src_stream = args[0]; o->eof = false; + + mp_int_t dict_opt = 0; + int dict_sz; + if (n_args > 1) { + dict_opt = mp_obj_get_int(args[1]); + } + if (dict_opt >= 0) { + dict_opt = uzlib_zlib_parse_header(&o->decomp); + if (dict_opt < 0) { + nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, "zlib header")); + } + dict_sz = 1 << dict_opt; + } else { + dict_sz = 1 << -dict_opt; + } + + uzlib_uncompress_init(&o->decomp, m_new(byte, dict_sz), dict_sz); return MP_OBJ_FROM_PTR(o); } -- cgit v1.2.3 From 778729c5977633978aef2ec302472505973a657e Mon Sep 17 00:00:00 2001 From: Radomir Dopieralski Date: Fri, 2 Sep 2016 16:15:37 +0200 Subject: extmod/framebuf: Add the xstep!=0 case to scroll() method. Adds horizontal scrolling. Right now, I'm just leaving the margins created by the scrolling as they were -- so they will repeat the edge of the framebuf. This is fast, and the user can always fill the margins themselves. --- extmod/modframebuf.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'extmod') diff --git a/extmod/modframebuf.c b/extmod/modframebuf.c index 569b75e1c..3c884c689 100644 --- a/extmod/modframebuf.c +++ b/extmod/modframebuf.c @@ -103,7 +103,7 @@ STATIC mp_obj_t framebuf1_scroll(mp_obj_t self_in, mp_obj_t xstep_in, mp_obj_t y mp_int_t xstep = mp_obj_get_int(xstep_in); mp_int_t ystep = mp_obj_get_int(ystep_in); int end = (self->height + 7) >> 3; - if (xstep == 0 && ystep > 0) { + if (ystep > 0) { for (int y = end; y > 0;) { --y; for (int x = 0; x < self->width; ++x) { @@ -114,7 +114,7 @@ STATIC mp_obj_t framebuf1_scroll(mp_obj_t self_in, mp_obj_t xstep_in, mp_obj_t y self->buf[y * self->stride + x] = (self->buf[y * self->stride + x] << ystep) | prev; } } - } else if (xstep == 0 && ystep < 0) { + } else if (ystep < 0) { for (int y = 0; y < end; ++y) { for (int x = 0; x < self->width; ++x) { int prev = 0; @@ -125,7 +125,20 @@ STATIC mp_obj_t framebuf1_scroll(mp_obj_t self_in, mp_obj_t xstep_in, mp_obj_t y } } } - // TODO xstep!=0 + if (xstep < 0) { + for (int y = 0; y < end; ++y) { + for (int x = 0; x < self->width + xstep; ++x) { + self->buf[y * self->stride + x] = self->buf[y * self->stride + x - xstep]; + } + } + } else if (xstep > 0) { + for (int y = 0; y < end; ++y) { + for (int x = self->width - 1; x >= xstep; --x) { + self->buf[y * self->stride + x] = self->buf[y * self->stride + x - xstep]; + } + } + } + // TODO: Should we clear the margin created by scrolling? return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_3(framebuf1_scroll_obj, framebuf1_scroll); -- cgit v1.2.3