Loading...
Searching...
No Matches
canvas_i.h
Go to the documentation of this file.
1
6#pragma once
7
8#include "canvas.h"
9#include <u8g2.h>
10#include <toolbox/compress.h>
11#include <m-array.h>
12#include <m-algo.h>
13#include <furi.h>
14
15#define ICON_DECOMPRESSOR_BUFFER_SIZE (128u * 64 / 8)
16
17#ifdef __cplusplus
18extern "C" {
19#endif
20
21typedef void (*CanvasCommitCallback)(
22 uint8_t* data,
23 size_t size,
24 CanvasOrientation orientation,
25 void* context);
26
27typedef struct {
28 CanvasCommitCallback callback;
29 void* context;
31
32ARRAY_DEF(CanvasCallbackPairArray, CanvasCallbackPair, M_POD_OPLIST);
33
34#define M_OPL_CanvasCallbackPairArray_t() ARRAY_OPLIST(CanvasCallbackPairArray, M_POD_OPLIST)
35
36ALGO_DEF(CanvasCallbackPairArray, CanvasCallbackPairArray_t);
37
40struct Canvas {
41 u8g2_t fb;
42 CanvasOrientation orientation;
43 size_t offset_x;
44 size_t offset_y;
45 size_t width;
46 size_t height;
47 CompressIcon* compress_icon;
48 CanvasCallbackPairArray_t canvas_callback_pair;
49 FuriMutex* mutex;
50};
51
56Canvas* canvas_init(void);
57
62void canvas_free(Canvas* canvas);
63
70uint8_t* canvas_get_buffer(Canvas* canvas);
71
78size_t canvas_get_buffer_size(const Canvas* canvas);
79
89 Canvas* canvas,
90 int32_t offset_x,
91 int32_t offset_y,
92 size_t width,
93 size_t height);
94
100void canvas_set_orientation(Canvas* canvas, CanvasOrientation orientation);
101
109
121 u8g2_t* u8g2,
122 int32_t x,
123 int32_t y,
124 size_t width,
125 size_t height,
126 const uint8_t* bitmap,
127 IconRotation rotation);
128
137void canvas_add_framebuffer_callback(Canvas* canvas, CanvasCommitCallback callback, void* context);
138
146 Canvas* canvas,
147 CanvasCommitCallback callback,
148 void* context);
149
150#ifdef __cplusplus
151}
152#endif
GUI: Canvas API.
CanvasOrientation
Canvas Orientation.
Definition canvas.h:45
IconRotation
Icon rotation.
Definition canvas.h:77
void canvas_remove_framebuffer_callback(Canvas *canvas, CanvasCommitCallback callback, void *context)
Remove canvas commit callback.
Definition canvas.c:582
void canvas_add_framebuffer_callback(Canvas *canvas, CanvasCommitCallback callback, void *context)
Add canvas commit callback.
Definition canvas.c:571
void canvas_set_orientation(Canvas *canvas, CanvasOrientation orientation)
Set canvas orientation.
Definition canvas.c:531
void canvas_free(Canvas *canvas)
Free canvas memory.
Definition canvas.c:41
size_t canvas_get_buffer_size(const Canvas *canvas)
Get canvas buffer size.
Definition canvas.c:91
CanvasOrientation canvas_get_orientation(const Canvas *canvas)
Get canvas orientation.
Definition canvas.c:567
void canvas_draw_u8g2_bitmap(u8g2_t *u8g2, int32_t x, int32_t y, size_t width, size_t height, const uint8_t *bitmap, IconRotation rotation)
Draw a u8g2 bitmap.
Definition canvas.c:351
void canvas_frame_set(Canvas *canvas, int32_t offset_x, int32_t offset_y, size_t width, size_t height)
Set drawing region relative to real screen buffer.
Definition canvas.c:96
Canvas * canvas_init(void)
Allocate memory and initialize canvas.
Definition canvas.c:16
uint8_t * canvas_get_buffer(Canvas *canvas)
Get canvas buffer.
Definition canvas.c:86
LZSS based compression HAL API.
Definition canvas_i.h:27
Canvas structure.
Definition canvas_i.h:40
Definition compress.c:41
Definition mutex.c:13
Definition u8g2.h:274