From bcde0aefbdb3c3b17bbed56340587e5d85cb72ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=82=E3=81=8F?= Date: Wed, 20 Mar 2024 00:23:06 +0900 Subject: [PATCH] [FL-3729] Gui: unicode support, new canvas API (#3322) * Revert "Rollback #3305 and #3297 fix various rendering issues (#3307)" This reverts commit 531ba24e9a1af8ff007e72dd976cb66259895bc7. * Gui: refactor canvas to use proper coordinate system types. Furi: new furi_break check macros. Desktop: proper types for negative offset. * Desktop: proper types in desktop_view_locked_doors_draw * Examples: update images example, off it goes --------- Co-authored-by: hedger --- .../example_custom_font/example_custom_font.c | 86 ++++++++---- .../examples/example_images/example_images.c | 4 +- .../desktop/views/desktop_view_locked.c | 20 +-- applications/services/gui/canvas.c | 124 ++++++++--------- applications/services/gui/canvas.h | 131 +++++++++--------- applications/services/gui/canvas_i.h | 24 ++-- furi/core/check.h | 7 + lib/u8g2/u8g2.h | 2 +- targets/f18/api_symbols.csv | 42 +++--- targets/f7/api_symbols.csv | 42 +++--- 10 files changed, 259 insertions(+), 223 deletions(-) diff --git a/applications/examples/example_custom_font/example_custom_font.c b/applications/examples/example_custom_font/example_custom_font.c index 2fec419041b..405db46e30a 100644 --- a/applications/examples/example_custom_font/example_custom_font.c +++ b/applications/examples/example_custom_font/example_custom_font.c @@ -11,35 +11,62 @@ //This arrays contains the font itself. You can use any u8g2 font you want /* -Fontname: -Raccoon-Fixed4x6-Medium-R-Normal--6-60-75-75-P-40-ISO10646-1 -Copyright: -Glyphs: 95/203 -BBX Build Mode: 0 + Fontname: -Misc-Fixed-Medium-R-Normal--6-60-75-75-C-40-ISO10646-1 + Copyright: Public domain font. Share and enjoy. + Glyphs: 191/919 + BBX Build Mode: 0 */ -const uint8_t u8g2_font_tom_thumb_4x6_tr[725] = - "_\0\2\2\2\3\3\4\4\3\6\0\377\5\377\5\0\0\352\1\330\2\270 \5\340\315\0!\6\265\310" - "\254\0\42\6\213\313$\25#\10\227\310\244\241\206\12$\10\227\310\215\70b\2%\10\227\310d\324F\1" - "&\10\227\310(\65R\22'\5\251\313\10(\6\266\310\251\62)\10\226\310\304\224\24\0*\6\217\312\244" - "\16+\7\217\311\245\225\0,\6\212\310)\0-\5\207\312\14.\5\245\310\4/\7\227\310Ve\4\60" - "\7\227\310-k\1\61\6\226\310\255\6\62\10\227\310h\220\312\1\63\11\227\310h\220\62X\0\64\10\227" - "\310$\65b\1\65\10\227\310\214\250\301\2\66\10\227\310\315\221F\0\67\10\227\310\314TF\0\70\10\227" - "\310\214\64\324\10\71\10\227\310\214\64\342\2:\6\255\311\244\0;\7\222\310e\240\0<\10\227\310\246\32" - "d\20=\6\217\311l\60>\11\227\310d\220A*\1\77\10\227\310\314\224a\2@\10\227\310UC\3" - "\1A\10\227\310UC\251\0B\10\227\310\250\264\322\2C\7\227\310\315\32\10D\10\227\310\250d-\0" - "E\10\227\310\214\70\342\0F\10\227\310\214\70b\4G\10\227\310\315\221\222\0H\10\227\310$\65\224\12" - "I\7\227\310\254X\15J\7\227\310\226\252\2K\10\227\310$\265\222\12L\7\227\310\304\346\0M\10\227" - "\310\244\61\224\12N\10\227\310\244q\250\0O\7\227\310UV\5P\10\227\310\250\264b\4Q\10\227\310" - "Uj$\1R\10\227\310\250\64V\1S\10\227\310m\220\301\2T\7\227\310\254\330\2U\7\227\310$" - "W\22V\10\227\310$\253L\0W\10\227\310$\65\206\12X\10\227\310$\325R\1Y\10\227\310$U" - "V\0Z\7\227\310\314T\16[\7\227\310\214X\16\134\10\217\311d\220A\0]\7\227\310\314r\4^" - "\5\213\313\65_\5\207\310\14`\6\212\313\304\0a\7\223\310\310\65\2b\10\227\310D\225\324\2c\7" - "\223\310\315\14\4d\10\227\310\246\245\222\0e\6\223\310\235\2f\10\227\310\246\264b\2g\10\227\307\35" - "\61%\0h\10\227\310D\225\254\0i\6\265\310\244\1j\10\233\307f\30U\5k\10\227\310\304\264T" - "\1l\7\227\310\310\326\0m\7\223\310\11\253\310d\220A*\1\77\11\253\310h\220\62L\0@\7" + "\253\310-\33\10A\10\253\310UC\251\0B\10\253\310\250\264\322\2C\10\253\310U\62U\0D\10\253" + "\310\250d-\0E\10\253\310\214\250\342\0F\10\253\310\214\250b\4G\10\253\310\315\244\222\0H\10\253" + "\310$\65\224\12I\7\253\310\254X\15J\7\253\310\226\252\2K\10\253\310$\265\222\12L\7\253\310\304" + "\346\0M\10\253\310\244\61\224\12N\10\253\310\252\241$\0O\7\253\310UV\5P\10\253\310\250\264b" + "\4Q\10\263\307UV\15\2R\10\253\310\250\264\222\12S\10\253\310m\220\301\2T\7\253\310\254\330\2" + "U\7\253\310$\327\10V\10\253\310$k\244\4W\10\253\310$\65\206\12X\10\253\310$\325R\1Y" + "\10\253\310$UV\0Z\7\253\310\314T\16[\6\352\310\254J\134\11\253\310\304\14\62\210\1]\6\252" + "\310\250j^\5\223\313\65_\5\213\307\14`\6\322\313\304\0a\7\243\310-\225\4b\10\253\310D\225" + "\324\2c\7\243\310\315\14\4d\10\253\310\246\245\222\0e\6\243\310USf\10\253\310\246\264b\2g" + "\10\253\307\255$\27\0h\10\253\310D\225\254\0i\10\253\310e$\323\0j\10\263\307fX.\0k" + "\10\253\310\304\264\222\12l\7\253\310\310\326\0m\10\243\310\244\241T\0n\7\243\310\250d\5o\7\243" + "\310U\252\2p\10\253\307\250\264b\4q\10\253\307-\225d\0r\10\243\310\244\25#\0s\10\243\310" + "\215\14\26\0t\10\253\310\245\25\63\10u\7\243\310$+\11v\7\243\310$\253\2w\10\243\310$\65" + "T\0x\7\243\310\244\62\25y\10\253\307$\225\344\2z\7\243\310\314\224\6{\10\263\307\246$k\20" + "|\6\351\310\14\1}\11\263\307d\20UL\21~\7\224\313%\225\0\0\0\0\4\377\377\4\1\11\253" + "\310\244\261\342\0\4\2\11\253\310\214\250\222\12\4\3\10\253\310\16Y\2\4\4\11\253\310M\225\201\0\4" + "\5\11\253\310m\220\301\2\4\6\10\253\310\254X\15\4\7\11\253\310\244\221b\32\4\10\10\253\310\226\252" + "\2\4\11\11\254\310L\325Z\2\4\12\11\254\310\244\326JK\4\13\11\253\310\250\250\222\12\4\14\10\253" + "\310\312\264\12\4\16\11\263\307\244\32u\2\4\17\11\263\307$\327H\11\4\20\11\253\310UC\251\0\4" + "\21\11\253\310\214\250\322\2\4\22\11\253\310\250\264\322\2\4\23\10\253\310\214\330\4\4\24\11\263\307\254\245" + "\206\12\4\25\11\253\310\214\250\342\0\4\26\12\253\310\244\221\322H\1\4\27\12\253\310h\220\62X\0\4" + "\30\11\253\310\304\64T\14\4\31\11\263\307\315\64T\14\4\32\11\253\310$\265\222\12\4\33\10\253\310-" + "W\0\4\34\11\253\310\244\241\254\0\4\35\11\253\310$\65\224\12\4\36\10\253\310UV\5\4\37\10\253" + "\310\214\344\12\4 \11\253\310\250\264b\4\4!\11\253\310U\62U\0\4\42\10\253\310\254\330\2\4#" + "\11\263\307$\253L\21\4$\12\253\310\245\221FJ\0\4%\11\253\310$\325R\1\4&\10\253\310$" + "\327\10\4'\11\253\310$\225d\1\4(\11\253\310$\65\216\0\4)\12\264\307\244\326#\203\0\4*" + "\13\254\310h\220\201LI\1\4+\12\254\310D\271\324H\1\4,\11\253\310\304\250\322\2\4-\11\253" + "\310h\220\344\2\4.\12\254\310\244\244.\225\0\4/\11\253\310\255\264T\0\4\60\10\243\310-\225\4" + "\4\61\11\253\310\315\221*\0\4\62\11\243\310\14\225\26\0\4\63\10\243\310\214X\2\4\64\11\253\307-" + "\65T\0\4\65\7\243\310US\4\66\11\244\310$S%\1\4\67\11\243\310\254\14\26\0\4\70\11\243" + "\310\244\61T\0\4\71\11\253\310\244\326P\1\4:\10\243\310$\265\12\4;\7\243\310-+\4<\11" + "\243\310\244\241T\0\4=\11\243\310\244\241T\0\4>\10\243\310U\252\2\4\77\10\243\310\214d\5\4" + "@\11\253\307\250\264b\4\4A\10\243\310\315\14\4\4B\10\243\310\254X\1\4C\11\253\307$\225\344" + "\2\4D\12\263\307\305\224T\231\0\4E\10\243\310\244\62\25\4F\11\253\307$k\304\0\4G\11\243" + "\310$\225d\0\4H\10\243\310\244q\4\4I\11\254\307\244\364\310 \4J\12\244\310h SR\0" + "\4K\11\244\310\304\245F\12\4L\11\243\310D\225\26\0\4M\10\243\310H\271\0\4N\12\244\310\244" + "\244\226J\0\4O\10\243\310\255\264\2\4Q\10\253\310\244\326\24\4R\11\263\307D\25U\31\4S\11" + "\253\310\246\64b\4\4T\11\243\310\215\224\201\0\4U\11\243\310\215\14\26\0\4V\11\253\310e$\323" + "\0\4W\11\253\310\244\14d\32\4X\11\263\307fX.\0\4Y\10\244\310\251\326\22\4Z\11\244\310" + "\244\264\322\22\4[\11\253\310D\25U\1\4\134\10\253\310\312\264\12\4^\11\263\307\244\32u\2\4_" + "\11\253\307$k\244\4\4\220\10\253\310\16Y\2\4\221\10\243\310\16\31\1\4\222\11\253\310\251\264b\2" + "\4\223\11\243\310\251\264\22\0\0"; // Screen is 128x64 px static void app_draw_callback(Canvas* canvas, void* ctx) { @@ -47,10 +74,11 @@ static void app_draw_callback(Canvas* canvas, void* ctx) { canvas_clear(canvas); - canvas_set_custom_u8g2_font(canvas, u8g2_font_tom_thumb_4x6_tr); + canvas_set_custom_u8g2_font(canvas, u8g2_font_4x6_t_cyrillic); canvas_draw_str(canvas, 0, 6, "This is a tiny custom font"); canvas_draw_str(canvas, 0, 12, "012345.?! ,:;\"\'@#$%"); + canvas_draw_str(canvas, 0, 18, "И немного юникода"); } static void app_input_callback(InputEvent* input_event, void* ctx) { diff --git a/applications/examples/example_images/example_images.c b/applications/examples/example_images/example_images.c index c43a30b698a..ba9a354f608 100644 --- a/applications/examples/example_images/example_images.c +++ b/applications/examples/example_images/example_images.c @@ -13,7 +13,7 @@ #include "example_images_icons.h" typedef struct { - uint8_t x, y; + int32_t x, y; } ImagePosition; static ImagePosition image_position = {.x = 0, .y = 0}; @@ -23,7 +23,7 @@ static void app_draw_callback(Canvas* canvas, void* ctx) { UNUSED(ctx); canvas_clear(canvas); - canvas_draw_icon(canvas, image_position.x % 128, image_position.y % 64, &I_dolphin_71x25); + canvas_draw_icon(canvas, image_position.x, image_position.y, &I_dolphin_71x25); } static void app_input_callback(InputEvent* input_event, void* ctx) { diff --git a/applications/services/desktop/views/desktop_view_locked.c b/applications/services/desktop/views/desktop_view_locked.c index 47e9802fdf9..34d92b0ddb2 100644 --- a/applications/services/desktop/views/desktop_view_locked.c +++ b/applications/services/desktop/views/desktop_view_locked.c @@ -14,14 +14,14 @@ #define LOCKED_HINT_TIMEOUT_MS (1000) #define UNLOCKED_HINT_TIMEOUT_MS (2000) -#define DOOR_OFFSET_START -55 -#define DOOR_OFFSET_END 0 +#define DOOR_OFFSET_START (-55) +#define DOOR_OFFSET_END (0) -#define DOOR_L_FINAL_POS 0 -#define DOOR_R_FINAL_POS 60 +#define DOOR_L_FINAL_POS (0) +#define DOOR_R_FINAL_POS (60) -#define UNLOCK_CNT 3 -#define UNLOCK_RST_TIMEOUT 600 +#define UNLOCK_CNT (3) +#define UNLOCK_RST_TIMEOUT (600) struct DesktopViewLocked { View* view; @@ -63,10 +63,10 @@ static void locked_view_timer_callback(void* context) { } static void desktop_view_locked_doors_draw(Canvas* canvas, DesktopViewLockedModel* model) { - int8_t offset = model->door_offset; - uint8_t door_left_x = DOOR_L_FINAL_POS + offset; - uint8_t door_right_x = DOOR_R_FINAL_POS - offset; - uint8_t height = icon_get_height(&I_DoorLeft_70x55); + int32_t offset = model->door_offset; + int32_t door_left_x = DOOR_L_FINAL_POS + offset; + int32_t door_right_x = DOOR_R_FINAL_POS - offset; + size_t height = icon_get_height(&I_DoorLeft_70x55); canvas_draw_icon(canvas, door_left_x, canvas_height(canvas) - height, &I_DoorLeft_70x55); canvas_draw_icon(canvas, door_right_x, canvas_height(canvas) - height, &I_DoorRight_70x55); } diff --git a/applications/services/gui/canvas.c b/applications/services/gui/canvas.c index 2c0d1d5a8b7..c2931658790 100644 --- a/applications/services/gui/canvas.c +++ b/applications/services/gui/canvas.c @@ -95,10 +95,10 @@ size_t canvas_get_buffer_size(const Canvas* canvas) { void canvas_frame_set( Canvas* canvas, - uint8_t offset_x, - uint8_t offset_y, - uint8_t width, - uint8_t height) { + int32_t offset_x, + int32_t offset_y, + size_t width, + size_t height) { furi_check(canvas); canvas->offset_x = offset_x; canvas->offset_y = offset_y; @@ -106,19 +106,19 @@ void canvas_frame_set( canvas->height = height; } -uint8_t canvas_width(const Canvas* canvas) { +size_t canvas_width(const Canvas* canvas) { furi_check(canvas); return canvas->width; } -uint8_t canvas_height(const Canvas* canvas) { +size_t canvas_height(const Canvas* canvas) { furi_check(canvas); return canvas->height; } -uint8_t canvas_current_font_height(const Canvas* canvas) { +size_t canvas_current_font_height(const Canvas* canvas) { furi_check(canvas); - uint8_t font_height = u8g2_GetMaxCharHeight(&canvas->fb); + size_t font_height = u8g2_GetMaxCharHeight(&canvas->fb); if(canvas->fb.font == u8g2_font_haxrcorp4089_tr) { font_height += 1; @@ -174,18 +174,18 @@ void canvas_set_custom_u8g2_font(Canvas* canvas, const uint8_t* font) { u8g2_SetFont(&canvas->fb, font); } -void canvas_draw_str(Canvas* canvas, uint8_t x, uint8_t y, const char* str) { +void canvas_draw_str(Canvas* canvas, int32_t x, int32_t y, const char* str) { furi_check(canvas); if(!str) return; x += canvas->offset_x; y += canvas->offset_y; - u8g2_DrawStr(&canvas->fb, x, y, str); + u8g2_DrawUTF8(&canvas->fb, x, y, str); } void canvas_draw_str_aligned( Canvas* canvas, - uint8_t x, - uint8_t y, + int32_t x, + int32_t y, Align horizontal, Align vertical, const char* str) { @@ -198,10 +198,10 @@ void canvas_draw_str_aligned( case AlignLeft: break; case AlignRight: - x -= u8g2_GetStrWidth(&canvas->fb, str); + x -= u8g2_GetUTF8Width(&canvas->fb, str); break; case AlignCenter: - x -= (u8g2_GetStrWidth(&canvas->fb, str) / 2); + x -= (u8g2_GetUTF8Width(&canvas->fb, str) / 2); break; default: furi_crash(); @@ -222,26 +222,26 @@ void canvas_draw_str_aligned( break; } - u8g2_DrawStr(&canvas->fb, x, y, str); + u8g2_DrawUTF8(&canvas->fb, x, y, str); } uint16_t canvas_string_width(Canvas* canvas, const char* str) { furi_check(canvas); if(!str) return 0; - return u8g2_GetStrWidth(&canvas->fb, str); + return u8g2_GetUTF8Width(&canvas->fb, str); } -uint8_t canvas_glyph_width(Canvas* canvas, uint16_t symbol) { +size_t canvas_glyph_width(Canvas* canvas, uint16_t symbol) { furi_check(canvas); return u8g2_GetGlyphWidth(&canvas->fb, symbol); } void canvas_draw_bitmap( Canvas* canvas, - uint8_t x, - uint8_t y, - uint8_t width, - uint8_t height, + int32_t x, + int32_t y, + size_t width, + size_t height, const uint8_t* compressed_bitmap_data) { furi_check(canvas); @@ -254,8 +254,8 @@ void canvas_draw_bitmap( void canvas_draw_icon_animation( Canvas* canvas, - uint8_t x, - uint8_t y, + int32_t x, + int32_t y, IconAnimation* icon_animation) { furi_check(canvas); furi_check(icon_animation); @@ -350,28 +350,28 @@ static void canvas_draw_u8g2_bitmap_int( void canvas_draw_u8g2_bitmap( u8g2_t* u8g2, - u8g2_uint_t x, - u8g2_uint_t y, - u8g2_uint_t w, - u8g2_uint_t h, + int32_t x, + int32_t y, + size_t width, + size_t height, const uint8_t* bitmap, IconRotation rotation) { #ifdef U8G2_WITH_INTERSECTION - if(u8g2_IsIntersection(u8g2, x, y, x + w, y + h) == 0) return; + if(u8g2_IsIntersection(u8g2, x, y, x + width, y + height) == 0) return; #endif /* U8G2_WITH_INTERSECTION */ switch(rotation) { case IconRotation0: - canvas_draw_u8g2_bitmap_int(u8g2, x, y, w, h, 0, 0, bitmap); + canvas_draw_u8g2_bitmap_int(u8g2, x, y, width, height, 0, 0, bitmap); break; case IconRotation90: - canvas_draw_u8g2_bitmap_int(u8g2, x, y, w, h, 0, 1, bitmap); + canvas_draw_u8g2_bitmap_int(u8g2, x, y, width, height, 0, 1, bitmap); break; case IconRotation180: - canvas_draw_u8g2_bitmap_int(u8g2, x, y, w, h, 1, 0, bitmap); + canvas_draw_u8g2_bitmap_int(u8g2, x, y, width, height, 1, 0, bitmap); break; case IconRotation270: - canvas_draw_u8g2_bitmap_int(u8g2, x, y, w, h, 1, 1, bitmap); + canvas_draw_u8g2_bitmap_int(u8g2, x, y, width, height, 1, 1, bitmap); break; default: break; @@ -380,8 +380,8 @@ void canvas_draw_u8g2_bitmap( void canvas_draw_icon_ex( Canvas* canvas, - uint8_t x, - uint8_t y, + int32_t x, + int32_t y, const Icon* icon, IconRotation rotation) { furi_check(canvas); @@ -395,7 +395,7 @@ void canvas_draw_icon_ex( &canvas->fb, x, y, icon_get_width(icon), icon_get_height(icon), icon_data, rotation); } -void canvas_draw_icon(Canvas* canvas, uint8_t x, uint8_t y, const Icon* icon) { +void canvas_draw_icon(Canvas* canvas, int32_t x, int32_t y, const Icon* icon) { furi_check(canvas); furi_check(icon); @@ -407,14 +407,14 @@ void canvas_draw_icon(Canvas* canvas, uint8_t x, uint8_t y, const Icon* icon) { &canvas->fb, x, y, icon_get_width(icon), icon_get_height(icon), icon_data, IconRotation0); } -void canvas_draw_dot(Canvas* canvas, uint8_t x, uint8_t y) { +void canvas_draw_dot(Canvas* canvas, int32_t x, int32_t y) { furi_check(canvas); x += canvas->offset_x; y += canvas->offset_y; u8g2_DrawPixel(&canvas->fb, x, y); } -void canvas_draw_box(Canvas* canvas, uint8_t x, uint8_t y, uint8_t width, uint8_t height) { +void canvas_draw_box(Canvas* canvas, int32_t x, int32_t y, size_t width, size_t height) { furi_check(canvas); x += canvas->offset_x; y += canvas->offset_y; @@ -423,18 +423,18 @@ void canvas_draw_box(Canvas* canvas, uint8_t x, uint8_t y, uint8_t width, uint8_ void canvas_draw_rbox( Canvas* canvas, - uint8_t x, - uint8_t y, - uint8_t width, - uint8_t height, - uint8_t radius) { + int32_t x, + int32_t y, + size_t width, + size_t height, + size_t radius) { furi_check(canvas); x += canvas->offset_x; y += canvas->offset_y; u8g2_DrawRBox(&canvas->fb, x, y, width, height, radius); } -void canvas_draw_frame(Canvas* canvas, uint8_t x, uint8_t y, uint8_t width, uint8_t height) { +void canvas_draw_frame(Canvas* canvas, int32_t x, int32_t y, size_t width, size_t height) { furi_check(canvas); x += canvas->offset_x; y += canvas->offset_y; @@ -443,18 +443,18 @@ void canvas_draw_frame(Canvas* canvas, uint8_t x, uint8_t y, uint8_t width, uint void canvas_draw_rframe( Canvas* canvas, - uint8_t x, - uint8_t y, - uint8_t width, - uint8_t height, - uint8_t radius) { + int32_t x, + int32_t y, + size_t width, + size_t height, + size_t radius) { furi_check(canvas); x += canvas->offset_x; y += canvas->offset_y; u8g2_DrawRFrame(&canvas->fb, x, y, width, height, radius); } -void canvas_draw_line(Canvas* canvas, uint8_t x1, uint8_t y1, uint8_t x2, uint8_t y2) { +void canvas_draw_line(Canvas* canvas, int32_t x1, int32_t y1, int32_t x2, int32_t y2) { furi_check(canvas); x1 += canvas->offset_x; y1 += canvas->offset_y; @@ -463,14 +463,14 @@ void canvas_draw_line(Canvas* canvas, uint8_t x1, uint8_t y1, uint8_t x2, uint8_ u8g2_DrawLine(&canvas->fb, x1, y1, x2, y2); } -void canvas_draw_circle(Canvas* canvas, uint8_t x, uint8_t y, uint8_t radius) { +void canvas_draw_circle(Canvas* canvas, int32_t x, int32_t y, size_t radius) { furi_check(canvas); x += canvas->offset_x; y += canvas->offset_y; u8g2_DrawCircle(&canvas->fb, x, y, radius, U8G2_DRAW_ALL); } -void canvas_draw_disc(Canvas* canvas, uint8_t x, uint8_t y, uint8_t radius) { +void canvas_draw_disc(Canvas* canvas, int32_t x, int32_t y, size_t radius) { furi_check(canvas); x += canvas->offset_x; y += canvas->offset_y; @@ -479,10 +479,10 @@ void canvas_draw_disc(Canvas* canvas, uint8_t x, uint8_t y, uint8_t radius) { void canvas_draw_triangle( Canvas* canvas, - uint8_t x, - uint8_t y, - uint8_t base, - uint8_t height, + int32_t x, + int32_t y, + size_t base, + size_t height, CanvasDirection dir) { furi_check(canvas); if(dir == CanvasDirectionBottomToTop) { @@ -506,18 +506,18 @@ void canvas_draw_triangle( void canvas_draw_xbm( Canvas* canvas, - uint8_t x, - uint8_t y, - uint8_t w, - uint8_t h, + int32_t x, + int32_t y, + size_t width, + size_t height, const uint8_t* bitmap) { furi_check(canvas); x += canvas->offset_x; y += canvas->offset_y; - canvas_draw_u8g2_bitmap(&canvas->fb, x, y, w, h, bitmap, IconRotation0); + canvas_draw_u8g2_bitmap(&canvas->fb, x, y, width, height, bitmap, IconRotation0); } -void canvas_draw_glyph(Canvas* canvas, uint8_t x, uint8_t y, uint16_t ch) { +void canvas_draw_glyph(Canvas* canvas, int32_t x, int32_t y, uint16_t ch) { furi_check(canvas); x += canvas->offset_x; y += canvas->offset_y; @@ -591,4 +591,4 @@ void canvas_remove_framebuffer_callback( furi_check(CanvasCallbackPairArray_count(canvas->canvas_callback_pair, p) == 1); CanvasCallbackPairArray_remove_val(canvas->canvas_callback_pair, p); canvas_unlock(canvas); -} \ No newline at end of file +} diff --git a/applications/services/gui/canvas.h b/applications/services/gui/canvas.h index b1a1b04be25..9554a200e3e 100644 --- a/applications/services/gui/canvas.h +++ b/applications/services/gui/canvas.h @@ -6,6 +6,7 @@ #pragma once #include +#include #include #include @@ -101,7 +102,7 @@ void canvas_commit(Canvas* canvas); * * @return width in pixels. */ -uint8_t canvas_width(const Canvas* canvas); +size_t canvas_width(const Canvas* canvas); /** Get Canvas height * @@ -109,7 +110,7 @@ uint8_t canvas_width(const Canvas* canvas); * * @return height in pixels. */ -uint8_t canvas_height(const Canvas* canvas); +size_t canvas_height(const Canvas* canvas); /** Get current font height * @@ -117,7 +118,7 @@ uint8_t canvas_height(const Canvas* canvas); * * @return height in pixels. */ -uint8_t canvas_current_font_height(const Canvas* canvas); +size_t canvas_current_font_height(const Canvas* canvas); /** Get font parameters * @@ -141,8 +142,7 @@ void canvas_clear(Canvas* canvas); */ void canvas_set_color(Canvas* canvas, Color color); -/** Set font swap - * Argument String Rotation Description +/** Set font swap Argument String Rotation Description * * @param canvas Canvas instance * @param dir Direction font @@ -176,7 +176,7 @@ void canvas_set_custom_u8g2_font(Canvas* canvas, const uint8_t* font); * @param y anchor point y coordinate * @param str C-string */ -void canvas_draw_str(Canvas* canvas, uint8_t x, uint8_t y, const char* str); +void canvas_draw_str(Canvas* canvas, int32_t x, int32_t y, const char* str); /** Draw aligned string defined by x, y. * @@ -192,8 +192,8 @@ void canvas_draw_str(Canvas* canvas, uint8_t x, uint8_t y, const char* str); */ void canvas_draw_str_aligned( Canvas* canvas, - uint8_t x, - uint8_t y, + int32_t x, + int32_t y, Align horizontal, Align vertical, const char* str); @@ -214,37 +214,37 @@ uint16_t canvas_string_width(Canvas* canvas, const char* str); * * @return width in pixels */ -uint8_t canvas_glyph_width(Canvas* canvas, uint16_t symbol); +size_t canvas_glyph_width(Canvas* canvas, uint16_t symbol); /** Draw bitmap picture at position defined by x,y. * - * @param canvas Canvas instance - * @param x x coordinate - * @param y y coordinate - * @param width width of bitmap - * @param height height of bitmap - * @param compressed_bitmap_data compressed bitmap data + * @param canvas Canvas instance + * @param x x coordinate + * @param y y coordinate + * @param width width of bitmap + * @param height height of bitmap + * @param compressed_bitmap_data compressed bitmap data */ void canvas_draw_bitmap( Canvas* canvas, - uint8_t x, - uint8_t y, - uint8_t width, - uint8_t height, + int32_t x, + int32_t y, + size_t width, + size_t height, const uint8_t* compressed_bitmap_data); /** Draw icon at position defined by x,y with rotation and flip. * - * @param canvas Canvas instance - * @param x x coordinate - * @param y y coordinate - * @param icon Icon instance - * @param rotation IconRotation + * @param canvas Canvas instance + * @param x x coordinate + * @param y y coordinate + * @param icon Icon instance + * @param rotation IconRotation */ void canvas_draw_icon_ex( Canvas* canvas, - uint8_t x, - uint8_t y, + int32_t x, + int32_t y, const Icon* icon, IconRotation rotation); @@ -257,8 +257,8 @@ void canvas_draw_icon_ex( */ void canvas_draw_icon_animation( Canvas* canvas, - uint8_t x, - uint8_t y, + int32_t x, + int32_t y, IconAnimation* icon_animation); /** Draw icon at position defined by x,y. @@ -268,23 +268,23 @@ void canvas_draw_icon_animation( * @param y y coordinate * @param icon Icon instance */ -void canvas_draw_icon(Canvas* canvas, uint8_t x, uint8_t y, const Icon* icon); +void canvas_draw_icon(Canvas* canvas, int32_t x, int32_t y, const Icon* icon); /** Draw XBM bitmap * * @param canvas Canvas instance * @param x x coordinate * @param y y coordinate - * @param w bitmap width - * @param h bitmap height + * @param[in] width bitmap width + * @param[in] height bitmap height * @param bitmap pointer to XBM bitmap data */ void canvas_draw_xbm( Canvas* canvas, - uint8_t x, - uint8_t y, - uint8_t w, - uint8_t h, + int32_t x, + int32_t y, + size_t width, + size_t height, const uint8_t* bitmap); /** Draw dot at x,y @@ -293,7 +293,7 @@ void canvas_draw_xbm( * @param x x coordinate * @param y y coordinate */ -void canvas_draw_dot(Canvas* canvas, uint8_t x, uint8_t y); +void canvas_draw_dot(Canvas* canvas, int32_t x, int32_t y); /** Draw box of width, height at x,y * @@ -303,7 +303,7 @@ void canvas_draw_dot(Canvas* canvas, uint8_t x, uint8_t y); * @param width box width * @param height box height */ -void canvas_draw_box(Canvas* canvas, uint8_t x, uint8_t y, uint8_t width, uint8_t height); +void canvas_draw_box(Canvas* canvas, int32_t x, int32_t y, size_t width, size_t height); /** Draw frame of width, height at x,y * @@ -313,7 +313,7 @@ void canvas_draw_box(Canvas* canvas, uint8_t x, uint8_t y, uint8_t width, uint8_ * @param width frame width * @param height frame height */ -void canvas_draw_frame(Canvas* canvas, uint8_t x, uint8_t y, uint8_t width, uint8_t height); +void canvas_draw_frame(Canvas* canvas, int32_t x, int32_t y, size_t width, size_t height); /** Draw line from x1,y1 to x2,y2 * @@ -323,41 +323,42 @@ void canvas_draw_frame(Canvas* canvas, uint8_t x, uint8_t y, uint8_t width, uint * @param x2 x2 coordinate * @param y2 y2 coordinate */ -void canvas_draw_line(Canvas* canvas, uint8_t x1, uint8_t y1, uint8_t x2, uint8_t y2); +void canvas_draw_line(Canvas* canvas, int32_t x1, int32_t y1, int32_t x2, int32_t y2); /** Draw circle at x,y with radius r * * @param canvas Canvas instance * @param x x coordinate * @param y y coordinate - * @param r radius + * @param radius radius */ -void canvas_draw_circle(Canvas* canvas, uint8_t x, uint8_t y, uint8_t r); +void canvas_draw_circle(Canvas* canvas, int32_t x, int32_t y, size_t radius); /** Draw disc at x,y with radius r * * @param canvas Canvas instance * @param x x coordinate * @param y y coordinate - * @param r radius + * @param radius radius */ -void canvas_draw_disc(Canvas* canvas, uint8_t x, uint8_t y, uint8_t r); +void canvas_draw_disc(Canvas* canvas, int32_t x, int32_t y, size_t radius); -/** Draw triangle with given base and height lengths and their intersection coordinate +/** Draw triangle with given base and height lengths and their intersection + * coordinate * - * @param canvas Canvas instance - * @param x x coordinate of base and height intersection - * @param y y coordinate of base and height intersection - * @param base length of triangle side - * @param height length of triangle height - * @param dir CanvasDirection triangle orientation + * @param canvas Canvas instance + * @param x x coordinate of base and height intersection + * @param y y coordinate of base and height intersection + * @param base length of triangle side + * @param height length of triangle height + * @param dir CanvasDirection triangle orientation */ void canvas_draw_triangle( Canvas* canvas, - uint8_t x, - uint8_t y, - uint8_t base, - uint8_t height, + int32_t x, + int32_t y, + size_t base, + size_t height, CanvasDirection dir); /** Draw glyph @@ -367,7 +368,7 @@ void canvas_draw_triangle( * @param y y coordinate * @param ch character */ -void canvas_draw_glyph(Canvas* canvas, uint8_t x, uint8_t y, uint16_t ch); +void canvas_draw_glyph(Canvas* canvas, int32_t x, int32_t y, uint16_t ch); /** Set transparency mode * @@ -387,11 +388,11 @@ void canvas_set_bitmap_mode(Canvas* canvas, bool alpha); */ void canvas_draw_rframe( Canvas* canvas, - uint8_t x, - uint8_t y, - uint8_t width, - uint8_t height, - uint8_t radius); + int32_t x, + int32_t y, + size_t width, + size_t height, + size_t radius); /** Draw rounded-corner box of width, height at x,y, with round value raduis * @@ -404,11 +405,11 @@ void canvas_draw_rframe( */ void canvas_draw_rbox( Canvas* canvas, - uint8_t x, - uint8_t y, - uint8_t width, - uint8_t height, - uint8_t radius); + int32_t x, + int32_t y, + size_t width, + size_t height, + size_t radius); #ifdef __cplusplus } diff --git a/applications/services/gui/canvas_i.h b/applications/services/gui/canvas_i.h index c31bdd3bb01..c204b970fbf 100644 --- a/applications/services/gui/canvas_i.h +++ b/applications/services/gui/canvas_i.h @@ -38,10 +38,10 @@ ALGO_DEF(CanvasCallbackPairArray, CanvasCallbackPairArray_t); struct Canvas { u8g2_t fb; CanvasOrientation orientation; - uint8_t offset_x; - uint8_t offset_y; - uint8_t width; - uint8_t height; + size_t offset_x; + size_t offset_y; + size_t width; + size_t height; CompressIcon* compress_icon; CanvasCallbackPairArray_t canvas_callback_pair; FuriMutex* mutex; @@ -85,10 +85,10 @@ size_t canvas_get_buffer_size(const Canvas* canvas); */ void canvas_frame_set( Canvas* canvas, - uint8_t offset_x, - uint8_t offset_y, - uint8_t width, - uint8_t height); + int32_t offset_x, + int32_t offset_y, + size_t width, + size_t height); /** Set canvas orientation * @@ -117,10 +117,10 @@ CanvasOrientation canvas_get_orientation(const Canvas* canvas); */ void canvas_draw_u8g2_bitmap( u8g2_t* u8g2, - uint8_t x, - uint8_t y, - uint8_t width, - uint8_t height, + int32_t x, + int32_t y, + size_t width, + size_t height, const uint8_t* bitmap, IconRotation rotation); diff --git a/furi/core/check.h b/furi/core/check.h index 13b3fd51bc6..a51d7b41eae 100644 --- a/furi/core/check.h +++ b/furi/core/check.h @@ -98,6 +98,13 @@ FURI_NORETURN void __furi_halt_implementation(void); #define furi_assert(...) \ M_APPLY(__furi_assert, M_DEFAULT_ARGS(2, (__FURI_ASSERT_MESSAGE_FLAG), __VA_ARGS__)) +#define furi_break(__e) \ + do { \ + if(!(__e)) { \ + asm volatile("bkpt 0"); \ + } \ + } while(0) + #ifdef __cplusplus } #endif diff --git a/lib/u8g2/u8g2.h b/lib/u8g2/u8g2.h index 68611d48277..540b7a87381 100644 --- a/lib/u8g2/u8g2.h +++ b/lib/u8g2/u8g2.h @@ -67,7 +67,7 @@ Use 16 Bit mode for any display with more than 240 pixel in one direction. */ -//#define U8G2_16BIT +#define U8G2_16BIT /* The following macro switches the library into dynamic display buffer allocation mode. diff --git a/targets/f18/api_symbols.csv b/targets/f18/api_symbols.csv index cc7d414a8f8..2a30a7690bd 100644 --- a/targets/f18/api_symbols.csv +++ b/targets/f18/api_symbols.csv @@ -712,27 +712,27 @@ Function,-,bzero,void,"void*, size_t" Function,+,calloc,void*,"size_t, size_t" Function,+,canvas_clear,void,Canvas* Function,+,canvas_commit,void,Canvas* -Function,+,canvas_current_font_height,uint8_t,const Canvas* -Function,+,canvas_draw_bitmap,void,"Canvas*, uint8_t, uint8_t, uint8_t, uint8_t, const uint8_t*" -Function,+,canvas_draw_box,void,"Canvas*, uint8_t, uint8_t, uint8_t, uint8_t" -Function,+,canvas_draw_circle,void,"Canvas*, uint8_t, uint8_t, uint8_t" -Function,+,canvas_draw_disc,void,"Canvas*, uint8_t, uint8_t, uint8_t" -Function,+,canvas_draw_dot,void,"Canvas*, uint8_t, uint8_t" -Function,+,canvas_draw_frame,void,"Canvas*, uint8_t, uint8_t, uint8_t, uint8_t" -Function,+,canvas_draw_glyph,void,"Canvas*, uint8_t, uint8_t, uint16_t" -Function,+,canvas_draw_icon,void,"Canvas*, uint8_t, uint8_t, const Icon*" -Function,+,canvas_draw_icon_animation,void,"Canvas*, uint8_t, uint8_t, IconAnimation*" -Function,+,canvas_draw_icon_ex,void,"Canvas*, uint8_t, uint8_t, const Icon*, IconRotation" -Function,+,canvas_draw_line,void,"Canvas*, uint8_t, uint8_t, uint8_t, uint8_t" -Function,+,canvas_draw_rbox,void,"Canvas*, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t" -Function,+,canvas_draw_rframe,void,"Canvas*, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t" -Function,+,canvas_draw_str,void,"Canvas*, uint8_t, uint8_t, const char*" -Function,+,canvas_draw_str_aligned,void,"Canvas*, uint8_t, uint8_t, Align, Align, const char*" -Function,+,canvas_draw_triangle,void,"Canvas*, uint8_t, uint8_t, uint8_t, uint8_t, CanvasDirection" -Function,+,canvas_draw_xbm,void,"Canvas*, uint8_t, uint8_t, uint8_t, uint8_t, const uint8_t*" +Function,+,canvas_current_font_height,size_t,const Canvas* +Function,+,canvas_draw_bitmap,void,"Canvas*, int32_t, int32_t, size_t, size_t, const uint8_t*" +Function,+,canvas_draw_box,void,"Canvas*, int32_t, int32_t, size_t, size_t" +Function,+,canvas_draw_circle,void,"Canvas*, int32_t, int32_t, size_t" +Function,+,canvas_draw_disc,void,"Canvas*, int32_t, int32_t, size_t" +Function,+,canvas_draw_dot,void,"Canvas*, int32_t, int32_t" +Function,+,canvas_draw_frame,void,"Canvas*, int32_t, int32_t, size_t, size_t" +Function,+,canvas_draw_glyph,void,"Canvas*, int32_t, int32_t, uint16_t" +Function,+,canvas_draw_icon,void,"Canvas*, int32_t, int32_t, const Icon*" +Function,+,canvas_draw_icon_animation,void,"Canvas*, int32_t, int32_t, IconAnimation*" +Function,+,canvas_draw_icon_ex,void,"Canvas*, int32_t, int32_t, const Icon*, IconRotation" +Function,+,canvas_draw_line,void,"Canvas*, int32_t, int32_t, int32_t, int32_t" +Function,+,canvas_draw_rbox,void,"Canvas*, int32_t, int32_t, size_t, size_t, size_t" +Function,+,canvas_draw_rframe,void,"Canvas*, int32_t, int32_t, size_t, size_t, size_t" +Function,+,canvas_draw_str,void,"Canvas*, int32_t, int32_t, const char*" +Function,+,canvas_draw_str_aligned,void,"Canvas*, int32_t, int32_t, Align, Align, const char*" +Function,+,canvas_draw_triangle,void,"Canvas*, int32_t, int32_t, size_t, size_t, CanvasDirection" +Function,+,canvas_draw_xbm,void,"Canvas*, int32_t, int32_t, size_t, size_t, const uint8_t*" Function,+,canvas_get_font_params,const CanvasFontParameters*,"const Canvas*, Font" -Function,+,canvas_glyph_width,uint8_t,"Canvas*, uint16_t" -Function,+,canvas_height,uint8_t,const Canvas* +Function,+,canvas_glyph_width,size_t,"Canvas*, uint16_t" +Function,+,canvas_height,size_t,const Canvas* Function,+,canvas_invert_color,void,Canvas* Function,+,canvas_reset,void,Canvas* Function,+,canvas_set_bitmap_mode,void,"Canvas*, _Bool" @@ -741,7 +741,7 @@ Function,+,canvas_set_custom_u8g2_font,void,"Canvas*, const uint8_t*" Function,+,canvas_set_font,void,"Canvas*, Font" Function,+,canvas_set_font_direction,void,"Canvas*, CanvasDirection" Function,+,canvas_string_width,uint16_t,"Canvas*, const char*" -Function,+,canvas_width,uint8_t,const Canvas* +Function,+,canvas_width,size_t,const Canvas* Function,-,cbrt,double,double Function,-,cbrtf,float,float Function,-,cbrtl,long double,long double diff --git a/targets/f7/api_symbols.csv b/targets/f7/api_symbols.csv index 878d22e2671..8c03a6676c5 100644 --- a/targets/f7/api_symbols.csv +++ b/targets/f7/api_symbols.csv @@ -780,27 +780,27 @@ Function,-,bzero,void,"void*, size_t" Function,+,calloc,void*,"size_t, size_t" Function,+,canvas_clear,void,Canvas* Function,+,canvas_commit,void,Canvas* -Function,+,canvas_current_font_height,uint8_t,const Canvas* -Function,+,canvas_draw_bitmap,void,"Canvas*, uint8_t, uint8_t, uint8_t, uint8_t, const uint8_t*" -Function,+,canvas_draw_box,void,"Canvas*, uint8_t, uint8_t, uint8_t, uint8_t" -Function,+,canvas_draw_circle,void,"Canvas*, uint8_t, uint8_t, uint8_t" -Function,+,canvas_draw_disc,void,"Canvas*, uint8_t, uint8_t, uint8_t" -Function,+,canvas_draw_dot,void,"Canvas*, uint8_t, uint8_t" -Function,+,canvas_draw_frame,void,"Canvas*, uint8_t, uint8_t, uint8_t, uint8_t" -Function,+,canvas_draw_glyph,void,"Canvas*, uint8_t, uint8_t, uint16_t" -Function,+,canvas_draw_icon,void,"Canvas*, uint8_t, uint8_t, const Icon*" -Function,+,canvas_draw_icon_animation,void,"Canvas*, uint8_t, uint8_t, IconAnimation*" -Function,+,canvas_draw_icon_ex,void,"Canvas*, uint8_t, uint8_t, const Icon*, IconRotation" -Function,+,canvas_draw_line,void,"Canvas*, uint8_t, uint8_t, uint8_t, uint8_t" -Function,+,canvas_draw_rbox,void,"Canvas*, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t" -Function,+,canvas_draw_rframe,void,"Canvas*, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t" -Function,+,canvas_draw_str,void,"Canvas*, uint8_t, uint8_t, const char*" -Function,+,canvas_draw_str_aligned,void,"Canvas*, uint8_t, uint8_t, Align, Align, const char*" -Function,+,canvas_draw_triangle,void,"Canvas*, uint8_t, uint8_t, uint8_t, uint8_t, CanvasDirection" -Function,+,canvas_draw_xbm,void,"Canvas*, uint8_t, uint8_t, uint8_t, uint8_t, const uint8_t*" +Function,+,canvas_current_font_height,size_t,const Canvas* +Function,+,canvas_draw_bitmap,void,"Canvas*, int32_t, int32_t, size_t, size_t, const uint8_t*" +Function,+,canvas_draw_box,void,"Canvas*, int32_t, int32_t, size_t, size_t" +Function,+,canvas_draw_circle,void,"Canvas*, int32_t, int32_t, size_t" +Function,+,canvas_draw_disc,void,"Canvas*, int32_t, int32_t, size_t" +Function,+,canvas_draw_dot,void,"Canvas*, int32_t, int32_t" +Function,+,canvas_draw_frame,void,"Canvas*, int32_t, int32_t, size_t, size_t" +Function,+,canvas_draw_glyph,void,"Canvas*, int32_t, int32_t, uint16_t" +Function,+,canvas_draw_icon,void,"Canvas*, int32_t, int32_t, const Icon*" +Function,+,canvas_draw_icon_animation,void,"Canvas*, int32_t, int32_t, IconAnimation*" +Function,+,canvas_draw_icon_ex,void,"Canvas*, int32_t, int32_t, const Icon*, IconRotation" +Function,+,canvas_draw_line,void,"Canvas*, int32_t, int32_t, int32_t, int32_t" +Function,+,canvas_draw_rbox,void,"Canvas*, int32_t, int32_t, size_t, size_t, size_t" +Function,+,canvas_draw_rframe,void,"Canvas*, int32_t, int32_t, size_t, size_t, size_t" +Function,+,canvas_draw_str,void,"Canvas*, int32_t, int32_t, const char*" +Function,+,canvas_draw_str_aligned,void,"Canvas*, int32_t, int32_t, Align, Align, const char*" +Function,+,canvas_draw_triangle,void,"Canvas*, int32_t, int32_t, size_t, size_t, CanvasDirection" +Function,+,canvas_draw_xbm,void,"Canvas*, int32_t, int32_t, size_t, size_t, const uint8_t*" Function,+,canvas_get_font_params,const CanvasFontParameters*,"const Canvas*, Font" -Function,+,canvas_glyph_width,uint8_t,"Canvas*, uint16_t" -Function,+,canvas_height,uint8_t,const Canvas* +Function,+,canvas_glyph_width,size_t,"Canvas*, uint16_t" +Function,+,canvas_height,size_t,const Canvas* Function,+,canvas_invert_color,void,Canvas* Function,+,canvas_reset,void,Canvas* Function,+,canvas_set_bitmap_mode,void,"Canvas*, _Bool" @@ -809,7 +809,7 @@ Function,+,canvas_set_custom_u8g2_font,void,"Canvas*, const uint8_t*" Function,+,canvas_set_font,void,"Canvas*, Font" Function,+,canvas_set_font_direction,void,"Canvas*, CanvasDirection" Function,+,canvas_string_width,uint16_t,"Canvas*, const char*" -Function,+,canvas_width,uint8_t,const Canvas* +Function,+,canvas_width,size_t,const Canvas* Function,-,cbrt,double,double Function,-,cbrtf,float,float Function,-,cbrtl,long double,long double