From da032a1d037bc5999a09554267d7a2e1d7b6066d Mon Sep 17 00:00:00 2001 From: Oreig403 <97249553+Oreig403@users.noreply.github.com> Date: Fri, 21 Oct 2022 20:11:28 +0200 Subject: [PATCH 01/15] add image support --- python/port/mod/kandinsky/modkandinsky.cpp | 61 ++++++++++++++++++- python/port/mod/kandinsky/modkandinsky.h | 2 + .../port/mod/kandinsky/modkandinsky_table.c | 6 +- 3 files changed, 66 insertions(+), 3 deletions(-) diff --git a/python/port/mod/kandinsky/modkandinsky.cpp b/python/port/mod/kandinsky/modkandinsky.cpp index 63e48320933..43c86a13961 100644 --- a/python/port/mod/kandinsky/modkandinsky.cpp +++ b/python/port/mod/kandinsky/modkandinsky.cpp @@ -1,14 +1,23 @@ extern "C" { #include "modkandinsky.h" #include +#include } -#include + +#include +#include #include #include #include "port.h" #include - +struct OBMHeader +{ + uint32_t signature; //Normally it is 32145 + int32_t width; + int32_t height; + const KDColor image_data; +}; static mp_obj_t TupleForKDColor(KDColor c) { mp_obj_tuple_t * t = static_cast(MP_OBJ_TO_PTR(mp_obj_new_tuple(3, NULL))); t->items[0] = MP_OBJ_NEW_SMALL_INT(c.red()); @@ -95,6 +104,54 @@ mp_obj_t modkandinsky_draw_circle(size_t n_args, const mp_obj_t * args) { KDIonContext::sharedContext()->drawCircle(center, r, color); return mp_const_none; } +mp_obj_t modkandinsky_draw_image(size_t n_args, const mp_obj_t * args) { + const char * image = mp_obj_str_get_str(args[0]); + mp_int_t x = mp_obj_get_int(args[1]); + mp_int_t y = mp_obj_get_int(args[2]); + mp_int_t width = mp_obj_get_int(args[3]); + mp_int_t height = mp_obj_get_int(args[4]); + + + if (width < 0) { + width = -width; + x = x - width; + } + if (height < 0) { + height = -height; + y = y - height; + } + int index = External::Archive::indexFromName(image); + if (index > -1) { + External::Archive::File image; + External::Archive::fileAtIndex(index, image); + OBMHeader* h = (OBMHeader*)image.data; + + + MicroPython::ExecutionEnvironment::currentExecutionEnvironment()->displaySandbox(); + KDIonContext::sharedContext()->fillRectWithPixels(KDRect(x, y, width, height), &(h->image_data), nullptr); + } + return mp_const_none; +} + +mp_obj_t modkandinsky_image_size(size_t n_args, const mp_obj_t * args) { + const char * image = mp_obj_str_get_str(args[0]); + int index = External::Archive::indexFromName(image); + if (index > -1) { + External::Archive::File image; + External::Archive::fileAtIndex(index, image); + OBMHeader* h = (OBMHeader*)image.data; + mp_obj_t sizeList = mp_obj_new_list(0, NULL); + mp_obj_list_append(sizeList, &(h->width)); + mp_obj_list_append(sizeList, &(h->height)); + mp_obj_t size[2]; + size[0] = mp_obj_new_int((h->width)); + size[1] = mp_obj_new_int((h->height)); + return mp_obj_new_tuple(2, size); + } + return mp_const_none; + +} + mp_obj_t modkandinsky_fill_rect(size_t n_args, const mp_obj_t * args) { mp_int_t x = mp_obj_get_int(args[0]); diff --git a/python/port/mod/kandinsky/modkandinsky.h b/python/port/mod/kandinsky/modkandinsky.h index 3ce71155adb..ec9ea1d9dbb 100644 --- a/python/port/mod/kandinsky/modkandinsky.h +++ b/python/port/mod/kandinsky/modkandinsky.h @@ -6,6 +6,8 @@ mp_obj_t modkandinsky_set_pixel(mp_obj_t x, mp_obj_t y, mp_obj_t color); mp_obj_t modkandinsky_draw_string(size_t n_args, const mp_obj_t *args); mp_obj_t modkandinsky_draw_line(size_t n_args, const mp_obj_t *args); mp_obj_t modkandinsky_draw_circle(size_t n_args, const mp_obj_t *args); +mp_obj_t modkandinsky_draw_image(size_t n_args, const mp_obj_t *args); +mp_obj_t modkandinsky_image_size(size_t n_args, const mp_obj_t *args); mp_obj_t modkandinsky_fill_rect(size_t n_args, const mp_obj_t *args); mp_obj_t modkandinsky_fill_circle(size_t n_args, const mp_obj_t *args); mp_obj_t modkandinsky_fill_polygon(size_t n_args, const mp_obj_t *args); diff --git a/python/port/mod/kandinsky/modkandinsky_table.c b/python/port/mod/kandinsky/modkandinsky_table.c index 033dbf5b673..50c177371c9 100644 --- a/python/port/mod/kandinsky/modkandinsky_table.c +++ b/python/port/mod/kandinsky/modkandinsky_table.c @@ -6,8 +6,10 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_3(modkandinsky_set_pixel_obj, modkandinsky_set_pi STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(modkandinsky_draw_string_obj, 3, 6, modkandinsky_draw_string); STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(modkandinsky_draw_line_obj, 5, 5, modkandinsky_draw_line); STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(modkandinsky_draw_circle_obj, 4, 4, modkandinsky_draw_circle); -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(modkandinsky_fill_rect_obj, 5, 5, modkandinsky_fill_rect); STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(modkandinsky_fill_circle_obj, 4, 4, modkandinsky_fill_circle); +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(modkandinsky_fill_rect_obj, 5, 5, modkandinsky_fill_rect); +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(modkandinsky_draw_image_obj, 5, 5, modkandinsky_draw_image); +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(modkandinsky_image_size_obj, 1, 1, modkandinsky_image_size); STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(modkandinsky_fill_polygon_obj, 2, 2, modkandinsky_fill_polygon); STATIC MP_DEFINE_CONST_FUN_OBJ_0(modkandinsky_wait_vblank_obj, modkandinsky_wait_vblank); STATIC MP_DEFINE_CONST_FUN_OBJ_0(modkandinsky_get_palette_obj, modkandinsky_get_palette); @@ -20,6 +22,8 @@ STATIC const mp_rom_map_elem_t modkandinsky_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_draw_string), (mp_obj_t)&modkandinsky_draw_string_obj }, { MP_ROM_QSTR(MP_QSTR_draw_line), (mp_obj_t)&modkandinsky_draw_line_obj }, { MP_ROM_QSTR(MP_QSTR_draw_circle), (mp_obj_t)&modkandinsky_draw_circle_obj }, + { MP_ROM_QSTR(MP_QSTR_draw_image), (mp_obj_t)&modkandinsky_draw_image_obj }, + { MP_ROM_QSTR(MP_QSTR_image_size), (mp_obj_t)&modkandinsky_image_size_obj }, { MP_ROM_QSTR(MP_QSTR_fill_rect), (mp_obj_t)&modkandinsky_fill_rect_obj }, { MP_ROM_QSTR(MP_QSTR_fill_circle), (mp_obj_t)&modkandinsky_fill_circle_obj }, { MP_ROM_QSTR(MP_QSTR_fill_polygon), (mp_obj_t)&modkandinsky_fill_polygon_obj }, From 420bb21a6675cec2353412bd86a85d28bb12bfce Mon Sep 17 00:00:00 2001 From: Oreig403 <97249553+Oreig403@users.noreply.github.com> Date: Fri, 21 Oct 2022 20:13:30 +0200 Subject: [PATCH 02/15] add image support --- python/port/genhdr/qstrdefs.in.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/python/port/genhdr/qstrdefs.in.h b/python/port/genhdr/qstrdefs.in.h index 3fae92b55b0..84a89ca9a20 100644 --- a/python/port/genhdr/qstrdefs.in.h +++ b/python/port/genhdr/qstrdefs.in.h @@ -399,6 +399,8 @@ Q(color) Q(draw_line) Q(draw_string) Q(draw_circle) +Q(draw_image) +Q(image_size) Q(fill_rect) Q(fill_circle) Q(fill_polygon) From 2143ba0756dab05ccbdbf0be4e14192d7e6f13d2 Mon Sep 17 00:00:00 2001 From: Oreig403 <97249553+Oreig403@users.noreply.github.com> Date: Fri, 21 Oct 2022 20:16:41 +0200 Subject: [PATCH 03/15] Add image in catalog --- apps/code/catalog.de.i18n | 2 ++ apps/code/catalog.en.i18n | 3 +++ apps/code/catalog.es.i18n | 2 ++ apps/code/catalog.fr.i18n | 2 ++ apps/code/catalog.hu.i18n | 2 ++ apps/code/catalog.it.i18n | 2 ++ apps/code/catalog.nl.i18n | 2 ++ apps/code/catalog.pt.i18n | 2 ++ apps/code/catalog.universal.i18n | 2 ++ apps/code/python_toolbox.cpp | 2 ++ 10 files changed, 21 insertions(+) diff --git a/apps/code/catalog.de.i18n b/apps/code/catalog.de.i18n index 5ead158750a..e4c90ddb155 100644 --- a/apps/code/catalog.de.i18n +++ b/apps/code/catalog.de.i18n @@ -46,6 +46,8 @@ PythonCount = "Zählt die Vorkommen von x" PythonDegrees = "x von Bogenmaß in Grad umrechnen" PythonDivMod = "Quotient und Rest" PythonDrawCircle = "Zeichne einen Kreis" +PythonDrawImage = "Zeichne ein Bild" +PythonImageSize = "Bildgröße zurückgeben [b,h]" PythonDrawLine = "Eine Linie zeichnen" PythonDrawString = "Text bei Pixel (x,y) darstellen" PythonErf = "Fehlerfunktion" diff --git a/apps/code/catalog.en.i18n b/apps/code/catalog.en.i18n index 62a9400577f..d595d783a28 100644 --- a/apps/code/catalog.en.i18n +++ b/apps/code/catalog.en.i18n @@ -46,6 +46,9 @@ PythonCount = "Count the occurrences of x" PythonDegrees = "Convert x from radians to degrees" PythonDivMod = "Quotient and remainder" PythonDrawCircle = "Draw a circle" +PythonDrawImage = "Draw an image" +PythonImageSize = "Return image size [w,h]" +PythonDrawImage = "Draw an image" PythonDrawLine = "Draw a line" PythonDrawString = "Display a text from pixel (x,y)" PythonErf = "Error function" diff --git a/apps/code/catalog.es.i18n b/apps/code/catalog.es.i18n index 883b47cf481..d9fa02a2aae 100644 --- a/apps/code/catalog.es.i18n +++ b/apps/code/catalog.es.i18n @@ -46,6 +46,8 @@ PythonCount = "Count the occurrences of x" PythonDegrees = "Convert x from radians to degrees" PythonDivMod = "Quotient and remainder" PythonDrawCircle = "Draw a circle" +PythonDrawImage = "Draw an image" +PythonImageSize = "Return image size [w,h]" PythonDrawLine = "Draw a line" PythonDrawString = "Display a text from pixel (x,y)" PythonErf = "Error function" diff --git a/apps/code/catalog.fr.i18n b/apps/code/catalog.fr.i18n index 99377015773..4087368959a 100644 --- a/apps/code/catalog.fr.i18n +++ b/apps/code/catalog.fr.i18n @@ -46,6 +46,8 @@ PythonCount = "Compte les occurrences de x" PythonDegrees = "Conversion de radians en degrés" PythonDivMod = "Quotient et reste" PythonDrawCircle = "Trace un cercle" +PythonDrawImage = "Dessine une image" +PythonImageSize = "Retourne la taille de l'image [w,h]" PythonDrawLine = "Trace une ligne" PythonDrawString = "Affiche un texte au pixel (x,y)" PythonErf = "Fonction d'erreur" diff --git a/apps/code/catalog.hu.i18n b/apps/code/catalog.hu.i18n index 6242e4dc35a..630c90a0b18 100644 --- a/apps/code/catalog.hu.i18n +++ b/apps/code/catalog.hu.i18n @@ -46,6 +46,8 @@ PythonCount = "Számolja az x elöfordulását" PythonDegrees = "x konvertálása radiánokrol fokokra" PythonDivMod = "Hányados és maradék" PythonDrawCircle = "Rajzolj egy kört" +PythonDrawImage = "Rajzolj egy képet" +PythonImageSize = "Visszatérés képmérete [w,h]" PythonDrawLine = "Húzzon egy vonalat " PythonDrawString = "Szöveg megjelenítése (x, y)-en" PythonErf = "Hiba funkció" diff --git a/apps/code/catalog.it.i18n b/apps/code/catalog.it.i18n index d8a24f355b9..3306bcabbc2 100644 --- a/apps/code/catalog.it.i18n +++ b/apps/code/catalog.it.i18n @@ -46,6 +46,8 @@ PythonCount = "Conta le ricorrenze di x" PythonDegrees = "Conversione di radianti in gradi" PythonDivMod = "Quoziente e resto" PythonDrawCircle = "Disegnare un cerchio" +PythonDrawImage = "Disegna un'immagine" +PythonImageSize = "Restituisci la dimensione dell'immagine [l,h]" PythonDrawLine = "Disegna una linea" PythonDrawString = "Visualizza il testo dal pixel x,y" PythonErf = "Funzione d'errore" diff --git a/apps/code/catalog.nl.i18n b/apps/code/catalog.nl.i18n index 876073d95b9..a4f29a3aa47 100644 --- a/apps/code/catalog.nl.i18n +++ b/apps/code/catalog.nl.i18n @@ -46,6 +46,8 @@ PythonCount = "Tel voorkomen van x" PythonDegrees = "Zet x om van radialen naar graden" PythonDivMod = "Quotiënt en rest" PythonDrawCircle = "Teken een cirkel" +PythonDrawImage = "Teken een afbeelding" +PythonImageSize = "Retour afbeeldingsgrootte [b,h]" PythonDrawLine = "Teken een lijn" PythonDrawString = "Geef een tekst weer van pixel (x,y)" PythonErf = "Error functie" diff --git a/apps/code/catalog.pt.i18n b/apps/code/catalog.pt.i18n index 155aa785f56..482153b29ba 100644 --- a/apps/code/catalog.pt.i18n +++ b/apps/code/catalog.pt.i18n @@ -46,6 +46,8 @@ PythonCount = "Contar as ocorrências de x" PythonDegrees = "Converter x de radianos para graus" PythonDivMod = "Quociente e resto" PythonDrawCircle = "Desenha um círculo" +PythonDrawImage = "Desenhe uma imagem" +PythonImageSize = "Tamanho da imagem de retorno [w,h]" PythonDrawLine = "Desenhe uma linha" PythonDrawString = "Mostrar o texto do pixel (x,y)" PythonErf = "Função erro" diff --git a/apps/code/catalog.universal.i18n b/apps/code/catalog.universal.i18n index ca6e19c4576..65c5329adcb 100644 --- a/apps/code/catalog.universal.i18n +++ b/apps/code/catalog.universal.i18n @@ -65,6 +65,8 @@ PythonCommandFabs = "fabs(x)" PythonCommandFillCircle = "fill_circle(x,y,r,color)" PythonCommandFillPolygon = "fill_polygon([(x1,y1),...],color)" PythonCommandFillRect = "fill_rect(x,y,width,height,color)" +PythonCommandDrawImage = "draw_image(image,x,y,width,height)" +PythonCommandImageSize = "image_size(image)" PythonCommandFloat = "float(x)" PythonCommandFloor = "floor(x)" PythonCommandFmod = "fmod(a,b)" diff --git a/apps/code/python_toolbox.cpp b/apps/code/python_toolbox.cpp index 1f75378d332..bcb673fb25b 100644 --- a/apps/code/python_toolbox.cpp +++ b/apps/code/python_toolbox.cpp @@ -374,6 +374,8 @@ const ToolboxMessageTree KandinskyModuleChildren[] = { ToolboxMessageTree::Leaf(I18n::Message::PythonCommandDrawString, I18n::Message::PythonDrawString), ToolboxMessageTree::Leaf(I18n::Message::PythonCommandDrawLine, I18n::Message::PythonDrawLine), ToolboxMessageTree::Leaf(I18n::Message::PythonCommandDrawCircle, I18n::Message::PythonDrawCircle), + ToolboxMessageTree::Leaf(I18n::Message::PythonCommandDrawImage, I18n::Message::PythonDrawImage), + ToolboxMessageTree::Leaf(I18n::Message::PythonCommandImageSize, I18n::Message::PythonImageSize), ToolboxMessageTree::Leaf(I18n::Message::PythonCommandFillRect, I18n::Message::PythonFillRect), ToolboxMessageTree::Leaf(I18n::Message::PythonCommandFillCircle, I18n::Message::PythonFillCircle), ToolboxMessageTree::Leaf(I18n::Message::PythonCommandFillPolygon, I18n::Message::PythonFillPolygon), From 71f2670ab7cc6ac42c7662ce5c0383573e38de4b Mon Sep 17 00:00:00 2001 From: Oreig403 <97249553+Oreig403@users.noreply.github.com> Date: Fri, 21 Oct 2022 20:23:48 +0200 Subject: [PATCH 04/15] add image support --- python/port/mod/kandinsky/modkandinsky.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/python/port/mod/kandinsky/modkandinsky.cpp b/python/port/mod/kandinsky/modkandinsky.cpp index 43c86a13961..b521f686bab 100644 --- a/python/port/mod/kandinsky/modkandinsky.cpp +++ b/python/port/mod/kandinsky/modkandinsky.cpp @@ -140,9 +140,6 @@ mp_obj_t modkandinsky_image_size(size_t n_args, const mp_obj_t * args) { External::Archive::File image; External::Archive::fileAtIndex(index, image); OBMHeader* h = (OBMHeader*)image.data; - mp_obj_t sizeList = mp_obj_new_list(0, NULL); - mp_obj_list_append(sizeList, &(h->width)); - mp_obj_list_append(sizeList, &(h->height)); mp_obj_t size[2]; size[0] = mp_obj_new_int((h->width)); size[1] = mp_obj_new_int((h->height)); From 86b24bf2bf27a551f994e6b4062204148e7d4a55 Mon Sep 17 00:00:00 2001 From: Oreig403 <97249553+Oreig403@users.noreply.github.com> Date: Fri, 21 Oct 2022 21:11:18 +0200 Subject: [PATCH 05/15] Update apps/code/catalog.en.i18n Co-authored-by: Yaya-Cout --- apps/code/catalog.en.i18n | 1 - 1 file changed, 1 deletion(-) diff --git a/apps/code/catalog.en.i18n b/apps/code/catalog.en.i18n index d595d783a28..359e7773622 100644 --- a/apps/code/catalog.en.i18n +++ b/apps/code/catalog.en.i18n @@ -48,7 +48,6 @@ PythonDivMod = "Quotient and remainder" PythonDrawCircle = "Draw a circle" PythonDrawImage = "Draw an image" PythonImageSize = "Return image size [w,h]" -PythonDrawImage = "Draw an image" PythonDrawLine = "Draw a line" PythonDrawString = "Display a text from pixel (x,y)" PythonErf = "Error function" From df7a90040e3804f53c41a773477166206c783ac9 Mon Sep 17 00:00:00 2001 From: Oreig403 <97249553+Oreig403@users.noreply.github.com> Date: Fri, 21 Oct 2022 21:27:54 +0200 Subject: [PATCH 06/15] Update modkandinsky_table.c --- python/port/mod/kandinsky/modkandinsky_table.c | 1 + 1 file changed, 1 insertion(+) diff --git a/python/port/mod/kandinsky/modkandinsky_table.c b/python/port/mod/kandinsky/modkandinsky_table.c index 50c177371c9..68f48e1d53b 100644 --- a/python/port/mod/kandinsky/modkandinsky_table.c +++ b/python/port/mod/kandinsky/modkandinsky_table.c @@ -6,6 +6,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_3(modkandinsky_set_pixel_obj, modkandinsky_set_pi STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(modkandinsky_draw_string_obj, 3, 6, modkandinsky_draw_string); STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(modkandinsky_draw_line_obj, 5, 5, modkandinsky_draw_line); STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(modkandinsky_draw_circle_obj, 4, 4, modkandinsky_draw_circle); +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(modkandinsky_fill_rect_obj, 5, 5, modkandinsky_fill_rect); STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(modkandinsky_fill_circle_obj, 4, 4, modkandinsky_fill_circle); STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(modkandinsky_fill_rect_obj, 5, 5, modkandinsky_fill_rect); STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(modkandinsky_draw_image_obj, 5, 5, modkandinsky_draw_image); From 7939fbed649c3b76ea06a4d7fcc1978c84ef4007 Mon Sep 17 00:00:00 2001 From: Oreig403 <97249553+Oreig403@users.noreply.github.com> Date: Fri, 21 Oct 2022 21:28:53 +0200 Subject: [PATCH 07/15] Update modkandinsky_table.c --- python/port/mod/kandinsky/modkandinsky_table.c | 1 - 1 file changed, 1 deletion(-) diff --git a/python/port/mod/kandinsky/modkandinsky_table.c b/python/port/mod/kandinsky/modkandinsky_table.c index 68f48e1d53b..a884561b565 100644 --- a/python/port/mod/kandinsky/modkandinsky_table.c +++ b/python/port/mod/kandinsky/modkandinsky_table.c @@ -8,7 +8,6 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(modkandinsky_draw_line_obj, 5, 5, mod STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(modkandinsky_draw_circle_obj, 4, 4, modkandinsky_draw_circle); STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(modkandinsky_fill_rect_obj, 5, 5, modkandinsky_fill_rect); STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(modkandinsky_fill_circle_obj, 4, 4, modkandinsky_fill_circle); -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(modkandinsky_fill_rect_obj, 5, 5, modkandinsky_fill_rect); STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(modkandinsky_draw_image_obj, 5, 5, modkandinsky_draw_image); STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(modkandinsky_image_size_obj, 1, 1, modkandinsky_image_size); STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(modkandinsky_fill_polygon_obj, 2, 2, modkandinsky_fill_polygon); From 2d459f89bd48f4ce6dea24ac1ec25e604e79035b Mon Sep 17 00:00:00 2001 From: Oreig403 <97249553+Oreig403@users.noreply.github.com> Date: Sat, 22 Oct 2022 10:08:26 +0200 Subject: [PATCH 08/15] Update modkandinsky.cpp --- python/port/mod/kandinsky/modkandinsky.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/python/port/mod/kandinsky/modkandinsky.cpp b/python/port/mod/kandinsky/modkandinsky.cpp index b521f686bab..735318e3bf3 100644 --- a/python/port/mod/kandinsky/modkandinsky.cpp +++ b/python/port/mod/kandinsky/modkandinsky.cpp @@ -3,8 +3,9 @@ extern "C" { #include #include } - +#ifdef HOME_DISPLAY_EXTERNALS #include +#endif #include #include #include @@ -105,6 +106,7 @@ mp_obj_t modkandinsky_draw_circle(size_t n_args, const mp_obj_t * args) { return mp_const_none; } mp_obj_t modkandinsky_draw_image(size_t n_args, const mp_obj_t * args) { + #ifdef HOME_DISPLAY_EXTERNALS const char * image = mp_obj_str_get_str(args[0]); mp_int_t x = mp_obj_get_int(args[1]); mp_int_t y = mp_obj_get_int(args[2]); @@ -125,28 +127,31 @@ mp_obj_t modkandinsky_draw_image(size_t n_args, const mp_obj_t * args) { External::Archive::File image; External::Archive::fileAtIndex(index, image); OBMHeader* h = (OBMHeader*)image.data; - - MicroPython::ExecutionEnvironment::currentExecutionEnvironment()->displaySandbox(); KDIonContext::sharedContext()->fillRectWithPixels(KDRect(x, y, width, height), &(h->image_data), nullptr); } + #endif return mp_const_none; } mp_obj_t modkandinsky_image_size(size_t n_args, const mp_obj_t * args) { + #ifdef HOME_DISPLAY_EXTERNALS const char * image = mp_obj_str_get_str(args[0]); int index = External::Archive::indexFromName(image); if (index > -1) { External::Archive::File image; External::Archive::fileAtIndex(index, image); OBMHeader* h = (OBMHeader*)image.data; + mp_obj_t sizeList = mp_obj_new_list(0, NULL); + mp_obj_list_append(sizeList, &(h->width)); + mp_obj_list_append(sizeList, &(h->height)); mp_obj_t size[2]; size[0] = mp_obj_new_int((h->width)); size[1] = mp_obj_new_int((h->height)); return mp_obj_new_tuple(2, size); } return mp_const_none; - + #endif } From 875fcbf22325eee4250027c1a5775b707624e8ce Mon Sep 17 00:00:00 2001 From: Oreig403 <97249553+Oreig403@users.noreply.github.com> Date: Sat, 22 Oct 2022 10:23:52 +0200 Subject: [PATCH 09/15] Update modkandinsky.cpp --- python/port/mod/kandinsky/modkandinsky.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/python/port/mod/kandinsky/modkandinsky.cpp b/python/port/mod/kandinsky/modkandinsky.cpp index 735318e3bf3..4ca0204bd35 100644 --- a/python/port/mod/kandinsky/modkandinsky.cpp +++ b/python/port/mod/kandinsky/modkandinsky.cpp @@ -150,8 +150,9 @@ mp_obj_t modkandinsky_image_size(size_t n_args, const mp_obj_t * args) { size[1] = mp_obj_new_int((h->height)); return mp_obj_new_tuple(2, size); } - return mp_const_none; #endif + return mp_const_none; + } From 3ab7bbe00892fc6733762fc696f1402bc22ccba0 Mon Sep 17 00:00:00 2001 From: Oreig403 <97249553+Oreig403@users.noreply.github.com> Date: Sun, 23 Oct 2022 19:06:26 +0200 Subject: [PATCH 10/15] Moving extapp_api and archive to ion --- apps/reader/list_book_controller.cpp | 2 +- apps/reader/list_book_controller.h | 4 ++-- apps/reader/read_book_controller.h | 2 +- apps/reader/utility.h | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/apps/reader/list_book_controller.cpp b/apps/reader/list_book_controller.cpp index 8dbf7aa3b56..0859f7b6f9e 100644 --- a/apps/reader/list_book_controller.cpp +++ b/apps/reader/list_book_controller.cpp @@ -103,4 +103,4 @@ Responder * ListBookController::defaultController() { return parentResponder(); } -} \ No newline at end of file +} diff --git a/apps/reader/list_book_controller.h b/apps/reader/list_book_controller.h index 3250b173f80..fdbafc6aef9 100644 --- a/apps/reader/list_book_controller.h +++ b/apps/reader/list_book_controller.h @@ -2,7 +2,7 @@ #define __LIST_BOOK_CONTROLLER_H__ #include -#include +#include #include "read_book_controller.h" @@ -40,4 +40,4 @@ class ListBookController : public ViewController, public SimpleListViewDataSourc } -#endif \ No newline at end of file +#endif diff --git a/apps/reader/read_book_controller.h b/apps/reader/read_book_controller.h index 7fb42b16587..df157142e8b 100644 --- a/apps/reader/read_book_controller.h +++ b/apps/reader/read_book_controller.h @@ -2,7 +2,7 @@ #define _READ_BOOK_CONTROLLER_H_ #include -#include "apps/external/archive.h" +#include #include "word_wrap_view.h" namespace Reader { diff --git a/apps/reader/utility.h b/apps/reader/utility.h index 61aabbf2cf6..8d9716b7d2a 100644 --- a/apps/reader/utility.h +++ b/apps/reader/utility.h @@ -1,7 +1,7 @@ #ifndef __UTILITY_H__ #define __UTILITY_H__ -#include +#include #include #include From b295495aaf30bfac63fec042a983d1dd936c37cb Mon Sep 17 00:00:00 2001 From: Oreig403 <97249553+Oreig403@users.noreply.github.com> Date: Sun, 23 Oct 2022 19:08:14 +0200 Subject: [PATCH 11/15] Moving extapp_api and archive to ion --- apps/home/controller.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/home/controller.cpp b/apps/home/controller.cpp index a79700b3f0d..8437d33558b 100644 --- a/apps/home/controller.cpp +++ b/apps/home/controller.cpp @@ -11,7 +11,7 @@ extern "C" { #ifdef HOME_DISPLAY_EXTERNALS #include "../external/external_icon.h" -#include "../external/archive.h" +#include #include #endif From 6b0688f1ac64d216c1fbd2f231f84ce6e38cc4e9 Mon Sep 17 00:00:00 2001 From: Oreig403 Date: Sun, 23 Oct 2022 20:11:43 +0200 Subject: [PATCH 12/15] Revert "Moving extapp_api and archive to ion" This reverts commit b295495aaf30bfac63fec042a983d1dd936c37cb. --- apps/home/controller.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/home/controller.cpp b/apps/home/controller.cpp index 8437d33558b..a79700b3f0d 100644 --- a/apps/home/controller.cpp +++ b/apps/home/controller.cpp @@ -11,7 +11,7 @@ extern "C" { #ifdef HOME_DISPLAY_EXTERNALS #include "../external/external_icon.h" -#include +#include "../external/archive.h" #include #endif From ef0e49f0cee7e074abc74f8fb7184b7eea885a0d Mon Sep 17 00:00:00 2001 From: Oreig403 Date: Sun, 23 Oct 2022 20:11:51 +0200 Subject: [PATCH 13/15] Revert "Revert "Moving extapp_api and archive to ion"" This reverts commit 6b0688f1ac64d216c1fbd2f231f84ce6e38cc4e9. --- apps/home/controller.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/home/controller.cpp b/apps/home/controller.cpp index a79700b3f0d..8437d33558b 100644 --- a/apps/home/controller.cpp +++ b/apps/home/controller.cpp @@ -11,7 +11,7 @@ extern "C" { #ifdef HOME_DISPLAY_EXTERNALS #include "../external/external_icon.h" -#include "../external/archive.h" +#include #include #endif From ef3011d0248666cfb430d38e4c9b5a349c83eb1d Mon Sep 17 00:00:00 2001 From: Oreig403 Date: Sun, 23 Oct 2022 20:11:56 +0200 Subject: [PATCH 14/15] Revert "Moving extapp_api and archive to ion" This reverts commit b295495aaf30bfac63fec042a983d1dd936c37cb. --- apps/home/controller.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/home/controller.cpp b/apps/home/controller.cpp index 8437d33558b..a79700b3f0d 100644 --- a/apps/home/controller.cpp +++ b/apps/home/controller.cpp @@ -11,7 +11,7 @@ extern "C" { #ifdef HOME_DISPLAY_EXTERNALS #include "../external/external_icon.h" -#include +#include "../external/archive.h" #include #endif From 7023d0b4373aac95dd8fe49bcf67456af25c04b2 Mon Sep 17 00:00:00 2001 From: Oreig403 Date: Sun, 23 Oct 2022 20:12:02 +0200 Subject: [PATCH 15/15] Revert "Moving extapp_api and archive to ion" This reverts commit 3ab7bbe00892fc6733762fc696f1402bc22ccba0. --- apps/reader/list_book_controller.cpp | 2 +- apps/reader/list_book_controller.h | 4 ++-- apps/reader/read_book_controller.h | 2 +- apps/reader/utility.h | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/apps/reader/list_book_controller.cpp b/apps/reader/list_book_controller.cpp index 0859f7b6f9e..8dbf7aa3b56 100644 --- a/apps/reader/list_book_controller.cpp +++ b/apps/reader/list_book_controller.cpp @@ -103,4 +103,4 @@ Responder * ListBookController::defaultController() { return parentResponder(); } -} +} \ No newline at end of file diff --git a/apps/reader/list_book_controller.h b/apps/reader/list_book_controller.h index fdbafc6aef9..3250b173f80 100644 --- a/apps/reader/list_book_controller.h +++ b/apps/reader/list_book_controller.h @@ -2,7 +2,7 @@ #define __LIST_BOOK_CONTROLLER_H__ #include -#include +#include #include "read_book_controller.h" @@ -40,4 +40,4 @@ class ListBookController : public ViewController, public SimpleListViewDataSourc } -#endif +#endif \ No newline at end of file diff --git a/apps/reader/read_book_controller.h b/apps/reader/read_book_controller.h index df157142e8b..7fb42b16587 100644 --- a/apps/reader/read_book_controller.h +++ b/apps/reader/read_book_controller.h @@ -2,7 +2,7 @@ #define _READ_BOOK_CONTROLLER_H_ #include -#include +#include "apps/external/archive.h" #include "word_wrap_view.h" namespace Reader { diff --git a/apps/reader/utility.h b/apps/reader/utility.h index 8d9716b7d2a..61aabbf2cf6 100644 --- a/apps/reader/utility.h +++ b/apps/reader/utility.h @@ -1,7 +1,7 @@ #ifndef __UTILITY_H__ #define __UTILITY_H__ -#include +#include #include #include