Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
st7789_mpy
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
st7789_mpy
Commits
24fd6208
Unverified
Commit
24fd6208
authored
Oct 16, 2021
by
Dennis Heynlein
Committed by
GitHub
Oct 16, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update st7789.c
Add Circle/Fill_Circle
parent
027ed4e6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
79 additions
and
0 deletions
+79
-0
st7789/st7789.c
st7789/st7789.c
+79
-0
No files found.
st7789/st7789.c
View file @
24fd6208
...
@@ -1074,6 +1074,82 @@ STATIC mp_obj_t st7789_ST7789_vline(size_t n_args, const mp_obj_t *args)
...
@@ -1074,6 +1074,82 @@ STATIC mp_obj_t st7789_ST7789_vline(size_t n_args, const mp_obj_t *args)
}
}
STATIC
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN
(
st7789_ST7789_vline_obj
,
5
,
5
,
st7789_ST7789_vline
);
STATIC
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN
(
st7789_ST7789_vline_obj
,
5
,
5
,
st7789_ST7789_vline
);
STATIC
mp_obj_t
st7789_ST7789_circle
(
size_t
n_args
,
const
mp_obj_t
*
args
)
{
st7789_ST7789_obj_t
*
self
=
MP_OBJ_TO_PTR
(
args
[
0
]);
mp_int_t
xm
=
mp_obj_get_int
(
args
[
1
]);
mp_int_t
ym
=
mp_obj_get_int
(
args
[
2
]);
mp_int_t
r
=
mp_obj_get_int
(
args
[
3
]);
mp_int_t
color
=
mp_obj_get_int
(
args
[
4
]);
mp_int_t
f
=
1
-
r
;
mp_int_t
ddF_x
=
1
;
mp_int_t
ddF_y
=
-
2
*
r
;
mp_int_t
x
=
0
;
mp_int_t
y
=
r
;
draw_pixel
(
self
,
xm
,
ym
+
r
,
color
);
draw_pixel
(
self
,
xm
,
ym
-
r
,
color
);
draw_pixel
(
self
,
xm
+
r
,
ym
,
color
);
draw_pixel
(
self
,
xm
-
r
,
ym
,
color
);
while
(
x
<
y
)
{
if
(
f
>=
0
)
{
y
-=
1
;
ddF_y
+=
2
;
f
+=
ddF_y
;
}
x
+=
1
;
ddF_x
+=
2
;
f
+=
ddF_x
;
draw_pixel
(
self
,
xm
+
x
,
ym
+
y
,
color
);
draw_pixel
(
self
,
xm
-
x
,
ym
+
y
,
color
);
draw_pixel
(
self
,
xm
+
x
,
ym
-
y
,
color
);
draw_pixel
(
self
,
xm
-
x
,
ym
-
y
,
color
);
draw_pixel
(
self
,
xm
+
y
,
ym
+
x
,
color
);
draw_pixel
(
self
,
xm
-
y
,
ym
+
x
,
color
);
draw_pixel
(
self
,
xm
+
y
,
ym
-
x
,
color
);
draw_pixel
(
self
,
xm
-
y
,
ym
-
x
,
color
);
}
return
mp_const_none
;
}
STATIC
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN
(
st7789_ST7789_circle_obj
,
5
,
5
,
st7789_ST7789_circle
);
STATIC
mp_obj_t
st7789_ST7789_fill_circle
(
size_t
n_args
,
const
mp_obj_t
*
args
)
{
st7789_ST7789_obj_t
*
self
=
MP_OBJ_TO_PTR
(
args
[
0
]);
mp_int_t
xm
=
mp_obj_get_int
(
args
[
1
]);
mp_int_t
ym
=
mp_obj_get_int
(
args
[
2
]);
mp_int_t
r
=
mp_obj_get_int
(
args
[
3
]);
mp_int_t
color
=
mp_obj_get_int
(
args
[
4
]);
mp_int_t
f
=
1
-
r
;
mp_int_t
ddF_x
=
1
;
mp_int_t
ddF_y
=
-
2
*
r
;
mp_int_t
x
=
0
;
mp_int_t
y
=
r
;
fast_vline
(
self
,
xm
,
ym
-
y
,
2
*
y
+
1
,
color
);
while
(
x
<
y
)
{
if
(
f
>=
0
)
{
y
-=
1
;
ddF_y
+=
2
;
f
+=
ddF_y
;
}
x
+=
1
;
ddF_x
+=
2
;
f
+=
ddF_x
;
fast_vline
(
self
,
xm
+
x
,
ym
-
y
,
2
*
y
+
1
,
color
);
fast_vline
(
self
,
xm
+
y
,
ym
-
x
,
2
*
x
+
1
,
color
);
fast_vline
(
self
,
xm
-
x
,
ym
-
y
,
2
*
y
+
1
,
color
);
fast_vline
(
self
,
xm
-
y
,
ym
-
x
,
2
*
x
+
1
,
color
);
}
return
mp_const_none
;
}
STATIC
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN
(
st7789_ST7789_fill_circle_obj
,
5
,
5
,
st7789_ST7789_fill_circle
);
STATIC
mp_obj_t
st7789_ST7789_rect
(
size_t
n_args
,
const
mp_obj_t
*
args
)
STATIC
mp_obj_t
st7789_ST7789_rect
(
size_t
n_args
,
const
mp_obj_t
*
args
)
{
{
st7789_ST7789_obj_t
*
self
=
MP_OBJ_TO_PTR
(
args
[
0
]);
st7789_ST7789_obj_t
*
self
=
MP_OBJ_TO_PTR
(
args
[
0
]);
...
@@ -1089,6 +1165,7 @@ STATIC mp_obj_t st7789_ST7789_rect(size_t n_args, const mp_obj_t *args)
...
@@ -1089,6 +1165,7 @@ STATIC mp_obj_t st7789_ST7789_rect(size_t n_args, const mp_obj_t *args)
fast_vline
(
self
,
x
+
w
-
1
,
y
,
h
,
color
);
fast_vline
(
self
,
x
+
w
-
1
,
y
,
h
,
color
);
return
mp_const_none
;
return
mp_const_none
;
}
}
STATIC
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN
(
st7789_ST7789_rect_obj
,
6
,
6
,
st7789_ST7789_rect
);
STATIC
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN
(
st7789_ST7789_rect_obj
,
6
,
6
,
st7789_ST7789_rect
);
STATIC
mp_obj_t
st7789_ST7789_madctl
(
size_t
n_args
,
const
mp_obj_t
*
args
)
STATIC
mp_obj_t
st7789_ST7789_madctl
(
size_t
n_args
,
const
mp_obj_t
*
args
)
...
@@ -1704,6 +1781,8 @@ STATIC const mp_rom_map_elem_t st7789_ST7789_locals_dict_table[] = {
...
@@ -1704,6 +1781,8 @@ STATIC const mp_rom_map_elem_t st7789_ST7789_locals_dict_table[] = {
{
MP_ROM_QSTR
(
MP_QSTR_fill
),
MP_ROM_PTR
(
&
st7789_ST7789_fill_obj
)},
{
MP_ROM_QSTR
(
MP_QSTR_fill
),
MP_ROM_PTR
(
&
st7789_ST7789_fill_obj
)},
{
MP_ROM_QSTR
(
MP_QSTR_hline
),
MP_ROM_PTR
(
&
st7789_ST7789_hline_obj
)},
{
MP_ROM_QSTR
(
MP_QSTR_hline
),
MP_ROM_PTR
(
&
st7789_ST7789_hline_obj
)},
{
MP_ROM_QSTR
(
MP_QSTR_vline
),
MP_ROM_PTR
(
&
st7789_ST7789_vline_obj
)},
{
MP_ROM_QSTR
(
MP_QSTR_vline
),
MP_ROM_PTR
(
&
st7789_ST7789_vline_obj
)},
{
MP_ROM_QSTR
(
MP_QSTR_fill_circle
),
MP_ROM_PTR
(
&
st7789_ST7789_fill_circle_obj
)},
{
MP_ROM_QSTR
(
MP_QSTR_circle
),
MP_ROM_PTR
(
&
st7789_ST7789_circle_obj
)},
{
MP_ROM_QSTR
(
MP_QSTR_rect
),
MP_ROM_PTR
(
&
st7789_ST7789_rect_obj
)},
{
MP_ROM_QSTR
(
MP_QSTR_rect
),
MP_ROM_PTR
(
&
st7789_ST7789_rect_obj
)},
{
MP_ROM_QSTR
(
MP_QSTR_text
),
MP_ROM_PTR
(
&
st7789_ST7789_text_obj
)},
{
MP_ROM_QSTR
(
MP_QSTR_text
),
MP_ROM_PTR
(
&
st7789_ST7789_text_obj
)},
{
MP_ROM_QSTR
(
MP_QSTR_rotation
),
MP_ROM_PTR
(
&
st7789_ST7789_rotation_obj
)},
{
MP_ROM_QSTR
(
MP_QSTR_rotation
),
MP_ROM_PTR
(
&
st7789_ST7789_rotation_obj
)},
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment