Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
F
firmware
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
card10
firmware
Commits
84f2fea2
Commit
84f2fea2
authored
5 years ago
by
fgross
Browse files
Options
Downloads
Patches
Plain Diff
First working implementation of framebuffer rendering in Python
parent
dd3a665c
No related branches found
No related tags found
1 merge request
!211
First working implementation of framebuffer rendering in Python
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
pycardium/modules/qstrdefs.h
+1
-0
1 addition, 0 deletions
pycardium/modules/qstrdefs.h
pycardium/modules/sys_display.c
+31
-0
31 additions, 0 deletions
pycardium/modules/sys_display.c
pycardium/mpconfigport.h
+1
-0
1 addition, 0 deletions
pycardium/mpconfigport.h
with
33 additions
and
0 deletions
pycardium/modules/qstrdefs.h
+
1
−
0
View file @
84f2fea2
...
...
@@ -91,6 +91,7 @@ Q(line)
Q
(
rect
)
Q
(
circ
)
Q
(
clear
)
Q
(
framebuffer
)
/* ambient */
Q
(
light_sensor
)
...
...
This diff is collapsed.
Click to expand it.
pycardium/modules/sys_display.c
+
31
−
0
View file @
84f2fea2
...
...
@@ -7,6 +7,16 @@
#include
<stdio.h>
// TODO: Where does this belong? Needs to be in sync with extmod/modframebuf
#define FRAMEBUF_RGB565 (1)
typedef
struct
_mp_obj_framebuf_t
{
mp_obj_base_t
base
;
mp_obj_t
buf_obj
;
// need to store this to prevent GC from reclaiming buf
void
*
buf
;
uint16_t
width
,
height
,
stride
;
uint8_t
format
;
}
mp_obj_framebuf_t
;
static
uint16_t
rgb888_to_rgb565
(
uint8_t
*
bytes
)
{
return
((
bytes
[
0
]
&
0
b11111000
)
<<
8
)
|
((
bytes
[
1
]
&
0
b11111100
)
<<
3
)
|
...
...
@@ -208,6 +218,26 @@ static mp_obj_t mp_display_update()
}
static
MP_DEFINE_CONST_FUN_OBJ_0
(
display_update_obj
,
mp_display_update
);
static
mp_obj_t
mp_display_framebuffer
(
mp_obj_t
fb_obj
)
{
mp_obj_framebuf_t
*
fb
=
MP_OBJ_TO_PTR
(
fb_obj
);
if
(
fb
->
format
!=
FRAMEBUF_RGB565
)
mp_raise_ValueError
(
"Framebuffer format has to be RGB565"
);
if
(
fb
->
width
!=
160
||
fb
->
height
!=
80
)
mp_raise_ValueError
(
"Framebuffer size has to match native display size (160x80)"
);
void
*
dfb
=
fb
->
buf
;
int
res
=
epic_disp_framebuffer
((
union
disp_framebuffer
*
)
dfb
);
if
(
res
<
0
)
{
mp_raise_OSError
(
-
res
);
}
return
mp_const_none
;
}
STATIC
MP_DEFINE_CONST_FUN_OBJ_1
(
display_framebuffer_obj
,
mp_display_framebuffer
);
static
mp_obj_t
mp_display_open
()
{
int
res
=
epic_disp_open
();
...
...
@@ -241,6 +271,7 @@ static const mp_rom_map_elem_t display_module_globals_table[] = {
{
MP_ROM_QSTR
(
MP_QSTR_circ
),
MP_ROM_PTR
(
&
display_circ_obj
)
},
{
MP_ROM_QSTR
(
MP_QSTR_clear
),
MP_ROM_PTR
(
&
display_clear_obj
)
},
{
MP_ROM_QSTR
(
MP_QSTR_update
),
MP_ROM_PTR
(
&
display_update_obj
)
},
{
MP_ROM_QSTR
(
MP_QSTR_framebuffer
),
MP_ROM_PTR
(
&
display_framebuffer_obj
)
},
};
static
MP_DEFINE_CONST_DICT
(
display_module_globals
,
display_module_globals_table
...
...
This diff is collapsed.
Click to expand it.
pycardium/mpconfigport.h
+
1
−
0
View file @
84f2fea2
...
...
@@ -43,6 +43,7 @@ int mp_hal_trng_read_int(void);
#define MICROPY_PY_UTIME_MP_HAL (1)
#define MICROPY_PY_IO_FILEIO (1)
#define MICROPY_PY_UERRNO (1)
#define MICROPY_PY_FRAMEBUF (1)
/* Modules */
#define MODULE_BHI160_ENABLED (1)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment