[FL-300] Launch applications from CLI (#380)

* app_loader: release console after cli start app cmd
* furi: add thread state getter
* app_loader: check thread started before launch with cli
* app_loader: remove view port from app loader
* blink: rework blink plugin to manage view and free resources
* vibro: rework vibro plugin to manage view and free resources
* music_player: rework app to manage exit and free resources
* input_dump: rework app to manage exit and free resources
* coreglitch_demo: add app exit and free resources
* floopper-bloopper: update submodule
* app-loader: remove applications context
* rules.mk: add submodule sync
* gui-test: add exit from application
* applications: exit on back short instead of press event
This commit is contained in:
gornekich
2021-03-18 10:58:16 +03:00
committed by GitHub
parent ca9862ef6c
commit 5eba573f43
13 changed files with 311 additions and 135 deletions

View File

@@ -1,13 +1,44 @@
#include <furi.h>
#include <input/input.h>
#include <gui/gui.h>
#include <api-hal.h>
#include "u8g2/u8g2.h"
extern TIM_HandleTypeDef SPEAKER_TIM;
bool exit_app;
static void event_cb(const void* value, void* ctx) {
furi_assert(value);
const InputEvent* event = value;
if(event->key == InputKeyBack && event->type == InputTypeShort) {
exit_app = true;
}
}
void coreglitch_draw_callback(Canvas* canvas, void* ctx) {
canvas_clear(canvas);
canvas_set_font(canvas, FontPrimary);
canvas_draw_str(canvas, 2, 10, "Coreglitch demo application");
}
int32_t coreglitch_demo_0(void* p) {
printf("coreglitch demo!\r\n");
exit_app = false;
PubSub* event_record = furi_record_open("input_events");
PubSubItem* event_pubsub = subscribe_pubsub(event_record, event_cb, NULL);
// Configure view port
ViewPort* view_port = view_port_alloc();
furi_check(view_port);
view_port_draw_callback_set(view_port, coreglitch_draw_callback, NULL);
// Register view port in GUI
Gui* gui = furi_record_open("gui");
gui_add_view_port(gui, view_port, GuiLayerFullscreen);
float notes[] = {
0.0,
330.0,
@@ -29,7 +60,7 @@ int32_t coreglitch_demo_0(void* p) {
uint8_t cnt = 0;
while(1) {
for(size_t note_idx = 0; note_idx < 400; note_idx++) {
for(size_t note_idx = 0; (note_idx < 400) && (!exit_app); note_idx++) {
float scale = scales[((cnt + note_idx) / 16) % 4];
float freq = notes[(note_idx + cnt / 2) % 8] * scale;
@@ -45,10 +76,17 @@ int32_t coreglitch_demo_0(void* p) {
// delay(1);
cnt++;
delay(100);
}
if(exit_app) {
break;
}
}
hal_pwm_stop(&SPEAKER_TIM, SPEAKER_CH);
view_port_enabled_set(view_port, false);
gui_remove_view_port(gui, view_port);
view_port_free(view_port);
unsubscribe_pubsub(event_pubsub);
return 0;
}