-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
209 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import dolp | ||
|
||
arduinoImg = bytearray(b'\x0F\x08\x3c\x66\xc2\x92\xd2\x46\x6c\x38\x6c\x46\xd2\x92\xc2\x66\x3c') | ||
maskImg = bytearray(b'\x08\x08\xf7\xbe\xff\xf7\x5f\xfe\xf7\xbd') | ||
|
||
dolp.begin() | ||
|
||
ani = dolp.Animation([maskImg, arduinoImg], [200,200]) | ||
o = dolp.new_entity() | ||
o.set_animation(ani) | ||
o.configure(30,30,8,8) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
#include "pentity.h" | ||
extern "C" | ||
{ | ||
#include <dolpmodule.h> | ||
#include "py/obj.h" | ||
#include "py/runtime.h" | ||
} | ||
|
||
mp_obj_t animation_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, 2, 3, false); | ||
dolp_animation_obj_t *p = m_new_obj(dolp_animation_obj_t); | ||
|
||
if (!mp_obj_is_type(args[0], &mp_type_list)) | ||
{ | ||
mp_raise_TypeError("first parameter should be a list of bytearray"); | ||
} | ||
if (!mp_obj_is_type(args[1], &mp_type_list)) | ||
{ | ||
mp_raise_TypeError("second parameter should be a list of int"); | ||
} | ||
if (n_args > 2 && !mp_obj_is_type(args[2], &mp_type_list)) | ||
{ | ||
mp_raise_TypeError("third parameter should be a list of bytearray"); | ||
} | ||
|
||
mp_obj_list_t *images = (mp_obj_list_t *)MP_OBJ_TO_PTR(args[0]); | ||
mp_obj_list_t *times = (mp_obj_list_t *)MP_OBJ_TO_PTR(args[1]); | ||
if (images->len != times->len) | ||
{ | ||
mp_raise_TypeError("length of bytearray list should equal the length of int list"); | ||
} | ||
mp_obj_list_t *masks = NULL; | ||
if (n_args > 2) | ||
{ | ||
masks = (mp_obj_list_t *)MP_OBJ_TO_PTR(args[2]); | ||
if (masks->len != images->len) | ||
{ | ||
mp_raise_TypeError("length of first bytearray list should equal the length of second bytearray list"); | ||
} | ||
} | ||
|
||
if (images->len < 1) | ||
{ | ||
mp_raise_TypeError("give me at least a frame!"); | ||
} | ||
|
||
for (size_t i = 0; i < images->len; i++) | ||
{ | ||
mp_buffer_info_t imgbuf; | ||
if (!mp_get_buffer(images->items[i], &imgbuf, 1)) | ||
{ | ||
mp_raise_TypeError("first parameter should be a list of bytearray"); | ||
} | ||
} | ||
|
||
for (size_t i = 0; i < times->len; i++) | ||
{ | ||
if (!mp_obj_is_int(times->items[i])) | ||
{ | ||
mp_raise_TypeError("second parameter should be a list of int"); | ||
} | ||
} | ||
|
||
if (masks) | ||
{ | ||
for (size_t i = 0; i < masks->len; i++) | ||
{ | ||
mp_buffer_info_t imgbuf; | ||
if (!mp_get_buffer(masks->items[i], &imgbuf, 1)) | ||
{ | ||
mp_raise_TypeError("third parameter should be a list of bytearray"); | ||
} | ||
} | ||
} | ||
|
||
p->base.type = &dolp_animation_type; | ||
p->animation = Animation(images, times, masks); | ||
return MP_OBJ_FROM_PTR(p); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters