Ver código fonte

Merge barcode_gen from https://github.com/xMasterX/all-the-plugins

Willy-JL 1 ano atrás
pai
commit
545fc1793f
2 arquivos alterados com 23 adições e 14 exclusões
  1. 1 1
      barcode_gen/application.fam
  2. 22 13
      barcode_gen/barcode_app.c

+ 1 - 1
barcode_gen/application.fam

@@ -11,6 +11,6 @@ App(
     fap_file_assets="barcode_encoding_files",
     fap_author="@Kingal1337",
     fap_weburl="https://github.com/Kingal1337/flipper-barcode-generator",
-    fap_version="1.2",
+    fap_version="1.3",
     fap_description="App allows you to display various barcodes on flipper screen",
 )

+ 22 - 13
barcode_gen/barcode_app.c

@@ -4,7 +4,6 @@
 #include <assets_icons.h>
 #include <notification/notification.h>
 #include <notification/notification_messages.h>
-#include <notification/notification_app.h>
 
 /**
  * Opens a file browser dialog and returns the filepath of the selected file
@@ -15,7 +14,14 @@
  * @returns true if a file is selected
 */
 
-NotificationApp* notifications = 0;
+static NotificationApp* barcode_notifications;
+
+const NotificationSequence sequence_display_backlight_barcode = {
+    &message_force_display_brightness_setting_1f,
+    &message_display_backlight_on,
+    &message_do_not_reset,
+    NULL,
+};
 
 static bool select_file(const char* folder, FuriString* file_path) {
     DialogsApp* dialogs = furi_record_open(RECORD_DIALOGS);
@@ -148,6 +154,8 @@ void select_barcode_item(BarcodeApp* app) {
             },
             true);
 
+        notification_message(barcode_notifications, &sequence_display_backlight_barcode);
+
         view_dispatcher_switch_to_view(app->view_dispatcher, BarcodeView);
     }
 
@@ -303,11 +311,11 @@ void free_app(BarcodeApp* app) {
     free(app);
 }
 
-void set_backlight_brightness(float brightness) {
-    NotificationApp* notifications = furi_record_open(RECORD_NOTIFICATION);
-    notifications->settings.display_brightness = brightness;
-    notification_message(notifications, &sequence_display_backlight_on);
-}
+/*void set_backlight_brightness(float brightness) {
+    NotificationApp* barcode_notifications = furi_record_open(RECORD_NOTIFICATION);
+    barcode_notifications->settings.display_brightness = brightness;
+    notification_message(barcode_notifications, &sequence_display_backlight_on);
+}*/
 
 int32_t barcode_main(void* p) {
     UNUSED(p);
@@ -329,12 +337,12 @@ int32_t barcode_main(void* p) {
 
     submenu_add_item(app->main_menu, "Edit Barcode", EditBarcodeItem, submenu_callback, app);
 
-    NotificationApp* notifications = furi_record_open(RECORD_NOTIFICATION);
+    barcode_notifications = furi_record_open(RECORD_NOTIFICATION);
     // Save original brightness
-    float originalBrightness = notifications->settings.display_brightness;
+    //float originalBrightness = barcode_notifications->settings.display_brightness;
     // force backlight and increase brightness
-    notification_message_block(notifications, &sequence_display_backlight_enforce_on);
-    set_backlight_brightness(10); // set to highest
+    //notification_message(barcode_notifications, &sequence_display_backlight_enforce_on);
+    //set_backlight_brightness(10); // set to highest
 
     /*****************************
      * Creating Text Input View
@@ -441,8 +449,9 @@ int32_t barcode_main(void* p) {
     view_dispatcher_run(app->view_dispatcher);
 
     free_app(app);
-    notification_message_block(notifications, &sequence_display_backlight_enforce_auto);
-    set_backlight_brightness(originalBrightness);
+    notification_message_block(barcode_notifications, &sequence_display_backlight_enforce_auto);
+    //set_backlight_brightness(originalBrightness);
+    furi_record_close(RECORD_NOTIFICATION);
 
     return 0;
 }