Skip to content

Commit

Permalink
Merge branch 'release-candidate' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
skotopes committed Dec 20, 2021
2 parents 06ad321 + 2ee2e8f commit a426762
Show file tree
Hide file tree
Showing 112 changed files with 3,104 additions and 3,475 deletions.
13 changes: 13 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
root = true

[*]
end_of_line = lf
insert_final_newline = true
charset = utf-8

[*.{cpp,h,c,py,sh}]
indent_style = space
indent_size = 4

[{Makefile,*.mk}]
indent_size = tab
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -147,5 +147,5 @@ jobs:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: |
[Click here](https://update.flipperzero.one/?url=https://update.flipperzero.one/builds/firmware/${{steps.names.outputs.artifacts-path}}/flipper-z-${{steps.names.outputs.default-target}}-full-${{steps.names.outputs.suffix}}.dfu&channel=${{steps.names.outputs.artifacts-path}}&version=${{steps.names.outputs.short-hash}}) to flash the `${{steps.names.outputs.short-hash}}` version of this branch via WebUSB.
[Click here](https://update.flipperzero.one/?url=https://update.flipperzero.one/builds/firmware/${{steps.names.outputs.artifacts-path}}/flipper-z-${{steps.names.outputs.default-target}}-full-${{steps.names.outputs.suffix}}.dfu&channel=${{steps.names.outputs.artifacts-path}}&version=${{steps.names.outputs.short-hash}}&target=${{steps.names.outputs.default-target}}) to flash the `${{steps.names.outputs.short-hash}}` version of this branch via WebUSB.
edit-mode: replace
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ venv/
__pycache__/
*.py[cod]
*$py.class
*.pickle

.obj/
bindings/
Expand All @@ -34,4 +35,4 @@ build
CMakeLists.txt

# bundle output
dist
dist
14 changes: 9 additions & 5 deletions applications/applications.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ extern int32_t subghz_app(void* p);
extern int32_t usb_mouse_app(void* p);
extern int32_t usb_test_app(void* p);
extern int32_t vibro_test_app(void* p);
extern int32_t ble_keyboard_app(void* p);
extern int32_t bt_hid_app(void* p);

// Plugins
extern int32_t music_player_app(void* p);
Expand All @@ -65,6 +65,7 @@ extern int32_t bt_settings_app(void* p);
extern int32_t desktop_settings_app(void* p);
extern int32_t about_settings_app(void* p);
extern int32_t power_settings_app(void* p);
extern int32_t system_settings_app(void* p);

const FlipperApplication FLIPPER_SERVICES[] = {
/* Services */
Expand Down Expand Up @@ -205,6 +206,9 @@ const size_t FLIPPER_ON_SYSTEM_START_COUNT =

// Plugin menu
const FlipperApplication FLIPPER_PLUGINS[] = {
#ifdef APP_BLE_HID
{.app = bt_hid_app, .name = "Bluetooth remote", .stack_size = 1024, .icon = NULL},
#endif

#ifdef APP_MUSIC_PLAYER
{.app = music_player_app, .name = "Music Player", .stack_size = 1024, .icon = &A_Plugins_14},
Expand All @@ -219,10 +223,6 @@ const size_t FLIPPER_PLUGINS_COUNT = sizeof(FLIPPER_PLUGINS) / sizeof(FlipperApp

// Plugin menu
const FlipperApplication FLIPPER_DEBUG_APPS[] = {
#ifdef APP_BLE_KEYBOARD
{.app = ble_keyboard_app, .name = "BLE keyboard demo", .stack_size = 1024, .icon = NULL},
#endif

#ifdef APP_BLINK
{.app = blink_test_app, .name = "Blink Test", .stack_size = 1024, .icon = NULL},
#endif
Expand Down Expand Up @@ -312,6 +312,10 @@ const FlipperApplication FLIPPER_SETTINGS_APPS[] = {
{.app = passport_app, .name = "Passport", .stack_size = 1024, .icon = NULL},
#endif

#ifdef SRV_GUI
{.app = system_settings_app, .name = "System", .stack_size = 1024, .icon = NULL},
#endif

#ifdef APP_ABOUT
{.app = about_settings_app, .name = "About", .stack_size = 1024, .icon = NULL},
#endif
Expand Down
8 changes: 4 additions & 4 deletions applications/applications.mk
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ APP_SD_TEST = 1
APP_VIBRO_TEST = 1
APP_USB_TEST = 1
APP_DISPLAY_TEST = 1
APP_BLE_KEYBOARD = 1
APP_BLE_HID = 1
APP_USB_MOUSE = 1
APP_BAD_USB = 1
APP_UART_ECHO = 1
Expand Down Expand Up @@ -167,9 +167,9 @@ CFLAGS += -DAPP_BAD_USB
SRV_GUI = 1
endif

APP_BLE_KEYBOARD ?=0
ifeq ($(APP_BLE_KEYBOARD), 1)
CFLAGS += -DAPP_BLE_KEYBOARD
APP_BLE_HID ?=0
ifeq ($(APP_BLE_HID), 1)
CFLAGS += -DAPP_BLE_HID
SRV_GUI = 1
endif

Expand Down
162 changes: 162 additions & 0 deletions applications/bt/bt_hid_app/bt_hid.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
#include "bt_hid.h"
#include <furi-hal-bt.h>
#include <applications/notification/notification-messages.h>

#define TAG "BtHidApp"

enum BtDebugSubmenuIndex {
BtHidSubmenuIndexKeynote,
BtHidSubmenuIndexMedia,
};

void bt_hid_submenu_callback(void* context, uint32_t index) {
furi_assert(context);
BtHid* app = context;
if(index == BtHidSubmenuIndexKeynote) {
app->view_id = BtHidViewKeynote;
view_dispatcher_switch_to_view(app->view_dispatcher, BtHidViewKeynote);
} else if(index == BtHidSubmenuIndexMedia) {
app->view_id = BtHidViewMedia;
view_dispatcher_switch_to_view(app->view_dispatcher, BtHidViewMedia);
}
}

void bt_hid_dialog_callback(DialogExResult result, void* context) {
furi_assert(context);
BtHid* app = context;
if(result == DialogExResultLeft) {
// TODO switch to Submenu after Media is done
view_dispatcher_stop(app->view_dispatcher);
} else if(result == DialogExResultRight) {
view_dispatcher_switch_to_view(app->view_dispatcher, BtHidViewKeynote);
}
}

uint32_t bt_hid_exit_confirm_view(void* context) {
return BtHidViewExitConfirm;
}

uint32_t bt_hid_exit(void* context) {
return VIEW_NONE;
}

void bt_hid_connection_status_changed_callback(BtStatus status, void* context) {
furi_assert(context);
BtHid* bt_hid = context;
bool connected = (status == BtStatusConnected);
if(connected) {
notification_internal_message(bt_hid->notifications, &sequence_set_blue_255);
} else {
notification_internal_message(bt_hid->notifications, &sequence_reset_blue);
}
bt_hid_keynote_set_connected_status(bt_hid->bt_hid_keynote, connected);
bt_hid_media_set_connected_status(bt_hid->bt_hid_media, connected);
}

BtHid* bt_hid_app_alloc() {
BtHid* app = furi_alloc(sizeof(BtHid));

// Gui
app->gui = furi_record_open("gui");

// Bt
app->bt = furi_record_open("bt");

// Notifications
app->notifications = furi_record_open("notification");

// View dispatcher
app->view_dispatcher = view_dispatcher_alloc();
view_dispatcher_enable_queue(app->view_dispatcher);
view_dispatcher_attach_to_gui(app->view_dispatcher, app->gui, ViewDispatcherTypeFullscreen);

// Submenu view
app->submenu = submenu_alloc();
submenu_add_item(
app->submenu, "Keynote", BtHidSubmenuIndexKeynote, bt_hid_submenu_callback, app);
submenu_add_item(
app->submenu, "Media player", BtHidSubmenuIndexMedia, bt_hid_submenu_callback, app);
view_set_previous_callback(submenu_get_view(app->submenu), bt_hid_exit);
view_dispatcher_add_view(
app->view_dispatcher, BtHidViewSubmenu, submenu_get_view(app->submenu));

// Dialog view
app->dialog = dialog_ex_alloc();
dialog_ex_set_result_callback(app->dialog, bt_hid_dialog_callback);
dialog_ex_set_context(app->dialog, app);
dialog_ex_set_left_button_text(app->dialog, "Exit");
dialog_ex_set_right_button_text(app->dialog, "Stay");
dialog_ex_set_header(app->dialog, "Close current app?", 16, 12, AlignLeft, AlignTop);
view_dispatcher_add_view(
app->view_dispatcher, BtHidViewExitConfirm, dialog_ex_get_view(app->dialog));

// Keynote view
app->bt_hid_keynote = bt_hid_keynote_alloc();
view_set_previous_callback(
bt_hid_keynote_get_view(app->bt_hid_keynote), bt_hid_exit_confirm_view);
view_dispatcher_add_view(
app->view_dispatcher, BtHidViewKeynote, bt_hid_keynote_get_view(app->bt_hid_keynote));

// Media view
app->bt_hid_media = bt_hid_media_alloc();
view_set_previous_callback(bt_hid_media_get_view(app->bt_hid_media), bt_hid_exit_confirm_view);
view_dispatcher_add_view(
app->view_dispatcher, BtHidViewMedia, bt_hid_media_get_view(app->bt_hid_media));

// TODO switch to menu after Media is done
view_dispatcher_switch_to_view(app->view_dispatcher, BtHidViewKeynote);

return app;
}

void bt_hid_app_free(BtHid* app) {
furi_assert(app);

// Reset notification
notification_internal_message(app->notifications, &sequence_reset_blue);

// Free views
view_dispatcher_remove_view(app->view_dispatcher, BtHidViewSubmenu);
submenu_free(app->submenu);
view_dispatcher_remove_view(app->view_dispatcher, BtHidViewExitConfirm);
dialog_ex_free(app->dialog);
view_dispatcher_remove_view(app->view_dispatcher, BtHidViewKeynote);
bt_hid_keynote_free(app->bt_hid_keynote);
view_dispatcher_remove_view(app->view_dispatcher, BtHidViewMedia);
bt_hid_media_free(app->bt_hid_media);
view_dispatcher_free(app->view_dispatcher);

// Close records
furi_record_close("gui");
app->gui = NULL;
furi_record_close("notification");
app->notifications = NULL;
furi_record_close("bt");
app->bt = NULL;

// Free rest
free(app);
}

int32_t bt_hid_app(void* p) {
// Switch profile to Hid
BtHid* app = bt_hid_app_alloc();
bt_set_status_changed_callback(app->bt, bt_hid_connection_status_changed_callback, app);
// Change profile
if(!bt_set_profile(app->bt, BtProfileHidKeyboard)) {
FURI_LOG_E(TAG, "Failed to switch profile");
bt_hid_app_free(app);
return -1;
}
furi_hal_bt_start_advertising();

view_dispatcher_run(app->view_dispatcher);

bt_set_status_changed_callback(app->bt, NULL, NULL);
// Change back profile to Serial
bt_set_profile(app->bt, BtProfileSerial);

bt_hid_app_free(app);

return 0;
}
32 changes: 32 additions & 0 deletions applications/bt/bt_hid_app/bt_hid.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#pragma once

#include <furi.h>
#include <bt/bt_service/bt.h>
#include <gui/gui.h>
#include <gui/view.h>
#include <gui/view_dispatcher.h>
#include <applications/notification/notification.h>

#include <gui/modules/submenu.h>
#include <gui/modules/dialog_ex.h>
#include "views/bt_hid_keynote.h"
#include "views/bt_hid_media.h"

typedef struct {
Bt* bt;
Gui* gui;
NotificationApp* notifications;
ViewDispatcher* view_dispatcher;
Submenu* submenu;
DialogEx* dialog;
BtHidKeynote* bt_hid_keynote;
BtHidMedia* bt_hid_media;
uint32_t view_id;
} BtHid;

typedef enum {
BtHidViewSubmenu,
BtHidViewKeynote,
BtHidViewMedia,
BtHidViewExitConfirm,
} BtHidView;
Loading

0 comments on commit a426762

Please sign in to comment.