@@ -56,6 +56,7 @@ typedef struct _mp_framebuf_p_t {
5656#define FRAMEBUF_RGB565 (1)
5757#define FRAMEBUF_GS2_HMSB (5)
5858#define FRAMEBUF_GS4_HMSB (2)
59+ #define FRAMEBUF_GS8 (6)
5960#define FRAMEBUF_MHLSB (3)
6061#define FRAMEBUF_MHMSB (4)
6162
@@ -206,11 +207,31 @@ STATIC void gs4_hmsb_fill_rect(const mp_obj_framebuf_t *fb, int x, int y, int w,
206207 }
207208}
208209
210+ // Functions for GS8 format
211+
212+ STATIC void gs8_setpixel (const mp_obj_framebuf_t * fb , int x , int y , uint32_t col ) {
213+ uint8_t * pixel = & ((uint8_t * )fb -> buf )[(x + y * fb -> stride )];
214+ * pixel = col & 0xff ;
215+ }
216+
217+ STATIC uint32_t gs8_getpixel (const mp_obj_framebuf_t * fb , int x , int y ) {
218+ return ((uint8_t * )fb -> buf )[(x + y * fb -> stride )];
219+ }
220+
221+ STATIC void gs8_fill_rect (const mp_obj_framebuf_t * fb , int x , int y , int w , int h , uint32_t col ) {
222+ uint8_t * pixel = & ((uint8_t * )fb -> buf )[(x + y * fb -> stride )];
223+ while (h -- ) {
224+ memset (pixel , col , w );
225+ pixel += fb -> stride ;
226+ }
227+ }
228+
209229STATIC mp_framebuf_p_t formats [] = {
210230 [FRAMEBUF_MVLSB ] = {mvlsb_setpixel , mvlsb_getpixel , mvlsb_fill_rect },
211231 [FRAMEBUF_RGB565 ] = {rgb565_setpixel , rgb565_getpixel , rgb565_fill_rect },
212232 [FRAMEBUF_GS2_HMSB ] = {gs2_hmsb_setpixel , gs2_hmsb_getpixel , gs2_hmsb_fill_rect },
213233 [FRAMEBUF_GS4_HMSB ] = {gs4_hmsb_setpixel , gs4_hmsb_getpixel , gs4_hmsb_fill_rect },
234+ [FRAMEBUF_GS8 ] = {gs8_setpixel , gs8_getpixel , gs8_fill_rect },
214235 [FRAMEBUF_MHLSB ] = {mono_horiz_setpixel , mono_horiz_getpixel , mono_horiz_fill_rect },
215236 [FRAMEBUF_MHMSB ] = {mono_horiz_setpixel , mono_horiz_getpixel , mono_horiz_fill_rect },
216237};
@@ -272,6 +293,8 @@ STATIC mp_obj_t framebuf_make_new(const mp_obj_type_t *type, size_t n_args, size
272293 case FRAMEBUF_GS4_HMSB :
273294 o -> stride = (o -> stride + 1 ) & ~1 ;
274295 break ;
296+ case FRAMEBUF_GS8 :
297+ break ;
275298 default :
276299 mp_raise_ValueError ("invalid format" );
277300 }
@@ -610,6 +633,7 @@ STATIC const mp_rom_map_elem_t framebuf_module_globals_table[] = {
610633 { MP_ROM_QSTR (MP_QSTR_RGB565 ), MP_ROM_INT (FRAMEBUF_RGB565 ) },
611634 { MP_ROM_QSTR (MP_QSTR_GS2_HMSB ), MP_ROM_INT (FRAMEBUF_GS2_HMSB ) },
612635 { MP_ROM_QSTR (MP_QSTR_GS4_HMSB ), MP_ROM_INT (FRAMEBUF_GS4_HMSB ) },
636+ { MP_ROM_QSTR (MP_QSTR_GS8 ), MP_ROM_INT (FRAMEBUF_GS8 ) },
613637 { MP_ROM_QSTR (MP_QSTR_MONO_HLSB ), MP_ROM_INT (FRAMEBUF_MHLSB ) },
614638 { MP_ROM_QSTR (MP_QSTR_MONO_HMSB ), MP_ROM_INT (FRAMEBUF_MHMSB ) },
615639};
0 commit comments