Skip to content

Commit

Permalink
Mise à jour applications externes
Browse files Browse the repository at this point in the history
  • Loading branch information
KaliStudio committed Mar 23, 2024
1 parent b29f58b commit 712ca8e
Show file tree
Hide file tree
Showing 90 changed files with 1,478 additions and 776 deletions.
9 changes: 9 additions & 0 deletions applications/external/airmouse/air_mouse.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ enum AirMouseSubmenuIndex {
AirMouseSubmenuIndexBtMouse,
AirMouseSubmenuIndexUsbMouse,
AirMouseSubmenuIndexCalibration,
AirMouseSubmenuIndexRemovePairing,
};

void air_mouse_submenu_callback(void* context, uint32_t index) {
Expand All @@ -24,6 +25,8 @@ void air_mouse_submenu_callback(void* context, uint32_t index) {
} else if(index == AirMouseSubmenuIndexCalibration) {
app->view_id = AirMouseViewCalibration;
view_dispatcher_switch_to_view(app->view_dispatcher, AirMouseViewCalibration);
} else if(index == AirMouseSubmenuIndexRemovePairing) {
bt_mouse_remove_pairing();
}
}

Expand Down Expand Up @@ -78,6 +81,12 @@ AirMouse* air_mouse_app_alloc() {
AirMouseSubmenuIndexCalibration,
air_mouse_submenu_callback,
app);
submenu_add_item(
app->submenu,
"Effacer paires bluetooth",
AirMouseSubmenuIndexRemovePairing,
air_mouse_submenu_callback,
app);
view_set_previous_callback(submenu_get_view(app->submenu), air_mouse_exit);
view_dispatcher_add_view(
app->view_dispatcher, AirMouseViewSubmenu, submenu_get_view(app->submenu));
Expand Down
4 changes: 2 additions & 2 deletions applications/external/airmouse/application.fam
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ App(
stack_size=10 * 1024,
fap_category="GPIO",
fap_icon="mouse_10px.png",
fap_version="0.9",
sources=["*.c", "*.cc"],
fap_version="1.1",
fap_libs=["ble_profile"],
sources=["*.c", "*.cc"],
)
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#define CARDBOARD_SDK_SENSORS_MEAN_FILTER_H_

#include <deque>
#include <cstddef>

#include "../util/vector.h"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#define CARDBOARD_SDK_SENSORS_MEDIAN_FILTER_H_

#include <deque>
#include <cstddef>

#include "../util/vector.h"

Expand Down
57 changes: 47 additions & 10 deletions applications/external/airmouse/views/bt_mouse.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@

#include <furi.h>
#include <furi_hal_bt.h>
#include <extra_profiles/hid_profile.h>
#include <furi_hal_usb_hid.h>
#include <profiles/serial_profile.h>
#include <extra_profiles/hid_profile.h>
#include <bt/bt_service/bt.h>
#include <gui/elements.h>
#include <notification/notification.h>
#include <notification/notification_messages.h>
#include <storage/storage.h>

