[FL-2627] Flipper applications: SDK, build and debug system (#1387)
* Added support for running applications from SD card (FAPs - Flipper Application Packages) * Added plugin_dist target for fbt to build FAPs * All apps of type FlipperAppType.EXTERNAL and FlipperAppType.PLUGIN are built as FAPs by default * Updated VSCode configuration for new fbt features - re-deploy stock configuration to use them * Added debugging support for FAPs with fbt debug & VSCode * Added public firmware API with automated versioning Co-authored-by: hedger <hedger@users.noreply.github.com> Co-authored-by: SG <who.just.the.doctor@gmail.com> Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
59
applications/main/infrared/views/infrared_debug_view.c
Normal file
59
applications/main/infrared/views/infrared_debug_view.c
Normal file
@@ -0,0 +1,59 @@
|
||||
#include "infrared_debug_view.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <gui/canvas.h>
|
||||
#include <gui/elements.h>
|
||||
|
||||
#define INFRARED_DEBUG_TEXT_LENGTH 64
|
||||
|
||||
struct InfraredDebugView {
|
||||
View* view;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
char text[INFRARED_DEBUG_TEXT_LENGTH];
|
||||
} InfraredDebugViewModel;
|
||||
|
||||
static void infrared_debug_view_draw_callback(Canvas* canvas, void* model) {
|
||||
InfraredDebugViewModel* debug_view_model = model;
|
||||
|
||||
canvas_clear(canvas);
|
||||
canvas_set_font(canvas, FontPrimary);
|
||||
elements_multiline_text_aligned(canvas, 64, 0, AlignCenter, AlignTop, "INFRARED monitor\n");
|
||||
canvas_set_font(canvas, FontKeyboard);
|
||||
|
||||
if(strlen(debug_view_model->text)) {
|
||||
elements_multiline_text_aligned(
|
||||
canvas, 64, 43, AlignCenter, AlignCenter, debug_view_model->text);
|
||||
}
|
||||
}
|
||||
|
||||
InfraredDebugView* infrared_debug_view_alloc() {
|
||||
InfraredDebugView* debug_view = malloc(sizeof(InfraredDebugView));
|
||||
debug_view->view = view_alloc();
|
||||
view_allocate_model(debug_view->view, ViewModelTypeLocking, sizeof(InfraredDebugViewModel));
|
||||
view_set_draw_callback(debug_view->view, infrared_debug_view_draw_callback);
|
||||
view_set_context(debug_view->view, debug_view);
|
||||
return debug_view;
|
||||
}
|
||||
void infrared_debug_view_free(InfraredDebugView* debug_view) {
|
||||
view_free(debug_view->view);
|
||||
free(debug_view);
|
||||
}
|
||||
|
||||
View* infrared_debug_view_get_view(InfraredDebugView* debug_view) {
|
||||
return debug_view->view;
|
||||
}
|
||||
|
||||
void infrared_debug_view_set_text(InfraredDebugView* debug_view, const char* fmt, ...) {
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
|
||||
InfraredDebugViewModel* model = view_get_model(debug_view->view);
|
||||
vsnprintf(model->text, INFRARED_DEBUG_TEXT_LENGTH, fmt, args);
|
||||
view_commit_model(debug_view->view, true);
|
||||
|
||||
va_end(args);
|
||||
}
|
11
applications/main/infrared/views/infrared_debug_view.h
Normal file
11
applications/main/infrared/views/infrared_debug_view.h
Normal file
@@ -0,0 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include <gui/view.h>
|
||||
|
||||
typedef struct InfraredDebugView InfraredDebugView;
|
||||
|
||||
InfraredDebugView* infrared_debug_view_alloc();
|
||||
void infrared_debug_view_free(InfraredDebugView* debug_view);
|
||||
|
||||
View* infrared_debug_view_get_view(InfraredDebugView* debug_view);
|
||||
void infrared_debug_view_set_text(InfraredDebugView* debug_view, const char* fmt, ...);
|
121
applications/main/infrared/views/infrared_progress_view.c
Normal file
121
applications/main/infrared/views/infrared_progress_view.c
Normal file
@@ -0,0 +1,121 @@
|
||||
#include <core/check.h>
|
||||
#include "furi_hal_resources.h"
|
||||
#include "assets_icons.h"
|
||||
#include "gui/canvas.h"
|
||||
#include "gui/view.h"
|
||||
#include "input/input.h"
|
||||
#include "m-string.h"
|
||||
#include <gui/elements.h>
|
||||
#include <furi.h>
|
||||
#include "infrared_progress_view.h"
|
||||
#include "gui/modules/button_panel.h"
|
||||
#include <stdint.h>
|
||||
|
||||
struct InfraredProgressView {
|
||||
View* view;
|
||||
InfraredProgressViewBackCallback back_callback;
|
||||
void* context;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
size_t progress;
|
||||
size_t progress_total;
|
||||
} InfraredProgressViewModel;
|
||||
|
||||
bool infrared_progress_view_increase_progress(InfraredProgressView* progress) {
|
||||
furi_assert(progress);
|
||||
bool result = false;
|
||||
|
||||
InfraredProgressViewModel* model = view_get_model(progress->view);
|
||||
if(model->progress < model->progress_total) {
|
||||
++model->progress;
|
||||
result = model->progress < model->progress_total;
|
||||
}
|
||||
view_commit_model(progress->view, true);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static void infrared_progress_view_draw_callback(Canvas* canvas, void* _model) {
|
||||
InfraredProgressViewModel* model = (InfraredProgressViewModel*)_model;
|
||||
|
||||
uint8_t x = 0;
|
||||
uint8_t y = 36;
|
||||
uint8_t width = 63;
|
||||
uint8_t height = 59;
|
||||
|
||||
elements_bold_rounded_frame(canvas, x, y, width, height);
|
||||
|
||||
canvas_set_font(canvas, FontSecondary);
|
||||
elements_multiline_text_aligned(
|
||||
canvas, x + 34, y + 9, AlignCenter, AlignCenter, "Sending ...");
|
||||
|
||||
float progress_value = (float)model->progress / model->progress_total;
|
||||
elements_progress_bar(canvas, x + 4, y + 19, width - 7, progress_value);
|
||||
|
||||
uint8_t percent_value = 100 * model->progress / model->progress_total;
|
||||
char percents_string[10] = {0};
|
||||
snprintf(percents_string, sizeof(percents_string), "%d%%", percent_value);
|
||||
elements_multiline_text_aligned(
|
||||
canvas, x + 33, y + 37, AlignCenter, AlignCenter, percents_string);
|
||||
|
||||
canvas_draw_icon(canvas, x + 14, y + height - 14, &I_Pin_back_arrow_10x8);
|
||||
canvas_draw_str(canvas, x + 30, y + height - 6, "= stop");
|
||||
}
|
||||
|
||||
void infrared_progress_view_set_progress_total(
|
||||
InfraredProgressView* progress,
|
||||
uint16_t progress_total) {
|
||||
furi_assert(progress);
|
||||
InfraredProgressViewModel* model = view_get_model(progress->view);
|
||||
model->progress = 0;
|
||||
model->progress_total = progress_total;
|
||||
view_commit_model(progress->view, false);
|
||||
}
|
||||
|
||||
bool infrared_progress_view_input_callback(InputEvent* event, void* context) {
|
||||
InfraredProgressView* instance = context;
|
||||
|
||||
if((event->type == InputTypeShort) && (event->key == InputKeyBack)) {
|
||||
if(instance->back_callback) {
|
||||
instance->back_callback(instance->context);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
InfraredProgressView* infrared_progress_view_alloc(void) {
|
||||
InfraredProgressView* instance = malloc(sizeof(InfraredProgressView));
|
||||
instance->view = view_alloc();
|
||||
view_allocate_model(instance->view, ViewModelTypeLocking, sizeof(InfraredProgressViewModel));
|
||||
InfraredProgressViewModel* model = view_get_model(instance->view);
|
||||
model->progress = 0;
|
||||
model->progress_total = 0;
|
||||
view_commit_model(instance->view, false);
|
||||
view_set_draw_callback(instance->view, infrared_progress_view_draw_callback);
|
||||
view_set_input_callback(instance->view, infrared_progress_view_input_callback);
|
||||
view_set_context(instance->view, instance);
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
void infrared_progress_view_free(InfraredProgressView* progress) {
|
||||
view_free(progress->view);
|
||||
free(progress);
|
||||
}
|
||||
|
||||
void infrared_progress_view_set_back_callback(
|
||||
InfraredProgressView* instance,
|
||||
InfraredProgressViewBackCallback callback,
|
||||
void* context) {
|
||||
furi_assert(instance);
|
||||
instance->back_callback = callback;
|
||||
instance->context = context;
|
||||
}
|
||||
|
||||
View* infrared_progress_view_get_view(InfraredProgressView* instance) {
|
||||
furi_assert(instance);
|
||||
furi_assert(instance->view);
|
||||
return instance->view;
|
||||
}
|
68
applications/main/infrared/views/infrared_progress_view.h
Normal file
68
applications/main/infrared/views/infrared_progress_view.h
Normal file
@@ -0,0 +1,68 @@
|
||||
/**
|
||||
* @file infrared_progress_view.h
|
||||
* Infrared: Custom Infrared view module.
|
||||
* It shows popup progress bar during brute force.
|
||||
*/
|
||||
#pragma once
|
||||
#include <gui/view.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** Anonumous instance */
|
||||
typedef struct InfraredProgressView InfraredProgressView;
|
||||
|
||||
/** Callback for back button handling */
|
||||
typedef void (*InfraredProgressViewBackCallback)(void*);
|
||||
|
||||
/** Allocate and initialize Infrared view
|
||||
*
|
||||
* @retval new allocated instance
|
||||
*/
|
||||
InfraredProgressView* infrared_progress_view_alloc();
|
||||
|
||||
/** Free previously allocated Progress view module instance
|
||||
*
|
||||
* @param instance to free
|
||||
*/
|
||||
void infrared_progress_view_free(InfraredProgressView* instance);
|
||||
|
||||
/** Get progress view module view
|
||||
*
|
||||
* @param instance view module
|
||||
* @retval view
|
||||
*/
|
||||
View* infrared_progress_view_get_view(InfraredProgressView* instance);
|
||||
|
||||
/** Increase progress on progress view module
|
||||
*
|
||||
* @param instance view module
|
||||
* @retval true - value is incremented and maximum is reached,
|
||||
* false - value is incremented and maximum is not reached
|
||||
*/
|
||||
bool infrared_progress_view_increase_progress(InfraredProgressView* instance);
|
||||
|
||||
/** Set maximum progress value
|
||||
*
|
||||
* @param instance - view module
|
||||
* @param progress_max - maximum value of progress
|
||||
*/
|
||||
void infrared_progress_view_set_progress_total(
|
||||
InfraredProgressView* instance,
|
||||
uint16_t progress_max);
|
||||
|
||||
/** Set back button callback
|
||||
*
|
||||
* @param instance - view module
|
||||
* @param callback - callback to call for back button
|
||||
* @param context - context to pass to callback
|
||||
*/
|
||||
void infrared_progress_view_set_back_callback(
|
||||
InfraredProgressView* instance,
|
||||
InfraredProgressViewBackCallback callback,
|
||||
void* context);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
Reference in New Issue
Block a user