2021-10-03 10:36:05 +00:00
|
|
|
/**
|
|
|
|
* @file canvas_i.h
|
|
|
|
* GUI: internal Canvas API
|
|
|
|
*/
|
|
|
|
|
Display and UI implementation (#169)
* Menu app. Lib: add mlib submodule.
* Menu: new startup lib dependency definition
* Menu: hierarchy in menu. Cube: fix heap1/4 inconsistency, stack protection.
* GUI: rendering pipeline initial version.
* GUI: layered widget composing, FURI record. Menu: FURI record, api.
* GUI: input dispatching. Menu: switch to input from GUI.
* GUI, MENU: code style cleanup, fix type conversion warnings.
* GUI, Menu: syntax check.
* Makefile: check and reinit submodules, format.
* Menu: lock on event processing. Makefile: proper submodule initialization.
* Menu: fix stack corruption by queue.
* GUI: refactor.
* Makefile: format rule fix, st-util pid.
* GUI, Menu, FURI: format with clang-format.
* GUI, MENU: locks in critical sections, fix stack corruption, ready signaling.
* Makefile: clang format rule cleanup.
* GUI,MENU: migrate to new API.
* Applications: PRODUCTION_HW variable, skip drivers build on local target.
* refactor production build
* add git to dockerfile
* GUI: uncomment lock block
Co-authored-by: Aleksandr Kutuzov <aku@plooks.com>
2020-10-14 10:21:55 +00:00
|
|
|
#pragma once
|
|
|
|
|
2020-12-14 10:50:32 +00:00
|
|
|
#include "canvas.h"
|
2021-02-03 09:52:54 +00:00
|
|
|
#include <u8g2.h>
|
2023-03-22 17:00:48 +00:00
|
|
|
#include <toolbox/compress.h>
|
2024-02-07 02:38:20 +00:00
|
|
|
#include <m-array.h>
|
|
|
|
#include <m-algo.h>
|
|
|
|
#include <furi.h>
|
|
|
|
|
2024-05-20 17:23:47 +00:00
|
|
|
#define ICON_DECOMPRESSOR_BUFFER_SIZE (128u * 64 / 8)
|
|
|
|
|
2024-02-07 02:38:20 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
typedef void (*CanvasCommitCallback)(
|
|
|
|
uint8_t* data,
|
|
|
|
size_t size,
|
|
|
|
CanvasOrientation orientation,
|
|
|
|
void* context);
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
CanvasCommitCallback callback;
|
|
|
|
void* context;
|
|
|
|
} CanvasCallbackPair;
|
|
|
|
|
|
|
|
ARRAY_DEF(CanvasCallbackPairArray, CanvasCallbackPair, M_POD_OPLIST);
|
|
|
|
|
|
|
|
#define M_OPL_CanvasCallbackPairArray_t() ARRAY_OPLIST(CanvasCallbackPairArray, M_POD_OPLIST)
|
|
|
|
|
|
|
|
ALGO_DEF(CanvasCallbackPairArray, CanvasCallbackPairArray_t);
|
2021-02-03 09:52:54 +00:00
|
|
|
|
2021-10-03 10:36:05 +00:00
|
|
|
/** Canvas structure
|
|
|
|
*/
|
2021-02-03 09:52:54 +00:00
|
|
|
struct Canvas {
|
|
|
|
u8g2_t fb;
|
2021-05-19 09:43:15 +00:00
|
|
|
CanvasOrientation orientation;
|
2024-03-19 15:23:06 +00:00
|
|
|
size_t offset_x;
|
|
|
|
size_t offset_y;
|
|
|
|
size_t width;
|
|
|
|
size_t height;
|
2023-03-22 17:00:48 +00:00
|
|
|
CompressIcon* compress_icon;
|
2024-02-07 02:38:20 +00:00
|
|
|
CanvasCallbackPairArray_t canvas_callback_pair;
|
|
|
|
FuriMutex* mutex;
|
2021-02-03 09:52:54 +00:00
|
|
|
};
|
Display and UI implementation (#169)
* Menu app. Lib: add mlib submodule.
* Menu: new startup lib dependency definition
* Menu: hierarchy in menu. Cube: fix heap1/4 inconsistency, stack protection.
* GUI: rendering pipeline initial version.
* GUI: layered widget composing, FURI record. Menu: FURI record, api.
* GUI: input dispatching. Menu: switch to input from GUI.
* GUI, MENU: code style cleanup, fix type conversion warnings.
* GUI, Menu: syntax check.
* Makefile: check and reinit submodules, format.
* Menu: lock on event processing. Makefile: proper submodule initialization.
* Menu: fix stack corruption by queue.
* GUI: refactor.
* Makefile: format rule fix, st-util pid.
* GUI, Menu, FURI: format with clang-format.
* GUI, MENU: locks in critical sections, fix stack corruption, ready signaling.
* Makefile: clang format rule cleanup.
* GUI,MENU: migrate to new API.
* Applications: PRODUCTION_HW variable, skip drivers build on local target.
* refactor production build
* add git to dockerfile
* GUI: uncomment lock block
Co-authored-by: Aleksandr Kutuzov <aku@plooks.com>
2020-10-14 10:21:55 +00:00
|
|
|
|
2021-10-03 10:36:05 +00:00
|
|
|
/** Allocate memory and initialize canvas
|
|
|
|
*
|
|
|
|
* @return Canvas instance
|
2020-12-14 10:50:32 +00:00
|
|
|
*/
|
2024-03-19 14:43:52 +00:00
|
|
|
Canvas* canvas_init(void);
|
Display and UI implementation (#169)
* Menu app. Lib: add mlib submodule.
* Menu: new startup lib dependency definition
* Menu: hierarchy in menu. Cube: fix heap1/4 inconsistency, stack protection.
* GUI: rendering pipeline initial version.
* GUI: layered widget composing, FURI record. Menu: FURI record, api.
* GUI: input dispatching. Menu: switch to input from GUI.
* GUI, MENU: code style cleanup, fix type conversion warnings.
* GUI, Menu: syntax check.
* Makefile: check and reinit submodules, format.
* Menu: lock on event processing. Makefile: proper submodule initialization.
* Menu: fix stack corruption by queue.
* GUI: refactor.
* Makefile: format rule fix, st-util pid.
* GUI, Menu, FURI: format with clang-format.
* GUI, MENU: locks in critical sections, fix stack corruption, ready signaling.
* Makefile: clang format rule cleanup.
* GUI,MENU: migrate to new API.
* Applications: PRODUCTION_HW variable, skip drivers build on local target.
* refactor production build
* add git to dockerfile
* GUI: uncomment lock block
Co-authored-by: Aleksandr Kutuzov <aku@plooks.com>
2020-10-14 10:21:55 +00:00
|
|
|
|
2021-10-03 10:36:05 +00:00
|
|
|
/** Free canvas memory
|
|
|
|
*
|
|
|
|
* @param canvas Canvas instance
|
2020-12-14 10:50:32 +00:00
|
|
|
*/
|
|
|
|
void canvas_free(Canvas* canvas);
|
2020-10-29 07:11:16 +00:00
|
|
|
|
2021-10-03 10:36:05 +00:00
|
|
|
/** Get canvas buffer.
|
|
|
|
*
|
|
|
|
* @param canvas Canvas instance
|
|
|
|
*
|
|
|
|
* @return pointer to buffer
|
2021-02-13 11:40:20 +00:00
|
|
|
*/
|
|
|
|
uint8_t* canvas_get_buffer(Canvas* canvas);
|
|
|
|
|
2021-10-03 10:36:05 +00:00
|
|
|
/** Get canvas buffer size.
|
|
|
|
*
|
|
|
|
* @param canvas Canvas instance
|
|
|
|
*
|
|
|
|
* @return size of canvas in bytes
|
2021-02-13 11:40:20 +00:00
|
|
|
*/
|
2023-02-09 04:58:01 +00:00
|
|
|
size_t canvas_get_buffer_size(const Canvas* canvas);
|
2021-02-13 11:40:20 +00:00
|
|
|
|
2021-10-03 10:36:05 +00:00
|
|
|
/** Set drawing region relative to real screen buffer
|
|
|
|
*
|
|
|
|
* @param canvas Canvas instance
|
|
|
|
* @param offset_x x coordinate offset
|
|
|
|
* @param offset_y y coordinate offset
|
|
|
|
* @param width width
|
|
|
|
* @param height height
|
2020-12-14 10:50:32 +00:00
|
|
|
*/
|
Display and UI implementation (#169)
* Menu app. Lib: add mlib submodule.
* Menu: new startup lib dependency definition
* Menu: hierarchy in menu. Cube: fix heap1/4 inconsistency, stack protection.
* GUI: rendering pipeline initial version.
* GUI: layered widget composing, FURI record. Menu: FURI record, api.
* GUI: input dispatching. Menu: switch to input from GUI.
* GUI, MENU: code style cleanup, fix type conversion warnings.
* GUI, Menu: syntax check.
* Makefile: check and reinit submodules, format.
* Menu: lock on event processing. Makefile: proper submodule initialization.
* Menu: fix stack corruption by queue.
* GUI: refactor.
* Makefile: format rule fix, st-util pid.
* GUI, Menu, FURI: format with clang-format.
* GUI, MENU: locks in critical sections, fix stack corruption, ready signaling.
* Makefile: clang format rule cleanup.
* GUI,MENU: migrate to new API.
* Applications: PRODUCTION_HW variable, skip drivers build on local target.
* refactor production build
* add git to dockerfile
* GUI: uncomment lock block
Co-authored-by: Aleksandr Kutuzov <aku@plooks.com>
2020-10-14 10:21:55 +00:00
|
|
|
void canvas_frame_set(
|
2020-12-14 10:50:32 +00:00
|
|
|
Canvas* canvas,
|
2024-03-19 15:23:06 +00:00
|
|
|
int32_t offset_x,
|
|
|
|
int32_t offset_y,
|
|
|
|
size_t width,
|
|
|
|
size_t height);
|
2021-05-19 09:43:15 +00:00
|
|
|
|
2021-10-03 10:36:05 +00:00
|
|
|
/** Set canvas orientation
|
|
|
|
*
|
|
|
|
* @param canvas Canvas instance
|
|
|
|
* @param orientation CanvasOrientation
|
2021-05-19 09:43:15 +00:00
|
|
|
*/
|
|
|
|
void canvas_set_orientation(Canvas* canvas, CanvasOrientation orientation);
|
|
|
|
|
2021-10-03 10:36:05 +00:00
|
|
|
/** Get canvas orientation
|
|
|
|
*
|
|
|
|
* @param canvas Canvas instance
|
|
|
|
*
|
|
|
|
* @return CanvasOrientation
|
2021-05-19 09:43:15 +00:00
|
|
|
*/
|
|
|
|
CanvasOrientation canvas_get_orientation(const Canvas* canvas);
|
2023-04-06 03:36:12 +00:00
|
|
|
|
|
|
|
/** Draw a u8g2 bitmap
|
|
|
|
*
|
2024-03-06 06:25:21 +00:00
|
|
|
* @param u8g2 u8g2 instance
|
2023-04-06 03:36:12 +00:00
|
|
|
* @param x x coordinate
|
|
|
|
* @param y y coordinate
|
|
|
|
* @param width width
|
|
|
|
* @param height height
|
|
|
|
* @param bitmap bitmap
|
|
|
|
* @param rotation rotation
|
|
|
|
*/
|
|
|
|
void canvas_draw_u8g2_bitmap(
|
|
|
|
u8g2_t* u8g2,
|
2024-03-19 15:23:06 +00:00
|
|
|
int32_t x,
|
|
|
|
int32_t y,
|
|
|
|
size_t width,
|
|
|
|
size_t height,
|
2023-04-06 03:36:12 +00:00
|
|
|
const uint8_t* bitmap,
|
2024-02-12 02:04:12 +00:00
|
|
|
IconRotation rotation);
|
2024-02-07 02:38:20 +00:00
|
|
|
|
|
|
|
/** Add canvas commit callback.
|
|
|
|
*
|
|
|
|
* This callback will be called upon Canvas commit.
|
|
|
|
*
|
|
|
|
* @param canvas Canvas instance
|
|
|
|
* @param callback CanvasCommitCallback
|
|
|
|
* @param context CanvasCommitCallback context
|
|
|
|
*/
|
|
|
|
void canvas_add_framebuffer_callback(Canvas* canvas, CanvasCommitCallback callback, void* context);
|
|
|
|
|
|
|
|
/** Remove canvas commit callback.
|
|
|
|
*
|
|
|
|
* @param canvas Canvas instance
|
|
|
|
* @param callback CanvasCommitCallback
|
|
|
|
* @param context CanvasCommitCallback context
|
|
|
|
*/
|
|
|
|
void canvas_remove_framebuffer_callback(
|
|
|
|
Canvas* canvas,
|
|
|
|
CanvasCommitCallback callback,
|
|
|
|
void* context);
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
2024-02-12 02:04:12 +00:00
|
|
|
#endif
|