typedef struct ButtonEvent {
int8_t button;
Expand All @@ -18,10 +20,10 @@ typedef struct ButtonEvent {
#define BTN_EVT_QUEUE_SIZE 32

struct BtMouse {
FuriHalBleProfileBase* hid;
View* view;
ViewDispatcher* view_dispatcher;
Bt* bt;
FuriHalBleProfileBase* ble_hid_profile;
NotificationApp* notifications;
FuriMutex* mutex;
FuriThread* thread;
Expand All @@ -41,12 +43,19 @@ struct BtMouse {
ButtonEvent queue[BTN_EVT_QUEUE_SIZE];
};

static const BleProfileHidParams ble_hid_params = {
.device_name_prefix = "AirMouse",
.mac_xor = 0x0001,
};

#define BT_MOUSE_FLAG_INPUT_EVENT (1UL << 0)
#define BT_MOUSE_FLAG_KILL_THREAD (1UL << 1)
#define BT_MOUSE_FLAG_ALL (BT_MOUSE_FLAG_INPUT_EVENT | BT_MOUSE_FLAG_KILL_THREAD)

#define MOUSE_SCROLL 2

#define HID_BT_KEYS_STORAGE_NAME ".bt_hid.keys"

static void bt_mouse_notify_event(BtMouse* bt_mouse) {
FuriThreadId thread_id = furi_thread_get_id(bt_mouse->thread);
furi_assert(thread_id);
Expand Down Expand Up @@ -119,7 +128,7 @@ static bool bt_mouse_input_callback(InputEvent* event, void* context) {
bool consumed = false;

if(event->type == InputTypeLong && event->key == InputKeyBack) {
ble_profile_hid_mouse_release_all(bt_mouse->ble_hid_profile);
ble_profile_hid_mouse_release_all(bt_mouse->hid);
} else {
bt_mouse_process(bt_mouse, event);
consumed = true;
Expand Down Expand Up @@ -204,18 +213,18 @@ static int32_t bt_mouse_thread_callback(void* context) {

if(bt_mouse->connected && send_buttons) {
if(event.state) {
ble_profile_hid_mouse_press(bt_mouse->ble_hid_profile, event.button);
ble_profile_hid_mouse_press(bt_mouse->hid, event.button);
} else {
ble_profile_hid_mouse_release(bt_mouse->ble_hid_profile, event.button);
ble_profile_hid_mouse_release(bt_mouse->hid, event.button);
}
}

if(bt_mouse->connected && (dx != 0 || dy != 0)) {
ble_profile_hid_mouse_move(bt_mouse->ble_hid_profile, dx, dy);
ble_profile_hid_mouse_move(bt_mouse->hid, dx, dy);
}

if(bt_mouse->connected && wheel != 0) {
ble_profile_hid_mouse_scroll(bt_mouse->ble_hid_profile, wheel);
ble_profile_hid_mouse_scroll(bt_mouse->hid, wheel);
}
}
}
Expand Down Expand Up @@ -251,15 +260,37 @@ void bt_mouse_enter_callback(void* context) {
BtMouse* bt_mouse = context;

bt_mouse->bt = furi_record_open(RECORD_BT);
bt_disconnect(bt_mouse->bt);

furi_delay_ms(200);
bt_keys_storage_set_storage_path(bt_mouse->bt, APP_DATA_PATH(HID_BT_KEYS_STORAGE_NAME));

bt_mouse->notifications = furi_record_open(RECORD_NOTIFICATION);
bt_set_status_changed_callback(
bt_mouse->bt, bt_mouse_connection_status_changed_callback, bt_mouse);
bt_mouse->ble_hid_profile = bt_profile_start(bt_mouse->bt, ble_profile_hid, NULL);
furi_check(bt_mouse->ble_hid_profile);
bt_mouse->hid = bt_profile_start(bt_mouse->bt, ble_profile_hid, (void*)&ble_hid_params);
furi_assert(bt_mouse->hid);
furi_hal_bt_start_advertising();
bt_mouse_thread_start(bt_mouse);
}

void bt_mouse_remove_pairing(void) {
Bt* bt = furi_record_open(RECORD_BT);
bt_disconnect(bt);

furi_delay_ms(200);
furi_hal_bt_stop_advertising();

bt_keys_storage_set_storage_path(bt, APP_DATA_PATH(HID_BT_KEYS_STORAGE_NAME));
bt_forget_bonded_devices(bt);

furi_delay_ms(200);
bt_keys_storage_set_default_path(bt);

furi_check(bt_profile_restore_default(bt));
furi_record_close(RECORD_BT);
}

bool bt_mouse_custom_callback(uint32_t event, void* context) {
UNUSED(event);
furi_assert(context);
Expand All @@ -281,7 +312,13 @@ void bt_mouse_exit_callback(void* context) {
notification_internal_message(bt_mouse->notifications, &sequence_reset_blue);

bt_set_status_changed_callback(bt_mouse->bt, NULL, NULL);
furi_check(bt_profile_restore_default(bt_mouse->bt));
bt_disconnect(bt_mouse->bt);

furi_delay_ms(200);
bt_keys_storage_set_default_path(bt_mouse->bt);

furi_hal_bt_stop_advertising();
bt_profile_restore_default(bt_mouse->bt);

furi_record_close(RECORD_NOTIFICATION);
bt_mouse->notifications = NULL;
Expand Down
2 changes: 2 additions & 0 deletions applications/external/airmouse/views/bt_mouse.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ void bt_mouse_free(BtMouse* bt_mouse);
View* bt_mouse_get_view(BtMouse* bt_mouse);

void bt_mouse_set_connected_status(BtMouse* bt_mouse, bool connected);

void bt_mouse_remove_pairing(void);
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,6 @@ int32_t flipper_atomicdiceroller_app() {
EventApp event;
FuriMessageQueue* event_queue = furi_message_queue_alloc(8, sizeof(EventApp));

furi_hal_gpio_init(&gpio_ext_pa7, GpioModeInterruptFall, GpioPullUp, GpioSpeedVeryHigh);

mutexStruct mutexVal;
mutexVal.cps = 0;
mutexVal.dice = 0;
Expand All @@ -190,6 +188,7 @@ int32_t flipper_atomicdiceroller_app() {

furi_hal_gpio_add_int_callback(&gpio_ext_pa7, gpiocallback, event_queue);
furi_hal_gpio_enable_int_callback(&gpio_ext_pa7);
furi_hal_gpio_init(&gpio_ext_pa7, GpioModeInterruptFall, GpioPullUp, GpioSpeedVeryHigh);

Gui* gui = furi_record_open(RECORD_GUI);
gui_add_view_port(gui, view_port, GuiLayerFullscreen);
Expand Down
8 changes: 2 additions & 6 deletions applications/external/barcode_gen/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,8 @@ Note: Barcode save locations have been moved from `/barcodes` to `/apps_data/bar
## Building
1) Clone the [flipperzero-firmware](https://github.com/flipperdevices/flipperzero-firmware) repository or a firmware of your choice
2) Clone this repository and put it in the `applications_user` folder
3) Build this app by using the command `./fbt fap_Barcode_App`
4) Copy the `.fap` from `build\f7-firmware-D\.extapps\Barcode_App.fap` to `apps\Misc` using the qFlipper app
5) While still in the qFlipper app, navigate to the root folder of the SD card and create the folder `apps_data`, if not already there
6) Navigate into `apps_data` and create another folder called `barcode_data`
7) Navigate into `barcode_data`
8) Drag & drop the encoding txts (`code39_encodings.txt`, `code128_encodings.txt` & `codabar_encodings.txt`) from the `encoding_tables` folder in this repository into the `barcode_data` folder
3) Build this app by using the command `./fbt fap_barcode_App`
4) Copy the `.fap` from `build\f7-firmware-D\.extapps\Barcode_App.fap` to `apps\Tools` using the qFlipper app

## Usage

Expand Down
4 changes: 2 additions & 2 deletions applications/external/barcode_gen/application.fam
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ App(
fap_category="Outils",
fap_icon="images/barcode_10.png",
fap_icon_assets="images",
fap_file_assets="encoding_tables",
fap_file_assets="barcode_encoding_files",
fap_author="@Kingal1337",
fap_weburl="https://github.com/Kingal1337/flipper-barcode-generator",
fap_version="1.1",
fap_version="1.2",
fap_description="L'application vous permet d'afficher divers codes-barres sur l'écran du flipper",
)
75 changes: 75 additions & 0 deletions applications/external/barcode_gen/barcode_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,10 @@ void submenu_callback(void* context, uint32_t index) {
edit_barcode_item(app);
} else if(index == CreateBarcodeItem) {
create_barcode_item(app);
} else if(index == AboutWidgetItem) {
view_dispatcher_switch_to_view(app->view_dispatcher, AboutWidgetView);
} else if(index == ErrorCodesWidgetItem) {
view_dispatcher_switch_to_view(app->view_dispatcher, ErrorCodesWidgetView);
}
}

Expand Down Expand Up @@ -270,6 +274,12 @@ void free_app(BarcodeApp* app) {
view_dispatcher_remove_view(app->view_dispatcher, TextInputView);
text_input_free(app->text_input);

view_dispatcher_remove_view(app->view_dispatcher, AboutWidgetView);
widget_free(app->about_widget);

view_dispatcher_remove_view(app->view_dispatcher, ErrorCodesWidgetView);
widget_free(app->error_codes_widget);

view_dispatcher_remove_view(app->view_dispatcher, MessageErrorView);
message_view_free(app->message_view);

Expand Down Expand Up @@ -350,6 +360,71 @@ int32_t barcode_main(void* p) {
view_dispatcher_add_view(
app->view_dispatcher, CreateBarcodeView, create_get_view(app->create_view));

/*****************************
* Creating Error Codes View
******************************/
app->error_codes_widget = widget_alloc();
widget_add_text_scroll_element(
app->error_codes_widget,
0,
0,
128,
64,
"\e#Error Codes\n"
"\e#Wrong # Of Characters\n"
"The barcode data has too \nmany or too few characters\n"
"UPC-A: 11-12 characters\n"
"EAN-8: 7-8 characters\n"
"EAN-13: 12-13 characters\n"
"Code128C - even # of \ncharacters\n"
"\n"
"\e#Invalid Characters\n"
"The barcode data has invalid \ncharacters.\n"
"Ex: UPC-A, EAN-8, EAN-13 barcodes can only have \nnumbers while Code128 can \nhave almost any character\n"
"\n"
"\e#Unsupported Type\n"
"The barcode type is not \nsupported by this application\n"
"\n"
"\e#File Opening Error\n"
"The barcode file could not be opened. One reason could be \nthat the file no longer exists\n"
"\n"
"\e#Invalid File Data\n"
"The barcode file could not find the keys \"Type\" or \"Data\". \nThis usually occurs when you edit the file manually and \naccidently change the keys\n"
"\n"
"\e#Missing Encoding Table\n"
"The encoding table files are \nmissing. This only occurs \nwhen you need to handle the \nencoding files manually. If you \ndownload the files from the \napp store this should not \noccur\n"
"\n"
"\e#Encoding Table Error\n"
"This occurs when the \nprogram cannot find a \ncharacter in the encoding \ntable, meaning that either the\ncharacter isn't supported \nor the character is missing \nfrom the encoding table\n"
"");
view_set_previous_callback(widget_get_view(app->error_codes_widget), main_menu_callback);
view_dispatcher_add_view(
app->view_dispatcher, ErrorCodesWidgetView, widget_get_view(app->error_codes_widget));
submenu_add_item(
app->main_menu, "Error Codes Info", ErrorCodesWidgetItem, submenu_callback, app);

/*****************************
* Creating About View
******************************/
app->about_widget = widget_alloc();
widget_add_text_scroll_element(
app->about_widget,
0,
0,
128,
64,
"Un générateur de codes-barres\n"
"capable de générer UPC-A,\n"
"EAN-8, EAN-13, Code-39,\n"
"Codabar, et Code-128\n"
"Pour plus d'informations ou\n"
"problèmes, allez à\n"
"https://github.com/Kingal1337/flipper-barcode-generator");
view_set_previous_callback(widget_get_view(app->about_widget), main_menu_callback);
view_dispatcher_add_view(
app->view_dispatcher, AboutWidgetView, widget_get_view(app->about_widget));
submenu_add_item(app->main_menu, "About", AboutWidgetItem, submenu_callback, app);

/*****************************
* Creating Barcode View
******************************/
Expand Down
12 changes: 9 additions & 3 deletions applications/external/barcode_gen/barcode_app.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
#include <furi_hal.h>

#include <gui/gui.h>
#include <gui/elements.h>
#include <input/input.h>
#include <dialogs/dialogs.h>
#include <gui/view_dispatcher.h>
#include <gui/modules/submenu.h>
#include <gui/modules/widget.h>
#include <gui/modules/text_input.h>
#include <gui/modules/text_input.h>

Expand Down Expand Up @@ -59,23 +61,27 @@ struct BarcodeApp {
CreateView* create_view;
Barcode* barcode_view;

Widget* about_widget;
Widget* error_codes_widget;
MessageView* message_view;
TextInput* text_input;
};

enum SubmenuItems {
SelectBarcodeItem,
EditBarcodeItem,

CreateBarcodeItem
CreateBarcodeItem,
ErrorCodesWidgetItem,
AboutWidgetItem
};

enum Views {
TextInputView,
AboutWidgetView,
ErrorCodesWidgetView,
MessageErrorView,
MainMenuView,
CreateBarcodeView,

BarcodeView
};

Expand Down
Loading

0 comments on commit 712ca8e

Please sign in to comment.