forked from flipperdevices/flipperzero-catalog-sample-app
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
165 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
dist/* | ||
.vscode | ||
.clang-format | ||
.editorconfig | ||
.env | ||
.ufbt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,5 @@ | ||
v0.5: | ||
* added images | ||
|
||
v0.4: | ||
* added changelog | ||
v1.0: | ||
* The first release of the plugin | ||
|
||
older: | ||
* various | ||
* fixes | ||
v0.5: | ||
* this is the example of the changelog |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,32 @@ | ||
# For details & more options, see documentation/AppManifests.md in firmware repo | ||
# Please refer to: | ||
# https://developer.flipper.net/flipperzero/doxygen/app_manifests.html | ||
|
||
App( | ||
appid="demo_app", # Must be unique | ||
name="App demo_app", # Displayed in UI | ||
name="Demo Application", # Displayed in UI | ||
apptype=FlipperAppType.EXTERNAL, | ||
entry_point="demo_app_app", | ||
stack_size=2 * 1024, | ||
entry_point="main_entrypoint", | ||
stack_size=2 * 1024, # size of memory stack it will allocate | ||
|
||
# source code settings | ||
sources=["src/*.c*", "src/*/*.c*"], # Due to limitation of the fbt, | ||
# you need to specify nested directories | ||
# manually since it doesn't support | ||
# recurse globbing such as "src/**/*.c*" | ||
|
||
# Dependencies | ||
requires=[ | ||
"gui", # allows to use GUI functions | ||
|
||
], | ||
|
||
# FAP Settings | ||
fap_category="Tools", | ||
# Optional values | ||
fap_description="A simple app", | ||
fap_description="A simple app for demonstration", | ||
fap_version="1.0", # (major, minor) | ||
fap_icon="demo_app.png", # 10x10 1-bit PNG | ||
# fap_author="J. Doe", | ||
# fap_weburl="https://github.com/user/demo_app", | ||
fap_icon_assets="images", # Image assets to compile for this application | ||
fap_icon="icon.png", # 10x10 1-bit PNG | ||
fap_author="Alex4386", | ||
fap_weburl="https://github.com/Alex4386/f0-template", | ||
fap_icon_assets="icons", # Image assets to compile for this application | ||
# available as {appid}_icons.h in the source code | ||
) |
This file was deleted.
Oops, something went wrong.
File renamed without changes
File renamed without changes.
File renamed without changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#include <furi.h> | ||
#include "main.h" | ||
|
||
int32_t main_entrypoint(void* p) { | ||
UNUSED(p); | ||
main(); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#include <gui/gui.h> | ||
#include <demo_app_icons.h> | ||
|
||
void on_draw(Canvas* canvas, void* context) { | ||
UNUSED(context); | ||
|
||
// clear canvas | ||
canvas_clear(canvas); | ||
|
||
// Set the font | ||
canvas_set_font(canvas, FontPrimary); | ||
canvas_draw_str(canvas, 32, 13, "Hello, World!"); | ||
|
||
// draw dolphin first | ||
canvas_draw_icon(canvas, 32, 34, &I_dolphin_71x25); | ||
|
||
// write press back | ||
canvas_set_font(canvas, FontSecondary); | ||
canvas_draw_str(canvas, 15, 26, " press back to exit FAP"); | ||
|
||
canvas_draw_line(canvas, 2, 16, 126, 16); | ||
} | ||
|
||
void on_input(InputEvent* event, void* context) { | ||
furi_assert(context); | ||
FuriMessageQueue* msg_queue = (FuriMessageQueue*)context; | ||
|
||
furi_message_queue_put(msg_queue, event, FuriWaitForever); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#pragma once | ||
#include <stdio.h> | ||
#include <furi.h> | ||
#include <gui/gui.h> | ||
|
||
void on_draw(Canvas* canvas, void* context); | ||
void on_input(InputEvent* event, void* context); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#include <stdio.h> | ||
#include <furi.h> | ||
#include <gui/gui.h> | ||
#include "events.h" | ||
#include "utils/gui.h" | ||
|
||
int main() { | ||
// 1. Provision the InputHandlers | ||
// Handle input event | ||
InputEvent event; | ||
GUISetupData* gui_setup = setup_gui(on_draw, on_input); | ||
|
||
// 2. Main EventLoop | ||
while(true) { | ||
// 4.1. Read input event from the message queue | ||
furi_check( | ||
furi_message_queue_get(gui_setup->msg_queue, &event, FuriWaitForever) == FuriStatusOk); | ||
|
||
// 4.2. check if the event is a quit event | ||
if(event.key == InputKeyBack) { | ||
break; | ||
} | ||
} | ||
|
||
// 3. Free the resources | ||
free_gui(gui_setup); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#pragma once | ||
|
||
int main(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#include <furi.h> | ||
#include <gui/gui.h> | ||
#include "gui.h" | ||
|
||
GUISetupData* setup_gui(ViewPortDrawCallback on_draw, ViewPortInputCallback on_input) { | ||
GUISetupData* data = malloc(sizeof(GUISetupData)); | ||
|
||
data->msg_queue = furi_message_queue_alloc(8, sizeof(InputEvent)); | ||
data->viewport = view_port_alloc(); | ||
|
||
view_port_draw_callback_set(data->viewport, on_draw, NULL); | ||
view_port_input_callback_set(data->viewport, on_input, data->msg_queue); | ||
data->gui = furi_record_open(RECORD_GUI); | ||
gui_add_view_port(data->gui, data->viewport, GuiLayerFullscreen); | ||
return data; | ||
} | ||
|
||
void free_gui(GUISetupData* data) { | ||
// nullguard! | ||
if(data == NULL) return; | ||
|
||
if(data->msg_queue != NULL) { | ||
furi_message_queue_free(data->msg_queue); | ||
} | ||
|
||
if(data->viewport != NULL) { | ||
if(data->gui != NULL) { | ||
gui_remove_view_port(data->gui, data->viewport); | ||
} | ||
|
||
view_port_enabled_set(data->viewport, false); | ||
view_port_free(data->viewport); | ||
} | ||
|
||
furi_record_close(RECORD_GUI); | ||
free(data); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#pragma once | ||
#include <gui/gui.h> | ||
|
||
typedef struct GUISetupData { | ||
FuriMessageQueue* msg_queue; | ||
ViewPort* viewport; | ||
Gui* gui; | ||
} GUISetupData; | ||
|
||
GUISetupData* setup_gui(ViewPortDrawCallback on_draw, ViewPortInputCallback on_input); | ||
void free_gui(GUISetupData* data); |