Skip to content

Commit 3288eff

Browse files
committed
【添加】image 显示功能
1 parent f7b0f42 commit 3288eff

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

port/genhdr/qstrdefs.generated.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -764,4 +764,5 @@ QDEF(MP_QSTR_period, (const byte*)"\xa0\x06" "period")
764764
QDEF(MP_QSTR_set_color, (const byte*)"\x25\x09" "set_color")
765765
QDEF(MP_QSTR_file_crc32, (const byte*)"\x6f\x0a" "file_crc32")
766766
QDEF(MP_QSTR_list_device, (const byte*)"\x20\x0b" "list_device")
767+
QDEF(MP_QSTR_show_image, (const byte*)"\xde\x0a" "show_image")
767768
// This file was automatically generated by makeqstrdata.py

port/modules/machine/machine_lcd.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,30 @@ STATIC mp_obj_t machine_lcd_set_color(size_t n_args, const mp_obj_t *args) {
189189
}
190190
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(machine_lcd_set_color_obj, 3, 3, machine_lcd_set_color);
191191

192+
/// \method show_image array
193+
///
194+
/// display the image on the lcd..
195+
/// @param x x position
196+
/// @param y y position
197+
/// @param length length of image
198+
/// @param wide wide of image
199+
/// @param p image_array
200+
STATIC mp_obj_t machine_lcd_show_image(size_t n_args, const mp_obj_t *args) {
201+
rt_uint16_t x = mp_obj_get_int(args[1]);
202+
rt_uint16_t y = mp_obj_get_int(args[2]);
203+
rt_uint16_t length = mp_obj_get_int(args[3]);
204+
rt_uint16_t wide = mp_obj_get_int(args[4]);
205+
206+
mp_buffer_info_t bufinfo;
207+
if (mp_get_buffer(args[5], &bufinfo, MP_BUFFER_READ))
208+
{
209+
lcd_show_image( x, y, length, wide, (const rt_uint8_t *)bufinfo.buf);
210+
}
211+
212+
return mp_const_none;
213+
}
214+
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(machine_lcd_show_image_obj, 6, 6, machine_lcd_show_image);
215+
192216
STATIC const mp_rom_map_elem_t machine_lcd_locals_dict_table[] = {
193217
// instance methods
194218
{ MP_ROM_QSTR(MP_QSTR_light), MP_ROM_PTR(&machine_lcd_light_obj) },
@@ -199,6 +223,7 @@ STATIC const mp_rom_map_elem_t machine_lcd_locals_dict_table[] = {
199223
{ MP_ROM_QSTR(MP_QSTR_rectangle), MP_ROM_PTR(&machine_lcd_rectangle_obj) },
200224
{ MP_ROM_QSTR(MP_QSTR_circle), MP_ROM_PTR(&machine_lcd_circle_obj) },
201225
{ MP_ROM_QSTR(MP_QSTR_set_color), MP_ROM_PTR(&machine_lcd_set_color_obj) },
226+
{ MP_ROM_QSTR(MP_QSTR_show_image), MP_ROM_PTR(&machine_lcd_show_image_obj) },
202227
// color
203228
{ MP_ROM_QSTR(MP_QSTR_WHITE), MP_ROM_INT(WHITE) },
204229
{ MP_ROM_QSTR(MP_QSTR_BLACK), MP_ROM_INT(BLACK) },

0 commit comments

Comments
 (0)