Просмотр исходного кода

Add notifications (blue LED during flash and vibrate at end)

0xchocolate 2 лет назад
Родитель
Сommit
2edae07bea
3 измененных файлов с 18 добавлено и 1 удалено
  1. 2 0
      esp_flasher_app.c
  2. 2 0
      esp_flasher_app_i.h
  3. 14 1
      esp_flasher_worker.c

+ 2 - 0
esp_flasher_app.c

@@ -27,6 +27,7 @@ EspFlasherApp* esp_flasher_app_alloc() {
     app->gui = furi_record_open(RECORD_GUI);
     app->gui = furi_record_open(RECORD_GUI);
     app->dialogs = furi_record_open(RECORD_DIALOGS);
     app->dialogs = furi_record_open(RECORD_DIALOGS);
     app->storage = furi_record_open(RECORD_STORAGE);
     app->storage = furi_record_open(RECORD_STORAGE);
+    app->notification = furi_record_open(RECORD_NOTIFICATION);
 
 
     app->view_dispatcher = view_dispatcher_alloc();
     app->view_dispatcher = view_dispatcher_alloc();
     app->scene_manager = scene_manager_alloc(&esp_flasher_scene_handlers, app);
     app->scene_manager = scene_manager_alloc(&esp_flasher_scene_handlers, app);
@@ -106,6 +107,7 @@ void esp_flasher_app_free(EspFlasherApp* app) {
     furi_record_close(RECORD_GUI);
     furi_record_close(RECORD_GUI);
     furi_record_close(RECORD_STORAGE);
     furi_record_close(RECORD_STORAGE);
     furi_record_close(RECORD_DIALOGS);
     furi_record_close(RECORD_DIALOGS);
+    furi_record_close(RECORD_NOTIFICATION);
 
 
     free(app);
     free(app);
 }
 }

+ 2 - 0
esp_flasher_app_i.h

@@ -20,6 +20,7 @@
 #include <storage/storage.h>
 #include <storage/storage.h>
 #include <lib/toolbox/path.h>
 #include <lib/toolbox/path.h>
 #include <dialogs/dialogs.h>
 #include <dialogs/dialogs.h>
+#include <notification/notification_messages.h>
 
 
 #define ESP_FLASHER_TEXT_BOX_STORE_SIZE (4096)
 #define ESP_FLASHER_TEXT_BOX_STORE_SIZE (4096)
 
 
@@ -47,6 +48,7 @@ struct EspFlasherApp {
     TextBox* text_box;
     TextBox* text_box;
     Storage* storage;
     Storage* storage;
     DialogsApp* dialogs;
     DialogsApp* dialogs;
+    NotificationApp* notification;
 
 
     VariableItemList* var_item_list;
     VariableItemList* var_item_list;
     Widget* widget;
     Widget* widget;

+ 14 - 1
esp_flasher_worker.c

@@ -131,6 +131,9 @@ static int32_t esp_flasher_flash_bin(void* context) {
     flash_rx_stream = furi_stream_buffer_alloc(RX_BUF_SIZE, 1);
     flash_rx_stream = furi_stream_buffer_alloc(RX_BUF_SIZE, 1);
     timer = furi_timer_alloc(_timer_callback, FuriTimerTypePeriodic, app);
     timer = furi_timer_alloc(_timer_callback, FuriTimerTypePeriodic, app);
 
 
+    // turn on flipper blue LED for duration of flash
+    notification_message(app->notification, &sequence_set_only_blue_255);
+
     loader_port_debug_print("Connecting\n");
     loader_port_debug_print("Connecting\n");
     esp_loader_connect_args_t connect_config = ESP_LOADER_CONNECT_DEFAULT();
     esp_loader_connect_args_t connect_config = ESP_LOADER_CONNECT_DEFAULT();
     err = esp_loader_connect(&connect_config);
     err = esp_loader_connect(&connect_config);
@@ -169,10 +172,20 @@ static int32_t esp_flasher_flash_bin(void* context) {
         loader_port_debug_print("Restoring transmission rate\n");
         loader_port_debug_print("Restoring transmission rate\n");
         furi_hal_uart_set_br(FuriHalUartIdUSART1, 115200);
         furi_hal_uart_set_br(FuriHalUartIdUSART1, 115200);
 #endif
 #endif
-        loader_port_debug_print("Done flashing. Please reset the board manually.\n");
+        loader_port_debug_print("Done flashing. Please reset the board manually if it doesn't auto-reset.\n");
+
+        // auto-reset for supported boards
         loader_port_reset_target();
         loader_port_reset_target();
+
+        // short buzz to alert user
+        notification_message(app->notification, &sequence_set_vibro_on);
+        loader_port_delay_ms(50);
+        notification_message(app->notification, &sequence_reset_vibro);
     }
     }
 
 
+    // turn off flipper blue LED
+    notification_message(app->notification, &sequence_reset_blue);
+
     // done
     // done
     app->flash_worker_busy = false;
     app->flash_worker_busy = false;