clarify this is viewport

This commit is contained in:
Derek Jamison 2024-01-28 11:27:45 -06:00
parent 97a19a32f6
commit dca8b03b8a
3 changed files with 47 additions and 27 deletions

View File

@ -1,31 +1,39 @@
# BASIC DEMO
## Introduction
This is a basic application for the Flipper Zero. The goal of this project is to use it as a starting point for other applications.
## Introduction
This is a basic ViewPort application for the Flipper Zero. The goal of this project is to use it as a starting point for other applications. When creating a UI for the Flipper Zero, you can choose from three techniques:
- "ViewPort" (single view that does all the rendering & input handling)
- "ViewDispatcher" (multiple views, single back button is handled for you)
- "SceneManager" (multiple views, back button history is handled for you)
## Installation Directions
This project is intended to be overlayed on top of an existing firmware repo.
- Clone, Build & Deploy an existing flipper zero firmware repo. See this [tutorial](/firmware/updating/README.md) for updating firmware.
- Copy the "basic_demo" [folder](..) to the \applications\plugins\basic_demo folder in your firmware.
- Build & deploy the firmware. See this [tutorial](/firmware/updating/README.md) for updating firmware.
- NOTE: You can also extract the basic_demo.FAP from resources.tar file and use qFlipper to copy the file to the SD Card/apps/Misc folder.
## Running the updated firmware
These directions assume you are starting at the flipper desktop. If not, please press the back button until you are at the desktop.
- Press the OK button on the flipper to pull up the main menu.
- Choose "Applications" from the menu.
- Choose "Misc" from the sub-menu.
- Choose "Basic Demo"
- Choose "Basic Viewport Demo"
- The flipper should say "Basic Demo".
- The flipper should say "Basic Viewport Demo".
- Press the BACK button to exit.
## How it works
- application.fam
- specifies the name of our application.
- specifies the entry point for our application.
- specifies we use the GUI.
@ -33,6 +41,7 @@ These directions assume you are starting at the flipper desktop. If not, please
- specifies our application can be found in the "Misc" category.
- basic_demo.png
- The icon for our application.
- basic_demo_app.c
@ -60,4 +69,3 @@ These directions assume you are starting at the flipper desktop. If not, please
- The message loop continues until processing is false.
- We release our application resources.
- We exit the program.

View File

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

@ -32,6 +32,7 @@ typedef struct {
typedef struct {
FuriString* buffer;
// You can add additional state here.
int32_t counter;
} DemoData;
typedef struct {
@ -56,17 +57,23 @@ static void basic_demo_render_callback(Canvas* canvas, void* ctx) {
}
DemoData* data = demo_context->data;
furi_string_printf(data->buffer, "Basic");
furi_string_cat_printf(data->buffer, " demo");
furi_string_printf(data->buffer, "Basic ViewPort demo");
canvas_set_font(canvas, FontPrimary);
canvas_draw_str_aligned(canvas, 45, 30, AlignLeft, AlignTop, furi_string_get_cstr(data->buffer));
canvas_draw_str_aligned(
canvas, 15, 25, AlignLeft, AlignTop, furi_string_get_cstr(data->buffer));
furi_string_printf(data->buffer, "OK pressed");
furi_string_cat_printf(data->buffer, " %ld times.", data->counter);
canvas_set_font(canvas, FontSecondary);
canvas_draw_str_aligned(
canvas, 15, 40, AlignLeft, AlignTop, furi_string_get_cstr(data->buffer));
// Release the context, so other threads can update the data.
furi_mutex_release(demo_context->mutex);
}
int32_t basic_demo_app(void* p) {
int32_t basic_view_port_demo_app(void* p) {
UNUSED(p);
// Configure our initial data.
@ -99,8 +106,13 @@ int32_t basic_demo_app(void* p) {
if(event.input.type == InputTypeShort && event.input.key == InputKeyBack) {
FURI_LOG_I(TAG, "Short-Back pressed. Exiting program.");
processing = false;
} else if(event.input.type == InputTypeShort && event.input.key == InputKeyOk) {
FURI_LOG_I(TAG, "Short-OK pressed.");
if(furi_mutex_acquire(demo_context->mutex, FuriWaitForever) == FuriStatusOk) {
demo_context->data->counter++;
furi_mutex_release(demo_context->mutex);
}
}
break;
default:
break;
}