2016-12-29 07:03:47 -05:00
|
|
|
/*
|
|
|
|
* This file is part of the Micro Python project, http://micropython.org/
|
|
|
|
*
|
|
|
|
* The MIT License (MIT)
|
|
|
|
*
|
|
|
|
* Copyright (c) 2016 Glenn Ruben Bakke
|
|
|
|
*
|
|
|
|
* 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 <stdint.h>
|
|
|
|
#include <string.h>
|
2017-01-03 15:12:39 -05:00
|
|
|
#include <stdbool.h>
|
2016-12-29 07:03:47 -05:00
|
|
|
|
|
|
|
#include "py/nlr.h"
|
|
|
|
#include "py/obj.h"
|
|
|
|
#include "py/runtime.h"
|
|
|
|
|
|
|
|
#include "lcd_mono_fb.h"
|
2016-12-29 09:35:24 -05:00
|
|
|
#include "font_petme128_8x8.h"
|
2016-12-29 07:03:47 -05:00
|
|
|
|
2016-12-29 11:03:15 -05:00
|
|
|
#if MICROPY_PY_LCD_MONO_FB
|
|
|
|
|
2016-12-29 08:30:24 -05:00
|
|
|
STATIC void lcd_enable_pixel(mp_obj_framebuf_t * p_framebuffer, uint16_t x, uint16_t y) {
|
2016-12-29 09:54:47 -05:00
|
|
|
uint16_t column = (x / 8);
|
|
|
|
uint16_t line = y;
|
|
|
|
uint8_t bit_pos = x % 8;
|
2016-12-29 07:03:47 -05:00
|
|
|
|
2016-12-29 09:54:47 -05:00
|
|
|
p_framebuffer->fb_bytes[line * (p_framebuffer->bytes_stride) + column].byte |= (1 << bit_pos);
|
|
|
|
p_framebuffer->fb_dirty[y / 8].byte |= (uint8_t)(0x1 << y % 8);
|
2016-12-29 07:03:47 -05:00
|
|
|
}
|
|
|
|
|
2016-12-29 08:30:24 -05:00
|
|
|
STATIC void lcd_disable_pixel(mp_obj_framebuf_t * p_framebuffer, uint16_t x, uint16_t y) {
|
2016-12-29 09:54:47 -05:00
|
|
|
uint16_t column = (x / 8);
|
|
|
|
uint16_t line = y;
|
2016-12-29 07:03:47 -05:00
|
|
|
uint8_t bit_pos = x % 8;
|
|
|
|
|
2016-12-29 08:26:26 -05:00
|
|
|
p_framebuffer->fb_bytes[line * (p_framebuffer->bytes_stride) + column].byte &= ~(1 << bit_pos);
|
|
|
|
p_framebuffer->fb_dirty[y/8].byte |= (uint8_t)(0x1 << y % 8);
|
2016-12-29 07:03:47 -05:00
|
|
|
}
|
|
|
|
|
2016-12-29 08:30:24 -05:00
|
|
|
STATIC void lcd_init(mp_obj_framebuf_t * p_framebuffer) {
|
2017-01-03 15:12:39 -05:00
|
|
|
p_framebuffer->fg_color = LCD_BLACK;
|
|
|
|
p_framebuffer->bg_color = LCD_WHITE;
|
2016-12-29 07:03:47 -05:00
|
|
|
|
2016-12-29 09:54:47 -05:00
|
|
|
memset(p_framebuffer->fb_bytes, 0x00, p_framebuffer->bytes_stride * p_framebuffer->height);
|
|
|
|
memset(p_framebuffer->fb_dirty, 0x00, p_framebuffer->dirty_stride);
|
2016-12-29 07:03:47 -05:00
|
|
|
}
|
|
|
|
|
2016-12-29 08:30:24 -05:00
|
|
|
STATIC void lcd_fg_color_set(mp_obj_framebuf_t * p_framebuffer, uint16_t color) {
|
2017-01-03 15:12:39 -05:00
|
|
|
p_framebuffer->fg_color = (color == 0) ? LCD_BLACK : LCD_WHITE;
|
2016-12-29 07:03:47 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
#if 0
|
2016-12-29 08:30:24 -05:00
|
|
|
STATIC uint16_t lcd_fg_color_get(mp_obj_framebuf_t * p_framebuffer) {
|
2017-01-03 15:12:39 -05:00
|
|
|
return p_framebuffer->fg_color;
|
2016-12-29 07:03:47 -05:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2016-12-29 08:30:24 -05:00
|
|
|
STATIC void lcd_bg_color_set(mp_obj_framebuf_t * p_framebuffer, uint16_t color) {
|
2017-01-03 15:12:39 -05:00
|
|
|
p_framebuffer->bg_color = (color == 0) ? LCD_BLACK : LCD_WHITE;
|
2016-12-29 07:03:47 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
#if 0
|
2016-12-29 08:30:24 -05:00
|
|
|
STATIC uint16_t lcd_bg_color_get(mp_obj_framebuf_t * p_framebuffer) {
|
2017-01-03 15:12:39 -05:00
|
|
|
return p_framebuffer->bg_color;
|
2016-12-29 07:03:47 -05:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2017-01-06 14:06:09 -05:00
|
|
|
void display_clear_screen(mp_obj_framebuf_t * p_framebuffer, uint8_t color) {
|
|
|
|
|
|
|
|
lcd_bg_color_set(p_framebuffer, color);
|
|
|
|
lcd_fg_color_set(p_framebuffer, !color);
|
|
|
|
|
2017-01-03 15:12:39 -05:00
|
|
|
if (p_framebuffer->bg_color == LCD_BLACK) {
|
2016-12-29 09:54:47 -05:00
|
|
|
memset(p_framebuffer->fb_bytes, 0x00, p_framebuffer->bytes_stride * p_framebuffer->height);
|
|
|
|
} else {
|
|
|
|
memset(p_framebuffer->fb_bytes, 0xFF, p_framebuffer->bytes_stride * p_framebuffer->height);
|
|
|
|
}
|
|
|
|
memset(p_framebuffer->fb_dirty, 0xFF, p_framebuffer->dirty_stride);
|
2016-12-29 07:03:47 -05:00
|
|
|
}
|
|
|
|
|
2016-12-29 08:30:24 -05:00
|
|
|
STATIC void lcd_print_char(mp_obj_framebuf_t * p_framebuffer, uint16_t x, uint16_t y, char ch) {
|
2016-12-29 09:54:47 -05:00
|
|
|
uint16_t col = x;
|
|
|
|
for (uint8_t i = 0; i < 8; i++) {
|
|
|
|
|
2017-01-03 15:12:39 -05:00
|
|
|
uint16_t current_col = col + (i * p_framebuffer->font_size);
|
2016-12-29 09:54:47 -05:00
|
|
|
|
|
|
|
for (uint8_t y_pos = 0; y_pos < 8; y_pos++) {
|
|
|
|
if ((((uint8_t)font_petme128_8x8[((ch - 32) * 8) + i]) >> y_pos) & 0x01) {
|
2017-01-03 15:12:39 -05:00
|
|
|
for (uint8_t s_w = 0; s_w < p_framebuffer->font_size; s_w++) {
|
|
|
|
for (uint8_t s_h = 0; s_h < p_framebuffer->font_size; s_h++) {
|
|
|
|
if (p_framebuffer->fg_color < LCD_WHITE) {
|
2016-12-29 09:54:47 -05:00
|
|
|
lcd_disable_pixel(p_framebuffer,
|
|
|
|
current_col + s_w,
|
2017-01-03 15:12:39 -05:00
|
|
|
y + (y_pos * p_framebuffer->font_size) + s_h);
|
2016-12-29 09:54:47 -05:00
|
|
|
} else {
|
|
|
|
lcd_enable_pixel(p_framebuffer,
|
|
|
|
current_col + s_w,
|
2017-01-03 15:12:39 -05:00
|
|
|
y + (y_pos * p_framebuffer->font_size) + s_h);
|
2016-12-29 09:54:47 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
2017-01-03 15:12:39 -05:00
|
|
|
for (uint8_t s_w = 0; s_w < p_framebuffer->font_size; s_w++) {
|
|
|
|
for (uint8_t s_h = 0; s_h < p_framebuffer->font_size; s_h++) {
|
|
|
|
if (p_framebuffer->bg_color < LCD_WHITE) {
|
2016-12-29 09:54:47 -05:00
|
|
|
lcd_disable_pixel(p_framebuffer,
|
|
|
|
current_col + s_w,
|
2017-01-03 15:12:39 -05:00
|
|
|
y + (y_pos * p_framebuffer->font_size) + s_h);
|
2016-12-29 09:54:47 -05:00
|
|
|
} else {
|
|
|
|
lcd_enable_pixel(p_framebuffer,
|
|
|
|
current_col + s_w,
|
2017-01-03 15:12:39 -05:00
|
|
|
y + (y_pos * p_framebuffer->font_size) + s_h);
|
2016-12-29 09:54:47 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-12-29 07:03:47 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
#if 0
|
2016-12-29 08:30:24 -05:00
|
|
|
STATIC void lcd_font_size_set(mp_obj_framebuf_t * p_framebuffer, uint8_t size) {
|
2016-12-29 09:54:47 -05:00
|
|
|
m_font_size = size;
|
2016-12-29 07:03:47 -05:00
|
|
|
}
|
|
|
|
|
2016-12-29 08:30:24 -05:00
|
|
|
STATIC uint8_t lcd_font_size_get(mp_obj_framebuf_t * p_framebuffer) {
|
2016-12-29 09:54:47 -05:00
|
|
|
return m_font_size;
|
2016-12-29 07:03:47 -05:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2017-01-06 14:06:09 -05:00
|
|
|
void display_print_string(mp_obj_framebuf_t * p_framebuffer, uint16_t x, uint16_t y, const char * p_str) {
|
2016-12-29 09:54:47 -05:00
|
|
|
uint16_t str_len = strlen(p_str);
|
|
|
|
for (uint16_t i = 0; i < str_len; i++) {
|
2017-01-03 15:12:39 -05:00
|
|
|
lcd_print_char(p_framebuffer, x + (i * 8 * p_framebuffer->font_size), y, p_str[i]);
|
2016-12-29 09:54:47 -05:00
|
|
|
}
|
2016-12-29 07:03:47 -05:00
|
|
|
}
|
|
|
|
|
2016-12-29 08:30:24 -05:00
|
|
|
STATIC void lcd_pixel_draw(mp_obj_framebuf_t * p_framebuffer, uint16_t x, uint16_t y, uint16_t color) {
|
2016-12-29 09:54:47 -05:00
|
|
|
if (color < LCD_WHITE) {
|
|
|
|
lcd_disable_pixel(p_framebuffer, x, y);
|
|
|
|
} else {
|
|
|
|
lcd_enable_pixel(p_framebuffer, x, y);
|
|
|
|
}
|
2016-12-29 07:03:47 -05:00
|
|
|
}
|
|
|
|
|
2017-01-06 14:06:09 -05:00
|
|
|
void display_update(mp_obj_framebuf_t * p_framebuffer, bool refresh, lcd_update_line_callback_t c_callback) {
|
2016-12-29 09:54:47 -05:00
|
|
|
for (uint16_t i = 0; i < p_framebuffer->dirty_stride; i++) {
|
2017-01-03 15:12:39 -05:00
|
|
|
if (p_framebuffer->fb_dirty[i].byte != 0 || refresh) {
|
2016-12-29 09:54:47 -05:00
|
|
|
for (uint16_t b = 0; b < 8; b++) {
|
2017-01-03 15:12:39 -05:00
|
|
|
if ((((p_framebuffer->fb_dirty[i].byte >> b) & 0x01) == 1) || refresh) {
|
2016-12-29 09:54:47 -05:00
|
|
|
uint16_t line_num = (i * 8) + b;
|
2017-01-06 14:06:09 -05:00
|
|
|
|
|
|
|
if (c_callback != NULL)
|
|
|
|
{
|
|
|
|
if (p_framebuffer->fb_old == NULL) {
|
|
|
|
c_callback(p_framebuffer,
|
|
|
|
line_num,
|
|
|
|
&p_framebuffer->fb_bytes[line_num * p_framebuffer->bytes_stride],
|
|
|
|
NULL);
|
|
|
|
}
|
2017-01-03 15:12:39 -05:00
|
|
|
} else {
|
2017-01-06 14:06:09 -05:00
|
|
|
mp_obj_t args[4];
|
|
|
|
mp_uint_t num_of_args = 3;
|
|
|
|
args[0] = p_framebuffer;
|
|
|
|
args[1] = MP_OBJ_NEW_SMALL_INT(line_num);
|
|
|
|
|
|
|
|
if (refresh == false) {
|
|
|
|
args[2] = mp_obj_new_bytearray_by_ref(p_framebuffer->bytes_stride,
|
|
|
|
&p_framebuffer->fb_bytes[line_num * p_framebuffer->bytes_stride]);
|
|
|
|
} else {
|
|
|
|
args[2] = mp_const_none;
|
|
|
|
}
|
2017-01-03 15:12:39 -05:00
|
|
|
|
2017-01-06 14:06:09 -05:00
|
|
|
if (p_framebuffer->fb_old != NULL) {
|
|
|
|
args[3] = mp_obj_new_bytearray_by_ref(p_framebuffer->bytes_stride,
|
|
|
|
&p_framebuffer->fb_bytes[line_num * p_framebuffer->bytes_stride]);
|
|
|
|
num_of_args = 4;
|
|
|
|
}
|
2017-01-03 15:12:39 -05:00
|
|
|
|
2017-01-06 14:06:09 -05:00
|
|
|
mp_call_function_n_kw(p_framebuffer->line_update_cb, num_of_args, 0, args);
|
|
|
|
}
|
2017-01-03 15:12:39 -05:00
|
|
|
|
|
|
|
// update old buffer
|
|
|
|
if (p_framebuffer->fb_old != NULL) {
|
|
|
|
memcpy(&p_framebuffer->fb_old[line_num * p_framebuffer->bytes_stride],
|
|
|
|
&p_framebuffer->fb_bytes[line_num * p_framebuffer->bytes_stride],
|
|
|
|
p_framebuffer->dirty_stride);
|
|
|
|
}
|
2016-12-29 09:54:47 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-03 15:12:39 -05:00
|
|
|
if (refresh == false) {
|
|
|
|
p_framebuffer->fb_dirty[i].byte = 0x00;
|
|
|
|
}
|
2016-12-29 09:54:47 -05:00
|
|
|
}
|
|
|
|
}
|
2016-12-29 07:03:47 -05:00
|
|
|
}
|
|
|
|
|
2017-01-05 13:58:12 -05:00
|
|
|
mp_obj_t lcd_mono_fb_helper_make_new(mp_int_t width, mp_int_t height, mp_int_t vertical) {
|
|
|
|
|
|
|
|
mp_obj_framebuf_t *o = m_new_obj(mp_obj_framebuf_t);
|
|
|
|
o->base.type = &mp_type_object;
|
|
|
|
|
|
|
|
o->width = width;
|
|
|
|
o->height = height;
|
|
|
|
|
|
|
|
o->bytes_stride = o->width / 8;
|
|
|
|
o->dirty_stride = o->height / 8;
|
|
|
|
|
|
|
|
o->fb_bytes = m_new(fb_byte_t, (o->bytes_stride) * o->height);
|
|
|
|
o->fb_dirty = m_new(fb_byte_t, o->dirty_stride);
|
|
|
|
|
|
|
|
// default to not use double buffer
|
|
|
|
o->fb_old = NULL;
|
|
|
|
|
|
|
|
o->font_size = 1;
|
|
|
|
|
|
|
|
lcd_init(o);
|
|
|
|
|
|
|
|
return MP_OBJ_FROM_PTR(o);
|
|
|
|
}
|
|
|
|
|
2016-12-29 07:03:47 -05:00
|
|
|
STATIC mp_obj_t lcd_mono_fb_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, 3, 4, false);
|
|
|
|
|
|
|
|
mp_obj_framebuf_t *o = m_new_obj(mp_obj_framebuf_t);
|
|
|
|
o->base.type = type;
|
|
|
|
|
|
|
|
o->line_update_cb = args[0];
|
|
|
|
|
|
|
|
o->width = mp_obj_get_int(args[1]);
|
|
|
|
o->height = mp_obj_get_int(args[2]);
|
|
|
|
|
2016-12-29 08:25:30 -05:00
|
|
|
o->bytes_stride = o->width / 8;
|
|
|
|
o->dirty_stride = o->height / 8;
|
|
|
|
|
|
|
|
o->fb_bytes = m_new(fb_byte_t, (o->bytes_stride) * o->height);
|
|
|
|
o->fb_dirty = m_new(fb_byte_t, o->dirty_stride);
|
2016-12-29 07:03:47 -05:00
|
|
|
|
2017-01-03 15:12:39 -05:00
|
|
|
// default to not use double buffer
|
|
|
|
o->fb_old = NULL;
|
|
|
|
|
|
|
|
o->font_size = 1;
|
|
|
|
|
|
|
|
if (n_args >= 4) {
|
|
|
|
if (mp_obj_is_true(args[3])) {
|
|
|
|
o->fb_old = m_new(fb_byte_t, (o->bytes_stride) * o->height);
|
|
|
|
}
|
|
|
|
}
|
2016-12-29 07:03:47 -05:00
|
|
|
|
|
|
|
lcd_init(o);
|
|
|
|
|
|
|
|
return MP_OBJ_FROM_PTR(o);
|
|
|
|
}
|
|
|
|
|
|
|
|
STATIC mp_obj_t lcd_mono_fb_fill(mp_obj_t self_in, mp_obj_t col_in) {
|
2016-12-29 09:54:47 -05:00
|
|
|
mp_obj_framebuf_t *self = MP_OBJ_TO_PTR(self_in);
|
2016-12-29 07:03:47 -05:00
|
|
|
mp_int_t col = mp_obj_get_int(col_in);
|
|
|
|
|
2017-01-06 14:06:09 -05:00
|
|
|
display_clear_screen(self, col);
|
2016-12-29 07:03:47 -05:00
|
|
|
|
|
|
|
return mp_const_none;
|
|
|
|
}
|
|
|
|
STATIC MP_DEFINE_CONST_FUN_OBJ_2(lcd_mono_fb_fill_obj, lcd_mono_fb_fill);
|
|
|
|
|
|
|
|
STATIC mp_obj_t lcd_mono_fb_pixel(size_t n_args, const mp_obj_t *args) {
|
2016-12-29 09:54:47 -05:00
|
|
|
mp_obj_framebuf_t *self = MP_OBJ_TO_PTR(args[0]);
|
2016-12-29 07:03:47 -05:00
|
|
|
mp_int_t x = mp_obj_get_int(args[1]);
|
|
|
|
mp_int_t y = mp_obj_get_int(args[2]);
|
2016-12-29 08:25:30 -05:00
|
|
|
mp_int_t color = mp_obj_get_int(args[3]);
|
2016-12-29 07:03:47 -05:00
|
|
|
|
2016-12-29 08:25:30 -05:00
|
|
|
lcd_pixel_draw(self, x, y, color);
|
2016-12-29 07:03:47 -05:00
|
|
|
|
|
|
|
return mp_const_none;
|
|
|
|
}
|
|
|
|
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(lcd_mono_fb_pixel_obj, 3, 4, lcd_mono_fb_pixel);
|
|
|
|
|
|
|
|
STATIC mp_obj_t lcd_mono_fb_scroll(mp_obj_t self_in, mp_obj_t xstep_in, mp_obj_t ystep_in) {
|
|
|
|
#if 0
|
2016-12-29 09:54:47 -05:00
|
|
|
mp_obj_framebuf_t *self = MP_OBJ_TO_PTR(self_in);
|
2016-12-29 07:03:47 -05:00
|
|
|
mp_int_t xstep = mp_obj_get_int(xstep_in);
|
|
|
|
mp_int_t ystep = mp_obj_get_int(ystep_in);
|
|
|
|
#endif
|
|
|
|
return mp_const_none;
|
|
|
|
}
|
|
|
|
STATIC MP_DEFINE_CONST_FUN_OBJ_3(lcd_mono_fb_scroll_obj, lcd_mono_fb_scroll);
|
|
|
|
|
|
|
|
STATIC mp_obj_t lcd_mono_fb_text(size_t n_args, const mp_obj_t *args) {
|
|
|
|
// extract arguments
|
2016-12-29 09:54:47 -05:00
|
|
|
mp_obj_framebuf_t *self = MP_OBJ_TO_PTR(args[0]);
|
2016-12-29 07:03:47 -05:00
|
|
|
const char *str = mp_obj_str_get_str(args[1]);
|
|
|
|
mp_int_t x0 = mp_obj_get_int(args[2]);
|
|
|
|
mp_int_t y0 = mp_obj_get_int(args[3]);
|
|
|
|
|
2017-01-06 14:06:09 -05:00
|
|
|
display_print_string(self, x0, y0, str);
|
2016-12-29 07:03:47 -05:00
|
|
|
|
|
|
|
return mp_const_none;
|
|
|
|
}
|
|
|
|
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(lcd_mono_fb_text_obj, 4, 5, lcd_mono_fb_text);
|
|
|
|
|
|
|
|
|
|
|
|
STATIC mp_obj_t lcd_mono_fb_show(mp_obj_t self_in) {
|
2016-12-29 09:54:47 -05:00
|
|
|
mp_obj_framebuf_t *self = MP_OBJ_TO_PTR(self_in);
|
2016-12-29 07:03:47 -05:00
|
|
|
|
2017-01-06 14:06:09 -05:00
|
|
|
display_update(self, false, NULL);
|
2016-12-29 07:03:47 -05:00
|
|
|
|
|
|
|
return mp_const_none;
|
|
|
|
}
|
|
|
|
STATIC MP_DEFINE_CONST_FUN_OBJ_1(lcd_mono_fb_show_obj, lcd_mono_fb_show);
|
|
|
|
|
2017-01-03 15:12:39 -05:00
|
|
|
STATIC mp_obj_t lcd_mono_fb_refresh(mp_obj_t self_in) {
|
|
|
|
mp_obj_framebuf_t *self = MP_OBJ_TO_PTR(self_in);
|
|
|
|
|
2017-01-06 14:06:09 -05:00
|
|
|
display_update(self, true, NULL);
|
2017-01-03 15:12:39 -05:00
|
|
|
|
|
|
|
return mp_const_none;
|
|
|
|
}
|
|
|
|
STATIC MP_DEFINE_CONST_FUN_OBJ_1(lcd_mono_fb_refresh_obj, lcd_mono_fb_refresh);
|
|
|
|
|
|
|
|
|
2016-12-29 07:03:47 -05:00
|
|
|
STATIC mp_obj_t lcd_mono_fb_del(mp_obj_t self_in) {
|
2016-12-29 09:54:47 -05:00
|
|
|
mp_obj_framebuf_t *self = MP_OBJ_TO_PTR(self_in);
|
2016-12-29 07:03:47 -05:00
|
|
|
|
|
|
|
m_free(self->fb_bytes);
|
|
|
|
m_free(self->fb_dirty);
|
|
|
|
|
2017-01-03 15:12:39 -05:00
|
|
|
if (self->fb_old != NULL) {
|
|
|
|
// free double buffer if used
|
|
|
|
m_free(self->fb_old);
|
|
|
|
}
|
|
|
|
|
2016-12-29 07:03:47 -05:00
|
|
|
return mp_const_none;
|
|
|
|
}
|
|
|
|
STATIC MP_DEFINE_CONST_FUN_OBJ_1(lcd_mono_fb_del_obj, lcd_mono_fb_del);
|
|
|
|
|
|
|
|
STATIC const mp_rom_map_elem_t lcd_mono_fb_locals_dict_table[] = {
|
|
|
|
{ MP_ROM_QSTR(MP_QSTR___del__), MP_ROM_PTR(&lcd_mono_fb_del_obj) },
|
|
|
|
{ MP_ROM_QSTR(MP_QSTR_fill), MP_ROM_PTR(&lcd_mono_fb_fill_obj) },
|
|
|
|
{ MP_ROM_QSTR(MP_QSTR_pixel), MP_ROM_PTR(&lcd_mono_fb_pixel_obj) },
|
|
|
|
{ MP_ROM_QSTR(MP_QSTR_scroll), MP_ROM_PTR(&lcd_mono_fb_scroll_obj) },
|
|
|
|
{ MP_ROM_QSTR(MP_QSTR_text), MP_ROM_PTR(&lcd_mono_fb_text_obj) },
|
2016-12-29 09:54:47 -05:00
|
|
|
{ MP_ROM_QSTR(MP_QSTR_show), MP_ROM_PTR(&lcd_mono_fb_show_obj) },
|
2017-01-03 15:12:39 -05:00
|
|
|
{ MP_ROM_QSTR(MP_QSTR_refresh), MP_ROM_PTR(&lcd_mono_fb_refresh_obj) },
|
2016-12-29 07:03:47 -05:00
|
|
|
};
|
|
|
|
STATIC MP_DEFINE_CONST_DICT(lcd_mono_fb_locals_dict, lcd_mono_fb_locals_dict_table);
|
|
|
|
|
|
|
|
STATIC const mp_obj_type_t mp_type_lcd_mono_fb = {
|
|
|
|
{ &mp_type_type },
|
|
|
|
.name = MP_QSTR_MonoFB,
|
|
|
|
.make_new = lcd_mono_fb_make_new,
|
|
|
|
.locals_dict = (mp_obj_t)&lcd_mono_fb_locals_dict,
|
|
|
|
};
|
|
|
|
|
|
|
|
STATIC const mp_rom_map_elem_t lcd_mono_fb_module_globals_table[] = {
|
|
|
|
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_lcd_mono_fb) },
|
|
|
|
{ MP_ROM_QSTR(MP_QSTR_MonoFB), MP_ROM_PTR(&mp_type_lcd_mono_fb) },
|
|
|
|
};
|
|
|
|
|
|
|
|
STATIC MP_DEFINE_CONST_DICT(lcd_mono_fb_module_globals, lcd_mono_fb_module_globals_table);
|
|
|
|
|
|
|
|
const mp_obj_module_t mp_module_lcd_mono_fb = {
|
|
|
|
.base = { &mp_type_module },
|
|
|
|
.globals = (mp_obj_dict_t*)&lcd_mono_fb_module_globals,
|
|
|
|
};
|
2016-12-29 11:03:15 -05:00
|
|
|
|
|
|
|
#endif // MICROPY_PY_LCD_MONO_FB
|