Skip to content

Commit f49e172

Browse files
committed
add build infrastructure
0 parents  commit f49e172

File tree

3 files changed

+91
-0
lines changed

3 files changed

+91
-0
lines changed

application.fam

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
App(
2+
appid="flipp_pomodoro",
3+
name="Flipp Pomodoro",
4+
apptype=FlipperAppType.EXTERNAL,
5+
entry_point="flipp_pomodoro_main",
6+
requires=["gui"],
7+
stack_size=1 * 1024,
8+
fap_category="Productivity",
9+
fap_icon_assets="images",
10+
)

flipp_pomodoro.c

+81
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
#include <furi.h>
2+
#include <furi_hal.h>
3+
4+
#include <gui/gui.h>
5+
#include <input/input.h>
6+
7+
/* Magic happens here -- this file is generated by fbt.
8+
* Just set fap_icon_assets in application.fam and #include {APPID}_icons.h */
9+
#include "flipp_pomodoro_icons.h"
10+
11+
typedef struct {
12+
uint8_t x, y;
13+
} ImagePosition;
14+
15+
static ImagePosition image_position = {.x = 0, .y = 0};
16+
17+
// Screen is 128x64 px
18+
static void app_draw_callback(Canvas* canvas, void* ctx) {
19+
UNUSED(ctx);
20+
21+
canvas_clear(canvas);
22+
canvas_draw_icon(canvas, image_position.x % 128, image_position.y % 64, &I_dolphin_71x25);
23+
}
24+
25+
static void app_input_callback(InputEvent* input_event, void* ctx) {
26+
furi_assert(ctx);
27+
28+
FuriMessageQueue* event_queue = ctx;
29+
furi_message_queue_put(event_queue, input_event, FuriWaitForever);
30+
}
31+
32+
int32_t flipp_pomodoro_main(void* p) {
33+
UNUSED(p);
34+
FuriMessageQueue* event_queue = furi_message_queue_alloc(8, sizeof(InputEvent));
35+
36+
// Configure view port
37+
ViewPort* view_port = view_port_alloc();
38+
view_port_draw_callback_set(view_port, app_draw_callback, view_port);
39+
view_port_input_callback_set(view_port, app_input_callback, event_queue);
40+
41+
// Register view port in GUI
42+
Gui* gui = furi_record_open(RECORD_GUI);
43+
gui_add_view_port(gui, view_port, GuiLayerFullscreen);
44+
45+
InputEvent event;
46+
47+
bool running = true;
48+
while(running) {
49+
if(furi_message_queue_get(event_queue, &event, 100) == FuriStatusOk) {
50+
if((event.type == InputTypePress) || (event.type == InputTypeRepeat)) {
51+
switch(event.key) {
52+
case InputKeyLeft:
53+
image_position.x -= 2;
54+
break;
55+
case InputKeyRight:
56+
image_position.x += 2;
57+
break;
58+
case InputKeyUp:
59+
image_position.y -= 2;
60+
break;
61+
case InputKeyDown:
62+
image_position.y += 2;
63+
break;
64+
default:
65+
running = false;
66+
break;
67+
}
68+
}
69+
}
70+
view_port_update(view_port);
71+
}
72+
73+
view_port_enabled_set(view_port, false);
74+
gui_remove_view_port(gui, view_port);
75+
view_port_free(view_port);
76+
furi_message_queue_free(event_queue);
77+
78+
furi_record_close(RECORD_GUI);
79+
80+
return 0;
81+
}

images/dolphin_71x25.png

1.16 KB
Loading

0 commit comments

Comments
 (0)