From 6d7ecf9a44aae79e7250a2ee43585b9862c5197d Mon Sep 17 00:00:00 2001 From: coreglitch Date: Wed, 18 Nov 2020 11:01:51 +0300 Subject: [PATCH] Floopper bloopper (#245) * add floopper bloopper build * enhance canvas api * update submodule --- .gitmodules | 3 +++ applications/applications.h | 10 ++++++++++ applications/applications.mk | 12 ++++++++++++ applications/floopper-bloopper | 1 + applications/gui/canvas.c | 34 ++++++++++++++++++++++++++++++++++ applications/gui/canvas.h | 13 +++++++++---- 6 files changed, 69 insertions(+), 4 deletions(-) create mode 160000 applications/floopper-bloopper diff --git a/.gitmodules b/.gitmodules index aab7c81c9..c962d488d 100644 --- a/.gitmodules +++ b/.gitmodules @@ -7,3 +7,6 @@ [submodule "lib/STM32CubeWB"] path = lib/STM32CubeWB url = https://github.com/STMicroelectronics/STM32CubeWB.git +[submodule "applications/floopper-bloopper"] + path = applications/floopper-bloopper + url = https://github.com/glitchcore/floopper-bloopper.git diff --git a/applications/applications.h b/applications/applications.h index a210efbf4..0d5e991a1 100644 --- a/applications/applications.h +++ b/applications/applications.h @@ -38,6 +38,7 @@ void app_gpio_test(void* p); void app_ibutton(void* p); void cli_task(void* p); void music_player(void* p); +void floopper_bloopper(void* p); const FlipperStartupApp FLIPPER_STARTUP[] = { #ifdef APP_DISPLAY @@ -134,6 +135,10 @@ const FlipperStartupApp FLIPPER_STARTUP[] = { #ifdef APP_GPIO_DEMO {.app = app_gpio_test, .name = "gpio test", .libs = {1, FURI_LIB{"gui_task"}}}, #endif + +#ifdef APP_FLOOPPER_BLOOPPER + {.app = floopper_bloopper, .name = "Floopper Bloopper", .libs = {1, FURI_LIB{"gui_task"}}}, +#endif }; const FlipperStartupApp FLIPPER_APPS[] = { @@ -184,4 +189,9 @@ const FlipperStartupApp FLIPPER_APPS[] = { #ifdef BUILD_MUSIC_PLAYER {.app = music_player, .name = "music player", .libs = {1, FURI_LIB{"gui_task"}}}, #endif + +#ifdef BUILD_FLOOPPER_BLOOPPER + {.app = floopper_bloopper, .name = "Floopper Bloopper", .libs = {1, FURI_LIB{"gui_task"}}}, +#endif + }; \ No newline at end of file diff --git a/applications/applications.mk b/applications/applications.mk index e675e87a1..c8440e945 100644 --- a/applications/applications.mk +++ b/applications/applications.mk @@ -24,6 +24,7 @@ BUILD_VIBRO_DEMO = 1 BUILD_SD_TEST = 1 BUILD_GPIO_DEMO = 1 BUILD_MUSIC_PLAYER = 1 +BUILD_FLOOPPER_BLOOPPER = 1 BUILD_IBUTTON = 1 endif @@ -259,6 +260,17 @@ CFLAGS += -DBUILD_MUSIC_PLAYER C_SOURCES += $(wildcard $(APP_DIR)/music-player/*.c) endif +APP_FLOOPPER_BLOOPPER ?= 0 +ifeq ($(APP_FLOOPPER_BLOOPPER), 1) +CFLAGS += -DAPP_FLOOPPER_BLOOPPER +BUILD_FLOOPPER_BLOOPPER = 1 +endif +BUILD_FLOOPPER_BLOOPPER ?= 0 +ifeq ($(BUILD_FLOOPPER_BLOOPPER), 1) +CFLAGS += -DBUILD_FLOOPPER_BLOOPPER +C_SOURCES += $(wildcard $(APP_DIR)/floopper-bloopper/*.c) +endif + APP_IBUTTON ?= 0 ifeq ($(APP_IBUTTON), 1) CFLAGS += -DAPP_IBUTTON diff --git a/applications/floopper-bloopper b/applications/floopper-bloopper new file mode 160000 index 000000000..203994985 --- /dev/null +++ b/applications/floopper-bloopper @@ -0,0 +1 @@ +Subproject commit 2039949856df06d7f6fa7698897acc48f4714976 diff --git a/applications/gui/canvas.c b/applications/gui/canvas.c index 31e6499fb..f91d145f9 100644 --- a/applications/gui/canvas.c +++ b/applications/gui/canvas.c @@ -27,6 +27,14 @@ void canvas_dot_draw(CanvasApi* api, uint8_t x, uint8_t y); void canvas_box_draw(CanvasApi* api, uint8_t x, uint8_t y, uint8_t width, uint8_t height); void canvas_draw_frame(CanvasApi* api, uint8_t x, uint8_t y, uint8_t width, uint8_t height); void canvas_draw_line(CanvasApi* api, uint8_t x1, uint8_t y1, uint8_t x2, uint8_t y2); +void canvas_draw_xbm( + CanvasApi* canvas, + uint8_t x, + uint8_t y, + uint8_t w, + uint8_t h, + const uint8_t* bitmap); +void canvas_draw_glyph(CanvasApi* canvas, uint8_t x, uint8_t y, uint16_t ch); uint8_t u8g2_gpio_and_delay_stm32(u8x8_t* u8x8, uint8_t msg, uint8_t arg_int, void* arg_ptr); uint8_t u8x8_hw_spi_stm32(u8x8_t* u8x8, uint8_t msg, uint8_t arg_int, void* arg_ptr); @@ -55,6 +63,8 @@ CanvasApi* canvas_api_init() { canvas->api.draw_box = canvas_box_draw; canvas->api.draw_frame = canvas_draw_frame; canvas->api.draw_line = canvas_draw_line; + canvas->api.draw_xbm = canvas_draw_xbm; + canvas->api.draw_glyph = canvas_draw_glyph; return (CanvasApi*)canvas; } @@ -123,6 +133,8 @@ void canvas_font_set(CanvasApi* api, Font font) { u8g2_SetFont(&canvas->fb, u8g2_font_helvB08_tf); } else if(font == FontSecondary) { u8g2_SetFont(&canvas->fb, u8g2_font_haxrcorp4089_tr); + } else if(font == FontGlyph) { + u8g2_SetFont(&canvas->fb, u8g2_font_unifont_t_symbols); } else { furi_check(0); } @@ -180,3 +192,25 @@ void canvas_draw_line(CanvasApi* api, uint8_t x1, uint8_t y1, uint8_t x2, uint8_ y2 += canvas->offset_y; u8g2_DrawLine(&canvas->fb, x1, y1, x2, y2); } + +void canvas_draw_xbm( + CanvasApi* api, + uint8_t x, + uint8_t y, + uint8_t w, + uint8_t h, + const uint8_t* bitmap) { + furi_assert(api); + Canvas* canvas = (Canvas*)api; + x += canvas->offset_x; + y += canvas->offset_y; + u8g2_DrawXBM(&canvas->fb, x, y, w, h, bitmap); +} + +void canvas_draw_glyph(CanvasApi* api, uint8_t x, uint8_t y, uint16_t ch) { + furi_assert(api); + Canvas* canvas = (Canvas*)api; + x += canvas->offset_x; + y += canvas->offset_y; + u8g2_DrawGlyph(&canvas->fb, x, y, ch); +} \ No newline at end of file diff --git a/applications/gui/canvas.h b/applications/gui/canvas.h index 2d0c5edb3..07201c062 100644 --- a/applications/gui/canvas.h +++ b/applications/gui/canvas.h @@ -9,10 +9,7 @@ typedef enum { ColorBlack = 0x01, } Color; -typedef enum { - FontPrimary = 0x00, - FontSecondary = 0x01, -} Font; +typedef enum { FontPrimary = 0x00, FontSecondary = 0x01, FontGlyph = 0x02 } Font; typedef struct CanvasApi CanvasApi; struct CanvasApi { @@ -26,8 +23,16 @@ struct CanvasApi { void (*draw_str)(CanvasApi* canvas, uint8_t x, uint8_t y, const char* str); void (*draw_icon)(CanvasApi* canvas, uint8_t x, uint8_t y, Icon* icon); + void (*draw_xbm)( + CanvasApi* canvas, + uint8_t x, + uint8_t y, + uint8_t w, + uint8_t h, + const uint8_t* bitmap); void (*draw_dot)(CanvasApi* canvas, uint8_t x, uint8_t y); void (*draw_box)(CanvasApi* canvas, uint8_t x, uint8_t y, uint8_t width, uint8_t height); void (*draw_frame)(CanvasApi* canvas, uint8_t x, uint8_t y, uint8_t width, uint8_t height); void (*draw_line)(CanvasApi* canvas, uint8_t x1, uint8_t y1, uint8_t x2, uint8_t y2); + void (*draw_glyph)(CanvasApi* canvas, uint8_t x, uint8_t y, uint16_t ch); };