MX пре 2 година
родитељ
комит
9da8600d87
53 измењених фајлова са 3953 додато и 3880 уклоњено
  1. 51 62
      apps_source_code/DVD-Bounce/dvdbounce.c
  2. 51 102
      apps_source_code/ServoTesterApp/app.c
  3. 0 1
      apps_source_code/barcode_gen/barcode_utils.c
  4. 1 1
      apps_source_code/barcode_gen/barcode_validator.c
  5. 1 1
      apps_source_code/barcode_gen/views/barcode_view.c
  6. 2 1
      apps_source_code/barcode_gen/views/create_view.c
  7. 45 43
      apps_source_code/esp32cam_camera/camera.c
  8. 29 10
      apps_source_code/esp32cam_camera/camera.h
  9. 2 1
      apps_source_code/esp32cam_marauder_companion/scenes/wifi_marauder_scene_console_output.c
  10. 10 5
      apps_source_code/esp32cam_marauder_companion/scenes/wifi_marauder_scene_log_viewer.c
  11. 1 1
      apps_source_code/esp32cam_marauder_companion/scenes/wifi_marauder_scene_start.c
  12. 3 2
      apps_source_code/esp32cam_morseflasher/scenes/uart_terminal_scene_console_output.c
  13. 8 1
      apps_source_code/esp32cam_morseflasher/scenes/uart_terminal_scene_start.c
  14. 5 4
      apps_source_code/esp32cam_morseflasher/uart_terminal_app.c
  15. 1 1
      apps_source_code/esp32cam_morseflasher/uart_terminal_uart.c
  16. 3 4
      apps_source_code/esp32cam_motion_detection/uart_echo.c
  17. 2 3
      apps_source_code/esp32cam_nannycam/uart_echo.c
  18. 2 3
      apps_source_code/esp32cam_qrcode/uart_echo.c
  19. 1 4
      apps_source_code/flipperscope/scenes/scope_scene_about.c
  20. 7 18
      apps_source_code/flipperscope/scenes/scope_scene_setup.c
  21. 3 15
      apps_source_code/flipperscope/scenes/scope_scene_start.c
  22. 0 1
      apps_source_code/flipperscope/scenes/scope_types.h
  23. 4 7
      apps_source_code/flipperscope/scope.c
  24. 8 13
      apps_source_code/flipperscope/scope_app_i.h
  25. 6 6
      apps_source_code/flizzer_tracker/tracker_engine/tracker_engine.c
  26. 152 152
      apps_source_code/gb-pokemon-trading/pokemon_app.cpp
  27. 3 3
      apps_source_code/gb-pokemon-trading/pokemon_app.h
  28. 276 289
      apps_source_code/gb-pokemon-trading/pokemon_data.h
  29. 2 7
      apps_source_code/gb-pokemon-trading/views/select_pokemon.cpp
  30. 1 1
      apps_source_code/gb-pokemon-trading/views/trade.hpp
  31. 43 42
      apps_source_code/gpio_7segment/gpio_7segment_app.c
  32. 59 109
      apps_source_code/mh_z19/mh_z19app.c
  33. 0 2
      apps_source_code/mifare_fuzzer/mifare_fuzzer_i.h
  34. 20 24
      apps_source_code/mifare_fuzzer/mifare_fuzzer_worker.c
  35. 4 2
      apps_source_code/mifare_fuzzer/mifare_fuzzer_worker.h
  36. 28 34
      apps_source_code/mifare_fuzzer/scenes/mifare_fuzzer_scene_attack.c
  37. 42 41
      apps_source_code/mifare_fuzzer/scenes/mifare_fuzzer_scene_emulator.c
  38. 21 28
      apps_source_code/mifare_fuzzer/scenes/mifare_fuzzer_scene_start.c
  39. 80 86
      apps_source_code/mifare_fuzzer/views/mifare_fuzzer_emulator.c
  40. 10 10
      apps_source_code/mifare_fuzzer/views/mifare_fuzzer_emulator.h
  41. 1787 1619
      apps_source_code/nrf24-batch/nrf24batch.c
  42. 8 9
      apps_source_code/nrf24-batch/nrf24batch.h
  43. 710 604
      apps_source_code/nrf24scan/nrf24scan.c
  44. 11 12
      apps_source_code/nrf24scan/nrf24scan.h
  45. 98 129
      apps_source_code/racegame/race.c
  46. 7 11
      apps_source_code/rcwl_0516/rcwl_0516.c
  47. 0 1
      apps_source_code/rcwl_0516/rcwl_0516.h
  48. 331 331
      apps_source_code/schip/schip.c
  49. 0 2
      apps_source_code/sony-intervalometer/intervalometer.h
  50. 1 8
      apps_source_code/usping/usping.c
  51. 1 2
      apps_source_code/video_player/init_deinit.c
  52. 1 1
      apps_source_code/video_player/video_player.h
  53. 11 11
      apps_source_code/wifi-map/wifi_map.c

+ 51 - 62
apps_source_code/DVD-Bounce/dvdbounce.c

@@ -5,7 +5,6 @@
 #include <input/input.h>
 #include "dvd_bounce_icons.h"
 
-
 //init some variables
 int x = 0;
 int y = 0;
@@ -28,16 +27,16 @@ static void app_draw_callback(Canvas* canvas, void* ctx) {
     //converts mode int to string
     itoa(mode, mode_str, 10);
     canvas_draw_str(canvas, 28, 8, mode_str);
-    switch(mode){
-        case 1:
-            canvas_draw_str(canvas, 2, 16, "Left/Right");
-            break;
-        case 2:
-            canvas_draw_str(canvas, 2, 16, "Up/Down");
-            break;
-        default:
-            canvas_draw_str(canvas, 2, 16, "Normal");
-            break;
+    switch(mode) {
+    case 1:
+        canvas_draw_str(canvas, 2, 16, "Left/Right");
+        break;
+    case 2:
+        canvas_draw_str(canvas, 2, 16, "Up/Down");
+        break;
+    default:
+        canvas_draw_str(canvas, 2, 16, "Normal");
+        break;
     }
 }
 
@@ -48,7 +47,7 @@ static void app_input_callback(InputEvent* input_event, void* ctx) {
     furi_message_queue_put(event_queue, input_event, FuriWaitForever);
 }
 
-int32_t bounce_moment(void* p){
+int32_t bounce_moment(void* p) {
     UNUSED(p);
     FuriMessageQueue* event_queue = furi_message_queue_alloc(8, sizeof(InputEvent));
 
@@ -65,80 +64,71 @@ int32_t bounce_moment(void* p){
 
     bool running = true;
     while(running) {
-        if (furi_message_queue_get(event_queue, &event, 100) == FuriStatusOk) {
-            if ((event.type == InputTypePress) || (event.type == InputTypeRepeat)) {
+        if(furi_message_queue_get(event_queue, &event, 100) == FuriStatusOk) {
+            if((event.type == InputTypePress) || (event.type == InputTypeRepeat)) {
                 //arrows move the ball by 10 in their respective directions
-                switch (event.key) {
-
-                    case InputKeyUp:
-                        y += -10;
-                        break;
-
-                    case InputKeyDown:
-                        y += 10;
-                        break;
-
-                    case InputKeyLeft:
-                        x += -10;
-                        break;
-
-                    case InputKeyRight:
-                        x += 10;
-                        break;
-                    //sets the ball to the middle of the screen and sets the current mode
-                    case InputKeyOk:
-                        x = 51;
-                        y = 19;
-                        if(mode == 2){
-                            mode = 0;
-                        }
-                        else{
-                            mode += 1;
-                        }
-                        break;
-                    //exits the program if back is pressed
-                    default:
-                        running = false;
-                        break;
-                    
+                switch(event.key) {
+                case InputKeyUp:
+                    y += -10;
+                    break;
+
+                case InputKeyDown:
+                    y += 10;
+                    break;
+
+                case InputKeyLeft:
+                    x += -10;
+                    break;
+
+                case InputKeyRight:
+                    x += 10;
+                    break;
+                //sets the ball to the middle of the screen and sets the current mode
+                case InputKeyOk:
+                    x = 51;
+                    y = 19;
+                    if(mode == 2) {
+                        mode = 0;
+                    } else {
+                        mode += 1;
+                    }
+                    break;
+                //exits the program if back is pressed
+                default:
+                    running = false;
+                    break;
                 }
             }
         }
 
-        
-        
-            
-
         //bunch of conditionals determining how the ball should move
-        if (x <= 0) {
+        if(x <= 0) {
             bounce_up = false;
         }
-        if (x >= 115) {
+        if(x >= 115) {
             bounce_up = true;
         }
-        if (y <= 0) {
+        if(y <= 0) {
             bounce_right = true;
         }
-        if (y >= 51) {
+        if(y >= 51) {
             bounce_right = false;
         }
 
-        if((bounce_up) && (mode != 2)){
+        if((bounce_up) && (mode != 2)) {
             x += -1;
         }
-        if((!bounce_up) && (mode != 2)){
+        if((!bounce_up) && (mode != 2)) {
             x += 1;
         }
-        if((bounce_right) && (mode != 1)){
+        if((bounce_right) && (mode != 1)) {
             y += 1;
         }
-        if((!bounce_right) && (mode != 1)){
+        if((!bounce_right) && (mode != 1)) {
             y += -1;
         }
 
-        
         view_port_update(view_port);
-        
     }
     //cleanup go brrrrr
     view_port_enabled_set(view_port, false);
@@ -148,6 +138,5 @@ int32_t bounce_moment(void* p){
 
     furi_record_close(RECORD_GUI);
 
-
     return 0;
 }

+ 51 - 102
apps_source_code/ServoTesterApp/app.c

@@ -16,18 +16,16 @@
 #define MAX_ANGLE 180
 #define FREQ 50
 
-typedef enum Mode
-{
+typedef enum Mode {
     Manual = 1,
     Center = 2,
     Sweep = 3,
 } Mode;
 
-typedef struct App
-{
-    Gui *gui;
-    ViewPort *view_port;
-    FuriMessageQueue *event_queue;
+typedef struct App {
+    Gui* gui;
+    ViewPort* view_port;
+    FuriMessageQueue* event_queue;
 
     int running;
     Mode mode;
@@ -37,14 +35,12 @@ typedef struct App
     FuriHalPwmOutputId ch;
 } App;
 
-void input_callback(InputEvent *input_event, void *ctx)
-{
-    App *app = ctx;
+void input_callback(InputEvent* input_event, void* ctx) {
+    App* app = ctx;
     furi_message_queue_put(app->event_queue, input_event, FuriWaitForever);
 }
 
-uint32_t angle_to_compare(uint8_t angle)
-{
+uint32_t angle_to_compare(uint8_t angle) {
     /*
         1%:   freq_div: 1280000, prescaler: 19, period: 64000, compare: 640
         3%:   freq_div: 1280000, prescaler: 19, period: 64000, compare: 1920
@@ -60,17 +56,14 @@ uint32_t angle_to_compare(uint8_t angle)
     uint32_t min_compare = 1920;
     uint32_t max_compare = 8320;
 
-    if (angle == MIN_ANGLE)
-        return min_compare;
-    if (angle == MAX_ANGLE)
-        return max_compare;
+    if(angle == MIN_ANGLE) return min_compare;
+    if(angle == MAX_ANGLE) return max_compare;
 
     return min_compare + floor(((float)angle / (float)MAX_ANGLE) * (max_compare - min_compare));
 }
 
-void render_callback(Canvas *const canvas, void *ctx)
-{
-    App *app = ctx;
+void render_callback(Canvas* const canvas, void* ctx) {
+    App* app = ctx;
 
     canvas_set_color(canvas, ColorWhite);
     canvas_draw_box(canvas, 0, 0, SCREEN_XRES - 1, SCREEN_YRES - 1);
@@ -86,30 +79,21 @@ void render_callback(Canvas *const canvas, void *ctx)
     uint8_t selector_base_x = 5;
     uint8_t r = 4;
     uint8_t correction = r;
-    if (app->mode == Manual)
-    {
+    if(app->mode == Manual) {
         canvas_draw_disc(canvas, selector_base_x, 30 - correction, r);
-    }
-    else
-    {
+    } else {
         canvas_draw_circle(canvas, selector_base_x, 30 - correction, r);
     }
 
-    if (app->mode == Center)
-    {
+    if(app->mode == Center) {
         canvas_draw_disc(canvas, selector_base_x, 45 - correction, r);
-    }
-    else
-    {
+    } else {
         canvas_draw_circle(canvas, selector_base_x, 45 - correction, r);
     }
 
-    if (app->mode == Sweep)
-    {
+    if(app->mode == Sweep) {
         canvas_draw_disc(canvas, selector_base_x, 60 - correction, r);
-    }
-    else
-    {
+    } else {
         canvas_draw_circle(canvas, selector_base_x, 60 - correction, r);
     }
 
@@ -122,9 +106,8 @@ void render_callback(Canvas *const canvas, void *ctx)
     canvas_draw_str(canvas, angle_base_x, 30, angle_str);
 }
 
-App *app_alloc()
-{
-    App *app = malloc(sizeof(App));
+App* app_alloc() {
+    App* app = malloc(sizeof(App));
 
     app->gui = furi_record_open(RECORD_GUI);
     app->view_port = view_port_alloc();
@@ -141,8 +124,7 @@ App *app_alloc()
     return app;
 }
 
-void app_free(App *app)
-{
+void app_free(App* app) {
     furi_assert(app);
 
     furi_hal_pwm_stop(app->ch);
@@ -157,64 +139,45 @@ void app_free(App *app)
     free(app);
 }
 
-void update_state(App *app, InputKey key)
-{
-    if (key == InputKeyUp)
-    {
-        if (app->mode == Manual)
-        {
+void update_state(App* app, InputKey key) {
+    if(key == InputKeyUp) {
+        if(app->mode == Manual) {
             app->angle = MIN_ANGLE;
             app->mode = Sweep;
-        }
-        else if (app->mode == Center)
-        {
+        } else if(app->mode == Center) {
             app->mode = Manual;
-        }
-        else if (app->mode == Sweep)
-        {
+        } else if(app->mode == Sweep) {
             app->mode = Center;
         }
     }
 
-    if (key == InputKeyDown)
-    {
-        if (app->mode == Manual)
-        {
+    if(key == InputKeyDown) {
+        if(app->mode == Manual) {
             app->mode = Center;
-        }
-        else if (app->mode == Center)
-        {
+        } else if(app->mode == Center) {
             app->angle = MIN_ANGLE;
             app->mode = Sweep;
-        }
-        else if (app->mode == Sweep)
-        {
+        } else if(app->mode == Sweep) {
             app->mode = Manual;
         }
     }
 
-    if (app->mode == Manual)
-    {
-        if (key == InputKeyRight)
-        {
-            if (app->angle < MAX_ANGLE)
-            {
+    if(app->mode == Manual) {
+        if(key == InputKeyRight) {
+            if(app->angle < MAX_ANGLE) {
                 app->angle = app->angle + 10;
             }
         }
 
-        if (key == InputKeyLeft)
-        {
-            if (app->angle > MIN_ANGLE)
-            {
+        if(key == InputKeyLeft) {
+            if(app->angle > MIN_ANGLE) {
                 app->angle = app->angle - 10;
             }
         }
     }
 }
 
-void custom_pwm_set_params(uint32_t freq, uint32_t compare)
-{
+void custom_pwm_set_params(uint32_t freq, uint32_t compare) {
     furi_assert(freq > 0);
     uint32_t freq_div = 64000000LU / freq;
 
@@ -227,61 +190,47 @@ void custom_pwm_set_params(uint32_t freq, uint32_t compare)
     LL_TIM_OC_SetCompareCH1(TIM1, compare);
 }
 
-void tick(void *ctx)
-{
-    App *app = ctx;
+void tick(void* ctx) {
+    App* app = ctx;
 
-    if (!app->running)
-        return;
-    if (app->mode != Sweep)
-        return;
+    if(!app->running) return;
+    if(app->mode != Sweep) return;
 
-    if (app->angle == MAX_ANGLE)
-    {
+    if(app->angle == MAX_ANGLE) {
         app->angle = MIN_ANGLE;
-    }
-    else if (app->angle == MIN_ANGLE)
-    {
+    } else if(app->angle == MIN_ANGLE) {
         app->angle = MAX_ANGLE;
     }
 
     custom_pwm_set_params(FREQ, angle_to_compare(app->angle));
 }
 
-int32_t servotester_app_entry(void *p)
-{
+int32_t servotester_app_entry(void* p) {
     UNUSED(p);
 
-    App *app = app_alloc();
+    App* app = app_alloc();
 
     furi_hal_pwm_start(app->ch, FREQ, angle_to_compare(app->angle));
     custom_pwm_set_params(FREQ, angle_to_compare(app->angle));
 
-    FuriTimer *timer = furi_timer_alloc(tick, FuriTimerTypePeriodic, app);
+    FuriTimer* timer = furi_timer_alloc(tick, FuriTimerTypePeriodic, app);
     furi_timer_start(timer, furi_kernel_get_tick_frequency() / 1);
 
     InputEvent input;
-    while (app->running)
-    {
+    while(app->running) {
         FuriStatus qstat = furi_message_queue_get(app->event_queue, &input, 100);
-        if (qstat == FuriStatusOk)
-        {
-            if (input.key == InputKeyBack)
-            {
+        if(qstat == FuriStatusOk) {
+            if(input.key == InputKeyBack) {
                 app->running = 0;
                 // TODO: handle InputTypeLong
-            }
-            else if (input.type == InputTypePress)
-            {
+            } else if(input.type == InputTypePress) {
                 update_state(app, input.key);
 
-                if (!app->running)
-                {
+                if(!app->running) {
                     break;
                 }
 
-                switch (app->mode)
-                {
+                switch(app->mode) {
                 case Manual:
                     custom_pwm_set_params(FREQ, angle_to_compare(app->angle));
                     break;

+ 0 - 1
apps_source_code/barcode_gen/barcode_utils.c

@@ -86,7 +86,6 @@ BarcodeTypeObj* get_type(FuriString* type_string) {
         return barcode_type_objs[CODABAR];
     }
 
-
     return barcode_type_objs[UNKNOWN];
 }
 

+ 1 - 1
apps_source_code/barcode_gen/barcode_validator.c

@@ -345,7 +345,7 @@ void code_128_loader(BarcodeData* barcode_data) {
     furi_string_free(barcode_bits);
 }
 
-void codabar_loader(BarcodeData* barcode_data){
+void codabar_loader(BarcodeData* barcode_data) {
     int barcode_length = furi_string_size(barcode_data->raw_data);
 
     int min_digits = barcode_data->type_obj->min_digits;

+ 1 - 1
apps_source_code/barcode_gen/views/barcode_view.c

@@ -322,7 +322,7 @@ static void draw_code_128(Canvas* canvas, BarcodeData* barcode_data) {
         canvas, 62, y + height + 8, AlignCenter, AlignBottom, furi_string_get_cstr(raw_data));
 }
 
-static void draw_codabar(Canvas* canvas, BarcodeData* barcode_data){
+static void draw_codabar(Canvas* canvas, BarcodeData* barcode_data) {
     FuriString* raw_data = barcode_data->raw_data;
     FuriString* barcode_digits = barcode_data->correct_data;
     //BarcodeTypeObj* type_obj = barcode_data->type_obj;

+ 2 - 1
apps_source_code/barcode_gen/views/create_view.c

@@ -448,7 +448,8 @@ void save_barcode(CreateView* create_view_object) {
 
         flipper_format_write_string_cstr(ff, "Version", FILE_VERSION);
 
-        flipper_format_write_comment_cstr(ff, "Types - UPC-A, EAN-8, EAN-13, CODE-39, CODE-128, Codabar");
+        flipper_format_write_comment_cstr(
+            ff, "Types - UPC-A, EAN-8, EAN-13, CODE-39, CODE-128, Codabar");
 
         flipper_format_write_string_cstr(ff, "Type", barcode_type->name);
 

+ 45 - 43
apps_source_code/esp32cam_camera/camera.c

@@ -1,6 +1,5 @@
 #include "camera.h"
 
-
 static void camera_view_draw_callback(Canvas* canvas, void* _model) {
     UartDumpModel* model = _model;
 
@@ -20,15 +19,14 @@ static void camera_view_draw_callback(Canvas* canvas, void* _model) {
         }
     }
 
-    if (!model->initialized){
-    
+    if(!model->initialized) {
         /*if(!model->marauderInitialized)
         {
           // Init marauder into stream mode
           uint8_t data[] = "\nstream\n";
           furi_hal_uart_tx(FuriHalUartIdUSART1, data, sizeof(data));
         }*/
-    
+
         canvas_draw_icon(canvas, 74, 16, &I_DolphinCommon_56x48);
         canvas_set_font(canvas, FontSecondary);
         canvas_draw_str(canvas, 8, 12, "Waiting ESP32-CAM...");
@@ -74,22 +72,26 @@ static void save_image(void* context) {
     get_timefilename(file_name);
 
     // this functions open a file, using write access and creates new file if not exist.
-    bool result = storage_file_open(file, furi_string_get_cstr(file_name), FSAM_WRITE, FSOM_OPEN_ALWAYS);
+    bool result =
+        storage_file_open(file, furi_string_get_cstr(file_name), FSAM_WRITE, FSOM_OPEN_ALWAYS);
     //bool result = storage_file_open(file, EXT_PATH("DCIM/test.bmp"), FSAM_WRITE, FSOM_OPEN_ALWAYS);
     furi_string_free(file_name);
 
-    if (result){
+    if(result) {
         storage_file_write(file, bitmap_header, BITMAP_HEADER_LENGTH);
-        with_view_model(app->view, UartDumpModel * model, {
-            int8_t row_buffer[ROW_BUFFER_LENGTH];
-            for (size_t i = 64; i > 0; --i) {
-                for (size_t j = 0; j < ROW_BUFFER_LENGTH; ++j){
-                    row_buffer[j] = model->pixels[((i-1)*ROW_BUFFER_LENGTH) + j];
+        with_view_model(
+            app->view,
+            UartDumpModel * model,
+            {
+                int8_t row_buffer[ROW_BUFFER_LENGTH];
+                for(size_t i = 64; i > 0; --i) {
+                    for(size_t j = 0; j < ROW_BUFFER_LENGTH; ++j) {
+                        row_buffer[j] = model->pixels[((i - 1) * ROW_BUFFER_LENGTH) + j];
+                    }
+                    storage_file_write(file, row_buffer, ROW_BUFFER_LENGTH);
                 }
-                storage_file_write(file, row_buffer, ROW_BUFFER_LENGTH);
-            }
-            
-        }, false);
+            },
+            false);
     }
 
     // Closing the "file descriptor"
@@ -102,26 +104,22 @@ static void save_image(void* context) {
 }
 
 static bool camera_view_input_callback(InputEvent* event, void* context) {
-    if (event->type == InputTypePress){
+    if(event->type == InputTypePress) {
         uint8_t data[1];
-        if (event->key == InputKeyUp){
+        if(event->key == InputKeyUp) {
             data[0] = 'C';
-        }
-        else if (event->key == InputKeyDown){
+        } else if(event->key == InputKeyDown) {
             data[0] = 'c';
-        }
-        else if (event->key == InputKeyRight){
+        } else if(event->key == InputKeyRight) {
             data[0] = '>';
-        }
-        else if (event->key == InputKeyLeft){
+        } else if(event->key == InputKeyLeft) {
             data[0] = '<';
-        }
-        else if (event->key == InputKeyOk){
+        } else if(event->key == InputKeyOk) {
             save_image(context);
         }
         furi_hal_uart_tx(FuriHalUartIdUSART1, data, 1);
     }
-    
+
     return false;
 }
 
@@ -141,36 +139,39 @@ static void camera_on_irq_cb(UartIrqEvent ev, uint8_t data, void* context) {
 }
 
 static void process_ringbuffer(UartDumpModel* model, uint8_t byte) {
-
     //// 1. Phase: filling the ringbuffer
-    if (model->ringbuffer_index == 0 && byte != 'Y'){ // First char has to be 'Y' in the buffer.
+    if(model->ringbuffer_index == 0 && byte != 'Y') { // First char has to be 'Y' in the buffer.
         return;
     }
-    
-    if (model->ringbuffer_index == 1 && byte != ':'){ // Second char has to be ':' in the buffer or reset.
+
+    if(model->ringbuffer_index == 1 &&
+       byte != ':') { // Second char has to be ':' in the buffer or reset.
         model->ringbuffer_index = 0;
         process_ringbuffer(model, byte);
         return;
     }
 
-    model->row_ringbuffer[model->ringbuffer_index] = byte; // Assign current byte to the ringbuffer;
+    model->row_ringbuffer[model->ringbuffer_index] =
+        byte; // Assign current byte to the ringbuffer;
     ++model->ringbuffer_index; // Increment the ringbuffer index
 
-    if (model->ringbuffer_index < RING_BUFFER_LENGTH){ // Let's wait 'till the buffer fills.
+    if(model->ringbuffer_index < RING_BUFFER_LENGTH) { // Let's wait 'till the buffer fills.
         return;
     }
 
     //// 2. Phase: flushing the ringbuffer to the framebuffer
     model->ringbuffer_index = 0; // Let's reset the ringbuffer
     model->initialized = true; // We've successfully established the connection
-    size_t row_start_index = model->row_ringbuffer[2] * ROW_BUFFER_LENGTH; // Third char will determine the row number
+    size_t row_start_index =
+        model->row_ringbuffer[2] * ROW_BUFFER_LENGTH; // Third char will determine the row number
 
-    if (row_start_index > LAST_ROW_INDEX){ // Failsafe
+    if(row_start_index > LAST_ROW_INDEX) { // Failsafe
         row_start_index = 0;
     }
 
-    for (size_t i = 0; i < ROW_BUFFER_LENGTH; ++i) {
-        model->pixels[row_start_index + i] = model->row_ringbuffer[i+3]; // Writing the remaining 16 bytes into the frame buffer
+    for(size_t i = 0; i < ROW_BUFFER_LENGTH; ++i) {
+        model->pixels[row_start_index + i] =
+            model->row_ringbuffer[i + 3]; // Writing the remaining 16 bytes into the frame buffer
     }
 }
 
@@ -195,7 +196,8 @@ static int32_t camera_worker(void* context) {
                     //furi_hal_uart_tx(FuriHalUartIdUSART1, data, length);
                     with_view_model(
                         app->view,
-                        UartDumpModel * model, {
+                        UartDumpModel * model,
+                        {
                             for(size_t i = 0; i < length; i++) {
                                 process_ringbuffer(model, data[i]);
                             }
@@ -205,7 +207,8 @@ static int32_t camera_worker(void* context) {
             } while(length > 0);
 
             notification_message(app->notification, &sequence_notification);
-            with_view_model(app->view, UartDumpModel * model, { UNUSED(model); }, true);
+            with_view_model(
+                app->view, UartDumpModel * model, { UNUSED(model); }, true);
         }
     }
 
@@ -260,10 +263,9 @@ static UartEchoApp* camera_app_alloc() {
     furi_delay_ms(200);
     furi_hal_power_enable_external_3_3v();
     furi_hal_power_enable_otg();
-    for(int i=0;i<2;i++)
-    {
-        furi_delay_ms(500); 
-        furi_hal_uart_tx(FuriHalUartIdUSART1, (uint8_t[1]){'c'}, 1); 
+    for(int i = 0; i < 2; i++) {
+        furi_delay_ms(500);
+        furi_hal_uart_tx(FuriHalUartIdUSART1, (uint8_t[1]){'c'}, 1);
     }
     furi_delay_ms(1);
     return app;
@@ -301,7 +303,7 @@ int32_t camera_app(void* p) {
     UartEchoApp* app = camera_app_alloc();
     view_dispatcher_run(app->view_dispatcher);
     camera_app_free(app);
-    
+
     furi_hal_power_disable_otg();
 
     return 0;

+ 29 - 10
apps_source_code/esp32cam_camera/camera.h

@@ -26,7 +26,8 @@
 #define FRAME_WIDTH 128
 #define FRAME_HEIGTH 64
 #define FRAME_BIT_DEPTH 1
-#define FRAME_BUFFER_LENGTH (FRAME_WIDTH * FRAME_HEIGTH * FRAME_BIT_DEPTH / 8) // 128*64*1 / 8 = 1024
+#define FRAME_BUFFER_LENGTH \
+    (FRAME_WIDTH * FRAME_HEIGTH * FRAME_BIT_DEPTH / 8) // 128*64*1 / 8 = 1024
 #define ROW_BUFFER_LENGTH (FRAME_WIDTH / 8) // 128/8 = 16
 #define LAST_ROW_INDEX (FRAME_BUFFER_LENGTH - ROW_BUFFER_LENGTH) // 1024 - 16 = 1008
 #define RING_BUFFER_LENGTH (ROW_BUFFER_LENGTH + 3) // ROW_BUFFER_LENGTH + Header => 16 + 3 = 19
@@ -34,17 +35,35 @@
 #define IMAGE_FILE_DIRECTORY_PATH EXT_PATH("DCIM")
 
 static const unsigned char bitmap_header[BITMAP_HEADER_LENGTH] = {
-	0x42, 0x4D, 0x3E, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3E, 0x00,
-	0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x40, 0x00,
-	0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF,
-	0xFF, 0x00
-};
+    0x42, 0x4D, 0x3E, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3E, 0x00, 0x00, 0x00, 0x28, 0x00,
+    0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00};
 
-const uint8_t _I_DolphinCommon_56x48_0[] = {0x01,0x00,0xdf,0x00,0x00,0x1f,0xfe,0x0e,0x05,0x3f,0x04,0x06,0x78,0x06,0x30,0x20,0xf8,0x00,0xc6,0x12,0x1c,0x04,0x0c,0x0a,0x38,0x08,0x08,0x0c,0x60,0xc0,0x21,0xe0,0x04,0x0a,0x18,0x02,0x1b,0x00,0x18,0xa3,0x00,0x21,0x90,0x01,0x8a,0x20,0x02,0x19,0x80,0x18,0x80,0x64,0x09,0x20,0x89,0x81,0x8c,0x3e,0x41,0xe2,0x80,0x50,0x00,0x43,0x08,0x01,0x0c,0xfc,0x68,0x40,0x61,0xc0,0x50,0x30,0x00,0x63,0xa0,0x7f,0x80,0xc4,0x41,0x19,0x07,0xff,0x02,0x06,0x18,0x24,0x03,0x41,0xf3,0x2b,0x10,0x19,0x38,0x10,0x30,0x31,0x7f,0xe0,0x34,0x08,0x30,0x19,0x60,0x80,0x65,0x86,0x0a,0x4c,0x0c,0x30,0x81,0xb9,0x41,0xa0,0x54,0x08,0xc7,0xe2,0x06,0x8a,0x18,0x25,0x02,0x21,0x0f,0x19,0x88,0xd8,0x6e,0x1b,0x01,0xd1,0x1b,0x86,0x39,0x66,0x3a,0xa4,0x1a,0x50,0x06,0x48,0x18,0x18,0xd0,0x03,0x01,0x41,0x98,0xcc,0x60,0x39,0x01,0x49,0x2d,0x06,0x03,0x50,0xf8,0x40,0x3e,0x02,0xc1,0x82,0x86,0xc7,0xfe,0x0f,0x28,0x2c,0x91,0xd2,0x90,0x9a,0x18,0x19,0x3e,0x6d,0x73,0x12,0x16,0x00,0x32,0x49,0x72,0xc0,0x7e,0x5d,0x44,0xba,0x2c,0x08,0xa4,0xc8,0x82,0x06,0x17,0xe0,0x81,0x90,0x2a,0x40,0x61,0xe1,0xa2,0x44,0x0c,0x76,0x2b,0xe8,0x89,0x26,0x43,0x83,0x31,0x8c,0x78,0x0c,0xb0,0x48,0x10,0x1a,0xe0,0x00,0x63,};
+const uint8_t _I_DolphinCommon_56x48_0[] = {
+    0x01, 0x00, 0xdf, 0x00, 0x00, 0x1f, 0xfe, 0x0e, 0x05, 0x3f, 0x04, 0x06, 0x78, 0x06, 0x30, 0x20,
+    0xf8, 0x00, 0xc6, 0x12, 0x1c, 0x04, 0x0c, 0x0a, 0x38, 0x08, 0x08, 0x0c, 0x60, 0xc0, 0x21, 0xe0,
+    0x04, 0x0a, 0x18, 0x02, 0x1b, 0x00, 0x18, 0xa3, 0x00, 0x21, 0x90, 0x01, 0x8a, 0x20, 0x02, 0x19,
+    0x80, 0x18, 0x80, 0x64, 0x09, 0x20, 0x89, 0x81, 0x8c, 0x3e, 0x41, 0xe2, 0x80, 0x50, 0x00, 0x43,
+    0x08, 0x01, 0x0c, 0xfc, 0x68, 0x40, 0x61, 0xc0, 0x50, 0x30, 0x00, 0x63, 0xa0, 0x7f, 0x80, 0xc4,
+    0x41, 0x19, 0x07, 0xff, 0x02, 0x06, 0x18, 0x24, 0x03, 0x41, 0xf3, 0x2b, 0x10, 0x19, 0x38, 0x10,
+    0x30, 0x31, 0x7f, 0xe0, 0x34, 0x08, 0x30, 0x19, 0x60, 0x80, 0x65, 0x86, 0x0a, 0x4c, 0x0c, 0x30,
+    0x81, 0xb9, 0x41, 0xa0, 0x54, 0x08, 0xc7, 0xe2, 0x06, 0x8a, 0x18, 0x25, 0x02, 0x21, 0x0f, 0x19,
+    0x88, 0xd8, 0x6e, 0x1b, 0x01, 0xd1, 0x1b, 0x86, 0x39, 0x66, 0x3a, 0xa4, 0x1a, 0x50, 0x06, 0x48,
+    0x18, 0x18, 0xd0, 0x03, 0x01, 0x41, 0x98, 0xcc, 0x60, 0x39, 0x01, 0x49, 0x2d, 0x06, 0x03, 0x50,
+    0xf8, 0x40, 0x3e, 0x02, 0xc1, 0x82, 0x86, 0xc7, 0xfe, 0x0f, 0x28, 0x2c, 0x91, 0xd2, 0x90, 0x9a,
+    0x18, 0x19, 0x3e, 0x6d, 0x73, 0x12, 0x16, 0x00, 0x32, 0x49, 0x72, 0xc0, 0x7e, 0x5d, 0x44, 0xba,
+    0x2c, 0x08, 0xa4, 0xc8, 0x82, 0x06, 0x17, 0xe0, 0x81, 0x90, 0x2a, 0x40, 0x61, 0xe1, 0xa2, 0x44,
+    0x0c, 0x76, 0x2b, 0xe8, 0x89, 0x26, 0x43, 0x83, 0x31, 0x8c, 0x78, 0x0c, 0xb0, 0x48, 0x10, 0x1a,
+    0xe0, 0x00, 0x63,
+};
 const uint8_t* const _I_DolphinCommon_56x48[] = {_I_DolphinCommon_56x48_0};
-const Icon I_DolphinCommon_56x48 = {.width=56,.height=48,.frame_count=1,.frame_rate=0,.frames=_I_DolphinCommon_56x48};
+const Icon I_DolphinCommon_56x48 = {
+    .width = 56,
+    .height = 48,
+    .frame_count = 1,
+    .frame_rate = 0,
+    .frames = _I_DolphinCommon_56x48};
 
 typedef struct UartDumpModel UartDumpModel;
 

+ 2 - 1
apps_source_code/esp32cam_marauder_companion/scenes/wifi_marauder_scene_console_output.c

@@ -82,7 +82,8 @@ void wifi_marauder_scene_console_output_on_enter(void* context) {
         }
 
         // If it is a sniff function, open the pcap file for recording
-        if(app->ok_to_save_pcaps && strncmp("sniff", app->selected_tx_string, strlen("sniff")) == 0) {
+        if(app->ok_to_save_pcaps &&
+           strncmp("sniff", app->selected_tx_string, strlen("sniff")) == 0) {
             app->is_writing_pcap = true;
             wifi_marauder_create_pcap_file(app);
         }

+ 10 - 5
apps_source_code/esp32cam_marauder_companion/scenes/wifi_marauder_scene_log_viewer.c

@@ -112,18 +112,23 @@ void wifi_marauder_scene_log_viewer_on_enter(void* context) {
     app->open_log_file_page = 0;
     app->open_log_file_num_pages = 0;
     bool saved_logs_exist = false;
-    if (!app->has_saved_logs_this_session && furi_string_empty(app->text_box_store)) {
+    if(!app->has_saved_logs_this_session && furi_string_empty(app->text_box_store)) {
         // no commands sent yet this session, find last saved log
-        if (storage_dir_open(app->log_file, MARAUDER_APP_FOLDER_LOGS)) {
+        if(storage_dir_open(app->log_file, MARAUDER_APP_FOLDER_LOGS)) {
             char name[70];
             char lastname[70];
-            while (storage_dir_read(app->log_file, NULL, name, sizeof(name))) {
+            while(storage_dir_read(app->log_file, NULL, name, sizeof(name))) {
                 // keep reading directory until last file is reached
                 strlcpy(lastname, name, sizeof(lastname));
                 saved_logs_exist = true;
             }
-            if (saved_logs_exist) {
-                snprintf(app->log_file_path, sizeof(app->log_file_path), "%s/%s", MARAUDER_APP_FOLDER_LOGS, lastname);
+            if(saved_logs_exist) {
+                snprintf(
+                    app->log_file_path,
+                    sizeof(app->log_file_path),
+                    "%s/%s",
+                    MARAUDER_APP_FOLDER_LOGS,
+                    lastname);
             }
         }
         storage_dir_close(app->log_file);

+ 1 - 1
apps_source_code/esp32cam_marauder_companion/scenes/wifi_marauder_scene_start.c

@@ -111,7 +111,7 @@ const WifiMarauderItem items[NUM_MENU_ITEMS] = {
      TOGGLE_ARGS,
      FOCUS_CONSOLE_END,
      NO_TIP},
-     {"Camera",
+    {"Camera",
      {"photo", "flashlight"},
      2,
      {"photo", "flashlight"},

+ 3 - 2
apps_source_code/esp32cam_morseflasher/scenes/uart_terminal_scene_console_output.c

@@ -35,8 +35,9 @@ void uart_terminal_scene_console_output_on_enter(void* context) {
         furi_string_reset(app->text_box_store);
         app->text_box_store_strlen = 0;
 
-        // app->show_stopscan_tip in the if is just a hack to get the help displayed since there is no commands in this app 
-        if(app->show_stopscan_tip || 0 == strncmp("help", app->selected_tx_string, strlen("help"))) {
+        // app->show_stopscan_tip in the if is just a hack to get the help displayed since there is no commands in this app
+        if(app->show_stopscan_tip ||
+           0 == strncmp("help", app->selected_tx_string, strlen("help"))) {
             const char* help_msg =
                 "Morse Flasher for\nMayhem Fin\n\nBased on UART terminal by\ncool4uma, which is a\nmodified WiFi Marauder\ncompanion by 0xchocolate\n\n";
             furi_string_cat_str(app->text_box_store, help_msg);

+ 8 - 1
apps_source_code/esp32cam_morseflasher/scenes/uart_terminal_scene_start.c

@@ -27,7 +27,14 @@ const UART_TerminalItem items[NUM_MENU_ITEMS] = {
     {"Quick message",
      {"SOS", "CQD", "VVV", "Eureka", "E.T ph...", "what h...", "Mayhem", "Flipper"},
      8,
-     {"sos", "cqd", "vvv", "eureka", "e.t. phone home", "what hath god wrought!", "let the mayhem begin", "flipper zero in da housa"},
+     {"sos",
+      "cqd",
+      "vvv",
+      "eureka",
+      "e.t. phone home",
+      "what hath god wrought!",
+      "let the mayhem begin",
+      "flipper zero in da housa"},
      NO_ARGS,
      FOCUS_CONSOLE_END,
      NO_TIP},

+ 5 - 4
apps_source_code/esp32cam_morseflasher/uart_terminal_app.c

@@ -58,7 +58,9 @@ UART_TerminalApp* uart_terminal_app_alloc() {
 
     app->text_input = uart_text_input_alloc();
     view_dispatcher_add_view(
-        app->view_dispatcher, UART_TerminalAppViewTextInput, uart_text_input_get_view(app->text_input));
+        app->view_dispatcher,
+        UART_TerminalAppViewTextInput,
+        uart_text_input_get_view(app->text_input));
 
     scene_manager_next_scene(app->scene_manager, UART_TerminalSceneStart);
 
@@ -95,9 +97,8 @@ int32_t uart_terminal_app(void* p) {
     furi_delay_ms(200);
     furi_hal_power_enable_external_3_3v();
     furi_hal_power_enable_otg();
-    for(int i=0;i<2;i++)
-    {
-        furi_delay_ms(500); 
+    for(int i = 0; i < 2; i++) {
+        furi_delay_ms(500);
         furi_hal_uart_tx(FuriHalUartIdUSART1, (uint8_t[1]){'.'}, 1);
     }
     furi_delay_ms(1);

+ 1 - 1
apps_source_code/esp32cam_morseflasher/uart_terminal_uart.c

@@ -71,7 +71,7 @@ UART_TerminalUart* uart_terminal_uart_init(UART_TerminalApp* app) {
     furi_hal_uart_set_irq_cb(UART_CH, uart_terminal_uart_on_irq_cb, uart);*/
 
     uart->app = app;
-	uart->rx_stream = furi_stream_buffer_alloc(RX_BUF_SIZE, 1);
+    uart->rx_stream = furi_stream_buffer_alloc(RX_BUF_SIZE, 1);
     uart->rx_thread = furi_thread_alloc();
     furi_thread_set_name(uart->rx_thread, "UART_TerminalUartRxThread");
     furi_thread_set_stack_size(uart->rx_thread, 1024);

+ 3 - 4
apps_source_code/esp32cam_motion_detection/uart_echo.c

@@ -52,7 +52,7 @@ static void uart_echo_on_irq_cb(UartIrqEvent ev, uint8_t data, void* context) {
 
 static void uart_echo_push_to_list(UartDumpModel* model, void* context, const char data) {
     // Alarm sound
-    if(data == '!'){
+    if(data == '!') {
         UartEchoApp* app = context;
         notification_message(app->notification, &sequence_alarm);
     }
@@ -185,9 +185,8 @@ static UartEchoApp* uart_echo_app_alloc() {
     furi_delay_ms(200);
     furi_hal_power_enable_external_3_3v();
     furi_hal_power_enable_otg();
-    for(int i=0;i<2;i++)
-    {
-        furi_delay_ms(500); 
+    for(int i = 0; i < 2; i++) {
+        furi_delay_ms(500);
         furi_hal_uart_tx(FuriHalUartIdUSART1, (uint8_t[1]){'m'}, 1);
     }
     furi_delay_ms(1);

+ 2 - 3
apps_source_code/esp32cam_nannycam/uart_echo.c

@@ -179,9 +179,8 @@ static UartEchoApp* uart_echo_app_alloc() {
     furi_delay_ms(200);
     furi_hal_power_enable_external_3_3v();
     furi_hal_power_enable_otg();
-    for(int i=0;i<2;i++)
-    {
-        furi_delay_ms(500); 
+    for(int i = 0; i < 2; i++) {
+        furi_delay_ms(500);
         furi_hal_uart_tx(FuriHalUartIdUSART1, (uint8_t[1]){'n'}, 1);
     }
     furi_delay_ms(1);

+ 2 - 3
apps_source_code/esp32cam_qrcode/uart_echo.c

@@ -179,9 +179,8 @@ static UartEchoApp* uart_echo_app_alloc() {
     furi_delay_ms(200);
     furi_hal_power_enable_external_3_3v();
     furi_hal_power_enable_otg();
-    for(int i=0;i<2;i++)
-    {
-        furi_delay_ms(500); 
+    for(int i = 0; i < 2; i++) {
+        furi_delay_ms(500);
         furi_hal_uart_tx(FuriHalUartIdUSART1, (uint8_t[1]){'q'}, 1);
     }
     furi_delay_ms(1);

+ 1 - 4
apps_source_code/flipperscope/scenes/scope_scene_about.c

@@ -1,9 +1,6 @@
 #include "../scope_app_i.h"
 
-void scope_scene_about_widget_callback(
-    GuiButtonType result,
-    InputType type,
-    void* context) {
+void scope_scene_about_widget_callback(GuiButtonType result, InputType type, void* context) {
     ScopeApp* app = context;
     if(type == InputTypeShort) {
         view_dispatcher_send_custom_event(app->view_dispatcher, result);

+ 7 - 18
apps_source_code/flipperscope/scenes/scope_scene_setup.c

@@ -1,9 +1,6 @@
 #include "../scope_app_i.h"
 
-void scope_scene_setup_widget_callback(
-    GuiButtonType result,
-    InputType type,
-    void* context) {
+void scope_scene_setup_widget_callback(GuiButtonType result, InputType type, void* context) {
     ScopeApp* app = context;
     if(type == InputTypeShort) {
         view_dispatcher_send_custom_event(app->view_dispatcher, result);
@@ -31,14 +28,10 @@ void scope_scene_setup_on_enter(void* context) {
     VariableItemList* var_item_list = app->variable_item_list;
     VariableItem* item;
     item = variable_item_list_add(
-        var_item_list,
-        "Time period",
-        COUNT_OF(time_list),
-        timeperiod_cb,
-        app);
+        var_item_list, "Time period", COUNT_OF(time_list), timeperiod_cb, app);
 
-    for (uint32_t i = 0; i < COUNT_OF(time_list); i++){
-        if(time_list[i].time == app->time){
+    for(uint32_t i = 0; i < COUNT_OF(time_list); i++) {
+        if(time_list[i].time == app->time) {
             variable_item_set_current_value_index(item, i);
             variable_item_set_current_value_text(item, time_list[i].str);
             break;
@@ -46,14 +39,10 @@ void scope_scene_setup_on_enter(void* context) {
     }
 
     item = variable_item_list_add(
-        var_item_list,
-        "Measurement",
-        COUNT_OF(measurement_list),
-        measurement_cb,
-        app);
+        var_item_list, "Measurement", COUNT_OF(measurement_list), measurement_cb, app);
 
-    for (uint32_t i = 0; i < COUNT_OF(measurement_list); i++){
-        if(measurement_list[i].type == app->measurement){
+    for(uint32_t i = 0; i < COUNT_OF(measurement_list); i++) {
+        if(measurement_list[i].type == app->measurement) {
             variable_item_set_current_value_index(item, i);
             variable_item_set_current_value_text(item, measurement_list[i].str);
             break;

+ 3 - 15
apps_source_code/flipperscope/scenes/scope_scene_start.c

@@ -17,25 +17,13 @@ void scope_scene_start_on_enter(void* context) {
     Submenu* submenu = app->submenu;
 
     submenu_add_item(
-        submenu,
-        "Run",
-        SubmenuIndexScopeRun,
-        scope_scene_start_submenu_callback,
-        app);
+        submenu, "Run", SubmenuIndexScopeRun, scope_scene_start_submenu_callback, app);
 
     submenu_add_item(
-        submenu,
-        "Setup",
-        SubmenuIndexScopeSetup,
-        scope_scene_start_submenu_callback,
-        app);
+        submenu, "Setup", SubmenuIndexScopeSetup, scope_scene_start_submenu_callback, app);
 
     submenu_add_item(
-        submenu,
-        "About",
-        SubmenuIndexScopeAbout,
-        scope_scene_start_submenu_callback,
-        app);
+        submenu, "About", SubmenuIndexScopeAbout, scope_scene_start_submenu_callback, app);
 
     submenu_set_selected_item(
         submenu, scene_manager_get_scene_state(app->scene_manager, ScopeSceneStart));

+ 0 - 1
apps_source_code/flipperscope/scenes/scope_types.h

@@ -12,4 +12,3 @@ typedef enum {
     ScopeViewSubmenu,
     ScopeViewWidget,
 } ScopeView;
-

+ 4 - 7
apps_source_code/flipperscope/scope.c

@@ -10,11 +10,10 @@
 
 #include "scope_app_i.h"
 
-void assert_failed(uint8_t * file, uint32_t line)
-{
+void assert_failed(uint8_t* file, uint32_t line) {
     UNUSED(file);
     UNUSED(line);
-    while (1) {
+    while(1) {
     }
 }
 
@@ -74,8 +73,7 @@ ScopeApp* scope_app_alloc() {
 
     // Widget
     app->widget = widget_alloc();
-    view_dispatcher_add_view(
-        app->view_dispatcher, ScopeViewWidget, widget_get_view(app->widget));
+    view_dispatcher_add_view(app->view_dispatcher, ScopeViewWidget, widget_get_view(app->widget));
 
     app->time = 0.001;
     app->measurement = m_time;
@@ -113,8 +111,7 @@ void scope_app_free(ScopeApp* app) {
     free(app);
 }
 
-int32_t scope_main(void *p)
-{
+int32_t scope_main(void* p) {
     UNUSED(p);
     ScopeApp* scope_app = scope_app_alloc();
     view_dispatcher_run(scope_app->view_dispatcher);

+ 8 - 13
apps_source_code/flipperscope/scope_app_i.h

@@ -15,29 +15,25 @@ typedef struct ScopeApp ScopeApp;
 
 typedef struct {
     double time;
-    char * str;
+    char* str;
 } timeperiod;
 
 static const timeperiod time_list[] = {
-    {1.0,  "1s"},
-    {0.1,  "0.1s"},
+    {1.0, "1s"},
+    {0.1, "0.1s"},
     {1e-3, "1ms"},
     {0.1e-3, "0.1ms"},
     {1e-6, "1us"},
-    {0.5e-6, "0.5us"}
-};
+    {0.5e-6, "0.5us"}};
 
-enum measureenum {m_time, m_voltage};
+enum measureenum { m_time, m_voltage };
 
 typedef struct {
     enum measureenum type;
-    char * str;
+    char* str;
 } measurement;
 
-static const measurement measurement_list[] = {
-    {m_time,  "Time"},
-    {m_voltage, "Voltage"}
-};
+static const measurement measurement_list[] = {{m_time, "Time"}, {m_voltage, "Voltage"}};
 
 struct ScopeApp {
     Gui* gui;
@@ -47,7 +43,6 @@ struct ScopeApp {
     VariableItemList* variable_item_list;
     Submenu* submenu;
     Widget* widget;
-    double time ;
+    double time;
     enum measureenum measurement;
 };
-

+ 6 - 6
apps_source_code/flizzer_tracker/tracker_engine/tracker_engine.c

@@ -400,9 +400,9 @@ void tracker_engine_advance_channel(TrackerEngine* tracker_engine, uint8_t chan)
 
             else {
                 te_channel->vibrato_position += ((uint32_t)te_channel->vibrato_speed << 21);
-                vib = (int32_t)(sound_engine_triangle(te_channel->vibrato_position >> 9) -
-                                WAVE_AMP / 2) *
-                      (int32_t)te_channel->vibrato_depth / (256 * 128);
+                vib =
+                    (int32_t)(sound_engine_triangle(te_channel->vibrato_position >> 9) - WAVE_AMP / 2) *
+                    (int32_t)te_channel->vibrato_depth / (256 * 128);
             }
         }
 
@@ -437,9 +437,9 @@ void tracker_engine_advance_channel(TrackerEngine* tracker_engine, uint8_t chan)
             tracker_engine->sound_engine->channel[chan].pw = tracker_engine->channel[chan].pw;
         }
 
-        int32_t chn_note = (int16_t)(te_channel->fixed_note != 0xffff ? te_channel->fixed_note :
-                                                                        te_channel->note) +
-                           vib + ((int16_t)te_channel->arpeggio_note << 8);
+        int32_t chn_note =
+            (int16_t)(te_channel->fixed_note != 0xffff ? te_channel->fixed_note : te_channel->note) +
+            vib + ((int16_t)te_channel->arpeggio_note << 8);
 
         if(chn_note < 0) {
             chn_note = 0;

+ 152 - 152
apps_source_code/gb-pokemon-trading/pokemon_app.cpp

@@ -1,158 +1,158 @@
 #include "pokemon_app.h"
 
 struct pokemon_lut pokemon_table[] = {
-	{ "Bulbasaur",	&I_bulbasaur,	0x99 },
-	{ "Ivysaur",	&I_ivysaur,	0x09 },
-	{ "Venusaur",	&I_venusaur,	0x9A },
-	{ "Charmander",	&I_charmander,	0xB0 },
-	{ "Charmeleon",	&I_charmeleon,	0xB2 },
-	{ "Charizard",	&I_charizard,	0xB4 },
-	{ "Squirtle",	&I_squirtle,	0xB1 },
-	{ "Wartortle",	&I_wartortle,	0xB3 },
-	{ "Blastoise",	&I_blastoise,	0x1C },
-	{ "Caterpie",	&I_caterpie,	0x7B },
-	{ "Metapod",	&I_metapod,	0x7C },
-	{ "Butterfree",	&I_butterfree,	0x7D },
-	{ "Weedle",	&I_weedle,	0x70 },
-	{ "Kakuna",	&I_kakuna,	0x71 },
-	{ "Beedrill",	&I_beedrill,	0x72 },
-	{ "Pidgey",	&I_pidgey,	0x24 },
-	{ "Pidgeotto",	&I_pidgeotto,	0x96 },
-	{ "Pidgeot",	&I_pidgeot,	0x97 },
-	{ "Rattata",	&I_rattata,	0xA5 },
-	{ "Raticate",	&I_raticate,	0xA6 },
-	{ "Spearow",	&I_spearow,	0x05 },
-	{ "Fearow",	&I_fearow,	0x23 },
-	{ "Ekans",	&I_ekans,	0x6C },
-	{ "Arbok",	&I_arbok,	0x2D },
-	{ "Pikachu",	&I_pikachu,	0x54 },
-	{ "Raichu",	&I_raichu,	0x55 },
-	{ "Sandshrew",	&I_sandshrew,	0x60 },
-	{ "Sandslash",	&I_sandslash,	0x61 },
-	{ "Nidoran ♀",	&I_nidoranf,	0x0F },
-	{ "Nidorina",	&I_nidorina,	0xA8 },
-	{ "Nidoqueen",	&I_nidoqueen,	0x10 },
-	{ "Nidoran ♂",	&I_nidoranm,	0x03 },
-	{ "Nidorino",	&I_nidorino,	0xA7 },
-	{ "Nidoking",	&I_nidoking,	0x07 },
-	{ "Clefairy",	&I_clefairy,	0x04 },
-	{ "Clefable",	&I_clefable,	0x8E },
-	{ "Vulpix",	&I_vulpix,	0x52 },
-	{ "Ninetales",	&I_ninetales,	0x53 },
-	{ "Jigglypuff",	&I_jigglypuff,	0x64 },
-	{ "Wigglytuff",	&I_wigglytuff,	0x65 },
-	{ "Zubat",	&I_zubat,	0x6B },
-	{ "Golbat",	&I_golbat,	0x82 },
-	{ "Oddish",	&I_oddish,	0xB9 },
-	{ "Gloom",	&I_gloom,	0xBA },
-	{ "Vileplume",	&I_vileplume,	0xBB },
-	{ "Paras",	&I_paras,	0x6D },
-	{ "Parasect",	&I_parasect,	0x2E },
-	{ "Venonat",	&I_venonat,	0x41 },
-	{ "Venomoth",	&I_venomoth,	0x77 },
-	{ "Diglett",	&I_diglett,	0x3B },
-	{ "Dugtrio",	&I_dugtrio,	0x76 },
-	{ "Meowth",	&I_meowth,	0x4D },
-	{ "Persian",	&I_persian,	0x90 },
-	{ "Psyduck",	&I_psyduck,	0x2F },
-	{ "Golduck",	&I_golduck,	0x80 },
-	{ "Mankey",	&I_mankey,	0x39 },
-	{ "Primeape",	&I_primeape,	0x75 },
-	{ "Growlithe",	&I_growlithe,	0x21 },
-	{ "Arcanine",	&I_arcanine,	0x14 },
-	{ "Poliwag",	&I_poliwag,	0x47 },
-	{ "Poliwhirl",	&I_poliwhirl,	0x6E },
-	{ "Poliwrath",	&I_poliwrath,	0x6F },
-	{ "Abra",	&I_abra,	0x94 },
-	{ "Kadabra",	&I_kadabra,	0x26 },
-	{ "Alakazam",	&I_alakazam,	0x95 },
-	{ "Machop",	&I_machop,	0x6A },
-	{ "Machoke",	&I_machoke,	0x29 },
-	{ "Machamp",	&I_machamp,	0x7E },
-	{ "Bellsprout",	&I_bellsprout,	0xBC },
-	{ "Weepinbell",	&I_weepinbell,	0xBD },
-	{ "Victreebel",	&I_victreebel,	0xBE },
-	{ "Tentacool",	&I_tentacool,	0x18 },
-	{ "Tentacruel",	&I_tentacruel,	0x9B },
-	{ "Geodude",	&I_geodude,	0xA9 },
-	{ "Graveler",	&I_graveler,	0x27 },
-	{ "Golem",	&I_golem,	0x31 },
-	{ "Ponyta",	&I_ponyta,	0xA3 },
-	{ "Rapidash",	&I_rapidash,	0xA4 },
-	{ "Slowpoke",	&I_slowpoke,	0x25 },
-	{ "Slowbro",	&I_slowbro,	0x08 },
-	{ "Magnemite",	&I_magnemite,	0xAD },
-	{ "Magneton",	&I_magneton,	0x36 },
-	{ "Farfetch'd",	&I_farfetchd,	0x40 },
-	{ "Doduo",	&I_doduo,	0x46 },
-	{ "Dodrio",	&I_dodrio,	0x74 },
-	{ "Seel",	&I_seel,	0x3A },
-	{ "Dewgong",	&I_dewgong,	0x78 },
-	{ "Grimer",	&I_grimer,	0x0D },
-	{ "Muk",	&I_muk,	        0x88 },
-	{ "Shellder",	&I_shellder,	0x17 },
-	{ "Cloyster",	&I_cloyster,	0x8B },
-	{ "Gastly",	&I_gastly,	0x19 },
-	{ "Haunter",	&I_haunter,	0x93 },
-	{ "Gengar",	&I_gengar,	0x0E },
-	{ "Onix",	&I_onix,	0x22 },
-	{ "Drowzee",	&I_drowzee,	0x30 },
-	{ "Hypno",	&I_hypno,	0x81 },
-	{ "Krabby",	&I_krabby,	0x4E },
-	{ "Kingler",	&I_kingler,	0x8A },
-	{ "Voltorb",	&I_voltorb,	0x06 },
-	{ "Electrode",	&I_electrode,	0x8D },
-	{ "Exeggcute",	&I_exeggcute,	0x0C },
-	{ "Exeggutor",	&I_exeggutor,	0x0A },
-	{ "Cubone",	&I_cubone,	0x11 },
-	{ "Marowak",	&I_marowak,	0x91 },
-	{ "Hitmonlee",	&I_hitmonlee,	0x2B },
-	{ "Hitmonchan",	&I_hitmonchan,	0x2C },
-	{ "Lickitung",	&I_lickitung,	0x0B },
-	{ "Koffing",	&I_koffing,	0x37 },
-	{ "Weezing",	&I_weezing,	0x8F },
-	{ "Rhyhorn",	&I_rhyhorn,	0x12 },
-	{ "Rhydon",	&I_rhydon,	0x01 },
-	{ "Chansey",	&I_chansey,	0x28 },
-	{ "Tangela",	&I_tangela,	0x1E },
-	{ "Kangaskhan",	&I_kangaskhan,	0x02 },
-	{ "Horsea",	&I_horsea,	0x5C },
-	{ "Seadra",	&I_seadra,	0x5D },
-	{ "Goldeen",	&I_goldeen,	0x9D },
-	{ "Seaking",	&I_seaking,	0x9E },
-	{ "Staryu",	&I_staryu,	0x1B },
-	{ "Starmie",	&I_starmie,	0x98 },
-	{ "Mr. Mime",	&I_mr_mime,	0x2A },
-	{ "Scyther",	&I_scyther,	0x1A },
-	{ "Jynx",	&I_jynx,	0x48 },
-	{ "Electabuzz",	&I_electabuzz,	0x35 },
-	{ "Magmar",	&I_magmar,	0x33 },
-	{ "Pinsir",	&I_pinsir,	0x1D },
-	{ "Tauros",	&I_tauros,	0x3C },
-	{ "Magikarp",	&I_magikarp,	0x85 },
-	{ "Gyarados",	&I_gyarados,	0x16 },
-	{ "Lapras",	&I_lapras,	0x13 },
-	{ "Ditto",	&I_ditto,	0x4C },
-	{ "Eevee",	&I_eevee,	0x66 },
-	{ "Vaporeon",	&I_vaporeon,	0x69 },
-	{ "Jolteon",	&I_jolteon,	0x68 },
-	{ "Flareon",	&I_flareon,	0x67 },
-	{ "Porygon",	&I_porygon,	0xAA },
-	{ "Omanyte",	&I_omanyte,	0x62 },
-	{ "Omastar",	&I_omastar,	0x63 },
-	{ "Kabuto",	&I_kabuto,	0x5A },
-	{ "Kabutops",	&I_kabutops,	0x5B },
-	{ "Aerodactyl",	&I_aerodactyl,	0xAB },
-	{ "Snorlax",	&I_snorlax,	0x84 },
-	{ "Articuno",	&I_articuno,	0x4A },
-	{ "Zapdos",	&I_zapdos,	0x4B },
-	{ "Moltres",	&I_moltres,	0x49 },
-	{ "Dratini",	&I_dratini,	0x58 },
-	{ "Dragonair",	&I_dragonair,	0x59 },
-	{ "Dragonite",	&I_dragonite,	0x42 },
-	{ "Mewtwo",	&I_mewtwo,	0x83 },
-	{ "Mew",	&I_mew,	        0x15 },
-	{ },
+    {"Bulbasaur", &I_bulbasaur, 0x99},
+    {"Ivysaur", &I_ivysaur, 0x09},
+    {"Venusaur", &I_venusaur, 0x9A},
+    {"Charmander", &I_charmander, 0xB0},
+    {"Charmeleon", &I_charmeleon, 0xB2},
+    {"Charizard", &I_charizard, 0xB4},
+    {"Squirtle", &I_squirtle, 0xB1},
+    {"Wartortle", &I_wartortle, 0xB3},
+    {"Blastoise", &I_blastoise, 0x1C},
+    {"Caterpie", &I_caterpie, 0x7B},
+    {"Metapod", &I_metapod, 0x7C},
+    {"Butterfree", &I_butterfree, 0x7D},
+    {"Weedle", &I_weedle, 0x70},
+    {"Kakuna", &I_kakuna, 0x71},
+    {"Beedrill", &I_beedrill, 0x72},
+    {"Pidgey", &I_pidgey, 0x24},
+    {"Pidgeotto", &I_pidgeotto, 0x96},
+    {"Pidgeot", &I_pidgeot, 0x97},
+    {"Rattata", &I_rattata, 0xA5},
+    {"Raticate", &I_raticate, 0xA6},
+    {"Spearow", &I_spearow, 0x05},
+    {"Fearow", &I_fearow, 0x23},
+    {"Ekans", &I_ekans, 0x6C},
+    {"Arbok", &I_arbok, 0x2D},
+    {"Pikachu", &I_pikachu, 0x54},
+    {"Raichu", &I_raichu, 0x55},
+    {"Sandshrew", &I_sandshrew, 0x60},
+    {"Sandslash", &I_sandslash, 0x61},
+    {"Nidoran ♀", &I_nidoranf, 0x0F},
+    {"Nidorina", &I_nidorina, 0xA8},
+    {"Nidoqueen", &I_nidoqueen, 0x10},
+    {"Nidoran ♂", &I_nidoranm, 0x03},
+    {"Nidorino", &I_nidorino, 0xA7},
+    {"Nidoking", &I_nidoking, 0x07},
+    {"Clefairy", &I_clefairy, 0x04},
+    {"Clefable", &I_clefable, 0x8E},
+    {"Vulpix", &I_vulpix, 0x52},
+    {"Ninetales", &I_ninetales, 0x53},
+    {"Jigglypuff", &I_jigglypuff, 0x64},
+    {"Wigglytuff", &I_wigglytuff, 0x65},
+    {"Zubat", &I_zubat, 0x6B},
+    {"Golbat", &I_golbat, 0x82},
+    {"Oddish", &I_oddish, 0xB9},
+    {"Gloom", &I_gloom, 0xBA},
+    {"Vileplume", &I_vileplume, 0xBB},
+    {"Paras", &I_paras, 0x6D},
+    {"Parasect", &I_parasect, 0x2E},
+    {"Venonat", &I_venonat, 0x41},
+    {"Venomoth", &I_venomoth, 0x77},
+    {"Diglett", &I_diglett, 0x3B},
+    {"Dugtrio", &I_dugtrio, 0x76},
+    {"Meowth", &I_meowth, 0x4D},
+    {"Persian", &I_persian, 0x90},
+    {"Psyduck", &I_psyduck, 0x2F},
+    {"Golduck", &I_golduck, 0x80},
+    {"Mankey", &I_mankey, 0x39},
+    {"Primeape", &I_primeape, 0x75},
+    {"Growlithe", &I_growlithe, 0x21},
+    {"Arcanine", &I_arcanine, 0x14},
+    {"Poliwag", &I_poliwag, 0x47},
+    {"Poliwhirl", &I_poliwhirl, 0x6E},
+    {"Poliwrath", &I_poliwrath, 0x6F},
+    {"Abra", &I_abra, 0x94},
+    {"Kadabra", &I_kadabra, 0x26},
+    {"Alakazam", &I_alakazam, 0x95},
+    {"Machop", &I_machop, 0x6A},
+    {"Machoke", &I_machoke, 0x29},
+    {"Machamp", &I_machamp, 0x7E},
+    {"Bellsprout", &I_bellsprout, 0xBC},
+    {"Weepinbell", &I_weepinbell, 0xBD},
+    {"Victreebel", &I_victreebel, 0xBE},
+    {"Tentacool", &I_tentacool, 0x18},
+    {"Tentacruel", &I_tentacruel, 0x9B},
+    {"Geodude", &I_geodude, 0xA9},
+    {"Graveler", &I_graveler, 0x27},
+    {"Golem", &I_golem, 0x31},
+    {"Ponyta", &I_ponyta, 0xA3},
+    {"Rapidash", &I_rapidash, 0xA4},
+    {"Slowpoke", &I_slowpoke, 0x25},
+    {"Slowbro", &I_slowbro, 0x08},
+    {"Magnemite", &I_magnemite, 0xAD},
+    {"Magneton", &I_magneton, 0x36},
+    {"Farfetch'd", &I_farfetchd, 0x40},
+    {"Doduo", &I_doduo, 0x46},
+    {"Dodrio", &I_dodrio, 0x74},
+    {"Seel", &I_seel, 0x3A},
+    {"Dewgong", &I_dewgong, 0x78},
+    {"Grimer", &I_grimer, 0x0D},
+    {"Muk", &I_muk, 0x88},
+    {"Shellder", &I_shellder, 0x17},
+    {"Cloyster", &I_cloyster, 0x8B},
+    {"Gastly", &I_gastly, 0x19},
+    {"Haunter", &I_haunter, 0x93},
+    {"Gengar", &I_gengar, 0x0E},
+    {"Onix", &I_onix, 0x22},
+    {"Drowzee", &I_drowzee, 0x30},
+    {"Hypno", &I_hypno, 0x81},
+    {"Krabby", &I_krabby, 0x4E},
+    {"Kingler", &I_kingler, 0x8A},
+    {"Voltorb", &I_voltorb, 0x06},
+    {"Electrode", &I_electrode, 0x8D},
+    {"Exeggcute", &I_exeggcute, 0x0C},
+    {"Exeggutor", &I_exeggutor, 0x0A},
+    {"Cubone", &I_cubone, 0x11},
+    {"Marowak", &I_marowak, 0x91},
+    {"Hitmonlee", &I_hitmonlee, 0x2B},
+    {"Hitmonchan", &I_hitmonchan, 0x2C},
+    {"Lickitung", &I_lickitung, 0x0B},
+    {"Koffing", &I_koffing, 0x37},
+    {"Weezing", &I_weezing, 0x8F},
+    {"Rhyhorn", &I_rhyhorn, 0x12},
+    {"Rhydon", &I_rhydon, 0x01},
+    {"Chansey", &I_chansey, 0x28},
+    {"Tangela", &I_tangela, 0x1E},
+    {"Kangaskhan", &I_kangaskhan, 0x02},
+    {"Horsea", &I_horsea, 0x5C},
+    {"Seadra", &I_seadra, 0x5D},
+    {"Goldeen", &I_goldeen, 0x9D},
+    {"Seaking", &I_seaking, 0x9E},
+    {"Staryu", &I_staryu, 0x1B},
+    {"Starmie", &I_starmie, 0x98},
+    {"Mr. Mime", &I_mr_mime, 0x2A},
+    {"Scyther", &I_scyther, 0x1A},
+    {"Jynx", &I_jynx, 0x48},
+    {"Electabuzz", &I_electabuzz, 0x35},
+    {"Magmar", &I_magmar, 0x33},
+    {"Pinsir", &I_pinsir, 0x1D},
+    {"Tauros", &I_tauros, 0x3C},
+    {"Magikarp", &I_magikarp, 0x85},
+    {"Gyarados", &I_gyarados, 0x16},
+    {"Lapras", &I_lapras, 0x13},
+    {"Ditto", &I_ditto, 0x4C},
+    {"Eevee", &I_eevee, 0x66},
+    {"Vaporeon", &I_vaporeon, 0x69},
+    {"Jolteon", &I_jolteon, 0x68},
+    {"Flareon", &I_flareon, 0x67},
+    {"Porygon", &I_porygon, 0xAA},
+    {"Omanyte", &I_omanyte, 0x62},
+    {"Omastar", &I_omastar, 0x63},
+    {"Kabuto", &I_kabuto, 0x5A},
+    {"Kabutops", &I_kabutops, 0x5B},
+    {"Aerodactyl", &I_aerodactyl, 0xAB},
+    {"Snorlax", &I_snorlax, 0x84},
+    {"Articuno", &I_articuno, 0x4A},
+    {"Zapdos", &I_zapdos, 0x4B},
+    {"Moltres", &I_moltres, 0x49},
+    {"Dratini", &I_dratini, 0x58},
+    {"Dragonair", &I_dragonair, 0x59},
+    {"Dragonite", &I_dragonite, 0x42},
+    {"Mewtwo", &I_mewtwo, 0x83},
+    {"Mew", &I_mew, 0x15},
+    {},
 };
 
 uint32_t pokemon_exit_confirm_view(void* context) {

+ 3 - 3
apps_source_code/gb-pokemon-trading/pokemon_app.h

@@ -16,9 +16,9 @@
 #define TAG "Pokemon"
 
 struct pokemon_lut {
-	const char *name;
-	const Icon *icon;
-	const uint8_t hex;
+    const char* name;
+    const Icon* icon;
+    const uint8_t hex;
 };
 
 typedef struct App App;

+ 276 - 289
apps_source_code/gb-pokemon-trading/pokemon_data.h

@@ -10,310 +10,297 @@
  * to set names and things on the fly in the flipper. Need to explore that.
  * once I get to that point.
  */
-#define TERM_		0x50
-#define SPACE_		0x7f
-#define A_		0x80
-#define B_		0x81
-#define C_		0x82
-#define D_		0x83
-#define E_		0x84
-#define F_		0x85
-#define G_		0x86
-#define H_		0x87
-#define I_		0x88
-#define J_		0x89
-#define K_		0x8a
-#define L_		0x8b
-#define M_		0x8c
-#define N_		0x8d
-#define O_		0x8e
-#define P_		0x8f
-#define Q_		0x90
-#define R_		0x91
-#define S_		0x92
-#define T_		0x93
-#define U_		0x94
-#define V_		0x95
-#define W_		0x96
-#define X_		0x97
-#define Y_		0x98
-#define Z_		0x99
-#define O_PAREN_	0x9a
-#define C_PAREN_	0x9b
-#define COLON_		0x9c
-#define SEMI_		0x9d
-#define O_BRACKET_	0x9e
-#define C_BRACKET_	0x9f
-#define a_		0xa0
-#define b_		0xa1
-#define c_		0xa2
-#define d_		0xa3
-#define e_		0xa4
-#define f_		0xa5
-#define g_		0xa6
-#define h_		0xa7
-#define i_		0xa8
-#define j_		0xa9
-#define k_		0xaa
-#define l_		0xab
-#define m_		0xac
-#define n_		0xad
-#define o_		0xae
-#define p_		0xaf
-#define q_		0xb0
-#define r_		0xb1
-#define s_		0xb2
-#define t_		0xb3
-#define u_		0xb4
-#define v_		0xb5
-#define w_		0xb6
-#define x_		0xb7
-#define y_		0xb8
-#define z_		0xb9
-#define e_ACCENT_	0xba
-#define d_TICK_		0xbb
-#define l_TICK_		0xbc
-#define s_TICK_		0xbd
-#define t_TICK_		0xbe
-#define v_TICK_		0xbf
-#define S_QUOTE_	0xe0
-#define PK_		0xe1
-#define MN_		0xe2
-#define DASH_		0xe3
-#define r_TICK_		0xe4
-#define m_TICK_		0xe5
-#define QUESTION_	0xe6
-#define EXCLAIM_	0xe7
-#define PERIOD_		0xe8
-#define R_ARR_		0xec
-#define D_ARR_		0xee
-#define MALE_		0xef
-#define FEMALE_		0xf5
-#define _0_		0xf6
-#define _1_		0xf7
-#define _2_		0xf8
-#define _3_		0xf9
-#define _4_		0xfa
-#define _5_		0xfb
-#define _6_		0xfc
-#define _7_		0xfd
-#define _8_		0xfe
-#define _9_		0xff
-
+#define TERM_ 0x50
+#define SPACE_ 0x7f
+#define A_ 0x80
+#define B_ 0x81
+#define C_ 0x82
+#define D_ 0x83
+#define E_ 0x84
+#define F_ 0x85
+#define G_ 0x86
+#define H_ 0x87
+#define I_ 0x88
+#define J_ 0x89
+#define K_ 0x8a
+#define L_ 0x8b
+#define M_ 0x8c
+#define N_ 0x8d
+#define O_ 0x8e
+#define P_ 0x8f
+#define Q_ 0x90
+#define R_ 0x91
+#define S_ 0x92
+#define T_ 0x93
+#define U_ 0x94
+#define V_ 0x95
+#define W_ 0x96
+#define X_ 0x97
+#define Y_ 0x98
+#define Z_ 0x99
+#define O_PAREN_ 0x9a
+#define C_PAREN_ 0x9b
+#define COLON_ 0x9c
+#define SEMI_ 0x9d
+#define O_BRACKET_ 0x9e
+#define C_BRACKET_ 0x9f
+#define a_ 0xa0
+#define b_ 0xa1
+#define c_ 0xa2
+#define d_ 0xa3
+#define e_ 0xa4
+#define f_ 0xa5
+#define g_ 0xa6
+#define h_ 0xa7
+#define i_ 0xa8
+#define j_ 0xa9
+#define k_ 0xaa
+#define l_ 0xab
+#define m_ 0xac
+#define n_ 0xad
+#define o_ 0xae
+#define p_ 0xaf
+#define q_ 0xb0
+#define r_ 0xb1
+#define s_ 0xb2
+#define t_ 0xb3
+#define u_ 0xb4
+#define v_ 0xb5
+#define w_ 0xb6
+#define x_ 0xb7
+#define y_ 0xb8
+#define z_ 0xb9
+#define e_ACCENT_ 0xba
+#define d_TICK_ 0xbb
+#define l_TICK_ 0xbc
+#define s_TICK_ 0xbd
+#define t_TICK_ 0xbe
+#define v_TICK_ 0xbf
+#define S_QUOTE_ 0xe0
+#define PK_ 0xe1
+#define MN_ 0xe2
+#define DASH_ 0xe3
+#define r_TICK_ 0xe4
+#define m_TICK_ 0xe5
+#define QUESTION_ 0xe6
+#define EXCLAIM_ 0xe7
+#define PERIOD_ 0xe8
+#define R_ARR_ 0xec
+#define D_ARR_ 0xee
+#define MALE_ 0xef
+#define FEMALE_ 0xf5
+#define _0_ 0xf6
+#define _1_ 0xf7
+#define _2_ 0xf8
+#define _3_ 0xf9
+#define _4_ 0xfa
+#define _5_ 0xfb
+#define _6_ 0xfc
+#define _7_ 0xfd
+#define _8_ 0xfe
+#define _9_ 0xff
 
 /* XXX: These are all opposite endianness on the flipper than they are in the
  * GB/Z80. e.g. a uint16_t value of 0x2c01 translates to 0x012c. Does flipper
  * API have calls to swap endianness?
  */
 struct __attribute__((__packed__)) pokemon_structure {
-	uint8_t species;
-	uint16_t hp;
-	uint8_t level;
-	uint8_t status_condition;
-	uint8_t type[2];
-	uint8_t catch_held;
-	uint8_t move[4];
-	uint16_t orig_trainer;
-	uint8_t exp[3];
-	uint16_t hp_ev;
-	uint16_t atk_ev;
-	uint16_t def_ev;
-	uint16_t spd_ev;
-	uint16_t special_ev;
-	uint16_t iv;
-	uint8_t move_pp[4];
-	uint8_t level_again;
-	uint16_t max_hp;
-	uint16_t atk;
-	uint16_t def;
-	uint16_t spd;
-	uint16_t special;
+    uint8_t species;
+    uint16_t hp;
+    uint8_t level;
+    uint8_t status_condition;
+    uint8_t type[2];
+    uint8_t catch_held;
+    uint8_t move[4];
+    uint16_t orig_trainer;
+    uint8_t exp[3];
+    uint16_t hp_ev;
+    uint16_t atk_ev;
+    uint16_t def_ev;
+    uint16_t spd_ev;
+    uint16_t special_ev;
+    uint16_t iv;
+    uint8_t move_pp[4];
+    uint8_t level_again;
+    uint16_t max_hp;
+    uint16_t atk;
+    uint16_t def;
+    uint16_t spd;
+    uint16_t special;
 };
 
 struct __attribute__((__packed__)) name {
-	unsigned char str[11];
+    unsigned char str[11];
 };
 
 struct __attribute__((__packed__)) trade_data_block {
-	unsigned char trainer_name[11];
-	uint8_t party_cnt;
-	uint8_t party_members[7]; // Unsure if last byte always needs to be 0xff for terminator
-	struct pokemon_structure party[6];
-	struct name ot_name[6];
-	struct name nickname[6];
-};
-
-struct trade_data_block DATA_BLOCK2 = {
-	.trainer_name = { F_, l_, i_, p_, p_, e_, r_, TERM_, 0x00, 0x00, 0x00 },
-	.party_cnt = 1,
-	.party_members = { 0x15, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff },
-	.party = {
-		{
-			.species = 0x4a,
-			.hp = 0x2c01,
-			.level = 0x4a,
-			.status_condition = 0x0,
-			.type = { 0x14, 0x08 },
-			.catch_held = 0x1f,
-			.move = { 0x7e, 0x38, 0x09, 0x19 },
-			.orig_trainer = 0xd204,
-			.exp = { 0x3, 0xd, 0x40 },
-			.hp_ev = 0xffff,
-			.atk_ev = 0xffff,
-			.def_ev = 0xffff,
-			.spd_ev = 0xffff,
-			.special_ev = 0xffff,
-			.iv = 0xffff,
-			.move_pp = { 0xc0, 0xc0, 0xc0, 0xc0 },
-			.level_again = 0x4a,
-			.max_hp = 0x2c01,
-			.atk = 0x9600,
-			.def = 0x9700,
-			.spd = 0x9800,
-			.special = 0x9900
-		},
-		{
-			.species = 0x4a,
-			.hp = 0x2c01,
-			.level = 0x4a,
-			.status_condition = 0x0,
-			.type = { 0x14, 0x08 },
-			.catch_held = 0x1f,
-			.move = { 0x7e, 0x38, 0x09, 0x19 },
-			.orig_trainer = 0xd204,
-			.exp = { 0x3, 0xd, 0x40 },
-			.hp_ev = 0xffff,
-			.atk_ev = 0xffff,
-			.def_ev = 0xffff,
-			.spd_ev = 0xffff,
-			.special_ev = 0xffff,
-			.iv = 0xffff,
-			.move_pp = { 0xc0, 0xc0, 0xc0, 0xc0 },
-			.level_again = 0x4a,
-			.max_hp = 0x2c01,
-			.atk = 0x9600,
-			.def = 0x9700,
-			.spd = 0x9800,
-			.special = 0x9900
-		},
-		{
-			.species = 0x4a,
-			.hp = 0x2c01,
-			.level = 0x4a,
-			.status_condition = 0x0,
-			.type = { 0x14, 0x08 },
-			.catch_held = 0x1f,
-			.move = { 0x7e, 0x38, 0x09, 0x19 },
-			.orig_trainer = 0xd204,
-			.exp = { 0x3, 0xd, 0x40 },
-			.hp_ev = 0xffff,
-			.atk_ev = 0xffff,
-			.def_ev = 0xffff,
-			.spd_ev = 0xffff,
-			.special_ev = 0xffff,
-			.iv = 0xffff,
-			.move_pp = { 0xc0, 0xc0, 0xc0, 0xc0 },
-			.level_again = 0x4a,
-			.max_hp = 0x2c01,
-			.atk = 0x9600,
-			.def = 0x9700,
-			.spd = 0x9800,
-			.special = 0x9900
-		},
-		{
-			.species = 0x4a,
-			.hp = 0x2c01,
-			.level = 0x4a,
-			.status_condition = 0x0,
-			.type = { 0x14, 0x08 },
-			.catch_held = 0x1f,
-			.move = { 0x7e, 0x38, 0x09, 0x19 },
-			.orig_trainer = 0xd204,
-			.exp = { 0x3, 0xd, 0x40 },
-			.hp_ev = 0xffff,
-			.atk_ev = 0xffff,
-			.def_ev = 0xffff,
-			.spd_ev = 0xffff,
-			.special_ev = 0xffff,
-			.iv = 0xffff,
-			.move_pp = { 0xc0, 0xc0, 0xc0, 0xc0 },
-			.level_again = 0x4a,
-			.max_hp = 0x2c01,
-			.atk = 0x9600,
-			.def = 0x9700,
-			.spd = 0x9800,
-			.special = 0x9900
-		},
-		{
-			.species = 0x4a,
-			.hp = 0x2c01,
-			.level = 0x4a,
-			.status_condition = 0x0,
-			.type = { 0x14, 0x08 },
-			.catch_held = 0x1f,
-			.move = { 0x7e, 0x38, 0x09, 0x19 },
-			.orig_trainer = 0xd204,
-			.exp = { 0x3, 0xd, 0x40 },
-			.hp_ev = 0xffff,
-			.atk_ev = 0xffff,
-			.def_ev = 0xffff,
-			.spd_ev = 0xffff,
-			.special_ev = 0xffff,
-			.iv = 0xffff,
-			.move_pp = { 0xc0, 0xc0, 0xc0, 0xc0 },
-			.level_again = 0x4a,
-			.max_hp = 0x2c01,
-			.atk = 0x9600,
-			.def = 0x9700,
-			.spd = 0x9800,
-			.special = 0x9900
-		},
-		{
-			.species = 0x4a,
-			.hp = 0x2c01,
-			.level = 0x4a,
-			.status_condition = 0x0,
-			.type = { 0x14, 0x08 },
-			.catch_held = 0x1f,
-			.move = { 0x7e, 0x38, 0x09, 0x19 },
-			.orig_trainer = 0xd204,
-			.exp = { 0x3, 0xd, 0x40 },
-			.hp_ev = 0xffff,
-			.atk_ev = 0xffff,
-			.def_ev = 0xffff,
-			.spd_ev = 0xffff,
-			.special_ev = 0xffff,
-			.iv = 0xffff,
-			.move_pp = { 0xc0, 0xc0, 0xc0, 0xc0 },
-			.level_again = 0x4a,
-			.max_hp = 0x2c01,
-			.atk = 0x9600,
-			.def = 0x9700,
-			.spd = 0x9800,
-			.special = 0x9900
-		},
-	},
-	/* NOTE: I think this shouldn't exceed 7 chars */
-	.ot_name = {
-		{ .str = { F_, l_, i_, p_, p_, e_, r_, TERM_, 0x00, 0x00 } },
-		{ .str = { F_, l_, i_, p_, p_, e_, r_, TERM_, 0x00, 0x00 } },
-		{ .str = { F_, l_, i_, p_, p_, e_, r_, TERM_, 0x00, 0x00 } },
-		{ .str = { F_, l_, i_, p_, p_, e_, r_, TERM_, 0x00, 0x00 } },
-		{ .str = { F_, l_, i_, p_, p_, e_, r_, TERM_, 0x00, 0x00 } },
-		{ .str = { F_, l_, i_, p_, p_, e_, r_, TERM_, 0x00, 0x00 } },
-	},
-	.nickname = {
-		{ .str = { F_, l_, o_, p_, p_, e_, r_, TERM_, 0x00, 0x00 } },
-		{ .str = { F_, l_, o_, p_, p_, e_, r_, TERM_, 0x00, 0x00 } },
-		{ .str = { F_, l_, o_, p_, p_, e_, r_, TERM_, 0x00, 0x00 } },
-		{ .str = { F_, l_, o_, p_, p_, e_, r_, TERM_, 0x00, 0x00 } },
-		{ .str = { F_, l_, o_, p_, p_, e_, r_, TERM_, 0x00, 0x00 } },
-		{ .str = { F_, l_, o_, p_, p_, e_, r_, TERM_, 0x00, 0x00 } },
-	}
+    unsigned char trainer_name[11];
+    uint8_t party_cnt;
+    uint8_t party_members[7]; // Unsure if last byte always needs to be 0xff for terminator
+    struct pokemon_structure party[6];
+    struct name ot_name[6];
+    struct name nickname[6];
 };
 
+struct trade_data_block DATA_BLOCK2 =
+    {.trainer_name = {F_, l_, i_, p_, p_, e_, r_, TERM_, 0x00, 0x00, 0x00},
+     .party_cnt = 1,
+     .party_members = {0x15, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff},
+     .party =
+         {
+             {.species = 0x4a,
+              .hp = 0x2c01,
+              .level = 0x4a,
+              .status_condition = 0x0,
+              .type = {0x14, 0x08},
+              .catch_held = 0x1f,
+              .move = {0x7e, 0x38, 0x09, 0x19},
+              .orig_trainer = 0xd204,
+              .exp = {0x3, 0xd, 0x40},
+              .hp_ev = 0xffff,
+              .atk_ev = 0xffff,
+              .def_ev = 0xffff,
+              .spd_ev = 0xffff,
+              .special_ev = 0xffff,
+              .iv = 0xffff,
+              .move_pp = {0xc0, 0xc0, 0xc0, 0xc0},
+              .level_again = 0x4a,
+              .max_hp = 0x2c01,
+              .atk = 0x9600,
+              .def = 0x9700,
+              .spd = 0x9800,
+              .special = 0x9900},
+             {.species = 0x4a,
+              .hp = 0x2c01,
+              .level = 0x4a,
+              .status_condition = 0x0,
+              .type = {0x14, 0x08},
+              .catch_held = 0x1f,
+              .move = {0x7e, 0x38, 0x09, 0x19},
+              .orig_trainer = 0xd204,
+              .exp = {0x3, 0xd, 0x40},
+              .hp_ev = 0xffff,
+              .atk_ev = 0xffff,
+              .def_ev = 0xffff,
+              .spd_ev = 0xffff,
+              .special_ev = 0xffff,
+              .iv = 0xffff,
+              .move_pp = {0xc0, 0xc0, 0xc0, 0xc0},
+              .level_again = 0x4a,
+              .max_hp = 0x2c01,
+              .atk = 0x9600,
+              .def = 0x9700,
+              .spd = 0x9800,
+              .special = 0x9900},
+             {.species = 0x4a,
+              .hp = 0x2c01,
+              .level = 0x4a,
+              .status_condition = 0x0,
+              .type = {0x14, 0x08},
+              .catch_held = 0x1f,
+              .move = {0x7e, 0x38, 0x09, 0x19},
+              .orig_trainer = 0xd204,
+              .exp = {0x3, 0xd, 0x40},
+              .hp_ev = 0xffff,
+              .atk_ev = 0xffff,
+              .def_ev = 0xffff,
+              .spd_ev = 0xffff,
+              .special_ev = 0xffff,
+              .iv = 0xffff,
+              .move_pp = {0xc0, 0xc0, 0xc0, 0xc0},
+              .level_again = 0x4a,
+              .max_hp = 0x2c01,
+              .atk = 0x9600,
+              .def = 0x9700,
+              .spd = 0x9800,
+              .special = 0x9900},
+             {.species = 0x4a,
+              .hp = 0x2c01,
+              .level = 0x4a,
+              .status_condition = 0x0,
+              .type = {0x14, 0x08},
+              .catch_held = 0x1f,
+              .move = {0x7e, 0x38, 0x09, 0x19},
+              .orig_trainer = 0xd204,
+              .exp = {0x3, 0xd, 0x40},
+              .hp_ev = 0xffff,
+              .atk_ev = 0xffff,
+              .def_ev = 0xffff,
+              .spd_ev = 0xffff,
+              .special_ev = 0xffff,
+              .iv = 0xffff,
+              .move_pp = {0xc0, 0xc0, 0xc0, 0xc0},
+              .level_again = 0x4a,
+              .max_hp = 0x2c01,
+              .atk = 0x9600,
+              .def = 0x9700,
+              .spd = 0x9800,
+              .special = 0x9900},
+             {.species = 0x4a,
+              .hp = 0x2c01,
+              .level = 0x4a,
+              .status_condition = 0x0,
+              .type = {0x14, 0x08},
+              .catch_held = 0x1f,
+              .move = {0x7e, 0x38, 0x09, 0x19},
+              .orig_trainer = 0xd204,
+              .exp = {0x3, 0xd, 0x40},
+              .hp_ev = 0xffff,
+              .atk_ev = 0xffff,
+              .def_ev = 0xffff,
+              .spd_ev = 0xffff,
+              .special_ev = 0xffff,
+              .iv = 0xffff,
+              .move_pp = {0xc0, 0xc0, 0xc0, 0xc0},
+              .level_again = 0x4a,
+              .max_hp = 0x2c01,
+              .atk = 0x9600,
+              .def = 0x9700,
+              .spd = 0x9800,
+              .special = 0x9900},
+             {.species = 0x4a,
+              .hp = 0x2c01,
+              .level = 0x4a,
+              .status_condition = 0x0,
+              .type = {0x14, 0x08},
+              .catch_held = 0x1f,
+              .move = {0x7e, 0x38, 0x09, 0x19},
+              .orig_trainer = 0xd204,
+              .exp = {0x3, 0xd, 0x40},
+              .hp_ev = 0xffff,
+              .atk_ev = 0xffff,
+              .def_ev = 0xffff,
+              .spd_ev = 0xffff,
+              .special_ev = 0xffff,
+              .iv = 0xffff,
+              .move_pp = {0xc0, 0xc0, 0xc0, 0xc0},
+              .level_again = 0x4a,
+              .max_hp = 0x2c01,
+              .atk = 0x9600,
+              .def = 0x9700,
+              .spd = 0x9800,
+              .special = 0x9900},
+         },
+     /* NOTE: I think this shouldn't exceed 7 chars */
+     .ot_name =
+         {
+             {.str = {F_, l_, i_, p_, p_, e_, r_, TERM_, 0x00, 0x00}},
+             {.str = {F_, l_, i_, p_, p_, e_, r_, TERM_, 0x00, 0x00}},
+             {.str = {F_, l_, i_, p_, p_, e_, r_, TERM_, 0x00, 0x00}},
+             {.str = {F_, l_, i_, p_, p_, e_, r_, TERM_, 0x00, 0x00}},
+             {.str = {F_, l_, i_, p_, p_, e_, r_, TERM_, 0x00, 0x00}},
+             {.str = {F_, l_, i_, p_, p_, e_, r_, TERM_, 0x00, 0x00}},
+         },
+     .nickname = {
+         {.str = {F_, l_, o_, p_, p_, e_, r_, TERM_, 0x00, 0x00}},
+         {.str = {F_, l_, o_, p_, p_, e_, r_, TERM_, 0x00, 0x00}},
+         {.str = {F_, l_, o_, p_, p_, e_, r_, TERM_, 0x00, 0x00}},
+         {.str = {F_, l_, o_, p_, p_, e_, r_, TERM_, 0x00, 0x00}},
+         {.str = {F_, l_, o_, p_, p_, e_, r_, TERM_, 0x00, 0x00}},
+         {.str = {F_, l_, o_, p_, p_, e_, r_, TERM_, 0x00, 0x00}},
+     }};
 
 unsigned char INPUT_BLOCK[405];
-unsigned char *DATA_BLOCK = (unsigned char *)&DATA_BLOCK2;
+unsigned char* DATA_BLOCK = (unsigned char*)&DATA_BLOCK2;
 
 #endif /* POKEMON_DATA_H */

+ 2 - 7
apps_source_code/gb-pokemon-trading/views/select_pokemon.cpp

@@ -8,15 +8,10 @@ static void select_pokemon_render_callback(Canvas* canvas, void* context) {
     const uint8_t current_index = model->current_pokemon;
     char pokedex_num[5];
 
-    snprintf(pokedex_num, sizeof(pokedex_num), "#%03d", current_index+1);
+    snprintf(pokedex_num, sizeof(pokedex_num), "#%03d", current_index + 1);
     canvas_set_font(canvas, FontPrimary);
     canvas_draw_str_aligned(
-        canvas,
-        55,
-        54 / 2,
-        AlignLeft,
-        AlignTop,
-	pokemon_table[current_index].name);
+        canvas, 55, 54 / 2, AlignLeft, AlignTop, pokemon_table[current_index].name);
 
     canvas_set_font(canvas, FontSecondary);
     canvas_draw_str_aligned(canvas, 55, 38, AlignLeft, AlignTop, pokedex_num);

+ 1 - 1
apps_source_code/gb-pokemon-trading/views/trade.hpp

@@ -67,6 +67,6 @@ void trade_free(App* app);
 View* trade_get_view(App* app);
 
 extern unsigned char INPUT_BLOCK[405];
-extern unsigned char *DATA_BLOCK;
+extern unsigned char* DATA_BLOCK;
 
 #endif /* TRADE_HPP */

+ 43 - 42
apps_source_code/gpio_7segment/gpio_7segment_app.c

@@ -65,16 +65,16 @@ seg:
 #define TAG "gpio_7segment_app"
 
 bool digits[70] = {
-    /* 0 */ false,  true,  true,  true,  true,  true,  true,
-    /* 1 */ false,  true, false, false, false, false,  true,
-    /* 2 */ true, false,  true,  true, false,  true,  true,
-    /* 3 */ true,  true,  true, false, false,  true,  true,
-    /* 4 */ true,  true, false, false,  true, false,  true,
-    /* 5 */ true,  true,  true, false,  true,  true, false,
-    /* 6 */ true,  true,  true,  true,  true,  true, false,
-    /* 7 */ false,  true, false, false, false,  true,  true,
+    /* 0 */ false, true,  true,  true,  true,  true,  true,
+    /* 1 */ false, true,  false, false, false, false, true,
+    /* 2 */ true,  false, true,  true,  false, true,  true,
+    /* 3 */ true,  true,  true,  false, false, true,  true,
+    /* 4 */ true,  true,  false, false, true,  false, true,
+    /* 5 */ true,  true,  true,  false, true,  true,  false,
+    /* 6 */ true,  true,  true,  true,  true,  true,  false,
+    /* 7 */ false, true,  false, false, false, true,  true,
     /* 8 */ true,  true,  true,  true,  true,  true,  true,
-    /* 9 */ true,  true,  true, false,  true,  true,  true,
+    /* 9 */ true,  true,  true,  false, true,  true,  true,
 };
 
 typedef enum {
@@ -83,7 +83,7 @@ typedef enum {
 
 typedef struct {
     GpioEventType type; // The reason for this event.
-    InputEvent input;   // This data is specific to keypress data.
+    InputEvent input; // This data is specific to keypress data.
 } GpioEvent;
 
 typedef struct {
@@ -107,7 +107,7 @@ static void gpio_7segment_input_callback(InputEvent* input_event, FuriMessageQue
     furi_message_queue_put(queue, &event, FuriWaitForever);
 }
 
-// Invoked by the draw callback to render the screen. 
+// Invoked by the draw callback to render the screen.
 // @param canvas surface to draw on.
 // @param ctx a pointer to the application GpioContext.
 static void gpio_7segment_render_callback(Canvas* canvas, void* ctx) {
@@ -138,11 +138,12 @@ static void gpio_7segment_render_callback(Canvas* canvas, void* ctx) {
     canvas_draw_str_aligned(canvas, 66, 26, AlignLeft, AlignTop, digits[index++] ? "C1" : "c1");
 
     // Tell user if GPIO pins are GND or 3.3v to glow.
-    canvas_draw_str_aligned(canvas, 90, 40, AlignLeft, AlignTop, data->invert?"GND":"3.3v");
+    canvas_draw_str_aligned(canvas, 90, 40, AlignLeft, AlignTop, data->invert ? "GND" : "3.3v");
 
     // Display the current number.
     furi_string_printf(data->buffer, "Digit: %d", data->digit);
-    canvas_draw_str_aligned(canvas, 90, 50, AlignLeft, AlignTop, furi_string_get_cstr(data->buffer));
+    canvas_draw_str_aligned(
+        canvas, 90, 50, AlignLeft, AlignTop, furi_string_get_cstr(data->buffer));
 
     // Release the context, so other threads can update the data.
     furi_mutex_release(context->mutex);
@@ -150,7 +151,7 @@ static void gpio_7segment_render_callback(Canvas* canvas, void* ctx) {
 
 // Sets the GPIO pin output to display a number.
 // @param digit a value between 0-9 to display.
-// @param invert use true if your 7-segment LED display is common anode 
+// @param invert use true if your 7-segment LED display is common anode
 // (and all the output pins go to cathode side of LEDs).  use false if
 // your display is common cathode.
 void gpio_7segment_show(int digit, bool invert) {
@@ -214,35 +215,35 @@ int32_t gpio_7segment_app(void* p) {
     GpioEvent event;
     bool processing = true;
     do {
-        if (furi_message_queue_get(context->queue, &event, FuriWaitForever) == FuriStatusOk) {
+        if(furi_message_queue_get(context->queue, &event, FuriWaitForever) == FuriStatusOk) {
             FURI_LOG_T(TAG, "Got event type: %d", event.type);
-            switch (event.type) {
-                case GpioEventTypeKey:
-                    // Short press of back button exits the program.
-                    if (event.input.type == InputTypeShort && event.input.key == InputKeyBack) {
-                        FURI_LOG_I(TAG, "Short-Back pressed. Exiting program.");
-                        processing = false;
-                    } else if (event.input.type == InputTypeShort && event.input.key == InputKeyOk) {
-                        FURI_LOG_I(TAG, "OK pressed.");
-                        if (furi_mutex_acquire(context->mutex, FuriWaitForever) == FuriStatusOk) {
-                            // Pick a random number between 1 and 6...
-                            context->data->digit = (furi_hal_random_get() % 6) + 1;
-                            
-                            gpio_7segment_show(context->data->digit, context->data->invert);
-                            furi_mutex_release(context->mutex);
-                        }
-                    } else if (event.input.type == InputTypeShort && event.input.key == InputKeyUp) {
-                        FURI_LOG_I(TAG, "UP pressed.");
-                        if (furi_mutex_acquire(context->mutex, FuriWaitForever) == FuriStatusOk) {
-                            // Invert our output (switch between common anode/cathode 7-segment LEDs)
-                            context->data->invert = !context->data->invert;
-                            gpio_7segment_show(context->data->digit, context->data->invert);
-                            furi_mutex_release(context->mutex);
-                        }
+            switch(event.type) {
+            case GpioEventTypeKey:
+                // Short press of back button exits the program.
+                if(event.input.type == InputTypeShort && event.input.key == InputKeyBack) {
+                    FURI_LOG_I(TAG, "Short-Back pressed. Exiting program.");
+                    processing = false;
+                } else if(event.input.type == InputTypeShort && event.input.key == InputKeyOk) {
+                    FURI_LOG_I(TAG, "OK pressed.");
+                    if(furi_mutex_acquire(context->mutex, FuriWaitForever) == FuriStatusOk) {
+                        // Pick a random number between 1 and 6...
+                        context->data->digit = (furi_hal_random_get() % 6) + 1;
+
+                        gpio_7segment_show(context->data->digit, context->data->invert);
+                        furi_mutex_release(context->mutex);
                     }
-                    break;
-                default:
-                    break;
+                } else if(event.input.type == InputTypeShort && event.input.key == InputKeyUp) {
+                    FURI_LOG_I(TAG, "UP pressed.");
+                    if(furi_mutex_acquire(context->mutex, FuriWaitForever) == FuriStatusOk) {
+                        // Invert our output (switch between common anode/cathode 7-segment LEDs)
+                        context->data->invert = !context->data->invert;
+                        gpio_7segment_show(context->data->digit, context->data->invert);
+                        furi_mutex_release(context->mutex);
+                    }
+                }
+                break;
+            default:
+                break;
             }
 
             // Send signal to update the screen (callback will get invoked at some point later.)
@@ -251,7 +252,7 @@ int32_t gpio_7segment_app(void* p) {
             // We had an issue getting message from the queue, so exit application.
             processing = false;
         }
-    } while (processing);
+    } while(processing);
 
     // Disconnect the GPIO pins.
     gpio_7segment_disconnect_pin(&gpio_ext_pa7);

+ 59 - 109
apps_source_code/mh_z19/mh_z19app.c

@@ -9,26 +9,20 @@
 #include <notification/notification_messages.h>
 #include <assets_icons.h>
 
-typedef enum
-{
+typedef enum {
     GreenStatus,
     YellowStatus,
     RedStatus,
 } StatusPPM;
 
-typedef enum
-{
-    RANGE_2000 = 2000,
-    RANGE_5000 = 5000
-} SensorRange;
+typedef enum { RANGE_2000 = 2000, RANGE_5000 = 5000 } SensorRange;
 
-struct MHZ19App
-{
-    Gui *gui;
-    ViewPort *view_port;
-    FuriMessageQueue *event_queue;
-    FuriMutex *mutex;
-    NotificationApp *notifications;
+struct MHZ19App {
+    Gui* gui;
+    ViewPort* view_port;
+    FuriMessageQueue* event_queue;
+    FuriMutex* mutex;
+    NotificationApp* notifications;
 
     bool have_5v;
     int32_t current_page;
@@ -37,7 +31,7 @@ struct MHZ19App
 
     SensorRange sensor_range;
 
-    const GpioPin *input_pin;
+    const GpioPin* input_pin;
 
     int32_t co2_ppm;
 };
@@ -73,15 +67,13 @@ const NotificationSequence red_led_sequence = {
     NULL,
 };
 
-void mh_z19app_draw_callback(Canvas *canvas, void *ctx)
-{
+void mh_z19app_draw_callback(Canvas* canvas, void* ctx) {
     furi_assert(ctx);
 
-    MHZ19App *app = ctx;
+    MHZ19App* app = ctx;
     canvas_clear(canvas);
 
-    if (!app->have_5v)
-    {
+    if(!app->have_5v) {
         canvas_set_font(canvas, FontPrimary);
         elements_multiline_text_aligned(
             canvas,
@@ -91,9 +83,7 @@ void mh_z19app_draw_callback(Canvas *canvas, void *ctx)
             AlignTop,
             "5V on GPIO must be\nenabled, or USB must\nbe connected.");
         return;
-    }
-    else if (app->current_page == 0)
-    {
+    } else if(app->current_page == 0) {
         canvas_set_font(canvas, FontPrimary);
         elements_multiline_text_aligned(
             canvas,
@@ -103,9 +93,7 @@ void mh_z19app_draw_callback(Canvas *canvas, void *ctx)
             AlignTop,
             "Connect sensor MH-Z19 to pins:\n5V -> 1\nGND -> 8\nPWM -> 3\nPress center button...");
         return;
-    }
-    else if (app->current_page == 1)
-    {
+    } else if(app->current_page == 1) {
         canvas_set_font(canvas, FontPrimary);
         elements_multiline_text_aligned(
             canvas,
@@ -117,13 +105,12 @@ void mh_z19app_draw_callback(Canvas *canvas, void *ctx)
         return;
     }
 
-    FuriString *strbuf = furi_string_alloc();
+    FuriString* strbuf = furi_string_alloc();
 
-    const Icon *icon;
-    FuriString *status_text = furi_string_alloc();
+    const Icon* icon;
+    FuriString* status_text = furi_string_alloc();
 
-    switch (app->status_ppm)
-    {
+    switch(app->status_ppm) {
     case GreenStatus:
         icon = &I_passport_okay1_46x49;
         furi_string_set_str(status_text, "it's OK!");
@@ -142,7 +129,7 @@ void mh_z19app_draw_callback(Canvas *canvas, void *ctx)
         break;
     }
 
-    const Icon *co2_icon = &I_co2;
+    const Icon* co2_icon = &I_co2;
 
     canvas_draw_icon(canvas, 9, 7, icon);
 
@@ -166,20 +153,17 @@ void mh_z19app_draw_callback(Canvas *canvas, void *ctx)
     furi_string_free(status_text);
 }
 
-void mh_z19app_input_callback(InputEvent *input_event, void *ctx)
-{
+void mh_z19app_input_callback(InputEvent* input_event, void* ctx) {
     furi_assert(ctx);
-    FuriMessageQueue *event_queue = ctx;
+    FuriMessageQueue* event_queue = ctx;
     furi_message_queue_put(event_queue, input_event, FuriWaitForever);
 }
 
-MHZ19App *mh_z19app_alloc()
-{
-    MHZ19App *app = (MHZ19App *)malloc(sizeof(MHZ19App));
+MHZ19App* mh_z19app_alloc() {
+    MHZ19App* app = (MHZ19App*)malloc(sizeof(MHZ19App));
 
     app->mutex = furi_mutex_alloc(FuriMutexTypeNormal);
-    if (!app->mutex)
-    {
+    if(!app->mutex) {
         FURI_LOG_E("MH-Z19", "cannot create mutex\r\n");
         free(app);
         return NULL;
@@ -197,18 +181,14 @@ MHZ19App *mh_z19app_alloc()
 
     // Enable 5v power, multiple attempts to avoid issues with power chip protection false triggering
     uint8_t attempts = 0;
-    while (!furi_hal_power_is_otg_enabled() && attempts++ < 5)
-    {
+    while(!furi_hal_power_is_otg_enabled() && attempts++ < 5) {
         furi_hal_power_enable_otg();
         furi_delay_ms(10);
     }
 
-    if (furi_hal_power_is_otg_enabled() || furi_hal_power_is_charging())
-    {
+    if(furi_hal_power_is_otg_enabled() || furi_hal_power_is_charging()) {
         app->have_5v = true;
-    }
-    else
-    {
+    } else {
         app->have_5v = false;
     }
 
@@ -222,12 +202,10 @@ MHZ19App *mh_z19app_alloc()
     return app;
 }
 
-void mh_z19app_free(MHZ19App *app)
-{
+void mh_z19app_free(MHZ19App* app) {
     furi_assert(app);
 
-    if (furi_hal_power_is_otg_enabled())
-    {
+    if(furi_hal_power_is_otg_enabled()) {
         furi_hal_power_disable_otg();
     }
 
@@ -246,8 +224,7 @@ void mh_z19app_free(MHZ19App *app)
     free(app);
 }
 
-void mh_z19app_init(MHZ19App *app)
-{
+void mh_z19app_init(MHZ19App* app) {
     furi_mutex_acquire(app->mutex, FuriWaitForever);
     app->co2_ppm = 0;
     app->status_ppm = GreenStatus;
@@ -259,28 +236,22 @@ void mh_z19app_init(MHZ19App *app)
 }
 
 int32_t calculate_ppm(
-    int32_t *prevVal,
+    int32_t* prevVal,
     int32_t val,
-    int32_t *th,
-    int32_t *tl,
-    int32_t *h,
-    int32_t *l,
-    SensorRange range)
-{
+    int32_t* th,
+    int32_t* tl,
+    int32_t* h,
+    int32_t* l,
+    SensorRange range) {
     int32_t tt = furi_get_tick();
-    if (val == 1)
-    {
-        if (val != *prevVal)
-        {
+    if(val == 1) {
+        if(val != *prevVal) {
             *h = tt;
             *tl = *h - *l;
             *prevVal = val;
         }
-    }
-    else
-    {
-        if (val != *prevVal)
-        {
+    } else {
+        if(val != *prevVal) {
             *l = tt;
             *th = *l - *h;
             *prevVal = val;
@@ -290,42 +261,28 @@ int32_t calculate_ppm(
     return -1;
 }
 
-void change_sensor_range(MHZ19App *app)
-{
-    if (app->sensor_range == RANGE_2000)
-    {
+void change_sensor_range(MHZ19App* app) {
+    if(app->sensor_range == RANGE_2000) {
         app->sensor_range = RANGE_5000;
-    }
-    else
-    {
+    } else {
         app->sensor_range = RANGE_2000;
     }
 }
 
-void send_notification_if_needed(MHZ19App *app, int32_t ppm)
-{
-    if (ppm > 0)
-    {
-        if (ppm > 1000)
-        {
-            if (app->status_ppm != RedStatus)
-            {
+void send_notification_if_needed(MHZ19App* app, int32_t ppm) {
+    if(ppm > 0) {
+        if(ppm > 1000) {
+            if(app->status_ppm != RedStatus) {
                 notification_message(app->notifications, &red_led_sequence);
                 app->status_ppm = RedStatus;
             }
-        }
-        else if (ppm > 800)
-        {
-            if (app->status_ppm != YellowStatus)
-            {
+        } else if(ppm > 800) {
+            if(app->status_ppm != YellowStatus) {
                 notification_message(app->notifications, &yellow_led_sequence);
                 app->status_ppm = YellowStatus;
             }
-        }
-        else
-        {
-            if (app->status_ppm != GreenStatus)
-            {
+        } else {
+            if(app->status_ppm != GreenStatus) {
                 notification_message(app->notifications, &green_led_sequence);
                 app->status_ppm = GreenStatus;
             }
@@ -333,12 +290,10 @@ void send_notification_if_needed(MHZ19App *app, int32_t ppm)
     }
 }
 
-int32_t mh_z19_app(void *p)
-{
+int32_t mh_z19_app(void* p) {
     UNUSED(p);
-    MHZ19App *app = mh_z19app_alloc();
-    if (!app)
-    {
+    MHZ19App* app = mh_z19app_alloc();
+    if(!app) {
         FURI_LOG_E("MH-Z19", "cannot create app\r\n");
         return -1;
     }
@@ -353,22 +308,17 @@ int32_t mh_z19_app(void *p)
     int32_t l = 0;
     int32_t ppm = 0;
 
-    for (bool processing = true; processing;)
-    {
+    for(bool processing = true; processing;) {
         furi_mutex_acquire(app->mutex, FuriWaitForever);
         ppm = calculate_ppm(
             &prevVal, furi_hal_gpio_read(app->input_pin), &th, &tl, &h, &l, app->sensor_range);
-        if (ppm > 0)
-        {
+        if(ppm > 0) {
             app->co2_ppm = ppm;
         }
         send_notification_if_needed(app, app->co2_ppm);
-        if (furi_message_queue_get(app->event_queue, &event, 100) == FuriStatusOk)
-        {
-            if (event.type == InputTypeShort)
-            {
-                switch (event.key)
-                {
+        if(furi_message_queue_get(app->event_queue, &event, 100) == FuriStatusOk) {
+            if(event.type == InputTypeShort) {
+                switch(event.key) {
                 case InputKeyBack:
                     processing = false;
                     break;

+ 0 - 2
apps_source_code/mifare_fuzzer/mifare_fuzzer_i.h

@@ -48,7 +48,6 @@ typedef enum {
 } MifareFuzzerView;
 
 struct MifareFuzzerApp {
-
     Gui* gui;
 
     ViewDispatcher* view_dispatcher;
@@ -74,5 +73,4 @@ struct MifareFuzzerApp {
     FuriString* file_path;
     FuriString* uid_str;
     Stream* uids_stream;
-
 };

+ 20 - 24
apps_source_code/mifare_fuzzer/mifare_fuzzer_worker.c

@@ -2,17 +2,18 @@
 #include "mifare_fuzzer_worker.h"
 
 /// @brief mifare_fuzzer_worker_alloc()
-/// @return 
+/// @return
 MifareFuzzerWorker* mifare_fuzzer_worker_alloc() {
     MifareFuzzerWorker* mifare_fuzzer_worker = malloc(sizeof(MifareFuzzerWorker));
     // Worker thread attributes
-    mifare_fuzzer_worker->thread = furi_thread_alloc_ex("MifareFuzzerWorker", 8192, mifare_fuzzer_worker_task, mifare_fuzzer_worker);
+    mifare_fuzzer_worker->thread = furi_thread_alloc_ex(
+        "MifareFuzzerWorker", 8192, mifare_fuzzer_worker_task, mifare_fuzzer_worker);
     mifare_fuzzer_worker->state = MifareFuzzerWorkerStateStop;
     return mifare_fuzzer_worker;
 }
 
 /// @brief mifare_fuzzer_worker_free()
-/// @param mifare_fuzzer_worker 
+/// @param mifare_fuzzer_worker
 void mifare_fuzzer_worker_free(MifareFuzzerWorker* mifare_fuzzer_worker) {
     furi_assert(mifare_fuzzer_worker);
     furi_thread_free(mifare_fuzzer_worker->thread);
@@ -20,17 +21,17 @@ void mifare_fuzzer_worker_free(MifareFuzzerWorker* mifare_fuzzer_worker) {
 }
 
 /// @brief mifare_fuzzer_worker_stop()
-/// @param mifare_fuzzer_worker 
+/// @param mifare_fuzzer_worker
 void mifare_fuzzer_worker_stop(MifareFuzzerWorker* mifare_fuzzer_worker) {
     furi_assert(mifare_fuzzer_worker);
-    if (mifare_fuzzer_worker->state != MifareFuzzerWorkerStateStop) {
+    if(mifare_fuzzer_worker->state != MifareFuzzerWorkerStateStop) {
         mifare_fuzzer_worker->state = MifareFuzzerWorkerStateStop;
         furi_thread_join(mifare_fuzzer_worker->thread);
     }
 }
 
 /// @brief mifare_fuzzer_worker_start()
-/// @param mifare_fuzzer_worker 
+/// @param mifare_fuzzer_worker
 void mifare_fuzzer_worker_start(MifareFuzzerWorker* mifare_fuzzer_worker) {
     furi_assert(mifare_fuzzer_worker);
     mifare_fuzzer_worker->state = MifareFuzzerWorkerStateEmulate;
@@ -38,27 +39,20 @@ void mifare_fuzzer_worker_start(MifareFuzzerWorker* mifare_fuzzer_worker) {
 }
 
 /// @brief mifare_fuzzer_worker_task()
-/// @param context 
-/// @return 
+/// @param context
+/// @return
 int32_t mifare_fuzzer_worker_task(void* context) {
     MifareFuzzerWorker* mifare_fuzzer_worker = context;
 
     if(mifare_fuzzer_worker->state == MifareFuzzerWorkerStateEmulate) {
-
         FuriHalNfcDevData params = mifare_fuzzer_worker->nfc_dev_data;
 
         furi_hal_nfc_exit_sleep();
         while(mifare_fuzzer_worker->state == MifareFuzzerWorkerStateEmulate) {
-            furi_hal_nfc_listen(
-                params.uid,
-                params.uid_len,
-                params.atqa,
-                params.sak, false, 500
-            );
+            furi_hal_nfc_listen(params.uid, params.uid_len, params.atqa, params.sak, false, 500);
             furi_delay_ms(50);
         }
         furi_hal_nfc_sleep();
-
     }
 
     mifare_fuzzer_worker->state = MifareFuzzerWorkerStateStop;
@@ -67,25 +61,27 @@ int32_t mifare_fuzzer_worker_task(void* context) {
 }
 
 /// @brief mifare_fuzzer_worker_is_emulating()
-/// @param mifare_fuzzer_worker 
-/// @return 
+/// @param mifare_fuzzer_worker
+/// @return
 bool mifare_fuzzer_worker_is_emulating(MifareFuzzerWorker* mifare_fuzzer_worker) {
-    if (mifare_fuzzer_worker->state == MifareFuzzerWorkerStateEmulate) {
+    if(mifare_fuzzer_worker->state == MifareFuzzerWorkerStateEmulate) {
         return true;
     }
     return false;
 }
 
 /// @brief mifare_fuzzer_worker_set_nfc_dev_data()
-/// @param mifare_fuzzer_worker 
-/// @param nfc_dev_data 
-void mifare_fuzzer_worker_set_nfc_dev_data(MifareFuzzerWorker* mifare_fuzzer_worker, FuriHalNfcDevData nfc_dev_data) {
+/// @param mifare_fuzzer_worker
+/// @param nfc_dev_data
+void mifare_fuzzer_worker_set_nfc_dev_data(
+    MifareFuzzerWorker* mifare_fuzzer_worker,
+    FuriHalNfcDevData nfc_dev_data) {
     mifare_fuzzer_worker->nfc_dev_data = nfc_dev_data;
 }
 
 /// @brief mifare_fuzzer_worker_get_nfc_dev_data()
-/// @param mifare_fuzzer_worker 
-/// @return 
+/// @param mifare_fuzzer_worker
+/// @return
 FuriHalNfcDevData mifare_fuzzer_worker_get_nfc_dev_data(MifareFuzzerWorker* mifare_fuzzer_worker) {
     return mifare_fuzzer_worker->nfc_dev_data;
 }

+ 4 - 2
apps_source_code/mifare_fuzzer/mifare_fuzzer_worker.h

@@ -23,7 +23,9 @@ void mifare_fuzzer_worker_stop(MifareFuzzerWorker* mifare_fuzzer_worker);
 void mifare_fuzzer_worker_start(MifareFuzzerWorker* mifare_fuzzer_worker);
 // task
 int32_t mifare_fuzzer_worker_task(void* context);
-// 
+//
 bool mifare_fuzzer_worker_is_emulating(MifareFuzzerWorker* mifare_fuzzer_worker);
-void mifare_fuzzer_worker_set_nfc_dev_data(MifareFuzzerWorker* mifare_fuzzer_worker, FuriHalNfcDevData nfc_dev_data);
+void mifare_fuzzer_worker_set_nfc_dev_data(
+    MifareFuzzerWorker* mifare_fuzzer_worker,
+    FuriHalNfcDevData nfc_dev_data);
 FuriHalNfcDevData mifare_fuzzer_worker_get_nfc_dev_data(MifareFuzzerWorker* mifare_fuzzer_worker);

+ 28 - 34
apps_source_code/mifare_fuzzer/scenes/mifare_fuzzer_scene_attack.c

@@ -8,13 +8,13 @@ enum SubmenuIndex {
 };
 
 /// @brief mifare_fuzzer_scene_attack_submenu_callback()
-/// @param context 
-/// @param index 
+/// @param context
+/// @param index
 void mifare_fuzzer_scene_attack_submenu_callback(void* context, uint32_t index) {
     //FURI_LOG_D(TAG, "mifare_fuzzer_scene_attack_submenu_callback() :: index = %ld", index);
     MifareFuzzerApp* app = context;
     uint8_t custom_event = 255;
-    switch(index){
+    switch(index) {
     case SubmenuIndexTestValue:
         custom_event = MifareFuzzerEventTestValueAttack;
         break;
@@ -32,7 +32,7 @@ void mifare_fuzzer_scene_attack_submenu_callback(void* context, uint32_t index)
 }
 
 /// @brief mifare_fuzzer_scene_attack_on_enter()
-/// @param context 
+/// @param context
 void mifare_fuzzer_scene_attack_on_enter(void* context) {
     //FURI_LOG_D(TAG, "mifare_fuzzer_scene_attack_on_enter()");
     MifareFuzzerApp* app = context;
@@ -44,41 +44,32 @@ void mifare_fuzzer_scene_attack_on_enter(void* context) {
         "Test Values",
         SubmenuIndexTestValue,
         mifare_fuzzer_scene_attack_submenu_callback,
-        app
-    );
+        app);
     submenu_add_item(
         submenu_attack,
         "Random Values",
         SubmenuIndexRandomValuesAttack,
         mifare_fuzzer_scene_attack_submenu_callback,
-        app
-    );
+        app);
     submenu_add_item(
         submenu_attack,
         "Load UIDs from file",
         SubmenuIndexLoadUIDsFromFile,
         mifare_fuzzer_scene_attack_submenu_callback,
-        app
-    );
+        app);
 
     // set selected menu
-    submenu_set_selected_item(submenu_attack,
-        scene_manager_get_scene_state(
-            app->scene_manager,
-            MifareFuzzerSceneAttack
-        )
-    );
+    submenu_set_selected_item(
+        submenu_attack,
+        scene_manager_get_scene_state(app->scene_manager, MifareFuzzerSceneAttack));
 
-    view_dispatcher_switch_to_view(
-        app->view_dispatcher,
-        MifareFuzzerViewSelectAttack
-    );
+    view_dispatcher_switch_to_view(app->view_dispatcher, MifareFuzzerViewSelectAttack);
 }
 
 /// @brief mifare_fuzzer_scene_attack_on_event()
-/// @param context 
-/// @param event 
-/// @return 
+/// @param context
+/// @param event
+/// @return
 bool mifare_fuzzer_scene_attack_on_event(void* context, SceneManagerEvent event) {
     //FURI_LOG_D(TAG, "mifare_fuzzer_scene_attack_on_event()");
     MifareFuzzerApp* app = context;
@@ -88,7 +79,8 @@ bool mifare_fuzzer_scene_attack_on_event(void* context, SceneManagerEvent event)
         //FURI_LOG_D(TAG, "mifare_fuzzer_scene_attack_on_event() :: event.event = %ld", event.event);
         if(event.event == MifareFuzzerEventTestValueAttack) {
             // save selected item
-            scene_manager_set_scene_state(app->scene_manager, MifareFuzzerSceneAttack, SubmenuIndexTestValue);
+            scene_manager_set_scene_state(
+                app->scene_manager, MifareFuzzerSceneAttack, SubmenuIndexTestValue);
             // set emulator attack
             app->attack = MifareFuzzerAttackTestValues;
             mifare_fuzzer_emulator_set_attack(app->emulator_view, app->attack);
@@ -97,7 +89,8 @@ bool mifare_fuzzer_scene_attack_on_event(void* context, SceneManagerEvent event)
             consumed = true;
         } else if(event.event == MifareFuzzerEventRandomValuesAttack) {
             // save selected item
-            scene_manager_set_scene_state(app->scene_manager, MifareFuzzerSceneAttack, SubmenuIndexRandomValuesAttack);
+            scene_manager_set_scene_state(
+                app->scene_manager, MifareFuzzerSceneAttack, SubmenuIndexRandomValuesAttack);
             // set emulator attack
             app->attack = MifareFuzzerAttackRandomValues;
             mifare_fuzzer_emulator_set_attack(app->emulator_view, app->attack);
@@ -106,7 +99,8 @@ bool mifare_fuzzer_scene_attack_on_event(void* context, SceneManagerEvent event)
             consumed = true;
         } else if(event.event == MifareFuzzerEventLoadUIDsFromFileAttack) {
             // save selected item
-            scene_manager_set_scene_state(app->scene_manager, MifareFuzzerSceneAttack, SubmenuIndexLoadUIDsFromFile);
+            scene_manager_set_scene_state(
+                app->scene_manager, MifareFuzzerSceneAttack, SubmenuIndexLoadUIDsFromFile);
             // set emulator attack
             app->attack = MifareFuzzerAttackLoadUidsFromFile;
             mifare_fuzzer_emulator_set_attack(app->emulator_view, app->attack);
@@ -115,14 +109,14 @@ bool mifare_fuzzer_scene_attack_on_event(void* context, SceneManagerEvent event)
             dialog_file_browser_set_basic_options(&browser_options, MIFARE_FUZZER_FILE_EXT, NULL);
             browser_options.hide_ext = false;
             bool res = dialog_file_browser_show(
-                app->dialogs,
-                app->file_path,
-                app->app_folder, &browser_options);
+                app->dialogs, app->file_path, app->app_folder, &browser_options);
             if(res) {
                 app->uids_stream = buffered_file_stream_alloc(app->storage);
-                    res = buffered_file_stream_open(
-                        app->uids_stream,
-                        furi_string_get_cstr(app->file_path), FSAM_READ, FSOM_OPEN_EXISTING);
+                res = buffered_file_stream_open(
+                    app->uids_stream,
+                    furi_string_get_cstr(app->file_path),
+                    FSAM_READ,
+                    FSOM_OPEN_EXISTING);
                 if(res) {
                     // open next scene
                     scene_manager_next_scene(app->scene_manager, MifareFuzzerSceneEmulator);
@@ -132,7 +126,7 @@ bool mifare_fuzzer_scene_attack_on_event(void* context, SceneManagerEvent event)
             }
             consumed = true;
         }
-    } else if (event.type == SceneManagerEventTypeTick) {
+    } else if(event.type == SceneManagerEventTypeTick) {
         //FURI_LOG_D(TAG, "mifare_fuzzer_scene_attack_on_event() :: SceneManagerEventTypeTick");
         //consumed = true;
     }
@@ -141,7 +135,7 @@ bool mifare_fuzzer_scene_attack_on_event(void* context, SceneManagerEvent event)
 }
 
 /// @brief mifare_fuzzer_scene_attack_on_exit()
-/// @param context 
+/// @param context
 void mifare_fuzzer_scene_attack_on_exit(void* context) {
     //FURI_LOG_D(TAG, "mifare_fuzzer_scene_attack_on_exit()");
     MifareFuzzerApp* app = context;

+ 42 - 41
apps_source_code/mifare_fuzzer/scenes/mifare_fuzzer_scene_emulator.c

@@ -16,8 +16,8 @@ uint8_t id_uid_test[9][7] = {
 };
 
 /// @brief mifare_fuzzer_scene_emulator_callback()
-/// @param event 
-/// @param context 
+/// @param event
+/// @param context
 static void mifare_fuzzer_scene_emulator_callback(MifareFuzzerEvent event, void* context) {
     //FURI_LOG_D(TAG, "mifare_fuzzer_scene_emulator_callback()");
     furi_assert(context);
@@ -26,7 +26,7 @@ static void mifare_fuzzer_scene_emulator_callback(MifareFuzzerEvent event, void*
 }
 
 /// @brief mifare_fuzzer_scene_emulator_on_enter()
-/// @param context 
+/// @param context
 void mifare_fuzzer_scene_emulator_on_enter(void* context) {
     //FURI_LOG_D(TAG, "mifare_fuzzer_scene_emulator_on_enter()");
     MifareFuzzerApp* app = context;
@@ -38,13 +38,14 @@ void mifare_fuzzer_scene_emulator_on_enter(void* context) {
     tick_counter = 0;
     mifare_fuzzer_emulator_set_tick_num(app->emulator_view, tick_counter);
     emulator->ticks_between_cards = MIFARE_FUZZER_DEFAULT_TICKS_BETWEEN_CARDS;
-    mifare_fuzzer_emulator_set_ticks_between_cards(app->emulator_view, emulator->ticks_between_cards);
+    mifare_fuzzer_emulator_set_ticks_between_cards(
+        app->emulator_view, emulator->ticks_between_cards);
     // init default card data
     FuriHalNfcDevData nfc_dev_data;
     nfc_dev_data.atqa[0] = 0x00;
     nfc_dev_data.atqa[1] = 0x00;
     nfc_dev_data.sak = 0x00;
-    if (app->card == MifareCardUltralight) {
+    if(app->card == MifareCardUltralight) {
         nfc_dev_data.uid_len = 0x07;
     } else {
         nfc_dev_data.uid_len = 0x04;
@@ -57,16 +58,13 @@ void mifare_fuzzer_scene_emulator_on_enter(void* context) {
     attack_step = 0;
 
     // switch to view
-    view_dispatcher_switch_to_view(
-        app->view_dispatcher,
-        MifareFuzzerViewEmulator
-    );
+    view_dispatcher_switch_to_view(app->view_dispatcher, MifareFuzzerViewEmulator);
 }
 
 /// @brief mifare_fuzzer_scene_emulator_on_event()
-/// @param context 
-/// @param event 
-/// @return 
+/// @param context
+/// @param event
+/// @return
 bool mifare_fuzzer_scene_emulator_on_event(void* context, SceneManagerEvent event) {
     //FURI_LOG_D(TAG, "mifare_fuzzer_scene_emulator_on_event()");
     FuriHalNfcDevData nfc_dev_data;
@@ -76,8 +74,8 @@ bool mifare_fuzzer_scene_emulator_on_event(void* context, SceneManagerEvent even
 
     bool consumed = false;
 
-    if (event.type == SceneManagerEventTypeCustom) {
-        if (event.event == MifareFuzzerEventStartAttack) {
+    if(event.type == SceneManagerEventTypeCustom) {
+        if(event.event == MifareFuzzerEventStartAttack) {
             //FURI_LOG_D(TAG, "mifare_fuzzer_scene_emulator_on_event() :: MifareFuzzerEventStartAttack");
 
             // Stop worker
@@ -85,17 +83,17 @@ bool mifare_fuzzer_scene_emulator_on_event(void* context, SceneManagerEvent even
 
             // Set card type
             // TODO: Move somewhere else, I do not like this to be there
-            if (app->card == MifareCardClassic1k) {
+            if(app->card == MifareCardClassic1k) {
                 nfc_dev_data.atqa[0] = 0x04;
                 nfc_dev_data.atqa[1] = 0x00;
                 nfc_dev_data.sak = 0x08;
                 nfc_dev_data.uid_len = 0x04;
-            } else if (app->card == MifareCardClassic4k) {
+            } else if(app->card == MifareCardClassic4k) {
                 nfc_dev_data.atqa[0] = 0x02;
                 nfc_dev_data.atqa[1] = 0x00;
                 nfc_dev_data.sak = 0x18;
                 nfc_dev_data.uid_len = 0x04;
-            } else if (app->card == MifareCardUltralight) {
+            } else if(app->card == MifareCardUltralight) {
                 nfc_dev_data.atqa[0] = 0x44;
                 nfc_dev_data.atqa[1] = 0x00;
                 nfc_dev_data.sak = 0x00;
@@ -103,19 +101,19 @@ bool mifare_fuzzer_scene_emulator_on_event(void* context, SceneManagerEvent even
             }
 
             // Set UIDs
-            if (app->attack == MifareFuzzerAttackTestValues) {
+            if(app->attack == MifareFuzzerAttackTestValues) {
                 // Load test UIDs
                 for(uint8_t i = 0; i < nfc_dev_data.uid_len; i++) {
                     nfc_dev_data.uid[i] = id_uid_test[attack_step][i];
                 }
                 // Next UIDs on next loop
-                if (attack_step >= 8) {
+                if(attack_step >= 8) {
                     attack_step = 0;
                 } else {
                     attack_step++;
                 }
-            } else if (app->attack == MifareFuzzerAttackRandomValues) {
-                if (app->card == MifareCardUltralight) {
+            } else if(app->attack == MifareFuzzerAttackRandomValues) {
+                if(app->card == MifareCardUltralight) {
                     // First byte of a 7 byte UID is the manufacturer-code
                     // https://github.com/Proxmark/proxmark3/blob/master/client/taginfo.c
                     // https://stackoverflow.com/questions/37837730/mifare-cards-distinguish-between-4-byte-and-7-byte-uids
@@ -132,10 +130,10 @@ bool mifare_fuzzer_scene_emulator_on_event(void* context, SceneManagerEvent even
                         nfc_dev_data.uid[i] = (furi_hal_random_get() & 0xFF);
                     }
                 }
-            } else if (app->attack == MifareFuzzerAttackLoadUidsFromFile) {
+            } else if(app->attack == MifareFuzzerAttackLoadUidsFromFile) {
                 //bool end_of_list = false;
                 // read stream
-                while(true){
+                while(true) {
                     furi_string_reset(app->uid_str);
                     if(!stream_read_line(app->uids_stream, app->uid_str)) {
                         // restart from beginning on empty line
@@ -146,7 +144,9 @@ bool mifare_fuzzer_scene_emulator_on_event(void* context, SceneManagerEvent even
                     // Skip comments
                     if(furi_string_get_char(app->uid_str, 0) == '#') continue;
                     // Skip lines with invalid length
-                    if((furi_string_size(app->uid_str) != 9) && (furi_string_size(app->uid_str) != 15)) continue;
+                    if((furi_string_size(app->uid_str) != 9) &&
+                       (furi_string_size(app->uid_str) != 15))
+                        continue;
                     break;
                 }
 
@@ -156,7 +156,7 @@ bool mifare_fuzzer_scene_emulator_on_event(void* context, SceneManagerEvent even
                 // parse string to UID
                 // TODO: a better validation on input?
                 for(uint8_t i = 0; i < nfc_dev_data.uid_len; i++) {
-                    if (i <= ((furi_string_size(app->uid_str) - 1) / 2)) {
+                    if(i <= ((furi_string_size(app->uid_str) - 1) / 2)) {
                         char temp_str[3];
                         temp_str[0] = furi_string_get_cstr(app->uid_str)[i * 2];
                         temp_str[1] = furi_string_get_cstr(app->uid_str)[i * 2 + 1];
@@ -166,7 +166,6 @@ bool mifare_fuzzer_scene_emulator_on_event(void* context, SceneManagerEvent even
                         nfc_dev_data.uid[i] = 0x00;
                     }
                 }
-
             }
 
             mifare_fuzzer_worker_set_nfc_dev_data(app->worker, nfc_dev_data);
@@ -179,27 +178,29 @@ bool mifare_fuzzer_scene_emulator_on_event(void* context, SceneManagerEvent even
             // Start worker
             mifare_fuzzer_worker_start(app->worker);
 
-        } else if (event.event == MifareFuzzerEventStopAttack) {
+        } else if(event.event == MifareFuzzerEventStopAttack) {
             //FURI_LOG_D(TAG, "mifare_fuzzer_scene_emulator_on_event() :: MifareFuzzerEventStopAttack");
             // Stop worker
             mifare_fuzzer_worker_stop(app->worker);
-        } else if (event.event == MifareFuzzerEventIncrementTicks) {
-            if (!emulator->is_attacking) {
-                if (emulator->ticks_between_cards < MIFARE_FUZZER_MAX_TICKS_BETWEEN_CARDS) {
+        } else if(event.event == MifareFuzzerEventIncrementTicks) {
+            if(!emulator->is_attacking) {
+                if(emulator->ticks_between_cards < MIFARE_FUZZER_MAX_TICKS_BETWEEN_CARDS) {
                     emulator->ticks_between_cards++;
-                    mifare_fuzzer_emulator_set_ticks_between_cards(app->emulator_view, emulator->ticks_between_cards);
+                    mifare_fuzzer_emulator_set_ticks_between_cards(
+                        app->emulator_view, emulator->ticks_between_cards);
                 };
             };
-        } else if (event.event == MifareFuzzerEventDecrementTicks) {
-            if (!emulator->is_attacking) {
-                if (emulator->ticks_between_cards > MIFARE_FUZZER_MIN_TICKS_BETWEEN_CARDS) {
+        } else if(event.event == MifareFuzzerEventDecrementTicks) {
+            if(!emulator->is_attacking) {
+                if(emulator->ticks_between_cards > MIFARE_FUZZER_MIN_TICKS_BETWEEN_CARDS) {
                     emulator->ticks_between_cards--;
-                    mifare_fuzzer_emulator_set_ticks_between_cards(app->emulator_view, emulator->ticks_between_cards);
+                    mifare_fuzzer_emulator_set_ticks_between_cards(
+                        app->emulator_view, emulator->ticks_between_cards);
                 };
             };
         }
         consumed = true;
-    } else if (event.type == SceneManagerEventTypeTick) {
+    } else if(event.type == SceneManagerEventTypeTick) {
         //FURI_LOG_D(TAG, "mifare_fuzzer_scene_emulator_on_event() :: SceneManagerEventTypeTick");
 
         // Used to check tick length (not perfect but enough)
@@ -208,14 +209,15 @@ bool mifare_fuzzer_scene_emulator_on_event(void* context, SceneManagerEvent even
         //FURI_LOG_D(TAG, "Time is: %.2d:%.2d:%.2d", curr_dt.hour, curr_dt.minute, curr_dt.second);
 
         // If emulator is attacking
-        if (emulator->is_attacking) {
+        if(emulator->is_attacking) {
             // increment tick_counter
             tick_counter++;
             mifare_fuzzer_emulator_set_tick_num(app->emulator_view, tick_counter);
             //FURI_LOG_D(TAG, "tick_counter is: %.2d", tick_counter);
-            if (tick_counter >= emulator->ticks_between_cards) {
+            if(tick_counter >= emulator->ticks_between_cards) {
                 // Queue event for changing UID
-                view_dispatcher_send_custom_event(app->view_dispatcher, MifareFuzzerEventStartAttack);
+                view_dispatcher_send_custom_event(
+                    app->view_dispatcher, MifareFuzzerEventStartAttack);
             }
         }
 
@@ -226,7 +228,7 @@ bool mifare_fuzzer_scene_emulator_on_event(void* context, SceneManagerEvent even
 }
 
 /// @brief mifare_fuzzer_scene_emulator_on_exit()
-/// @param context 
+/// @param context
 void mifare_fuzzer_scene_emulator_on_exit(void* context) {
     //FURI_LOG_D(TAG, "mifare_fuzzer_scene_emulator_on_exit()");
     MifareFuzzerApp* app = context;
@@ -237,5 +239,4 @@ void mifare_fuzzer_scene_emulator_on_exit(void* context) {
         stream_rewind(app->uids_stream);
         buffered_file_stream_close(app->uids_stream);
     }
-
 }

+ 21 - 28
apps_source_code/mifare_fuzzer/scenes/mifare_fuzzer_scene_start.c

@@ -8,13 +8,13 @@ enum SubmenuIndex {
 };
 
 /// @brief mifare_fuzzer_scene_start_submenu_callback()
-/// @param context 
-/// @param index 
+/// @param context
+/// @param index
 void mifare_fuzzer_scene_start_submenu_callback(void* context, uint32_t index) {
     //FURI_LOG_D(TAG, "mifare_fuzzer_scene_start_submenu_callback() :: index = %ld", index);
     MifareFuzzerApp* app = context;
     uint8_t custom_event = 255;
-    switch(index){
+    switch(index) {
     case SubmenuIndexClassic1k:
         custom_event = MifareFuzzerEventClassic1k;
         break;
@@ -32,7 +32,7 @@ void mifare_fuzzer_scene_start_submenu_callback(void* context, uint32_t index) {
 }
 
 /// @brief mifare_fuzzer_scene_start_on_enter()
-/// @param context 
+/// @param context
 void mifare_fuzzer_scene_start_on_enter(void* context) {
     //FURI_LOG_D(TAG, "mifare_fuzzer_scene_start_on_enter()");
     MifareFuzzerApp* app = context;
@@ -44,41 +44,31 @@ void mifare_fuzzer_scene_start_on_enter(void* context) {
         "Classic 1k",
         SubmenuIndexClassic1k,
         mifare_fuzzer_scene_start_submenu_callback,
-        app
-    );
+        app);
     submenu_add_item(
         submenu_card,
         "Classic 4k",
         SubmenuIndexClassic4k,
         mifare_fuzzer_scene_start_submenu_callback,
-        app
-    );
+        app);
     submenu_add_item(
         submenu_card,
         "Ultralight",
         SubmenuIndexUltralight,
         mifare_fuzzer_scene_start_submenu_callback,
-        app
-    );
+        app);
 
     // set selected menu
-    submenu_set_selected_item(submenu_card,
-        scene_manager_get_scene_state(
-            app->scene_manager,
-            MifareFuzzerSceneStart
-        )
-    );
+    submenu_set_selected_item(
+        submenu_card, scene_manager_get_scene_state(app->scene_manager, MifareFuzzerSceneStart));
 
-    view_dispatcher_switch_to_view(
-        app->view_dispatcher,
-        MifareFuzzerViewSelectCard
-    );
+    view_dispatcher_switch_to_view(app->view_dispatcher, MifareFuzzerViewSelectCard);
 }
 
 /// @brief mifare_fuzzer_scene_start_on_event()
-/// @param context 
-/// @param event 
-/// @return 
+/// @param context
+/// @param event
+/// @return
 bool mifare_fuzzer_scene_start_on_event(void* context, SceneManagerEvent event) {
     //FURI_LOG_D(TAG, "mifare_fuzzer_scene_start_on_event()");
     MifareFuzzerApp* app = context;
@@ -88,7 +78,8 @@ bool mifare_fuzzer_scene_start_on_event(void* context, SceneManagerEvent event)
         //FURI_LOG_D(TAG, "mifare_fuzzer_scene_start_on_event() :: event.event = %ld", event.event);
         if(event.event == MifareFuzzerEventClassic1k) {
             // save selected item
-            scene_manager_set_scene_state(app->scene_manager, MifareFuzzerSceneStart, SubmenuIndexClassic1k);
+            scene_manager_set_scene_state(
+                app->scene_manager, MifareFuzzerSceneStart, SubmenuIndexClassic1k);
             // set emulator card
             app->card = MifareCardClassic1k;
             mifare_fuzzer_emulator_set_card(app->emulator_view, app->card);
@@ -97,7 +88,8 @@ bool mifare_fuzzer_scene_start_on_event(void* context, SceneManagerEvent event)
             consumed = true;
         } else if(event.event == MifareFuzzerEventClassic4k) {
             // save selected item
-            scene_manager_set_scene_state(app->scene_manager, MifareFuzzerSceneStart, SubmenuIndexClassic4k);
+            scene_manager_set_scene_state(
+                app->scene_manager, MifareFuzzerSceneStart, SubmenuIndexClassic4k);
             // set emulator card
             app->card = MifareCardClassic4k;
             mifare_fuzzer_emulator_set_card(app->emulator_view, app->card);
@@ -106,7 +98,8 @@ bool mifare_fuzzer_scene_start_on_event(void* context, SceneManagerEvent event)
             consumed = true;
         } else if(event.event == MifareFuzzerEventUltralight) {
             // save selected item
-            scene_manager_set_scene_state(app->scene_manager, MifareFuzzerSceneStart, SubmenuIndexUltralight);
+            scene_manager_set_scene_state(
+                app->scene_manager, MifareFuzzerSceneStart, SubmenuIndexUltralight);
             // set emulator card
             app->card = MifareCardUltralight;
             mifare_fuzzer_emulator_set_card(app->emulator_view, app->card);
@@ -114,7 +107,7 @@ bool mifare_fuzzer_scene_start_on_event(void* context, SceneManagerEvent event)
             scene_manager_next_scene(app->scene_manager, MifareFuzzerSceneAttack);
             consumed = true;
         }
-    } else if (event.type == SceneManagerEventTypeTick) {
+    } else if(event.type == SceneManagerEventTypeTick) {
         //FURI_LOG_D(TAG, "mifare_fuzzer_scene_start_on_event() :: SceneManagerEventTypeTick");
         //consumed = true;
     }
@@ -123,7 +116,7 @@ bool mifare_fuzzer_scene_start_on_event(void* context, SceneManagerEvent event)
 }
 
 /// @brief mifare_fuzzer_scene_start_on_exit()
-/// @param context 
+/// @param context
 void mifare_fuzzer_scene_start_on_exit(void* context) {
     //FURI_LOG_D(TAG, "mifare_fuzzer_scene_start_on_exit()");
     MifareFuzzerApp* app = context;

+ 80 - 86
apps_source_code/mifare_fuzzer/views/mifare_fuzzer_emulator.c

@@ -5,9 +5,9 @@
 // Screen is 128 × 64 pixels
 
 /// @brief mifare_fuzzer_emulator_set_callback
-/// @param mifare_fuzzer_emulator 
-/// @param callback 
-/// @param context 
+/// @param mifare_fuzzer_emulator
+/// @param callback
+/// @param context
 void mifare_fuzzer_emulator_set_callback(
     MifareFuzzerEmulator* mifare_fuzzer_emulator,
     MifareFuzzerEmulatorCallback callback,
@@ -20,8 +20,8 @@ void mifare_fuzzer_emulator_set_callback(
 }
 
 /// @brief mifare_fuzzer_emulator_draw_callback
-/// @param canvas 
-/// @param _model 
+/// @param canvas
+/// @param _model
 static void mifare_fuzzer_emulator_draw_callback(Canvas* canvas, void* _model) {
     MifareFuzzerEmulatorModel* model = _model;
     FuriString* furi_string = furi_string_alloc();
@@ -40,7 +40,7 @@ static void mifare_fuzzer_emulator_draw_callback(Canvas* canvas, void* _model) {
     char uid_char[3];
     cpos = 0;
     for(uint8_t i = 0; i < model->nfc_dev_data.uid_len; i++) {
-        if (i > 0) {
+        if(i > 0) {
             uid[cpos] = ':';
             cpos++;
         }
@@ -56,17 +56,17 @@ static void mifare_fuzzer_emulator_draw_callback(Canvas* canvas, void* _model) {
     // Secondary font
     canvas_set_font(canvas, FontSecondary);
     // Card
-    canvas_draw_str(canvas,   4, 22, "c:");
-    canvas_draw_str(canvas,  15, 22, model->mifare_card_dsc);
+    canvas_draw_str(canvas, 4, 22, "c:");
+    canvas_draw_str(canvas, 15, 22, model->mifare_card_dsc);
     // Timing
     furi_string_printf(furi_string, "%d", model->ticks_between_cards);
-    canvas_draw_str(canvas,  90, 22, "t:");
+    canvas_draw_str(canvas, 90, 22, "t:");
     canvas_draw_str(canvas, 100, 22, furi_string_get_cstr(furi_string));
     // Attack
-    canvas_draw_str(canvas,   4, 33, "a:");
-    canvas_draw_str(canvas,  15, 33, model->attack_dsc);
+    canvas_draw_str(canvas, 4, 33, "a:");
+    canvas_draw_str(canvas, 15, 33, model->attack_dsc);
 
-    if (!model->is_attacking) {
+    if(!model->is_attacking) {
         elements_button_left(canvas, "t-1");
         elements_button_center(canvas, "Start");
         elements_button_right(canvas, "t+1");
@@ -80,9 +80,9 @@ static void mifare_fuzzer_emulator_draw_callback(Canvas* canvas, void* _model) {
 }
 
 /// @brief mifare_fuzzer_emulator_input_callback
-/// @param event 
-/// @param context 
-/// @return 
+/// @param event
+/// @param context
+/// @return
 static bool mifare_fuzzer_emulator_input_callback(InputEvent* event, void* context) {
     //FURI_LOG_D(TAG, "mifare_fuzzer_emulator_input_callback()");
     furi_assert(context);
@@ -91,13 +91,15 @@ static bool mifare_fuzzer_emulator_input_callback(InputEvent* event, void* conte
 
     if(event->type == InputTypeShort) {
         if(event->key == InputKeyRight) {
-            if (!mifare_fuzzer_emulator->is_attacking) {
-                mifare_fuzzer_emulator->callback(MifareFuzzerEventIncrementTicks, mifare_fuzzer_emulator->context);
+            if(!mifare_fuzzer_emulator->is_attacking) {
+                mifare_fuzzer_emulator->callback(
+                    MifareFuzzerEventIncrementTicks, mifare_fuzzer_emulator->context);
             };
             consumed = true;
         } else if(event->key == InputKeyLeft) {
-            if (!mifare_fuzzer_emulator->is_attacking) {
-                mifare_fuzzer_emulator->callback(MifareFuzzerEventDecrementTicks, mifare_fuzzer_emulator->context);
+            if(!mifare_fuzzer_emulator->is_attacking) {
+                mifare_fuzzer_emulator->callback(
+                    MifareFuzzerEventDecrementTicks, mifare_fuzzer_emulator->context);
             };
             consumed = true;
         } else if(event->key == InputKeyUp) {
@@ -105,23 +107,22 @@ static bool mifare_fuzzer_emulator_input_callback(InputEvent* event, void* conte
         } else if(event->key == InputKeyDown) {
             consumed = true;
         } else if(event->key == InputKeyOk) {
-
             // Toggle attack
-            if (mifare_fuzzer_emulator->is_attacking) {
+            if(mifare_fuzzer_emulator->is_attacking) {
                 mifare_fuzzer_emulator->is_attacking = false;
-                mifare_fuzzer_emulator->callback(MifareFuzzerEventStopAttack, mifare_fuzzer_emulator->context);
+                mifare_fuzzer_emulator->callback(
+                    MifareFuzzerEventStopAttack, mifare_fuzzer_emulator->context);
             } else {
                 mifare_fuzzer_emulator->is_attacking = true;
-                mifare_fuzzer_emulator->callback(MifareFuzzerEventStartAttack, mifare_fuzzer_emulator->context);
+                mifare_fuzzer_emulator->callback(
+                    MifareFuzzerEventStartAttack, mifare_fuzzer_emulator->context);
             }
 
             with_view_model(
                 mifare_fuzzer_emulator->view,
-                MifareFuzzerEmulatorModel* model,
-                {
-                    model->is_attacking = mifare_fuzzer_emulator->is_attacking;
-                }, true
-            );
+                MifareFuzzerEmulatorModel * model,
+                { model->is_attacking = mifare_fuzzer_emulator->is_attacking; },
+                true);
 
             consumed = true;
         }
@@ -131,7 +132,7 @@ static bool mifare_fuzzer_emulator_input_callback(InputEvent* event, void* conte
 }
 
 /// @brief mifare_fuzzer_emulator_enter_callback
-/// @param context 
+/// @param context
 static void mifare_fuzzer_emulator_enter_callback(void* context) {
     //FURI_LOG_D(TAG, "mifare_fuzzer_emulator_enter_callback()");
     furi_assert(context);
@@ -141,40 +142,34 @@ static void mifare_fuzzer_emulator_enter_callback(void* context) {
     mifare_fuzzer_emulator->is_attacking = false;
     with_view_model(
         mifare_fuzzer_emulator->view,
-        MifareFuzzerEmulatorModel* model,
-        {
-            model->is_attacking = false;
-        },
-        true
-    );
-
+        MifareFuzzerEmulatorModel * model,
+        { model->is_attacking = false; },
+        true);
 }
 
 /// @brief mifare_fuzzer_emulator_alloc
-/// @return 
+/// @return
 MifareFuzzerEmulator* mifare_fuzzer_emulator_alloc() {
     MifareFuzzerEmulator* mifare_fuzzer_emulator = malloc(sizeof(MifareFuzzerEmulator));
     mifare_fuzzer_emulator->view = view_alloc();
     view_set_context(mifare_fuzzer_emulator->view, mifare_fuzzer_emulator);
-    view_allocate_model(mifare_fuzzer_emulator->view, ViewModelTypeLocking, sizeof(MifareFuzzerEmulatorModel));
+    view_allocate_model(
+        mifare_fuzzer_emulator->view, ViewModelTypeLocking, sizeof(MifareFuzzerEmulatorModel));
     view_set_draw_callback(mifare_fuzzer_emulator->view, mifare_fuzzer_emulator_draw_callback);
     view_set_input_callback(mifare_fuzzer_emulator->view, mifare_fuzzer_emulator_input_callback);
     view_set_enter_callback(mifare_fuzzer_emulator->view, mifare_fuzzer_emulator_enter_callback);
 
     with_view_model(
         mifare_fuzzer_emulator->view,
-        MifareFuzzerEmulatorModel* model,
-        {
-            model->title = "Mifare Fuzzer (emulator)";
-        },
-        true
-    );
+        MifareFuzzerEmulatorModel * model,
+        { model->title = "Mifare Fuzzer (emulator)"; },
+        true);
 
     return mifare_fuzzer_emulator;
 }
 
 /// @brief mifare_fuzzer_emulator_free
-/// @param context 
+/// @param context
 void mifare_fuzzer_emulator_free(MifareFuzzerEmulator* context) {
     //FURI_LOG_D(TAG, "mifare_fuzzer_emulator_free()");
     furi_assert(context);
@@ -195,23 +190,25 @@ void mifare_fuzzer_emulator_free(MifareFuzzerEmulator* context) {
 }
 
 /// @brief mifare_fuzzer_emulator_get_view
-/// @param mifare_fuzzer_emulator 
-/// @return 
+/// @param mifare_fuzzer_emulator
+/// @return
 View* mifare_fuzzer_emulator_get_view(MifareFuzzerEmulator* mifare_fuzzer_emulator) {
     furi_assert(mifare_fuzzer_emulator);
     return mifare_fuzzer_emulator->view;
 }
 
 /// @brief Set card type
-/// @param mifare_fuzzer_emulator 
-/// @param mifare_card 
-void mifare_fuzzer_emulator_set_card(MifareFuzzerEmulator* mifare_fuzzer_emulator, MifareCard mifare_card) {
+/// @param mifare_fuzzer_emulator
+/// @param mifare_card
+void mifare_fuzzer_emulator_set_card(
+    MifareFuzzerEmulator* mifare_fuzzer_emulator,
+    MifareCard mifare_card) {
     furi_assert(mifare_fuzzer_emulator);
     furi_assert(mifare_card);
 
     with_view_model(
         mifare_fuzzer_emulator->view,
-        MifareFuzzerEmulatorModel* model,
+        MifareFuzzerEmulatorModel * model,
         {
             model->mifare_card = mifare_card;
             switch(mifare_card) {
@@ -226,21 +223,21 @@ void mifare_fuzzer_emulator_set_card(MifareFuzzerEmulator* mifare_fuzzer_emulato
                 break;
             }
         },
-        true
-    );
-
+        true);
 }
 
 /// @brief Set attack type
-/// @param mifare_fuzzer_emulator 
-/// @param mifare_attack 
-void mifare_fuzzer_emulator_set_attack(MifareFuzzerEmulator* mifare_fuzzer_emulator, MifareFuzzerAttack mifare_attack) {
+/// @param mifare_fuzzer_emulator
+/// @param mifare_attack
+void mifare_fuzzer_emulator_set_attack(
+    MifareFuzzerEmulator* mifare_fuzzer_emulator,
+    MifareFuzzerAttack mifare_attack) {
     furi_assert(mifare_fuzzer_emulator);
     furi_assert(mifare_attack);
 
     with_view_model(
         mifare_fuzzer_emulator->view,
-        MifareFuzzerEmulatorModel* model,
+        MifareFuzzerEmulatorModel * model,
         {
             model->attack = mifare_attack;
             switch(mifare_attack) {
@@ -255,53 +252,50 @@ void mifare_fuzzer_emulator_set_attack(MifareFuzzerEmulator* mifare_fuzzer_emula
                 break;
             }
         },
-        true
-    );
-
+        true);
 }
 
 /// @brief mifare_fuzzer_emulator_set_nfc_dev_data
-/// @param mifare_fuzzer_emulator 
-/// @param nfc_dev_data 
-void mifare_fuzzer_emulator_set_nfc_dev_data(MifareFuzzerEmulator* mifare_fuzzer_emulator, FuriHalNfcDevData nfc_dev_data) {
+/// @param mifare_fuzzer_emulator
+/// @param nfc_dev_data
+void mifare_fuzzer_emulator_set_nfc_dev_data(
+    MifareFuzzerEmulator* mifare_fuzzer_emulator,
+    FuriHalNfcDevData nfc_dev_data) {
     furi_assert(mifare_fuzzer_emulator);
 
     with_view_model(
         mifare_fuzzer_emulator->view,
-        MifareFuzzerEmulatorModel* model,
-        {
-            model->nfc_dev_data = nfc_dev_data;
-        }, true
-    );
+        MifareFuzzerEmulatorModel * model,
+        { model->nfc_dev_data = nfc_dev_data; },
+        true);
 }
 
-
 /// @brief mifare_fuzzer_emulator_set_ticks_between_cards
-/// @param mifare_fuzzer_emulator 
-/// @param ticks 
-void mifare_fuzzer_emulator_set_ticks_between_cards(MifareFuzzerEmulator* mifare_fuzzer_emulator, uint8_t ticks) {
+/// @param mifare_fuzzer_emulator
+/// @param ticks
+void mifare_fuzzer_emulator_set_ticks_between_cards(
+    MifareFuzzerEmulator* mifare_fuzzer_emulator,
+    uint8_t ticks) {
     furi_assert(mifare_fuzzer_emulator);
 
     with_view_model(
         mifare_fuzzer_emulator->view,
-        MifareFuzzerEmulatorModel* model,
-        {
-            model->ticks_between_cards = ticks;
-        }, true
-    );
+        MifareFuzzerEmulatorModel * model,
+        { model->ticks_between_cards = ticks; },
+        true);
 }
 
 /// @brief mifare_fuzzer_emulator_set_tick_num
-/// @param mifare_fuzzer_emulator 
-/// @param tick_num 
-void mifare_fuzzer_emulator_set_tick_num(MifareFuzzerEmulator* mifare_fuzzer_emulator, uint8_t tick_num) {
+/// @param mifare_fuzzer_emulator
+/// @param tick_num
+void mifare_fuzzer_emulator_set_tick_num(
+    MifareFuzzerEmulator* mifare_fuzzer_emulator,
+    uint8_t tick_num) {
     furi_assert(mifare_fuzzer_emulator);
 
     with_view_model(
         mifare_fuzzer_emulator->view,
-        MifareFuzzerEmulatorModel* model,
-        {
-            model->tick_num = tick_num;
-        }, true
-    );
+        MifareFuzzerEmulatorModel * model,
+        { model->tick_num = tick_num; },
+        true);
 }

+ 10 - 10
apps_source_code/mifare_fuzzer/views/mifare_fuzzer_emulator.h

@@ -45,26 +45,26 @@ void mifare_fuzzer_emulator_free(MifareFuzzerEmulator* context);
 
 View* mifare_fuzzer_emulator_get_view(MifareFuzzerEmulator* context);
 
-void mifare_fuzzer_emulator_set_card(MifareFuzzerEmulator* mifare_fuzzer_emulator, MifareCard mifare_card);
-void mifare_fuzzer_emulator_set_attack(MifareFuzzerEmulator* mifare_fuzzer_emulator, MifareFuzzerAttack mifare_attack);
+void mifare_fuzzer_emulator_set_card(
+    MifareFuzzerEmulator* mifare_fuzzer_emulator,
+    MifareCard mifare_card);
+void mifare_fuzzer_emulator_set_attack(
+    MifareFuzzerEmulator* mifare_fuzzer_emulator,
+    MifareFuzzerAttack mifare_attack);
 
 void mifare_fuzzer_emulator_set_callback(
     MifareFuzzerEmulator* mifare_fuzzer_emulator,
     MifareFuzzerEmulatorCallback callback,
-    void* context
-);
+    void* context);
 
 void mifare_fuzzer_emulator_set_nfc_dev_data(
     MifareFuzzerEmulator* mifare_fuzzer_emulator,
-    FuriHalNfcDevData nfc_dev_data
-);
+    FuriHalNfcDevData nfc_dev_data);
 
 void mifare_fuzzer_emulator_set_ticks_between_cards(
     MifareFuzzerEmulator* mifare_fuzzer_emulator,
-    uint8_t ticks
-);
+    uint8_t ticks);
 
 void mifare_fuzzer_emulator_set_tick_num(
     MifareFuzzerEmulator* mifare_fuzzer_emulator,
-    uint8_t tick_num
-);
+    uint8_t tick_num);

+ 1787 - 1619
apps_source_code/nrf24-batch/nrf24batch.c

@@ -2,7 +2,7 @@
 // Written by vad7, 10.01.2023. vad7@yahoo.com
 //
 #include "nrf24batch.h"
- 
+
 #include <furi.h>
 #include <furi_hal.h>
 #include <gui/gui.h>
@@ -13,16 +13,16 @@
 #include <nrf24.h>
 #include <u8g2.h>
 
-#define TAG 		"nrf24batch"
-#define VERSION		"1.9"
+#define TAG "nrf24batch"
+#define VERSION "1.9"
 
-#define SCAN_APP_PATH_FOLDER 	"/ext/nrf24batch"
-#define LOG_FILEEXT	 			".txt"
-#define NRF_READ_TIMEOUT		300UL	// ms
-#define WORK_PERIOD				2		// ms, Timer period
-#define MAX_CHANNEL				125
-#define FONT_5x7_SCREEN_WIDTH 	25
-#define NRF_EN_DYN_ACK			0		// does not work on some nrf24l01+ chips, (0/1)
+#define SCAN_APP_PATH_FOLDER "/ext/nrf24batch"
+#define LOG_FILEEXT ".txt"
+#define NRF_READ_TIMEOUT 300UL // ms
+#define WORK_PERIOD 2 // ms, Timer period
+#define MAX_CHANNEL 125
+#define FONT_5x7_SCREEN_WIDTH 25
+#define NRF_EN_DYN_ACK 0 // does not work on some nrf24l01+ chips, (0/1)
 
 const char SettingsFld_Info[] = "Info:";
 const char SettingsFld_Ch[] = "Ch:";
@@ -37,9 +37,9 @@ const char SettingsFld_WriteStart[] = "Write start:";
 const char SettingsFld_Payload[] = "Payload struct:";
 const char SettingsFld_ReadDefault[] = "R default:";
 const char SettingsFld_WriteDefault[] = "W default:";
-const char SettingsFld_Read[] = "R:";	// Read cmd
-const char SettingsFld_Write[] = "W:";	// Write cmd
-const char SettingsFld_Set[] = "S:";	// Set cmd (like Write but without "Write start" packet)
+const char SettingsFld_Read[] = "R:"; // Read cmd
+const char SettingsFld_Write[] = "W:"; // Write cmd
+const char SettingsFld_Set[] = "S:"; // Set cmd (like Write but without "Write start" packet)
 const char SettingsFld_ReadBatch[] = "RBatch:";
 const char SettingsFld_WriteBatch[] = "WBatch:";
 const char SettingsFld_SetBatch[] = "SBatch:";
@@ -53,23 +53,16 @@ const char AskQuestion_Save[] = "SAVE BATCH?";
 nRF24Batch* APP;
 uint8_t what_doing = 0; // 0 - setup, 1 - cmd list, 2 - read/write/listen cmd
 enum {
-	rwt_set_batch = 0,	// fast send packet without question
-	rwt_read_batch,		// Send read cmd and wait for answer in batch
-	rwt_read_cmd,		// Send read cmd and wait for answer
-	rwt_write_batch,	// Send write cmd (with Write start pkt if available) with a question before it
-	rwt_listen,			// Listen mode (wait incoming pkts)
-	rwt_max
-};
-uint8_t rw_type = rwt_read_batch;	// What to do: rwt_*
-enum {
-	sst_none = 0,
-	sst_sending,
-	sst_receiving,
-	sst_ok,
-	sst_error,
-	sst_timeout
+    rwt_set_batch = 0, // fast send packet without question
+    rwt_read_batch, // Send read cmd and wait for answer in batch
+    rwt_read_cmd, // Send read cmd and wait for answer
+    rwt_write_batch, // Send write cmd (with Write start pkt if available) with a question before it
+    rwt_listen, // Listen mode (wait incoming pkts)
+    rwt_max
 };
-uint8_t send_status = sst_none;// sst_*
+uint8_t rw_type = rwt_read_batch; // What to do: rwt_*
+enum { sst_none = 0, sst_sending, sst_receiving, sst_ok, sst_error, sst_timeout };
+uint8_t send_status = sst_none; // sst_*
 bool cmd_array = false;
 uint8_t cmd_array_idx;
 uint8_t cmd_array_cnt = 0;
@@ -82,1723 +75,1898 @@ char Info[35] = "";
 char file_name[FONT_5x7_SCREEN_WIDTH];
 char ERR_STR[FONT_5x7_SCREEN_WIDTH];
 uint8_t ERR = 0;
-uint8_t NRF_rate; 	// 0 - 250Kbps, 1 - 1Mbps, 2 - 2Mbps
-uint8_t NRF_channel;// 0..125
-uint8_t NRF_DPL;	// 1 - Dynamic Payload Length
-uint8_t NRF_CRC;	// 1 - No, 1 - CRC 1byte, 2 - CRC 2byte
-uint8_t NRF_RETR = ((0b0011<<4) | 0b1111); // Automatic Retransmission, ARD, ARC
-uint8_t NRF_Payload;// Payload len in bytes, 0..32
+uint8_t NRF_rate; // 0 - 250Kbps, 1 - 1Mbps, 2 - 2Mbps
+uint8_t NRF_channel; // 0..125
+uint8_t NRF_DPL; // 1 - Dynamic Payload Length
+uint8_t NRF_CRC; // 1 - No, 1 - CRC 1byte, 2 - CRC 2byte
+uint8_t NRF_RETR = ((0b0011 << 4) | 0b1111); // Automatic Retransmission, ARD, ARC
+uint8_t NRF_Payload; // Payload len in bytes, 0..32
 bool NRF_ERROR = 0;
-uint8_t NRF_INITED = 0;	// 0 - not, 1 - rw, rwt_listen - listen
+uint8_t NRF_INITED = 0; // 0 - not, 1 - rw, rwt_listen - listen
 bool NRF_BOARD_POWER_5V = false;
 uint8_t NRF_last_packet_send_st = 0;
-uint8_t NRF_resend = 1; // number of transaction attempts 
-int8_t  NRF_repeat = 0; // count number of repeated requests (until < NRF_resend)
+uint8_t NRF_resend = 1; // number of transaction attempts
+int8_t NRF_repeat = 0; // count number of repeated requests (until < NRF_resend)
 uint32_t NRF_time;
 uint16_t ReadCmdRepeatPeriod = 10; // s
 bool ReadRepeat = false;
-uint32_t delay_between_pkt = 10;// ms
+uint32_t delay_between_pkt = 10; // ms
 
-uint8_t addr[5];				// nRF24 address, MSB first
-uint8_t addr_len = 0;			// 2..5
+uint8_t addr[5]; // nRF24 address, MSB first
+uint8_t addr_len = 0; // 2..5
 uint8_t payload[32];
 uint8_t payload_receive[32];
-uint8_t payload_struct[32]; 	// sizeof(1..4) in bytes of each field, example: 2,1,1
+uint8_t payload_struct[32]; // sizeof(1..4) in bytes of each field, example: 2,1,1
 uint8_t payload_fields = 0;
-uint8_t payload_size = 0;		// bytes
-uint16_t view_Batch = 0;		// view pos in Batch or inside WriteBatch (Log[view_Batch])
-uint16_t view_WriteBatch = 0;	// view pos of WriteBatch list
-uint8_t setup_cursor = 0;		// cursor position on Setup scr
+uint8_t payload_size = 0; // bytes
+uint16_t view_Batch = 0; // view pos in Batch or inside WriteBatch (Log[view_Batch])
+uint16_t view_WriteBatch = 0; // view pos of WriteBatch list
+uint8_t setup_cursor = 0; // cursor position on Setup scr
 uint8_t Edit = 0;
-char   *Edit_pos;
-char   *Edit_start;
-bool Edit_hex;					// 0 - decimal, 1 - hex
-bool Edited = false;			// list of cmds edited
+char* Edit_pos;
+char* Edit_start;
+bool Edit_hex; // 0 - decimal, 1 - hex
+bool Edited = false; // list of cmds edited
 
 Stream* file_stream = NULL;
-FuriString *ReadDefault = NULL;
-FuriString *WriteDefault = NULL;
-FuriString *WriteStart = NULL;
-FuriString *Constants = NULL;		// text of STR=x
+FuriString* ReadDefault = NULL;
+FuriString* WriteDefault = NULL;
+FuriString* WriteStart = NULL;
+FuriString* Constants = NULL; // text of STR=x
 uint8_t listen_addr[5];
 uint8_t listen_addr_len = 0;
-char *ListenFields = NULL;			// ptr to string: field1,field2,... max 5 field now
+char* ListenFields = NULL; // ptr to string: field1,field2,... max 5 field now
 bool ListenNew;
-FuriHalRtcDateTime ListenLastTime = { 0 };
+FuriHalRtcDateTime ListenLastTime = {0};
 uint32_t ListenPrev = 0;
 uint32_t ListenLast = 0;
-FuriString **Read_cmd = NULL;		// Names of read cmd
+FuriString** Read_cmd = NULL; // Names of read cmd
 uint16_t Read_cmd_Total = 0;
-FuriString **Log = NULL;			// Strings: var=n
+FuriString** Log = NULL; // Strings: var=n
 uint16_t Log_Total = 0;
-FuriString **ReadBatch_cmd = NULL;	// Names of read batch cmd
+FuriString** ReadBatch_cmd = NULL; // Names of read batch cmd
 uint16_t ReadBatch_cmd_Total = 0;
-char *ReadBatch_cmd_curr = NULL;	// =0xFFFFFFFF - finish
-FuriString **WriteBatch_cmd = NULL;	// Names of write batch cmd
+char* ReadBatch_cmd_curr = NULL; // =0xFFFFFFFF - finish
+FuriString** WriteBatch_cmd = NULL; // Names of write batch cmd
 uint16_t WriteBatch_cmd_Total = 0;
-uint16_t WriteBatch_cmd_curr = 0;	// == _Total - finish
-FuriString **SetBatch_cmd = NULL;	// Names of set batch cmd
+uint16_t WriteBatch_cmd_curr = 0; // == _Total - finish
+FuriString** SetBatch_cmd = NULL; // Names of set batch cmd
 uint16_t SetBatch_cmd_Total = 0;
-uint16_t SetBatch_cmd_curr = 0;	// == _Total - finish
+uint16_t SetBatch_cmd_curr = 0; // == _Total - finish
 
-#define POWER_READ_PERIOD	501		// ms
+#define POWER_READ_PERIOD 501 // ms
 uint16_t pwr_read_timer = 0;
 int Current = 0;
 int CurrentStart = 0;
 
-enum {
-	ask_write_batch = 1,
-	ask_save_batch,
-	ask_skip_cmd,
-	ask_return,
-	ask_exit
-};
-uint8_t ask_question = 0;		// 1 - Ask now - ask_*
-uint8_t ask_question_answer = 0;// 0 - no, 1 - yes
+enum { ask_write_batch = 1, ask_save_batch, ask_skip_cmd, ask_return, ask_exit };
+uint8_t ask_question = 0; // 1 - Ask now - ask_*
+uint8_t ask_question_answer = 0; // 0 - no, 1 - yes
 
-static bool ask_fill_screen_buf(void)
-{
-	if(ask_question == ask_write_batch) strcpy(screen_buf, "RUN WRITE BATCH?");
-	else if(ask_question == ask_save_batch) strcpy(screen_buf, "SAVE AS WRITE BATCH?");
-	else if(ask_question == ask_skip_cmd) strcpy(screen_buf, "SKIP CMD?");
-	else if(ask_question == ask_return) strcpy(screen_buf, "RETURN?");
-	else if(ask_question == ask_exit) strcpy(screen_buf, "EXIT?");
-	else return false;
-	strcat(screen_buf, ask_question_answer ? " YES" : " NO");
-	return true;
+static bool ask_fill_screen_buf(void) {
+    if(ask_question == ask_write_batch)
+        strcpy(screen_buf, "RUN WRITE BATCH?");
+    else if(ask_question == ask_save_batch)
+        strcpy(screen_buf, "SAVE AS WRITE BATCH?");
+    else if(ask_question == ask_skip_cmd)
+        strcpy(screen_buf, "SKIP CMD?");
+    else if(ask_question == ask_return)
+        strcpy(screen_buf, "RETURN?");
+    else if(ask_question == ask_exit)
+        strcpy(screen_buf, "EXIT?");
+    else
+        return false;
+    strcat(screen_buf, ask_question_answer ? " YES" : " NO");
+    return true;
 }
 
 //#define MIN(a, b)  ((a<b)?a:b)
 
 static uint8_t GetHexVal(char hex) {
-	return hex == 0 ? 0 : ((uint8_t)hex - ((uint8_t)hex < 58 ? 48 : ((uint8_t)hex < 97 ? 55 : 87)));
+    return hex == 0 ? 0 :
+                      ((uint8_t)hex - ((uint8_t)hex < 58 ? 48 : ((uint8_t)hex < 97 ? 55 : 87)));
 }
 
-static bool is_digit(char *ptr, bool hex)
-{
-	char c = *ptr;
-	if(c >= '0' && c <= '9') return true;
-	if(hex) {
-		c &= ~0x20;
-		if(c >= 'A' && c <= 'F') return true;
-	} else if(c == '-') return true;
-	return false;
+static bool is_digit(char* ptr, bool hex) {
+    char c = *ptr;
+    if(c >= '0' && c <= '9') return true;
+    if(hex) {
+        c &= ~0x20;
+        if(c >= 'A' && c <= 'F') return true;
+    } else if(c == '-')
+        return true;
+    return false;
 }
 
 // Return num bytes in array
-static uint8_t ConvertHexToArray(char * hex, uint8_t * array, uint8_t maxlen) {
-	uint8_t len = 0;
-	while(maxlen) {
-		uint8_t ch = *hex++;
-		if(ch < ' ') break;
-		if(ch < '0') continue;
-		*array++ = (GetHexVal(ch) << 4) + GetHexVal(*hex++);
-		len++;
-		maxlen--;
-	}
-	return len;
+static uint8_t ConvertHexToArray(char* hex, uint8_t* array, uint8_t maxlen) {
+    uint8_t len = 0;
+    while(maxlen) {
+        uint8_t ch = *hex++;
+        if(ch < ' ') break;
+        if(ch < '0') continue;
+        *array++ = (GetHexVal(ch) << 4) + GetHexVal(*hex++);
+        len++;
+        maxlen--;
+    }
+    return len;
 }
 
-int32_t str_to_int(char *p)
-{
-	if(*(p+1) == 'x') { // hex
-		return strtol(p + 2, NULL, 16);
-	} else return strtol(p, NULL, 10);
+int32_t str_to_int(char* p) {
+    if(*(p + 1) == 'x') { // hex
+        return strtol(p + 2, NULL, 16);
+    } else
+        return strtol(p, NULL, 10);
 }
 
-void str_rtrim(char *p)
-{
-	char *delim_col = strchr(p, '\r'); 
-	if(delim_col) *delim_col = '\0';
-	else { 
-		delim_col = strchr(p, '\n'); 
-		if(delim_col) *delim_col = '\0';
-	}
+void str_rtrim(char* p) {
+    char* delim_col = strchr(p, '\r');
+    if(delim_col)
+        *delim_col = '\0';
+    else {
+        delim_col = strchr(p, '\n');
+        if(delim_col) *delim_col = '\0';
+    }
 }
 
-static void add_to_str_hex_bytes(char *out, uint8_t *arr, int bytes)
-{
-	if(bytes <= 0) return;
-	out += strlen(out);
-	do {
-		snprintf(out, 3, "%02X", *arr++);
-		out += 2;
-	} while(--bytes);
+static void add_to_str_hex_bytes(char* out, uint8_t* arr, int bytes) {
+    if(bytes <= 0) return;
+    out += strlen(out);
+    do {
+        snprintf(out, 3, "%02X", *arr++);
+        out += 2;
+    } while(--bytes);
 }
 
 // skip leading zeros
-static void add_to_str_hex_variable(char *out, uint8_t *arr, int size)
-{
-	if(size <= 0) return;
-	out += strlen(out);
-	arr += size - 1;
-	while(*arr == 0 && size > 1) {
-		arr--;
-		size--;
-	}
-	do {
-		snprintf(out, 3, "%02X", *arr--);
-		out += 2;
-	} while(--size);
+static void add_to_str_hex_variable(char* out, uint8_t* arr, int size) {
+    if(size <= 0) return;
+    out += strlen(out);
+    arr += size - 1;
+    while(*arr == 0 && size > 1) {
+        arr--;
+        size--;
+    }
+    do {
+        snprintf(out, 3, "%02X", *arr--);
+        out += 2;
+    } while(--size);
 }
 
-void Edit_insert_digit(char new)
-{
-	if(*Edit_pos == '-') return;
-	if(what_doing <= 1) {
-		if(strlen(Edit_start) < (what_doing == 0 && setup_cursor == 2 ? 3 : 5 * 2)) {
-			memmove(Edit_pos + 1, Edit_pos, strlen(Edit_pos) + 1);
-			*Edit_pos = new;
-		}
-	} else {
-		FuriString *fs = Log[view_Batch];
-		FuriString *ns = furi_string_alloc();
-		if(ns) {
-			uint16_t len = Edit_pos - (char*)furi_string_get_cstr(fs);
-			furi_string_set_n(ns, fs, 0, len);
-			furi_string_cat_printf(ns, "%c", new);
-			furi_string_cat_str(ns, Edit_pos);
-			Log[view_Batch] = ns;
-			Edit_pos = (char*)furi_string_get_cstr(ns);
-			Edit_start = Edit_pos + (Edit_start - (char*)furi_string_get_cstr(fs));
-			Edit_pos += len;
-			furi_string_free(fs);
-		}
-	}
+void Edit_insert_digit(char new) {
+    if(*Edit_pos == '-') return;
+    if(what_doing <= 1) {
+        if(strlen(Edit_start) < (what_doing == 0 && setup_cursor == 2 ? 3 : 5 * 2)) {
+            memmove(Edit_pos + 1, Edit_pos, strlen(Edit_pos) + 1);
+            *Edit_pos = new;
+        }
+    } else {
+        FuriString* fs = Log[view_Batch];
+        FuriString* ns = furi_string_alloc();
+        if(ns) {
+            uint16_t len = Edit_pos - (char*)furi_string_get_cstr(fs);
+            furi_string_set_n(ns, fs, 0, len);
+            furi_string_cat_printf(ns, "%c", new);
+            furi_string_cat_str(ns, Edit_pos);
+            Log[view_Batch] = ns;
+            Edit_pos = (char*)furi_string_get_cstr(ns);
+            Edit_start = Edit_pos + (Edit_start - (char*)furi_string_get_cstr(fs));
+            Edit_pos += len;
+            furi_string_free(fs);
+        }
+    }
 }
 
-int32_t get_payload_receive_field(uint8_t *var, uint8_t size)
-{
-	if(size <= 1) return *var;
-	else if(size == 2) return *(int16_t*)var;
-	else if(size == 3) return (*(uint32_t*)var) & 0xFFFFFF;
-	else return *(int32_t*)var;
+int32_t get_payload_receive_field(uint8_t* var, uint8_t size) {
+    if(size <= 1)
+        return *var;
+    else if(size == 2)
+        return *(int16_t*)var;
+    else if(size == 3)
+        return (*(uint32_t*)var) & 0xFFFFFF;
+    else
+        return *(int32_t*)var;
 }
 
-void free_Log()
-{
-	if(Log_Total) {
-		for(uint16_t i = 0; i < Log_Total; i++) if(Log[i]) furi_string_free(Log[i]);
-		Log_Total = 0;
-	}
-	if(Log) {
-		free(Log);
-		Log = NULL;
-	}
+void free_Log() {
+    if(Log_Total) {
+        for(uint16_t i = 0; i < Log_Total; i++)
+            if(Log[i]) furi_string_free(Log[i]);
+        Log_Total = 0;
+    }
+    if(Log) {
+        free(Log);
+        Log = NULL;
+    }
 }
 
-void free_store(void)
-{
-	if(Constants) {
-		furi_string_free(Constants);
-		Constants = NULL;
-	}
-	if(ReadDefault) {
-		furi_string_free(ReadDefault);
-		ReadDefault = NULL;
-	}
-	if(WriteDefault) {
-		furi_string_free(WriteDefault);
-		WriteDefault = NULL;
-	}
-	if(WriteStart) {
-		furi_string_free(WriteStart);
-		WriteDefault = NULL;
-	}
-	if(ListenFields) {
-		free(ListenFields);
-		ListenFields = NULL;
-	}
-	if(Read_cmd_Total) {
-		for(uint16_t i = 0; i < Read_cmd_Total; i++) furi_string_free(Read_cmd[i]);
-		Read_cmd_Total = 0;
-	}
-	if(Read_cmd) {
-		free(Read_cmd);
-		Read_cmd = NULL;
-	}
-	if(ReadBatch_cmd_Total) {
-		for(uint16_t i = 0; i < ReadBatch_cmd_Total; i++) furi_string_free(ReadBatch_cmd[i]);
-		ReadBatch_cmd_Total = 0;
-	}
-	if(ReadBatch_cmd) {
-		free(ReadBatch_cmd);
-		ReadBatch_cmd = NULL;
-	}
-	if(WriteBatch_cmd_Total) {
-		for(uint16_t i = 0; i < WriteBatch_cmd_Total; i++) furi_string_free(WriteBatch_cmd[i]);
-		WriteBatch_cmd_Total = 0;
-	}
-	if(WriteBatch_cmd) {
-		free(WriteBatch_cmd);
-		WriteBatch_cmd = NULL;
-	}
-	if(SetBatch_cmd_Total) {
-		for(uint16_t i = 0; i < SetBatch_cmd_Total; i++) furi_string_free(SetBatch_cmd[i]);
-		SetBatch_cmd_Total = 0;
-	}
-	if(SetBatch_cmd) {
-		free(SetBatch_cmd);
-		SetBatch_cmd = NULL;
-	}
-	free_Log();
+void free_store(void) {
+    if(Constants) {
+        furi_string_free(Constants);
+        Constants = NULL;
+    }
+    if(ReadDefault) {
+        furi_string_free(ReadDefault);
+        ReadDefault = NULL;
+    }
+    if(WriteDefault) {
+        furi_string_free(WriteDefault);
+        WriteDefault = NULL;
+    }
+    if(WriteStart) {
+        furi_string_free(WriteStart);
+        WriteDefault = NULL;
+    }
+    if(ListenFields) {
+        free(ListenFields);
+        ListenFields = NULL;
+    }
+    if(Read_cmd_Total) {
+        for(uint16_t i = 0; i < Read_cmd_Total; i++) furi_string_free(Read_cmd[i]);
+        Read_cmd_Total = 0;
+    }
+    if(Read_cmd) {
+        free(Read_cmd);
+        Read_cmd = NULL;
+    }
+    if(ReadBatch_cmd_Total) {
+        for(uint16_t i = 0; i < ReadBatch_cmd_Total; i++) furi_string_free(ReadBatch_cmd[i]);
+        ReadBatch_cmd_Total = 0;
+    }
+    if(ReadBatch_cmd) {
+        free(ReadBatch_cmd);
+        ReadBatch_cmd = NULL;
+    }
+    if(WriteBatch_cmd_Total) {
+        for(uint16_t i = 0; i < WriteBatch_cmd_Total; i++) furi_string_free(WriteBatch_cmd[i]);
+        WriteBatch_cmd_Total = 0;
+    }
+    if(WriteBatch_cmd) {
+        free(WriteBatch_cmd);
+        WriteBatch_cmd = NULL;
+    }
+    if(SetBatch_cmd_Total) {
+        for(uint16_t i = 0; i < SetBatch_cmd_Total; i++) furi_string_free(SetBatch_cmd[i]);
+        SetBatch_cmd_Total = 0;
+    }
+    if(SetBatch_cmd) {
+        free(SetBatch_cmd);
+        SetBatch_cmd = NULL;
+    }
+    free_Log();
 }
 
-void update_power(void)
-{
-	Current = furi_hal_power_get_battery_current(FuriHalPowerICFuelGauge) * 1000;
+void update_power(void) {
+    Current = furi_hal_power_get_battery_current(FuriHalPowerICFuelGauge) * 1000;
 }
 
-void check_en_power_5V(void)
-{
-	if(!furi_hal_power_is_otg_enabled() && !furi_hal_power_is_charging()) {
-		FURI_LOG_D("PWR", "NO 5V, TURN ON");
-		notification_message(APP->notification, &sequence_blink_yellow_100);
-		furi_delay_ms(10);
-		update_power();
-		CurrentStart = Current;
-		furi_hal_power_enable_otg();
-		NRF_BOARD_POWER_5V = true;
-		furi_delay_ms(100);
-		NRF_INITED = 0;
-	}
+void check_en_power_5V(void) {
+    if(!furi_hal_power_is_otg_enabled() && !furi_hal_power_is_charging()) {
+        FURI_LOG_D("PWR", "NO 5V, TURN ON");
+        notification_message(APP->notification, &sequence_blink_yellow_100);
+        furi_delay_ms(10);
+        update_power();
+        CurrentStart = Current;
+        furi_hal_power_enable_otg();
+        NRF_BOARD_POWER_5V = true;
+        furi_delay_ms(100);
+        NRF_INITED = 0;
+    }
 }
 
 static bool select_settings_file() {
-	DialogsApp* dialogs = furi_record_open("dialogs");
-	bool result = false;
-	FuriString* path;
-	path = furi_string_alloc();
-	furi_string_set(path, SCAN_APP_PATH_FOLDER);
-	DialogsFileBrowserOptions browser_options;
-	dialog_file_browser_set_basic_options(&browser_options, ".txt", NULL);
-	browser_options.hide_ext = false;
-	bool ret = dialog_file_browser_show(dialogs, path, path, &browser_options);
-	furi_record_close("dialogs");
-	if(ret) {
-		if(!file_stream_open(file_stream, furi_string_get_cstr(path), FSAM_READ_WRITE, FSOM_OPEN_EXISTING)) {
-			FURI_LOG_D(TAG, "Cannot open file \"%s\"", furi_string_get_cstr(path));
-			file_stream_close(file_stream);
-		} else {
-			FURI_LOG_D(TAG, "Open file \"%s\"", furi_string_get_cstr(path));
-			strncpy(file_name, furi_string_get_cstr(path) + sizeof(SCAN_APP_PATH_FOLDER), sizeof(file_name));
-			result = true;
-		}
-	}
-	furi_string_free(path);
-	return result;
+    DialogsApp* dialogs = furi_record_open("dialogs");
+    bool result = false;
+    FuriString* path;
+    path = furi_string_alloc();
+    furi_string_set(path, SCAN_APP_PATH_FOLDER);
+    DialogsFileBrowserOptions browser_options;
+    dialog_file_browser_set_basic_options(&browser_options, ".txt", NULL);
+    browser_options.hide_ext = false;
+    bool ret = dialog_file_browser_show(dialogs, path, path, &browser_options);
+    furi_record_close("dialogs");
+    if(ret) {
+        if(!file_stream_open(
+               file_stream, furi_string_get_cstr(path), FSAM_READ_WRITE, FSOM_OPEN_EXISTING)) {
+            FURI_LOG_D(TAG, "Cannot open file \"%s\"", furi_string_get_cstr(path));
+            file_stream_close(file_stream);
+        } else {
+            FURI_LOG_D(TAG, "Open file \"%s\"", furi_string_get_cstr(path));
+            strncpy(
+                file_name,
+                furi_string_get_cstr(path) + sizeof(SCAN_APP_PATH_FOLDER),
+                sizeof(file_name));
+            result = true;
+        }
+    }
+    furi_string_free(path);
+    return result;
 }
 
-static void prepare_nrf24(void)
-{
-	check_en_power_5V();
-	if(!NRF_INITED || rw_type == rwt_listen || NRF_INITED == rwt_listen) {
-		FURI_LOG_D("NRF", "Prepare");
-		uint8_t adrlen, *adr;
-		if(rw_type == rwt_listen) {
-			adrlen = listen_addr_len;
-			adr = listen_addr;
-			NRF_INITED = rwt_listen;
-		} else {
-			adrlen = addr_len;
-			adr = addr;
-			NRF_INITED = 1;
-		}
-		furi_hal_gpio_write(nrf24_CE_PIN, false);
-		nrf24_set_mac(REG_RX_ADDR_P0, adr, adrlen);
-		uint8_t tmp[5] = { 0 };
-		nrf24_read_reg(nrf24_HANDLE, REG_RX_ADDR_P0, tmp, adrlen);
-		for(uint8_t i = 0; i < adrlen / 2; i++) {
-			uint8_t tb = tmp[i];
-			tmp[i] = tmp[adrlen - i - 1];
-			tmp[adrlen - i - 1] = tb;
-		}
-		NRF_ERROR = memcmp(adr, tmp, adrlen) != 0;
-		if(NRF_ERROR) {
-			NRF_INITED = 0;
-			return;
-		}
-		// EN_DYN_ACK(0x01) option for W_TX_PAYLOAD_NOACK cmd broke AA on some fake nRF24l01+, i.e. set it to 0
-		nrf24_write_reg(nrf24_HANDLE, REG_FEATURE, NRF_EN_DYN_ACK + (NRF_DPL ? 4 : 0)); // Dynamic Payload, Payload with ACK, W_TX_PAYLOAD_NOACK command
-		nrf24_write_reg(nrf24_HANDLE, REG_RF_CH, NRF_channel);
-		nrf24_write_reg(nrf24_HANDLE, REG_RF_SETUP, (NRF_rate == 0 ? 0b00100000 : NRF_rate == 1 ? 0 : 0b00001000) | 0b111); // +TX high power
-		nrf24_write_reg(nrf24_HANDLE, REG_CONFIG, 0x70 | ((NRF_CRC == 1 ? 0b1000 : NRF_CRC == 2 ? 0b1100 : 0))); // Mask all interrupts
-		nrf24_write_reg(nrf24_HANDLE, REG_SETUP_RETR, NRF_RETR); // Automatic Retransmission, ARD<<4 + ARC
-		nrf24_write_reg(nrf24_HANDLE, REG_EN_AA, 0x01); // Auto acknowledgement
-		nrf24_write_reg(nrf24_HANDLE, REG_DYNPD, NRF_DPL ? 0x3F : 0); // Enable dynamic payload reg
-		nrf24_write_reg(nrf24_HANDLE, RX_PW_P0, payload_size);
-		nrf24_set_maclen(nrf24_HANDLE, adrlen);
-		nrf24_set_mac(REG_TX_ADDR, adr, adrlen);
-		nrf24_write_reg(nrf24_HANDLE, REG_EN_RXADDR, 1);
-		//nrf24_set_idle(nrf24_HANDLE);
-	}
-	nrf24_flush_tx(nrf24_HANDLE);
-	nrf24_flush_rx(nrf24_HANDLE);
-	nrf24_write_reg(nrf24_HANDLE, REG_STATUS, MAX_RT | RX_DR | TX_DS);
+static void prepare_nrf24(void) {
+    check_en_power_5V();
+    if(!NRF_INITED || rw_type == rwt_listen || NRF_INITED == rwt_listen) {
+        FURI_LOG_D("NRF", "Prepare");
+        uint8_t adrlen, *adr;
+        if(rw_type == rwt_listen) {
+            adrlen = listen_addr_len;
+            adr = listen_addr;
+            NRF_INITED = rwt_listen;
+        } else {
+            adrlen = addr_len;
+            adr = addr;
+            NRF_INITED = 1;
+        }
+        furi_hal_gpio_write(nrf24_CE_PIN, false);
+        nrf24_set_mac(REG_RX_ADDR_P0, adr, adrlen);
+        uint8_t tmp[5] = {0};
+        nrf24_read_reg(nrf24_HANDLE, REG_RX_ADDR_P0, tmp, adrlen);
+        for(uint8_t i = 0; i < adrlen / 2; i++) {
+            uint8_t tb = tmp[i];
+            tmp[i] = tmp[adrlen - i - 1];
+            tmp[adrlen - i - 1] = tb;
+        }
+        NRF_ERROR = memcmp(adr, tmp, adrlen) != 0;
+        if(NRF_ERROR) {
+            NRF_INITED = 0;
+            return;
+        }
+        // EN_DYN_ACK(0x01) option for W_TX_PAYLOAD_NOACK cmd broke AA on some fake nRF24l01+, i.e. set it to 0
+        nrf24_write_reg(
+            nrf24_HANDLE,
+            REG_FEATURE,
+            NRF_EN_DYN_ACK +
+                (NRF_DPL ? 4 :
+                           0)); // Dynamic Payload, Payload with ACK, W_TX_PAYLOAD_NOACK command
+        nrf24_write_reg(nrf24_HANDLE, REG_RF_CH, NRF_channel);
+        nrf24_write_reg(
+            nrf24_HANDLE,
+            REG_RF_SETUP,
+            (NRF_rate == 0 ? 0b00100000 :
+             NRF_rate == 1 ? 0 :
+                             0b00001000) |
+                0b111); // +TX high power
+        nrf24_write_reg(
+            nrf24_HANDLE,
+            REG_CONFIG,
+            0x70 | ((NRF_CRC == 1 ? 0b1000 :
+                     NRF_CRC == 2 ? 0b1100 :
+                                    0))); // Mask all interrupts
+        nrf24_write_reg(
+            nrf24_HANDLE, REG_SETUP_RETR, NRF_RETR); // Automatic Retransmission, ARD<<4 + ARC
+        nrf24_write_reg(nrf24_HANDLE, REG_EN_AA, 0x01); // Auto acknowledgement
+        nrf24_write_reg(nrf24_HANDLE, REG_DYNPD, NRF_DPL ? 0x3F : 0); // Enable dynamic payload reg
+        nrf24_write_reg(nrf24_HANDLE, RX_PW_P0, payload_size);
+        nrf24_set_maclen(nrf24_HANDLE, adrlen);
+        nrf24_set_mac(REG_TX_ADDR, adr, adrlen);
+        nrf24_write_reg(nrf24_HANDLE, REG_EN_RXADDR, 1);
+        //nrf24_set_idle(nrf24_HANDLE);
+    }
+    nrf24_flush_tx(nrf24_HANDLE);
+    nrf24_flush_rx(nrf24_HANDLE);
+    nrf24_write_reg(nrf24_HANDLE, REG_STATUS, MAX_RT | RX_DR | TX_DS);
 }
 
 // true - ok
-uint8_t nrf24_send_packet()
-{
-	if(furi_log_get_level() == FuriLogLevelDebug) {
-		char buf[65]; buf[0] = 0; add_to_str_hex_bytes(buf, payload, payload_size); FURI_LOG_D(TAG, "SEND: %s", buf);
-	}
-	//nrf24_flush_tx(nrf24_HANDLE);
-	//nrf24_write_reg(nrf24_HANDLE, REG_STATUS, RX_DR | TX_DS | MAX_RT);
-	NRF_last_packet_send_st = nrf24_txpacket(nrf24_HANDLE, payload, payload_size, true); // ACK
-	if(NRF_last_packet_send_st) { 
-		if((rw_type == rwt_read_cmd || rw_type == rwt_read_batch) && send_status == sst_sending) { // Read
-			nrf24_set_rx_mode(nrf24_HANDLE);
-			send_status = sst_receiving; // receiving
-		}
-	} else notification_message(APP->notification, &sequence_blink_red_100);
-	NRF_time = furi_get_tick();
-	FURI_LOG_D(TAG, "Send packet: %d%s", NRF_last_packet_send_st, send_status == sst_receiving ? ", Receiving" : "");
-	return NRF_last_packet_send_st;
+uint8_t nrf24_send_packet() {
+    if(furi_log_get_level() == FuriLogLevelDebug) {
+        char buf[65];
+        buf[0] = 0;
+        add_to_str_hex_bytes(buf, payload, payload_size);
+        FURI_LOG_D(TAG, "SEND: %s", buf);
+    }
+    //nrf24_flush_tx(nrf24_HANDLE);
+    //nrf24_write_reg(nrf24_HANDLE, REG_STATUS, RX_DR | TX_DS | MAX_RT);
+    NRF_last_packet_send_st = nrf24_txpacket(nrf24_HANDLE, payload, payload_size, true); // ACK
+    if(NRF_last_packet_send_st) {
+        if((rw_type == rwt_read_cmd || rw_type == rwt_read_batch) &&
+           send_status == sst_sending) { // Read
+            nrf24_set_rx_mode(nrf24_HANDLE);
+            send_status = sst_receiving; // receiving
+        }
+    } else
+        notification_message(APP->notification, &sequence_blink_red_100);
+    NRF_time = furi_get_tick();
+    FURI_LOG_D(
+        TAG,
+        "Send packet: %d%s",
+        NRF_last_packet_send_st,
+        send_status == sst_receiving ? ", Receiving" : "");
+    return NRF_last_packet_send_st;
 }
 
-uint8_t nrf24_resend_read_packet()
-{
-	if(Log_Total && !cmd_array) {
-		FuriString *str = Log[Log_Total - 1];
-		char *p = strstr(furi_string_get_cstr(str), ": ");
-		if(p) {
-			if(strncmp(p + 2, "0x", 2) == 0) p += 2;
-			furi_string_left(str, p - furi_string_get_cstr(str) + 2);
-		}
-	}
-	return nrf24_send_packet();
+uint8_t nrf24_resend_read_packet() {
+    if(Log_Total && !cmd_array) {
+        FuriString* str = Log[Log_Total - 1];
+        char* p = strstr(furi_string_get_cstr(str), ": ");
+        if(p) {
+            if(strncmp(p + 2, "0x", 2) == 0) p += 2;
+            furi_string_left(str, p - furi_string_get_cstr(str) + 2);
+        }
+    }
+    return nrf24_send_packet();
 }
 
 // true - new packet
 bool nrf24_read_newpacket() {
-	bool found = false;
-	uint8_t packetsize;
-	uint8_t st = nrf24_rxpacket(nrf24_HANDLE, payload_receive, &packetsize, NRF_DPL ? 0 : payload_size);
-	if(st & RX_DR) {
-		NRF_time = furi_get_tick();
-		if(furi_log_get_level() == FuriLogLevelDebug) {
-			char buf[65]; buf[0] = 0; add_to_str_hex_bytes(buf, payload_receive, packetsize); FURI_LOG_D(TAG, "READ(%X): %s", st, buf);
-		}
-		if(Log_Total) {
-			FuriString *str = Log[Log_Total - 1];
-			uint8_t size = 1;
-			char *p = strchr((char*)furi_string_get_cstr(str), '*');
-			if(p) {
-				p++;
-				if(*p == '=') size = 0; // string
-				else {
-					size = *p - '0';
-					if(size > 4) size = 0;
-				}
-			}
-			int32_t var = get_payload_receive_field(payload_receive, size);
-			//FURI_LOG_D(TAG, "VAR(%d): %ld", size, var);
-			if(size == 0) furi_string_cat_printf(str, "%c", (char)var);
-			else {
-				char hex[9];
-				hex[0] = '\0';
-				add_to_str_hex_variable(hex, (uint8_t*)&var, size);
-				if((cmd_array && cmd_array_hex) || furi_string_end_with_str(str, "0x")) furi_string_cat_str(str, hex);
-				else {
-					if(var >= 0 && var <= 9) furi_string_cat_printf(str, "%ld", var);
-					else furi_string_cat_printf(str, "%ld (%s)", var, hex);
-				}
-			}
-			if(cmd_array) {
-				if(--cmd_array_cnt) {
-					furi_string_cat_str(str, ",");
-					if(cmd_array_hex) furi_string_cat_str(str, "0x");
-					payload[cmd_array_idx] += size;	// next array element
-					NRF_repeat = -1;
-					send_status = sst_sending;	// Will be send after delay_between_pkt
-				} else send_status = sst_ok;
-			} else {
-				if(size == 0) { // string, until '\0'
-					if(var == 0) send_status = sst_ok;
-				} else send_status = sst_ok;
-			}
-		}
-		//notification_message(APP->notification, &sequence_blink_white_100);
-		found = true;
-	} else if(st & 0x80) { // NRF24 hardware error
-		NRF_ERROR = 1;
-		NRF_INITED = 0;
-	}
-	return found;
+    bool found = false;
+    uint8_t packetsize;
+    uint8_t st =
+        nrf24_rxpacket(nrf24_HANDLE, payload_receive, &packetsize, NRF_DPL ? 0 : payload_size);
+    if(st & RX_DR) {
+        NRF_time = furi_get_tick();
+        if(furi_log_get_level() == FuriLogLevelDebug) {
+            char buf[65];
+            buf[0] = 0;
+            add_to_str_hex_bytes(buf, payload_receive, packetsize);
+            FURI_LOG_D(TAG, "READ(%X): %s", st, buf);
+        }
+        if(Log_Total) {
+            FuriString* str = Log[Log_Total - 1];
+            uint8_t size = 1;
+            char* p = strchr((char*)furi_string_get_cstr(str), '*');
+            if(p) {
+                p++;
+                if(*p == '=')
+                    size = 0; // string
+                else {
+                    size = *p - '0';
+                    if(size > 4) size = 0;
+                }
+            }
+            int32_t var = get_payload_receive_field(payload_receive, size);
+            //FURI_LOG_D(TAG, "VAR(%d): %ld", size, var);
+            if(size == 0)
+                furi_string_cat_printf(str, "%c", (char)var);
+            else {
+                char hex[9];
+                hex[0] = '\0';
+                add_to_str_hex_variable(hex, (uint8_t*)&var, size);
+                if((cmd_array && cmd_array_hex) || furi_string_end_with_str(str, "0x"))
+                    furi_string_cat_str(str, hex);
+                else {
+                    if(var >= 0 && var <= 9)
+                        furi_string_cat_printf(str, "%ld", var);
+                    else
+                        furi_string_cat_printf(str, "%ld (%s)", var, hex);
+                }
+            }
+            if(cmd_array) {
+                if(--cmd_array_cnt) {
+                    furi_string_cat_str(str, ",");
+                    if(cmd_array_hex) furi_string_cat_str(str, "0x");
+                    payload[cmd_array_idx] += size; // next array element
+                    NRF_repeat = -1;
+                    send_status = sst_sending; // Will be send after delay_between_pkt
+                } else
+                    send_status = sst_ok;
+            } else {
+                if(size == 0) { // string, until '\0'
+                    if(var == 0) send_status = sst_ok;
+                } else
+                    send_status = sst_ok;
+            }
+        }
+        //notification_message(APP->notification, &sequence_blink_white_100);
+        found = true;
+    } else if(st & 0x80) { // NRF24 hardware error
+        NRF_ERROR = 1;
+        NRF_INITED = 0;
+    }
+    return found;
 }
 
 // Search in constatnt pull (Const1=n; Const2=n;...)
 // VAR_EMPTY - not found
-int32_t subs_constant(char *p, uint8_t len)
-{
-	char *c = (char*)furi_string_get_cstr(Constants);
-	while((c = strchr(c, *p))) {
-		if(strncmp(c, p, len) != 0) {
-			c++;
-			continue;
-		}
-		if(c == (char*)furi_string_get_cstr(Constants) || *(c-1) == ';' ||  *(c-1) <= ' ') {
-			c += len;
-			if(*c == '=') {
-				c++;
-				return str_to_int(c);
-			}
-		} else c += len;
-	}
-	return VAR_EMPTY;
+int32_t subs_constant(char* p, uint8_t len) {
+    char* c = (char*)furi_string_get_cstr(Constants);
+    while((c = strchr(c, *p))) {
+        if(strncmp(c, p, len) != 0) {
+            c++;
+            continue;
+        }
+        if(c == (char*)furi_string_get_cstr(Constants) || *(c - 1) == ';' || *(c - 1) <= ' ') {
+            c += len;
+            if(*c == '=') {
+                c++;
+                return str_to_int(c);
+            }
+        } else
+            c += len;
+    }
+    return VAR_EMPTY;
 }
 
 // fill payload with default = p
 // if var_n = VAR_EMPTY - skip filling var_*
-bool fill_payload(char *p, uint8_t *idx_i, int32_t var_n)
-{
-	if(idx_i) *idx_i = 255;
-	uint8_t fld = 0; // field #
-	uint8_t idx = 0; // byte index
-	do {
-		int32_t b = 0;
-		char *end = strchr(p, ',');
-		if(*p >= '0' && *p <= '9') { // Number found
-			b = str_to_int(p);
-		} else if(*p == 'i' && *(p + 1) == ':') { // 'i:' array index
-			b = str_to_int(p + 2);
-		 	if(idx_i) *idx_i = idx;
-		} else if(*p == 'n' && *(p + 1) < '0') { // var_n
-			if(var_n != VAR_EMPTY) b = var_n;
-		} else if(*p >= 'A') { // constant found
-			uint8_t len;
-			if(end) len =  end - p;
-			else {
-				len = strlen(p);
-				if(*(p + len - 1) == '#') len--;
-			}
-			b = subs_constant(p, len);
-			if(b == VAR_EMPTY) {
-				ERR = 1;
-				memset(ERR_STR, 0, sizeof(ERR_STR));
-				strcpy(ERR_STR, "No ");
-				strncpy(ERR_STR + strlen(ERR_STR), p, sizeof(ERR_STR) - 4);
-				FURI_LOG_D(TAG, "Constant not found: %s", p);
-				return false;
-			}
-		} else if(end == p) {
-			idx += payload_struct[fld];
-		} else if(*p == '#') { // value in Hexadecimal, end string
-			break;
-		} else {
-			ERR = 2;
-			strcpy(ERR_STR, "char: ");
-			uint8_t l = strlen(ERR_STR);
-			ERR_STR[l] = *p;
-			ERR_STR[l+1] = '\0';
-			FURI_LOG_D(TAG, "Wrong format char(%c)", *p);
-			return false;
-		}
-		if(end != p) {
-			payload[idx++] = b;
-			if(payload_struct[fld] > 1) payload[idx++] = b >> 8;
-			if(payload_struct[fld] > 2) payload[idx++] = b >> 16;
-			if(payload_struct[fld] > 3) payload[idx++] = b >> 24;
-		}
-		if(++fld == payload_fields || idx >= sizeof(payload) || end == NULL) break;
-		p = end + 1;
-	} while(1);
-	return true;
+bool fill_payload(char* p, uint8_t* idx_i, int32_t var_n) {
+    if(idx_i) *idx_i = 255;
+    uint8_t fld = 0; // field #
+    uint8_t idx = 0; // byte index
+    do {
+        int32_t b = 0;
+        char* end = strchr(p, ',');
+        if(*p >= '0' && *p <= '9') { // Number found
+            b = str_to_int(p);
+        } else if(*p == 'i' && *(p + 1) == ':') { // 'i:' array index
+            b = str_to_int(p + 2);
+            if(idx_i) *idx_i = idx;
+        } else if(*p == 'n' && *(p + 1) < '0') { // var_n
+            if(var_n != VAR_EMPTY) b = var_n;
+        } else if(*p >= 'A') { // constant found
+            uint8_t len;
+            if(end)
+                len = end - p;
+            else {
+                len = strlen(p);
+                if(*(p + len - 1) == '#') len--;
+            }
+            b = subs_constant(p, len);
+            if(b == VAR_EMPTY) {
+                ERR = 1;
+                memset(ERR_STR, 0, sizeof(ERR_STR));
+                strcpy(ERR_STR, "No ");
+                strncpy(ERR_STR + strlen(ERR_STR), p, sizeof(ERR_STR) - 4);
+                FURI_LOG_D(TAG, "Constant not found: %s", p);
+                return false;
+            }
+        } else if(end == p) {
+            idx += payload_struct[fld];
+        } else if(*p == '#') { // value in Hexadecimal, end string
+            break;
+        } else {
+            ERR = 2;
+            strcpy(ERR_STR, "char: ");
+            uint8_t l = strlen(ERR_STR);
+            ERR_STR[l] = *p;
+            ERR_STR[l + 1] = '\0';
+            FURI_LOG_D(TAG, "Wrong format char(%c)", *p);
+            return false;
+        }
+        if(end != p) {
+            payload[idx++] = b;
+            if(payload_struct[fld] > 1) payload[idx++] = b >> 8;
+            if(payload_struct[fld] > 2) payload[idx++] = b >> 16;
+            if(payload_struct[fld] > 3) payload[idx++] = b >> 24;
+        }
+        if(++fld == payload_fields || idx >= sizeof(payload) || end == NULL) break;
+        p = end + 1;
+    } while(1);
+    return true;
 }
 
 // Cmd: "name=payload"
-bool Run_Read_cmd(FuriString *cmd)
-{
-	char *p = (char*)furi_string_get_cstr(cmd);
-	p = strchr(p, '=');
-	if(p == NULL) return false;
-	if(Log == NULL) Log = malloc(sizeof(Log));
-	else Log = realloc(Log, sizeof(Log) * (Log_Total + 1));
-	if(Log == NULL) {
-		ERR = 3;
-		strcpy(ERR_STR, "Memory low");
-		FURI_LOG_D(TAG, ERR_STR);
-		return false;
-	}
-	FuriString *fs = furi_string_alloc();
-	furi_string_set_strn(fs, (char*)furi_string_get_cstr(cmd), p - (char*)furi_string_get_cstr(cmd));
-	furi_string_cat_str(fs, ": ");
-	bool hexval;
-	if((hexval = *(p + strlen(p) - 1) == '#')) furi_string_cat_str(fs, "0x"); // value in Hex format
-	Log[Log_Total++] = fs;
-	p++;
-	memset(payload, 0, sizeof(payload));
-	if(ReadDefault && !fill_payload((char*)furi_string_get_cstr(ReadDefault), NULL, VAR_EMPTY)) return false;
-	if(!fill_payload(p, &cmd_array_idx, VAR_EMPTY)) return false;
-	memset(payload_receive, 0, sizeof(payload_receive));
-	cmd_array = false;
-	if(*(p - 2) == ']' && cmd_array_idx != 255) { // array
-		p = strchr(furi_string_get_cstr(cmd), '[');
-		if(p) {
-			cmd_array_cnt = str_to_int(p + 1);
-			if(cmd_array_cnt > 1) {
-				cmd_array_hex = hexval;
-				cmd_array = true; // array
-			}
-		}
-	}
-	prepare_nrf24();
-	if(NRF_ERROR) return false;
-	what_doing = 2;
-	NRF_repeat = 0;
-	send_status = sst_sending; // Read - sending
-	nrf24_send_packet();
-	return true;
+bool Run_Read_cmd(FuriString* cmd) {
+    char* p = (char*)furi_string_get_cstr(cmd);
+    p = strchr(p, '=');
+    if(p == NULL) return false;
+    if(Log == NULL)
+        Log = malloc(sizeof(Log));
+    else
+        Log = realloc(Log, sizeof(Log) * (Log_Total + 1));
+    if(Log == NULL) {
+        ERR = 3;
+        strcpy(ERR_STR, "Memory low");
+        FURI_LOG_D(TAG, ERR_STR);
+        return false;
+    }
+    FuriString* fs = furi_string_alloc();
+    furi_string_set_strn(
+        fs, (char*)furi_string_get_cstr(cmd), p - (char*)furi_string_get_cstr(cmd));
+    furi_string_cat_str(fs, ": ");
+    bool hexval;
+    if((hexval = *(p + strlen(p) - 1) == '#'))
+        furi_string_cat_str(fs, "0x"); // value in Hex format
+    Log[Log_Total++] = fs;
+    p++;
+    memset(payload, 0, sizeof(payload));
+    if(ReadDefault && !fill_payload((char*)furi_string_get_cstr(ReadDefault), NULL, VAR_EMPTY))
+        return false;
+    if(!fill_payload(p, &cmd_array_idx, VAR_EMPTY)) return false;
+    memset(payload_receive, 0, sizeof(payload_receive));
+    cmd_array = false;
+    if(*(p - 2) == ']' && cmd_array_idx != 255) { // array
+        p = strchr(furi_string_get_cstr(cmd), '[');
+        if(p) {
+            cmd_array_cnt = str_to_int(p + 1);
+            if(cmd_array_cnt > 1) {
+                cmd_array_hex = hexval;
+                cmd_array = true; // array
+            }
+        }
+    }
+    prepare_nrf24();
+    if(NRF_ERROR) return false;
+    what_doing = 2;
+    NRF_repeat = 0;
+    send_status = sst_sending; // Read - sending
+    nrf24_send_packet();
+    return true;
 }
 
 // run commands one by one, true - command running
-bool Run_ReadBatch_cmd(FuriString *cmd)
-{
-	char *p;
-	if(cmd) {
-		p = strchr((char*)furi_string_get_cstr(cmd), ':');
-		if(p == NULL) {
-			ERR = 5;
-			strcpy(ERR_STR, "WRONG FORMAT");
-			return false;
-		}
-		p += 2;
-		ReadBatch_cmd_curr = NULL;
-		free_Log();
-	} else {
-		if(ReadBatch_cmd_curr) p = ReadBatch_cmd_curr; else return false;
-	}
-	char *end = strchr(p, ';');
-	uint8_t len;
-	if(end) len = end - p;
-	else {
-		str_rtrim(p);
-		len = strlen(p);
-	}
-	for(uint16_t i = 0; i < Read_cmd_Total; i++) {
-		FuriString *fs = Read_cmd[i];
-		if(strncmp((char*)furi_string_get_cstr(fs), p, len) == 0) {
-			char c = *((char*)furi_string_get_cstr(fs) + len);
-			if(c != '=' && c != '*' && c != '[') continue;
-			if(end) ReadBatch_cmd_curr = end + 1; else ReadBatch_cmd_curr = (char*)0xFFFFFFFF;
-			if(!Run_Read_cmd(fs)) break;
-			return true;
-		}
-	}
-	if(NRF_ERROR) return false;
-	if(ERR == 0) {
-		ERR = 4;
-		strcpy(ERR_STR, "NOT FOUND");
-		FuriString *fs = furi_string_alloc();
-		furi_string_set_strn(fs, p, len);
-		Log[Log_Total++] = fs;
-		FURI_LOG_D(TAG, "CMD %s: %s", ERR_STR, p);
-	}
-	view_Batch = Log_Total ? Log_Total - 1 : 0;
-	return false;
+bool Run_ReadBatch_cmd(FuriString* cmd) {
+    char* p;
+    if(cmd) {
+        p = strchr((char*)furi_string_get_cstr(cmd), ':');
+        if(p == NULL) {
+            ERR = 5;
+            strcpy(ERR_STR, "WRONG FORMAT");
+            return false;
+        }
+        p += 2;
+        ReadBatch_cmd_curr = NULL;
+        free_Log();
+    } else {
+        if(ReadBatch_cmd_curr)
+            p = ReadBatch_cmd_curr;
+        else
+            return false;
+    }
+    char* end = strchr(p, ';');
+    uint8_t len;
+    if(end)
+        len = end - p;
+    else {
+        str_rtrim(p);
+        len = strlen(p);
+    }
+    for(uint16_t i = 0; i < Read_cmd_Total; i++) {
+        FuriString* fs = Read_cmd[i];
+        if(strncmp((char*)furi_string_get_cstr(fs), p, len) == 0) {
+            char c = *((char*)furi_string_get_cstr(fs) + len);
+            if(c != '=' && c != '*' && c != '[') continue;
+            if(end)
+                ReadBatch_cmd_curr = end + 1;
+            else
+                ReadBatch_cmd_curr = (char*)0xFFFFFFFF;
+            if(!Run_Read_cmd(fs)) break;
+            return true;
+        }
+    }
+    if(NRF_ERROR) return false;
+    if(ERR == 0) {
+        ERR = 4;
+        strcpy(ERR_STR, "NOT FOUND");
+        FuriString* fs = furi_string_alloc();
+        furi_string_set_strn(fs, p, len);
+        Log[Log_Total++] = fs;
+        FURI_LOG_D(TAG, "CMD %s: %s", ERR_STR, p);
+    }
+    view_Batch = Log_Total ? Log_Total - 1 : 0;
+    return false;
 }
 
-void Prepare_Write_cmd(FuriString *cmd)
-{
-	free_Log();
-	if(cmd == NULL) return;
-	char *end, *p = strchr((char*)furi_string_get_cstr(cmd), ':');
-	if(p == NULL) {
-		ERR = 8;
-		strcpy(ERR_STR, "Wrong batch");
-		FURI_LOG_D(TAG, ERR_STR);
-		return;
-	}
-	p += 2;
-	Log = malloc(sizeof(Log));
-	do {
-		end = strchr(p, ';');
-		uint8_t len;
-		if(end) {
-			len = end - p;
-			end++;
-		} else {
-			str_rtrim(p);
-			len = strlen(p);
-		}
-		FuriString *fs = furi_string_alloc();
-		if(Log_Total) Log = realloc(Log, sizeof(Log) * (Log_Total + 1));
-		if(Log == NULL) {
-			ERR = 3;
-			strcpy(ERR_STR, "Memory low");
-			FURI_LOG_D(TAG, ERR_STR);
-			return;
-		}
-		furi_string_set_strn(fs, p, len);
-		Log[Log_Total++] = fs;
-	} while((p = end));
+void Prepare_Write_cmd(FuriString* cmd) {
+    free_Log();
+    if(cmd == NULL) return;
+    char *end, *p = strchr((char*)furi_string_get_cstr(cmd), ':');
+    if(p == NULL) {
+        ERR = 8;
+        strcpy(ERR_STR, "Wrong batch");
+        FURI_LOG_D(TAG, ERR_STR);
+        return;
+    }
+    p += 2;
+    Log = malloc(sizeof(Log));
+    do {
+        end = strchr(p, ';');
+        uint8_t len;
+        if(end) {
+            len = end - p;
+            end++;
+        } else {
+            str_rtrim(p);
+            len = strlen(p);
+        }
+        FuriString* fs = furi_string_alloc();
+        if(Log_Total) Log = realloc(Log, sizeof(Log) * (Log_Total + 1));
+        if(Log == NULL) {
+            ERR = 3;
+            strcpy(ERR_STR, "Memory low");
+            FURI_LOG_D(TAG, ERR_STR);
+            return;
+        }
+        furi_string_set_strn(fs, p, len);
+        Log[Log_Total++] = fs;
+    } while((p = end));
 }
 
 // Write / Set batch
-bool Run_WriteBatch_cmd()
-{
-	if(Log_Total == 0) return false;
-	uint16_t cmd_curr = rw_type == rwt_write_batch ? WriteBatch_cmd_curr : SetBatch_cmd_curr;
-	if(cmd_curr == 0) { // first
-		prepare_nrf24();
-		if(NRF_ERROR) return false;
-		if(rw_type == rwt_write_batch && WriteStart) {
-			if(!fill_payload((char*)furi_string_get_cstr(WriteStart), NULL, VAR_EMPTY)) return false;
-			send_status = sst_sending;
-			if(!nrf24_send_packet()) return false;
-		}
-	}
-	char *p = (char*)furi_string_get_cstr(Log[cmd_curr]);
-	uint16_t len = furi_string_size(Log[cmd_curr]);
-	char *arr = NULL;
-	cmd_array = false;
-	int32_t new = 0;
-	for(uint16_t i = 0; i < len; i++) {
-		if(p[i] == '=') {
-			len = i;
-			char *p2 = p + i + 1;
-			if(*p2 == '{') {
-				arr = ++p2; // array
-				cmd_array = true;
-			}
-			new = str_to_int(p2);
-			break;
-		}
-	}
-	FURI_LOG_D(TAG, "%cBatch: =%d, (%d)%s", rw_type == rwt_write_batch ? 'W' : 'S', (int)new, len, p);
-	char *w, *delim_col, i, size;
-	FuriString* str = furi_string_alloc();
-	stream_rewind(file_stream);
-	while(stream_read_line(file_stream, str)) {
-		w = (char*)furi_string_get_cstr(str);
-		if(strncmp(w, SettingsFld_Write, sizeof(SettingsFld_Write)-1) == 0) w +=  sizeof(SettingsFld_Write);
-		else if(strncmp(w, SettingsFld_Set, sizeof(SettingsFld_Set)-1) == 0) w +=  sizeof(SettingsFld_Set);
-		else continue;
-		delim_col = strchr(w, '=');
-		if(delim_col == NULL) continue;
-		size = 1;
-		if(*(delim_col - 2) == '*') {
-			if(len != delim_col - w - 2) continue;
-			size = *(delim_col - 1) - '0';
-			new = new & (size == 1 ? 0xFF : size == 2 ? 0xFFFF : size == 3 ? 0xFFFFFF : 0xFFFFFFFF);
-		} else if(len != delim_col - w) continue;
-		if(strncmp(p, w, len) != 0) continue;
-		delim_col++;
-		str_rtrim(delim_col);
-		cmd_array_cnt = 255;
-		do {
-			memset(payload, 0, sizeof(payload));
-			if(WriteDefault && !fill_payload((char*)furi_string_get_cstr(WriteDefault), NULL, new)) {
-				view_Batch = cmd_curr;
-				return false;
-			}
-			if(!fill_payload(delim_col, &cmd_array_idx, VAR_EMPTY)) {
-				view_Batch = cmd_curr;
-				return false;
-			}
-			if(cmd_array && cmd_array_idx != 255) {
- 				if(cmd_array_cnt != 255) payload[cmd_array_idx] = cmd_array_cnt;
-			} else cmd_array = false;
-			send_status = sst_sending;
-			NRF_repeat = 0;
-			i = 0;
-			do {
-				if(nrf24_send_packet()) break;
-				furi_delay_ms(delay_between_pkt);
-			} while(i++ < NRF_resend);
-			if(i < NRF_resend || i == 0) { // ok
-				if(cmd_array) { // array
-					for(; arr != NULL;) {
-						if(*arr == ',') break;
-						if(*arr == '}' || *arr < ' ') arr = NULL; else arr++;
-					}
-					if(arr == NULL) {
-						send_status = sst_ok; 
-						break;
-					}
-					arr++;
-					new = str_to_int(arr);
-					cmd_array_cnt = payload[cmd_array_idx] + size;
-					//furi_delay_ms(delay_between_pkt); // do it fast
-					continue; // send next array element
-				} else send_status = sst_ok; 
-			}
-			break;
-		} while(1);
-		if(send_status != sst_ok) { 
-			send_status = sst_error;
-			view_Batch = cmd_curr;
-			return false;
-		}
-		return true;
-	}
-	ERR = 7;
-	strcpy(ERR_STR, "NOT FOUND!");
-	send_status = sst_error;
-	view_Batch = cmd_curr;
-	return false;
+bool Run_WriteBatch_cmd() {
+    if(Log_Total == 0) return false;
+    uint16_t cmd_curr = rw_type == rwt_write_batch ? WriteBatch_cmd_curr : SetBatch_cmd_curr;
+    if(cmd_curr == 0) { // first
+        prepare_nrf24();
+        if(NRF_ERROR) return false;
+        if(rw_type == rwt_write_batch && WriteStart) {
+            if(!fill_payload((char*)furi_string_get_cstr(WriteStart), NULL, VAR_EMPTY))
+                return false;
+            send_status = sst_sending;
+            if(!nrf24_send_packet()) return false;
+        }
+    }
+    char* p = (char*)furi_string_get_cstr(Log[cmd_curr]);
+    uint16_t len = furi_string_size(Log[cmd_curr]);
+    char* arr = NULL;
+    cmd_array = false;
+    int32_t new = 0;
+    for(uint16_t i = 0; i < len; i++) {
+        if(p[i] == '=') {
+            len = i;
+            char* p2 = p + i + 1;
+            if(*p2 == '{') {
+                arr = ++p2; // array
+                cmd_array = true;
+            }
+            new = str_to_int(p2);
+            break;
+        }
+    }
+    FURI_LOG_D(
+        TAG, "%cBatch: =%d, (%d)%s", rw_type == rwt_write_batch ? 'W' : 'S', (int)new, len, p);
+    char *w, *delim_col, i, size;
+    FuriString* str = furi_string_alloc();
+    stream_rewind(file_stream);
+    while(stream_read_line(file_stream, str)) {
+        w = (char*)furi_string_get_cstr(str);
+        if(strncmp(w, SettingsFld_Write, sizeof(SettingsFld_Write) - 1) == 0)
+            w += sizeof(SettingsFld_Write);
+        else if(strncmp(w, SettingsFld_Set, sizeof(SettingsFld_Set) - 1) == 0)
+            w += sizeof(SettingsFld_Set);
+        else
+            continue;
+        delim_col = strchr(w, '=');
+        if(delim_col == NULL) continue;
+        size = 1;
+        if(*(delim_col - 2) == '*') {
+            if(len != delim_col - w - 2) continue;
+            size = *(delim_col - 1) - '0';
+            new = new&(size == 1 ? 0xFF : size == 2 ? 0xFFFF : size == 3 ? 0xFFFFFF : 0xFFFFFFFF);
+        } else if(len != delim_col - w)
+            continue;
+        if(strncmp(p, w, len) != 0) continue;
+        delim_col++;
+        str_rtrim(delim_col);
+        cmd_array_cnt = 255;
+        do {
+            memset(payload, 0, sizeof(payload));
+            if(WriteDefault &&
+               !fill_payload((char*)furi_string_get_cstr(WriteDefault), NULL, new)) {
+                view_Batch = cmd_curr;
+                return false;
+            }
+            if(!fill_payload(delim_col, &cmd_array_idx, VAR_EMPTY)) {
+                view_Batch = cmd_curr;
+                return false;
+            }
+            if(cmd_array && cmd_array_idx != 255) {
+                if(cmd_array_cnt != 255) payload[cmd_array_idx] = cmd_array_cnt;
+            } else
+                cmd_array = false;
+            send_status = sst_sending;
+            NRF_repeat = 0;
+            i = 0;
+            do {
+                if(nrf24_send_packet()) break;
+                furi_delay_ms(delay_between_pkt);
+            } while(i++ < NRF_resend);
+            if(i < NRF_resend || i == 0) { // ok
+                if(cmd_array) { // array
+                    for(; arr != NULL;) {
+                        if(*arr == ',') break;
+                        if(*arr == '}' || *arr < ' ')
+                            arr = NULL;
+                        else
+                            arr++;
+                    }
+                    if(arr == NULL) {
+                        send_status = sst_ok;
+                        break;
+                    }
+                    arr++;
+                    new = str_to_int(arr);
+                    cmd_array_cnt = payload[cmd_array_idx] + size;
+                    //furi_delay_ms(delay_between_pkt); // do it fast
+                    continue; // send next array element
+                } else
+                    send_status = sst_ok;
+            }
+            break;
+        } while(1);
+        if(send_status != sst_ok) {
+            send_status = sst_error;
+            view_Batch = cmd_curr;
+            return false;
+        }
+        return true;
+    }
+    ERR = 7;
+    strcpy(ERR_STR, "NOT FOUND!");
+    send_status = sst_error;
+    view_Batch = cmd_curr;
+    return false;
 }
 
 // Return 0 - success, otherwise an error
 static uint8_t load_settings_file() {
-	uint8_t err = 0;
-	FURI_LOG_D(TAG, "Loading settings file");
-	FuriString* str = furi_string_alloc();
-	free_store();
-	Info[0] = '\0';
-	NRF_INITED = false;
-	while(stream_read_line(file_stream, str)) {
-		char *p = (char*)furi_string_get_cstr(str);
-		if(*p <= '!' || *p == ';') continue;
-		//char* delim_eq = strchr(p, '=');
-		char *delim_col = strchr(p, ':');
-		if(delim_col == NULL) { // Constant found - no ':'
-			if(Constants == NULL) {
-				Constants = furi_string_alloc_set(str);
-			} else furi_string_cat(Constants, str);
-		} else {
-			str_rtrim(p);
-			if(strncmp(p, SettingsFld_Rate, sizeof(SettingsFld_Rate)-1) == 0) {
-				NRF_rate = str_to_int(p + sizeof(SettingsFld_Rate));
-			} else if(strncmp(p, SettingsFld_Info, sizeof(SettingsFld_Info)-1) == 0) {
-				strncpy(Info, p + sizeof(SettingsFld_Info), sizeof(Info)-1);
-			} else if(strncmp(p, SettingsFld_Ch, sizeof(SettingsFld_Ch)-1) == 0) {
-				NRF_channel = str_to_int(p + sizeof(SettingsFld_Ch));
-			} else if(strncmp(p, SettingsFld_Address, sizeof(SettingsFld_Address)-1) == 0) {
-				p += sizeof(SettingsFld_Address);
-				addr_len = ConvertHexToArray(p, addr, 5);
-			} else if(strncmp(p, SettingsFld_CRC, sizeof(SettingsFld_CRC)-1) == 0) {
-				NRF_CRC = str_to_int(p + sizeof(SettingsFld_CRC));
-			} else if(strncmp(p, SettingsFld_DPL, sizeof(SettingsFld_DPL)-1) == 0) {
-				NRF_DPL = str_to_int(p + sizeof(SettingsFld_DPL));
-			} else if(strncmp(p, SettingsFld_RETR, sizeof(SettingsFld_RETR)-1) == 0) {
-				NRF_RETR = str_to_int(p + sizeof(SettingsFld_RETR));
-			} else if(strncmp(p, SettingsFld_Resend, sizeof(SettingsFld_Resend)-1) == 0) {
-				NRF_resend = str_to_int(p + sizeof(SettingsFld_Resend));
-			} else if(strncmp(p, SettingsFld_Delay, sizeof(SettingsFld_Delay)-1) == 0) {
-				delay_between_pkt = str_to_int(p + sizeof(SettingsFld_Delay));
-			} else if(strncmp(p, SettingsFld_ReadCmdRepeatPeriod, sizeof(SettingsFld_ReadCmdRepeatPeriod)-1) == 0) {
-				ReadCmdRepeatPeriod = str_to_int(p + sizeof(SettingsFld_ReadCmdRepeatPeriod));
-			} else if(strncmp(p, SettingsFld_Payload, sizeof(SettingsFld_Payload)-1) == 0) {
-				p += sizeof(SettingsFld_Payload);
-				payload_fields = 0;
-				payload_size = 0;
-				do {
-					uint8_t b = str_to_int(p);
-					if(b < 1 || b > 4) {
-						FURI_LOG_D(TAG, "Wrong payload format (%d)", b);
-						err = 3;
-						break;
-					}
-					payload_struct[payload_fields++] = b;
-					payload_size += b;
-					if(payload_fields == sizeof(payload_struct) - 1) break;
-					if((p = strchr(p, ',')) == NULL) break;
-					p++;
-				} while(1);
-				FURI_LOG_D(TAG, "Payload fields %d: %d,%d,%d", payload_fields, payload_struct[0], payload_struct[1], payload_struct[2]);
-			} else if(strncmp(p, SettingsFld_ReadDefault, sizeof(SettingsFld_ReadDefault)-1) == 0) {
-				ReadDefault = furi_string_alloc_set_str(p + sizeof(SettingsFld_ReadDefault));
-			} else if(strncmp(p, SettingsFld_WriteStart, sizeof(SettingsFld_WriteStart)-1) == 0) {
-				WriteStart = furi_string_alloc_set_str(p + sizeof(SettingsFld_WriteStart));
-			} else if(strncmp(p, SettingsFld_WriteDefault, sizeof(SettingsFld_WriteDefault)-1) == 0) {
-				WriteDefault = furi_string_alloc_set_str(p + sizeof(SettingsFld_WriteDefault));
-			} else if(strncmp(p, SettingsFld_Read, sizeof(SettingsFld_Read)-1) == 0) {
-				p += sizeof(SettingsFld_Read);
-				if(Read_cmd == NULL) Read_cmd = malloc(sizeof(Read_cmd));
-				else {
-					Read_cmd = realloc(Read_cmd, sizeof(Read_cmd) * (Read_cmd_Total + 1));
-				}
-				if(Read_cmd == NULL) {
-					FURI_LOG_D(TAG, "Memory low, err 4");
-					err = 4;
-					break;
-				}
-				Read_cmd[Read_cmd_Total++] = furi_string_alloc_set_str(p);
-			} else if(strncmp(p, SettingsFld_ReadBatch, sizeof(SettingsFld_ReadBatch)-1) == 0) {
-				p += sizeof(SettingsFld_ReadBatch);
-				if(ReadBatch_cmd == NULL) ReadBatch_cmd = malloc(sizeof(ReadBatch_cmd));
-				else {
-					ReadBatch_cmd = realloc(ReadBatch_cmd, sizeof(ReadBatch_cmd) * (ReadBatch_cmd_Total + 1));
-				}
-				if(ReadBatch_cmd == NULL) {
-					FURI_LOG_D(TAG, "Memory low, err 5");
-					err = 5;
-					break;
-				}
-				ReadBatch_cmd[ReadBatch_cmd_Total++] = furi_string_alloc_set_str(p);
-			} else if(strncmp(p, SettingsFld_WriteBatch, sizeof(SettingsFld_WriteBatch)-1) == 0) {
-				p += sizeof(SettingsFld_WriteBatch);
-				if(WriteBatch_cmd == NULL) WriteBatch_cmd = malloc(sizeof(WriteBatch_cmd));
-				else {
-					WriteBatch_cmd = realloc(WriteBatch_cmd, sizeof(WriteBatch_cmd) * (WriteBatch_cmd_Total + 1));
-				}
-				if(WriteBatch_cmd == NULL) {
-					FURI_LOG_D(TAG, "Memory low, err 6");
-					err = 6;
-					break;
-				}
-				WriteBatch_cmd[WriteBatch_cmd_Total++] = furi_string_alloc_set_str(p);
-			} else if(strncmp(p, SettingsFld_SetBatch, sizeof(SettingsFld_SetBatch)-1) == 0) {
-				p += sizeof(SettingsFld_SetBatch);
-				if(SetBatch_cmd == NULL) SetBatch_cmd = malloc(sizeof(SetBatch_cmd));
-				else {
-					SetBatch_cmd = realloc(SetBatch_cmd, sizeof(SetBatch_cmd) * (SetBatch_cmd_Total + 1));
-				}
-				if(SetBatch_cmd == NULL) {
-					FURI_LOG_D(TAG, "Memory low, err 7");
-					err = 7;
-					break;
-				}
-				SetBatch_cmd[SetBatch_cmd_Total++] = furi_string_alloc_set_str(p);
-			} else if(strncmp(p, SettingsFld_Listen, sizeof(SettingsFld_Listen)-1) == 0) {
-				p += sizeof(SettingsFld_Listen);
-				char *p2 = strchr(p, '=');
-				if(p2) {
-					listen_addr_len = ConvertHexToArray(p, listen_addr, (p2 - p) / 2);
-					p2++;
-					uint8_t len = strlen(p2);
-					ListenFields = malloc(len + 1);
-					if(ListenFields) memcpy(ListenFields, p2, len);
-				}
-			}
-		}
-	}
-	furi_string_free(str);
-	return err;
+    uint8_t err = 0;
+    FURI_LOG_D(TAG, "Loading settings file");
+    FuriString* str = furi_string_alloc();
+    free_store();
+    Info[0] = '\0';
+    NRF_INITED = false;
+    while(stream_read_line(file_stream, str)) {
+        char* p = (char*)furi_string_get_cstr(str);
+        if(*p <= '!' || *p == ';') continue;
+        //char* delim_eq = strchr(p, '=');
+        char* delim_col = strchr(p, ':');
+        if(delim_col == NULL) { // Constant found - no ':'
+            if(Constants == NULL) {
+                Constants = furi_string_alloc_set(str);
+            } else
+                furi_string_cat(Constants, str);
+        } else {
+            str_rtrim(p);
+            if(strncmp(p, SettingsFld_Rate, sizeof(SettingsFld_Rate) - 1) == 0) {
+                NRF_rate = str_to_int(p + sizeof(SettingsFld_Rate));
+            } else if(strncmp(p, SettingsFld_Info, sizeof(SettingsFld_Info) - 1) == 0) {
+                strncpy(Info, p + sizeof(SettingsFld_Info), sizeof(Info) - 1);
+            } else if(strncmp(p, SettingsFld_Ch, sizeof(SettingsFld_Ch) - 1) == 0) {
+                NRF_channel = str_to_int(p + sizeof(SettingsFld_Ch));
+            } else if(strncmp(p, SettingsFld_Address, sizeof(SettingsFld_Address) - 1) == 0) {
+                p += sizeof(SettingsFld_Address);
+                addr_len = ConvertHexToArray(p, addr, 5);
+            } else if(strncmp(p, SettingsFld_CRC, sizeof(SettingsFld_CRC) - 1) == 0) {
+                NRF_CRC = str_to_int(p + sizeof(SettingsFld_CRC));
+            } else if(strncmp(p, SettingsFld_DPL, sizeof(SettingsFld_DPL) - 1) == 0) {
+                NRF_DPL = str_to_int(p + sizeof(SettingsFld_DPL));
+            } else if(strncmp(p, SettingsFld_RETR, sizeof(SettingsFld_RETR) - 1) == 0) {
+                NRF_RETR = str_to_int(p + sizeof(SettingsFld_RETR));
+            } else if(strncmp(p, SettingsFld_Resend, sizeof(SettingsFld_Resend) - 1) == 0) {
+                NRF_resend = str_to_int(p + sizeof(SettingsFld_Resend));
+            } else if(strncmp(p, SettingsFld_Delay, sizeof(SettingsFld_Delay) - 1) == 0) {
+                delay_between_pkt = str_to_int(p + sizeof(SettingsFld_Delay));
+            } else if(
+                strncmp(
+                    p,
+                    SettingsFld_ReadCmdRepeatPeriod,
+                    sizeof(SettingsFld_ReadCmdRepeatPeriod) - 1) == 0) {
+                ReadCmdRepeatPeriod = str_to_int(p + sizeof(SettingsFld_ReadCmdRepeatPeriod));
+            } else if(strncmp(p, SettingsFld_Payload, sizeof(SettingsFld_Payload) - 1) == 0) {
+                p += sizeof(SettingsFld_Payload);
+                payload_fields = 0;
+                payload_size = 0;
+                do {
+                    uint8_t b = str_to_int(p);
+                    if(b < 1 || b > 4) {
+                        FURI_LOG_D(TAG, "Wrong payload format (%d)", b);
+                        err = 3;
+                        break;
+                    }
+                    payload_struct[payload_fields++] = b;
+                    payload_size += b;
+                    if(payload_fields == sizeof(payload_struct) - 1) break;
+                    if((p = strchr(p, ',')) == NULL) break;
+                    p++;
+                } while(1);
+                FURI_LOG_D(
+                    TAG,
+                    "Payload fields %d: %d,%d,%d",
+                    payload_fields,
+                    payload_struct[0],
+                    payload_struct[1],
+                    payload_struct[2]);
+            } else if(strncmp(p, SettingsFld_ReadDefault, sizeof(SettingsFld_ReadDefault) - 1) == 0) {
+                ReadDefault = furi_string_alloc_set_str(p + sizeof(SettingsFld_ReadDefault));
+            } else if(strncmp(p, SettingsFld_WriteStart, sizeof(SettingsFld_WriteStart) - 1) == 0) {
+                WriteStart = furi_string_alloc_set_str(p + sizeof(SettingsFld_WriteStart));
+            } else if(strncmp(p, SettingsFld_WriteDefault, sizeof(SettingsFld_WriteDefault) - 1) == 0) {
+                WriteDefault = furi_string_alloc_set_str(p + sizeof(SettingsFld_WriteDefault));
+            } else if(strncmp(p, SettingsFld_Read, sizeof(SettingsFld_Read) - 1) == 0) {
+                p += sizeof(SettingsFld_Read);
+                if(Read_cmd == NULL)
+                    Read_cmd = malloc(sizeof(Read_cmd));
+                else {
+                    Read_cmd = realloc(Read_cmd, sizeof(Read_cmd) * (Read_cmd_Total + 1));
+                }
+                if(Read_cmd == NULL) {
+                    FURI_LOG_D(TAG, "Memory low, err 4");
+                    err = 4;
+                    break;
+                }
+                Read_cmd[Read_cmd_Total++] = furi_string_alloc_set_str(p);
+            } else if(strncmp(p, SettingsFld_ReadBatch, sizeof(SettingsFld_ReadBatch) - 1) == 0) {
+                p += sizeof(SettingsFld_ReadBatch);
+                if(ReadBatch_cmd == NULL)
+                    ReadBatch_cmd = malloc(sizeof(ReadBatch_cmd));
+                else {
+                    ReadBatch_cmd =
+                        realloc(ReadBatch_cmd, sizeof(ReadBatch_cmd) * (ReadBatch_cmd_Total + 1));
+                }
+                if(ReadBatch_cmd == NULL) {
+                    FURI_LOG_D(TAG, "Memory low, err 5");
+                    err = 5;
+                    break;
+                }
+                ReadBatch_cmd[ReadBatch_cmd_Total++] = furi_string_alloc_set_str(p);
+            } else if(strncmp(p, SettingsFld_WriteBatch, sizeof(SettingsFld_WriteBatch) - 1) == 0) {
+                p += sizeof(SettingsFld_WriteBatch);
+                if(WriteBatch_cmd == NULL)
+                    WriteBatch_cmd = malloc(sizeof(WriteBatch_cmd));
+                else {
+                    WriteBatch_cmd = realloc(
+                        WriteBatch_cmd, sizeof(WriteBatch_cmd) * (WriteBatch_cmd_Total + 1));
+                }
+                if(WriteBatch_cmd == NULL) {
+                    FURI_LOG_D(TAG, "Memory low, err 6");
+                    err = 6;
+                    break;
+                }
+                WriteBatch_cmd[WriteBatch_cmd_Total++] = furi_string_alloc_set_str(p);
+            } else if(strncmp(p, SettingsFld_SetBatch, sizeof(SettingsFld_SetBatch) - 1) == 0) {
+                p += sizeof(SettingsFld_SetBatch);
+                if(SetBatch_cmd == NULL)
+                    SetBatch_cmd = malloc(sizeof(SetBatch_cmd));
+                else {
+                    SetBatch_cmd =
+                        realloc(SetBatch_cmd, sizeof(SetBatch_cmd) * (SetBatch_cmd_Total + 1));
+                }
+                if(SetBatch_cmd == NULL) {
+                    FURI_LOG_D(TAG, "Memory low, err 7");
+                    err = 7;
+                    break;
+                }
+                SetBatch_cmd[SetBatch_cmd_Total++] = furi_string_alloc_set_str(p);
+            } else if(strncmp(p, SettingsFld_Listen, sizeof(SettingsFld_Listen) - 1) == 0) {
+                p += sizeof(SettingsFld_Listen);
+                char* p2 = strchr(p, '=');
+                if(p2) {
+                    listen_addr_len = ConvertHexToArray(p, listen_addr, (p2 - p) / 2);
+                    p2++;
+                    uint8_t len = strlen(p2);
+                    ListenFields = malloc(len + 1);
+                    if(ListenFields) memcpy(ListenFields, p2, len);
+                }
+            }
+        }
+    }
+    furi_string_free(str);
+    return err;
 }
 
-static void save_batch(void)
-{
-	FURI_LOG_D(TAG, "Save Batch");
-	char *p, *p2;
-	stream_seek(file_stream, 0, StreamOffsetFromEnd); 
+static void save_batch(void) {
+    FURI_LOG_D(TAG, "Save Batch");
+    char *p, *p2;
+    stream_seek(file_stream, 0, StreamOffsetFromEnd);
     FuriHalRtcDateTime dt;
     furi_hal_rtc_get_datetime(&dt);
-	stream_write_format(file_stream, "\n%s ", SettingsFld_WriteBatch);
-	p = (char*)furi_string_get_cstr(ReadBatch_cmd[view_cmd[rwt_read_batch]]);
-	p2 = strchr(p, ':');
-	if(p2 == NULL) p2 = p + strlen(p);
-	stream_write(file_stream, (uint8_t*)p, p2 - p);
-	stream_write_format(file_stream, " %02d.%02d.%02d %02d.%02d: ", dt.day, dt.month, dt.year % 100, dt.hour, dt.minute);
-	for(uint16_t i = 0; i < Log_Total; i++) {
-		p = (char*) furi_string_get_cstr(Log[i]);
-		p2 = strchr(p, ':');
-		if(p2 && *(p2-1) != '*') {	// skip string
-			if(*(p2-1) == ']') { // array
-				char *p3 = strchr(p, '[');
-				if(p3) {
-					stream_write(file_stream, (uint8_t*)p, p3 - p - (*(p3-2) == '*' ? 2 : 0));
-					stream_write_cstring(file_stream, "={");
-					p = (p2 += 2);
-					do {
-						while(is_digit(p2, true) || *p2 == 'x') p2++;
-						stream_write(file_stream, (uint8_t*)p, p2 - p);
-						char c = *p2;
-						if(c == '\0') break;
-						if(c != ',') {
-							p2 = strchr(p2, ',');
-							if(p2 == NULL) break;
-						}
-						stream_write_char(file_stream, ',');
-						p = ++p2;
-					} while(1);
-					stream_write_char(file_stream, '}');
-				}
-			} else {
-				stream_write(file_stream, (uint8_t*)p, p2 - p - (*(p2-2) == '*' ? 2 : 0));
-				stream_write_char(file_stream, '=');
-				p2 += 2;
-				p = strchr(p2, ' ');
-				if(p == NULL) p = p2 + strlen(p2);
-				stream_write(file_stream, (uint8_t*)p2, p - p2);
-			}
-			if(i < Log_Total - 1) stream_write_char(file_stream, ';');
-		}
-	}
+    stream_write_format(file_stream, "\n%s ", SettingsFld_WriteBatch);
+    p = (char*)furi_string_get_cstr(ReadBatch_cmd[view_cmd[rwt_read_batch]]);
+    p2 = strchr(p, ':');
+    if(p2 == NULL) p2 = p + strlen(p);
+    stream_write(file_stream, (uint8_t*)p, p2 - p);
+    stream_write_format(
+        file_stream,
+        " %02d.%02d.%02d %02d.%02d: ",
+        dt.day,
+        dt.month,
+        dt.year % 100,
+        dt.hour,
+        dt.minute);
+    for(uint16_t i = 0; i < Log_Total; i++) {
+        p = (char*)furi_string_get_cstr(Log[i]);
+        p2 = strchr(p, ':');
+        if(p2 && *(p2 - 1) != '*') { // skip string
+            if(*(p2 - 1) == ']') { // array
+                char* p3 = strchr(p, '[');
+                if(p3) {
+                    stream_write(file_stream, (uint8_t*)p, p3 - p - (*(p3 - 2) == '*' ? 2 : 0));
+                    stream_write_cstring(file_stream, "={");
+                    p = (p2 += 2);
+                    do {
+                        while(is_digit(p2, true) || *p2 == 'x') p2++;
+                        stream_write(file_stream, (uint8_t*)p, p2 - p);
+                        char c = *p2;
+                        if(c == '\0') break;
+                        if(c != ',') {
+                            p2 = strchr(p2, ',');
+                            if(p2 == NULL) break;
+                        }
+                        stream_write_char(file_stream, ',');
+                        p = ++p2;
+                    } while(1);
+                    stream_write_char(file_stream, '}');
+                }
+            } else {
+                stream_write(file_stream, (uint8_t*)p, p2 - p - (*(p2 - 2) == '*' ? 2 : 0));
+                stream_write_char(file_stream, '=');
+                p2 += 2;
+                p = strchr(p2, ' ');
+                if(p == NULL) p = p2 + strlen(p2);
+                stream_write(file_stream, (uint8_t*)p2, p - p2);
+            }
+            if(i < Log_Total - 1) stream_write_char(file_stream, ';');
+        }
+    }
 }
 
 static void input_callback(InputEvent* input_event, FuriMessageQueue* event_queue) {
-	furi_assert(event_queue);
-	PluginEvent event = {.type = EventTypeKey, .input = *input_event};
-	furi_message_queue_put(event_queue, &event, FuriWaitForever);
+    furi_assert(event_queue);
+    PluginEvent event = {.type = EventTypeKey, .input = *input_event};
+    furi_message_queue_put(event_queue, &event, FuriWaitForever);
 }
 
-void display_remove_asterisk(char *fsp, uint8_t vx)
-{
-	char *p2 = strchr(fsp, '*');
-	if(p2) { // remove '*' or '*n'
-		int pos = p2 - fsp;
-		if((pos -= vx) < 0) pos = 0;
-		char c = *(p2 + 1);
-		if(*(screen_buf + pos))
-			memmove(screen_buf + pos, screen_buf + pos + (c == ':' || c == '=' ? 1 : 2), FONT_5x7_SCREEN_WIDTH + 1 + 2 - pos);
-	}
+void display_remove_asterisk(char* fsp, uint8_t vx) {
+    char* p2 = strchr(fsp, '*');
+    if(p2) { // remove '*' or '*n'
+        int pos = p2 - fsp;
+        if((pos -= vx) < 0) pos = 0;
+        char c = *(p2 + 1);
+        if(*(screen_buf + pos))
+            memmove(
+                screen_buf + pos,
+                screen_buf + pos + (c == ':' || c == '=' ? 1 : 2),
+                FONT_5x7_SCREEN_WIDTH + 1 + 2 - pos);
+    }
 }
 
-void render_display_list(Canvas* const canvas, FuriString ***fsa, char delim, uint16_t view_pos, uint16_t max_i)
-{
-	uint16_t page = view_pos & ~7;
-	char *p, *end;
-	uint16_t y, len;
-	for(uint8_t i = 0; i < 8 && page + i < max_i; i++) {
-		y = 14 + i * 7;
-		p = (char*) furi_string_get_cstr((*fsa)[page + i]);
-		end = strchr(p, delim);
-		if(end) {
-			len = MIN(end - p, view_x);
-			len = MIN(end - p - len, FONT_5x7_SCREEN_WIDTH);
-			strncpy(screen_buf, p + view_x, len);
-			screen_buf[len] = '\0';
-			display_remove_asterisk(p, MIN(end - p, view_x));
-			canvas_draw_str(canvas, 5, y, screen_buf);
-		}
-		if((view_pos & 7) == i) {
-			canvas_draw_str(canvas, 0, y, ">");
-			canvas_draw_str(canvas, -1, y, ">");
-		}
-	}
+void render_display_list(
+    Canvas* const canvas,
+    FuriString*** fsa,
+    char delim,
+    uint16_t view_pos,
+    uint16_t max_i) {
+    uint16_t page = view_pos & ~7;
+    char *p, *end;
+    uint16_t y, len;
+    for(uint8_t i = 0; i < 8 && page + i < max_i; i++) {
+        y = 14 + i * 7;
+        p = (char*)furi_string_get_cstr((*fsa)[page + i]);
+        end = strchr(p, delim);
+        if(end) {
+            len = MIN(end - p, view_x);
+            len = MIN(end - p - len, FONT_5x7_SCREEN_WIDTH);
+            strncpy(screen_buf, p + view_x, len);
+            screen_buf[len] = '\0';
+            display_remove_asterisk(p, MIN(end - p, view_x));
+            canvas_draw_str(canvas, 5, y, screen_buf);
+        }
+        if((view_pos & 7) == i) {
+            canvas_draw_str(canvas, 0, y, ">");
+            canvas_draw_str(canvas, -1, y, ">");
+        }
+    }
 }
 
-void display_edit_ttf_font(Canvas* const canvas, uint8_t start_x, uint8_t start_y)
-{
-	screen_buf[0] = *Edit_pos; screen_buf[1] = '\0';
-	int n = canvas_string_width(canvas, screen_buf);
-	int len = Edit_pos - Edit_start;
-	memcpy(screen_buf, Edit_start, len);
-	screen_buf[len] = '\0';
-	int x = start_x + canvas_string_width(canvas, screen_buf);
-	int len2 = strlen(Edit_pos);
-	memcpy(screen_buf + len, Edit_pos, len2);
-	screen_buf[len + len2] = '\0';
-	canvas_draw_str(canvas, start_x, start_y, screen_buf);
-	start_y += 1;
-	canvas_draw_line(canvas, x + (len ? 1 : 0), start_y, x + n + (*Edit_pos == '1' && len ? 1 : 0), start_y);
+void display_edit_ttf_font(Canvas* const canvas, uint8_t start_x, uint8_t start_y) {
+    screen_buf[0] = *Edit_pos;
+    screen_buf[1] = '\0';
+    int n = canvas_string_width(canvas, screen_buf);
+    int len = Edit_pos - Edit_start;
+    memcpy(screen_buf, Edit_start, len);
+    screen_buf[len] = '\0';
+    int x = start_x + canvas_string_width(canvas, screen_buf);
+    int len2 = strlen(Edit_pos);
+    memcpy(screen_buf + len, Edit_pos, len2);
+    screen_buf[len + len2] = '\0';
+    canvas_draw_str(canvas, start_x, start_y, screen_buf);
+    start_y += 1;
+    canvas_draw_line(
+        canvas, x + (len ? 1 : 0), start_y, x + n + (*Edit_pos == '1' && len ? 1 : 0), start_y);
 }
 
-void display_add_status(void)
-{
-	if(NRF_ERROR) strcat(screen_buf, "nRF24 ERROR!");
-	else if(ERR) snprintf(screen_buf, sizeof(screen_buf), "ERROR %s", ERR_STR); 
-	else if(send_status == sst_error) strcat(screen_buf, "NO ACK!");
-	else if(send_status == sst_timeout) strcat(screen_buf, "TIMEOUT!");
-	else if(send_status == sst_none) ;
-	else if(send_status == sst_sending) strcat(screen_buf, "sending");
-	else if(send_status == sst_receiving) strcat(screen_buf, "receiving");
-	else if(send_status == sst_ok && 
-		(rw_type == rwt_read_cmd
-		|| (rw_type == rwt_read_batch && (uint32_t)ReadBatch_cmd_curr == 0xFFFFFFFF) 
-		|| (rw_type == rwt_set_batch && SetBatch_cmd_curr == Log_Total) 
-		|| (rw_type == rwt_write_batch && WriteBatch_cmd_curr == Log_Total)))
-			strcat(screen_buf, "OK");
-	else strcat(screen_buf, "working");
+void display_add_status(void) {
+    if(NRF_ERROR)
+        strcat(screen_buf, "nRF24 ERROR!");
+    else if(ERR)
+        snprintf(screen_buf, sizeof(screen_buf), "ERROR %s", ERR_STR);
+    else if(send_status == sst_error)
+        strcat(screen_buf, "NO ACK!");
+    else if(send_status == sst_timeout)
+        strcat(screen_buf, "TIMEOUT!");
+    else if(send_status == sst_none)
+        ;
+    else if(send_status == sst_sending)
+        strcat(screen_buf, "sending");
+    else if(send_status == sst_receiving)
+        strcat(screen_buf, "receiving");
+    else if(
+        send_status == sst_ok &&
+        (rw_type == rwt_read_cmd ||
+         (rw_type == rwt_read_batch && (uint32_t)ReadBatch_cmd_curr == 0xFFFFFFFF) ||
+         (rw_type == rwt_set_batch && SetBatch_cmd_curr == Log_Total) ||
+         (rw_type == rwt_write_batch && WriteBatch_cmd_curr == Log_Total)))
+        strcat(screen_buf, "OK");
+    else
+        strcat(screen_buf, "working");
 }
 
 static void render_callback(Canvas* const canvas, void* ctx) {
-	if(ctx == NULL) return;
-	const PluginState* plugin_state = ctx;
-	if(furi_mutex_acquire(plugin_state->mutex, 5) != FuriStatusOk) return;
+    if(ctx == NULL) return;
+    const PluginState* plugin_state = ctx;
+    if(furi_mutex_acquire(plugin_state->mutex, 5) != FuriStatusOk) return;
 
-	//canvas_draw_frame(canvas, 0, 0, 128, 64); // border around the edge of the screen
-	if(what_doing == 0) {
-		canvas_set_font(canvas, FontSecondary); // 8x10 font, 6 lines
-		snprintf(screen_buf, sizeof(screen_buf), "%s: %s", addr_len ? "File" : "Open", file_name);
-		canvas_draw_str(canvas, 8, 10, screen_buf);
-		if(addr_len) {
-			if(Edit) {
-				if(setup_cursor == 1) display_edit_ttf_font(canvas, 45, 20);
-				else if(setup_cursor == 2) display_edit_ttf_font(canvas, 55, 30);
-			}
-			if(!Edit || setup_cursor != 1) {
-				screen_buf[0] = '\0';
-				add_to_str_hex_bytes(screen_buf, addr, addr_len);
-				canvas_draw_str(canvas, 45, 20, screen_buf);
-			}
-			if(!Edit || setup_cursor != 2) {
-				snprintf(screen_buf, sizeof(screen_buf), "%d", NRF_channel);
-				canvas_draw_str(canvas, 55, 30, screen_buf);
-			}
-			canvas_draw_str(canvas, 8, 20, "Address:");
-			snprintf(screen_buf, sizeof(screen_buf), "Rate: %d, Ch:", NRF_rate);
-			canvas_draw_str(canvas, 8, 30, screen_buf);
-			snprintf(screen_buf, sizeof(screen_buf), "RB: %d, R: %d, WB: %d", ReadBatch_cmd_Total, Read_cmd_Total, WriteBatch_cmd_Total);
-			canvas_draw_str(canvas, 8, 40, screen_buf);
-			canvas_draw_str(canvas, 0, 64, Info);
-			canvas_draw_str(canvas, 0, 10 + setup_cursor * 10, ">");
-		} else {
-			snprintf(screen_buf, sizeof(screen_buf), "Ver. %s,  vad7", VERSION);
-			canvas_draw_str(canvas, 10, 60, screen_buf);
-			canvas_draw_str(canvas, 0, 10, ">");
-		}
-	} else if(what_doing == 1){
-		if(rw_type == rwt_listen) {
-			canvas_set_font(canvas, FontSecondary); // 8x10 font, 6 lines
-			canvas_draw_str(canvas, 0, 10, "Listen mode");
-			canvas_draw_str(canvas, 0, 25, "Address:");
-			if(Edit) display_edit_ttf_font(canvas, 40, 25); 
-			else if(listen_addr_len) {
-				screen_buf[0] = '\0';
-				add_to_str_hex_bytes(screen_buf, listen_addr, listen_addr_len);
-				canvas_draw_str(canvas, 40, 25, screen_buf);
-			}
-			snprintf(screen_buf, sizeof(screen_buf), "I: %d +(%d) mA", Current - CurrentStart, CurrentStart);
-			canvas_draw_str(canvas, 0, 60, screen_buf);
-		} else {
-			canvas_set_font(canvas, FontBatteryPercent); // 5x7 font, 9 lines, 25 cols
-			if(rw_type == rwt_read_batch) {
-				canvas_draw_str(canvas, 0, 7, "Read Batch:");
-				render_display_list(canvas, &ReadBatch_cmd, ':', view_cmd[rw_type], ReadBatch_cmd_Total);
-			} else if(rw_type == rwt_read_cmd) {
-				canvas_draw_str(canvas, 0, 7, "Read Command:");
-				render_display_list(canvas, &Read_cmd, '=', view_cmd[rw_type], Read_cmd_Total);
-			} else if(rw_type == rwt_write_batch) {
-				if(!ask_fill_screen_buf()) strcpy(screen_buf, "Write Batch:");
-				canvas_draw_str(canvas, 0, 7, screen_buf);
-				render_display_list(canvas, &WriteBatch_cmd, ':', view_cmd[rw_type], WriteBatch_cmd_Total);
-			} else if(rw_type == rwt_set_batch) {
-				strcpy(screen_buf, "Set: ");
-				display_add_status();
-				canvas_draw_str(canvas, 0, 7, screen_buf);
-				render_display_list(canvas, &SetBatch_cmd, ':', view_cmd[rw_type], SetBatch_cmd_Total);
-			}
-		}
-	} else { // what_doing == 2
-		if(rw_type == rwt_listen) {
-			canvas_set_font(canvas, FontSecondary); // 8x10 font, 6 lines
-			strcpy(screen_buf, "Listen: ");
-			if(NRF_ERROR) strcat(screen_buf, "nRF24 ERROR!");
-			else if(ListenNew) {
-				snprintf(screen_buf + strlen(screen_buf), 16, "%02d:%02d:%02d", ListenLastTime.hour, ListenLastTime.minute, ListenLastTime.second);
-				if(ListenPrev) snprintf(screen_buf + strlen(screen_buf), 16, " (%lu)", ListenLast - ListenPrev);
-			} else strcat(screen_buf, "receiving");
-			snprintf(screen_buf + strlen(screen_buf), 16, " %dmA", Current - CurrentStart);
-			canvas_draw_str(canvas, 0, 10, screen_buf);
-			if(ListenFields) {
-				char *p2, *p = ListenFields;
-				uint8_t hex, len, *pld = payload_receive;
-				for(uint8_t i = 0; i < 5 && *p; i++) {
-					hex = false;
-					p2 = strchr(p, ',');
-					if(p2 == NULL) p2 = p + strlen(p);
-					if(*(p2 - 1) == '#') hex = true;
-					memcpy(screen_buf, p, len = p2 - p);
-					strcpy(screen_buf + len, ": ");
-					if(ListenNew) {
-						len = payload_struct[i];
-						int32_t n = get_payload_receive_field(pld, len);
-						if(hex)	{
-							strcat(screen_buf, "0x");
-							add_to_str_hex_variable(screen_buf, pld, len);
-						} else {
-							snprintf(screen_buf + strlen(screen_buf), 20, "%ld", n);
-							if(n > 9) {
-								strcat(screen_buf, " (");
-								add_to_str_hex_variable(screen_buf, pld, len);
-								strcat(screen_buf, ")");
-							}
-						}
-						pld += len;
-					}
-					canvas_draw_str(canvas, 0, 20 + i * 10, screen_buf);
-					if(*p2 == '\0') break;
-					p = p2 + 1;
-				}
-			}
-		} else if(rw_type == rwt_read_cmd) {	// Read command
-			canvas_set_font(canvas, FontSecondary); // 8x10 font, 6 lines
-			if(!ask_fill_screen_buf()) {
-				strcpy(screen_buf, "Read ");
-				strcat(screen_buf, ReadRepeat ? "rep: " : "cmd: ");
-			}
-			display_add_status();
-			canvas_draw_str(canvas, 0, 10, screen_buf);
-			if(Log_Total) {
-				char *p = (char*)furi_string_get_cstr(Log[Log_Total - 1]);
-				uint8_t vx = MIN(view_x, strlen(p));
-				strncpy(screen_buf, p + vx, 30);
-				display_remove_asterisk(p, vx);
-				canvas_draw_str(canvas, 0, 15 + 10, screen_buf);
-			}
-		} else if(rw_type == rwt_set_batch) {
-				canvas_set_font(canvas, FontBatteryPercent); // 5x7 font, 9 lines, 25 cols
-				strcpy(screen_buf, "Set: ");
-				display_add_status();
-				canvas_draw_str(canvas, 0, 7, screen_buf);
-				render_display_list(canvas, &SetBatch_cmd, ':', view_cmd[rw_type], SetBatch_cmd_Total);
-		} else { // rwt_read_batch, rwt_write_batch
-			canvas_set_font(canvas, FontBatteryPercent); // 5x7 font, 9 lines, 25 cols
-			if(!ask_fill_screen_buf()) {
-				strcpy(screen_buf, rw_type == rwt_read_batch ? "Read Batch: " : "Write: ");
-				if(rw_type == rwt_read_batch || send_status != sst_none) {
-					display_add_status();
-				} else if(rw_type == rwt_write_batch) {
-					char *p = (char*)furi_string_get_cstr(WriteBatch_cmd[view_cmd[rwt_write_batch]]);
-					char *end = strchr(p, ':');
-					if(end) {
-						uint8_t len = end - p;
-						uint8_t lenb = strlen(screen_buf);
-						end = screen_buf + lenb;
-						lenb = FONT_5x7_SCREEN_WIDTH - lenb;
-						if(len > lenb) {
-							if(view_x < len) {
-								strncpy(end, p + view_x, len = MIN(lenb, len - view_x));
-								end[len] = '\0';
-							}
-						} else {
-							strncpy(end, p, len);
-							end[len] = '\0';
-						}
-					}
-				}
-			}
-			canvas_draw_str(canvas, 0, 7, screen_buf);
-			if(Log_Total) {
-				char *p;
-				uint16_t y, page = view_Batch & ~7;
-				uint8_t vx;
-				for(uint8_t i = 0; i < 8 && page + i < Log_Total; i++) {
-					p = (char*)furi_string_get_cstr(Log[page + i]);
-					y = 14 + i * 7;
-					vx = MIN(view_x, strlen(p));
-					if((view_Batch & 7) == i) {
-						canvas_draw_str(canvas, 0, y, ">");
-						canvas_draw_str(canvas, -1, y, ">");
-						if(Edit) {
-							int n = Edit_pos - p - vx - (FONT_5x7_SCREEN_WIDTH - 4);
-							if(n > 0) vx += n;	// fix out of screen
-							int x = 6 + (Edit_pos - p - vx) * 5;
-							canvas_draw_line(canvas, x - 1, y, x - 1, y - 1);
-							canvas_draw_line(canvas, x - 1, y, n = x + 1 * 5, y);
-							canvas_draw_line(canvas, n, y, n, y - 1);
-						}
-					}
-					strncpy(screen_buf, p + vx, FONT_5x7_SCREEN_WIDTH + 2);
-					screen_buf[FONT_5x7_SCREEN_WIDTH + 2] = '\0';
-					display_remove_asterisk(p, vx);
-					canvas_draw_str(canvas, 6, y, screen_buf);
-				}
-			}
-		}
-	}
-	furi_mutex_release(plugin_state->mutex);
-} 
+    //canvas_draw_frame(canvas, 0, 0, 128, 64); // border around the edge of the screen
+    if(what_doing == 0) {
+        canvas_set_font(canvas, FontSecondary); // 8x10 font, 6 lines
+        snprintf(screen_buf, sizeof(screen_buf), "%s: %s", addr_len ? "File" : "Open", file_name);
+        canvas_draw_str(canvas, 8, 10, screen_buf);
+        if(addr_len) {
+            if(Edit) {
+                if(setup_cursor == 1)
+                    display_edit_ttf_font(canvas, 45, 20);
+                else if(setup_cursor == 2)
+                    display_edit_ttf_font(canvas, 55, 30);
+            }
+            if(!Edit || setup_cursor != 1) {
+                screen_buf[0] = '\0';
+                add_to_str_hex_bytes(screen_buf, addr, addr_len);
+                canvas_draw_str(canvas, 45, 20, screen_buf);
+            }
+            if(!Edit || setup_cursor != 2) {
+                snprintf(screen_buf, sizeof(screen_buf), "%d", NRF_channel);
+                canvas_draw_str(canvas, 55, 30, screen_buf);
+            }
+            canvas_draw_str(canvas, 8, 20, "Address:");
+            snprintf(screen_buf, sizeof(screen_buf), "Rate: %d, Ch:", NRF_rate);
+            canvas_draw_str(canvas, 8, 30, screen_buf);
+            snprintf(
+                screen_buf,
+                sizeof(screen_buf),
+                "RB: %d, R: %d, WB: %d",
+                ReadBatch_cmd_Total,
+                Read_cmd_Total,
+                WriteBatch_cmd_Total);
+            canvas_draw_str(canvas, 8, 40, screen_buf);
+            canvas_draw_str(canvas, 0, 64, Info);
+            canvas_draw_str(canvas, 0, 10 + setup_cursor * 10, ">");
+        } else {
+            snprintf(screen_buf, sizeof(screen_buf), "Ver. %s,  vad7", VERSION);
+            canvas_draw_str(canvas, 10, 60, screen_buf);
+            canvas_draw_str(canvas, 0, 10, ">");
+        }
+    } else if(what_doing == 1) {
+        if(rw_type == rwt_listen) {
+            canvas_set_font(canvas, FontSecondary); // 8x10 font, 6 lines
+            canvas_draw_str(canvas, 0, 10, "Listen mode");
+            canvas_draw_str(canvas, 0, 25, "Address:");
+            if(Edit)
+                display_edit_ttf_font(canvas, 40, 25);
+            else if(listen_addr_len) {
+                screen_buf[0] = '\0';
+                add_to_str_hex_bytes(screen_buf, listen_addr, listen_addr_len);
+                canvas_draw_str(canvas, 40, 25, screen_buf);
+            }
+            snprintf(
+                screen_buf,
+                sizeof(screen_buf),
+                "I: %d +(%d) mA",
+                Current - CurrentStart,
+                CurrentStart);
+            canvas_draw_str(canvas, 0, 60, screen_buf);
+        } else {
+            canvas_set_font(canvas, FontBatteryPercent); // 5x7 font, 9 lines, 25 cols
+            if(rw_type == rwt_read_batch) {
+                canvas_draw_str(canvas, 0, 7, "Read Batch:");
+                render_display_list(
+                    canvas, &ReadBatch_cmd, ':', view_cmd[rw_type], ReadBatch_cmd_Total);
+            } else if(rw_type == rwt_read_cmd) {
+                canvas_draw_str(canvas, 0, 7, "Read Command:");
+                render_display_list(canvas, &Read_cmd, '=', view_cmd[rw_type], Read_cmd_Total);
+            } else if(rw_type == rwt_write_batch) {
+                if(!ask_fill_screen_buf()) strcpy(screen_buf, "Write Batch:");
+                canvas_draw_str(canvas, 0, 7, screen_buf);
+                render_display_list(
+                    canvas, &WriteBatch_cmd, ':', view_cmd[rw_type], WriteBatch_cmd_Total);
+            } else if(rw_type == rwt_set_batch) {
+                strcpy(screen_buf, "Set: ");
+                display_add_status();
+                canvas_draw_str(canvas, 0, 7, screen_buf);
+                render_display_list(
+                    canvas, &SetBatch_cmd, ':', view_cmd[rw_type], SetBatch_cmd_Total);
+            }
+        }
+    } else { // what_doing == 2
+        if(rw_type == rwt_listen) {
+            canvas_set_font(canvas, FontSecondary); // 8x10 font, 6 lines
+            strcpy(screen_buf, "Listen: ");
+            if(NRF_ERROR)
+                strcat(screen_buf, "nRF24 ERROR!");
+            else if(ListenNew) {
+                snprintf(
+                    screen_buf + strlen(screen_buf),
+                    16,
+                    "%02d:%02d:%02d",
+                    ListenLastTime.hour,
+                    ListenLastTime.minute,
+                    ListenLastTime.second);
+                if(ListenPrev)
+                    snprintf(
+                        screen_buf + strlen(screen_buf), 16, " (%lu)", ListenLast - ListenPrev);
+            } else
+                strcat(screen_buf, "receiving");
+            snprintf(screen_buf + strlen(screen_buf), 16, " %dmA", Current - CurrentStart);
+            canvas_draw_str(canvas, 0, 10, screen_buf);
+            if(ListenFields) {
+                char *p2, *p = ListenFields;
+                uint8_t hex, len, *pld = payload_receive;
+                for(uint8_t i = 0; i < 5 && *p; i++) {
+                    hex = false;
+                    p2 = strchr(p, ',');
+                    if(p2 == NULL) p2 = p + strlen(p);
+                    if(*(p2 - 1) == '#') hex = true;
+                    memcpy(screen_buf, p, len = p2 - p);
+                    strcpy(screen_buf + len, ": ");
+                    if(ListenNew) {
+                        len = payload_struct[i];
+                        int32_t n = get_payload_receive_field(pld, len);
+                        if(hex) {
+                            strcat(screen_buf, "0x");
+                            add_to_str_hex_variable(screen_buf, pld, len);
+                        } else {
+                            snprintf(screen_buf + strlen(screen_buf), 20, "%ld", n);
+                            if(n > 9) {
+                                strcat(screen_buf, " (");
+                                add_to_str_hex_variable(screen_buf, pld, len);
+                                strcat(screen_buf, ")");
+                            }
+                        }
+                        pld += len;
+                    }
+                    canvas_draw_str(canvas, 0, 20 + i * 10, screen_buf);
+                    if(*p2 == '\0') break;
+                    p = p2 + 1;
+                }
+            }
+        } else if(rw_type == rwt_read_cmd) { // Read command
+            canvas_set_font(canvas, FontSecondary); // 8x10 font, 6 lines
+            if(!ask_fill_screen_buf()) {
+                strcpy(screen_buf, "Read ");
+                strcat(screen_buf, ReadRepeat ? "rep: " : "cmd: ");
+            }
+            display_add_status();
+            canvas_draw_str(canvas, 0, 10, screen_buf);
+            if(Log_Total) {
+                char* p = (char*)furi_string_get_cstr(Log[Log_Total - 1]);
+                uint8_t vx = MIN(view_x, strlen(p));
+                strncpy(screen_buf, p + vx, 30);
+                display_remove_asterisk(p, vx);
+                canvas_draw_str(canvas, 0, 15 + 10, screen_buf);
+            }
+        } else if(rw_type == rwt_set_batch) {
+            canvas_set_font(canvas, FontBatteryPercent); // 5x7 font, 9 lines, 25 cols
+            strcpy(screen_buf, "Set: ");
+            display_add_status();
+            canvas_draw_str(canvas, 0, 7, screen_buf);
+            render_display_list(canvas, &SetBatch_cmd, ':', view_cmd[rw_type], SetBatch_cmd_Total);
+        } else { // rwt_read_batch, rwt_write_batch
+            canvas_set_font(canvas, FontBatteryPercent); // 5x7 font, 9 lines, 25 cols
+            if(!ask_fill_screen_buf()) {
+                strcpy(screen_buf, rw_type == rwt_read_batch ? "Read Batch: " : "Write: ");
+                if(rw_type == rwt_read_batch || send_status != sst_none) {
+                    display_add_status();
+                } else if(rw_type == rwt_write_batch) {
+                    char* p =
+                        (char*)furi_string_get_cstr(WriteBatch_cmd[view_cmd[rwt_write_batch]]);
+                    char* end = strchr(p, ':');
+                    if(end) {
+                        uint8_t len = end - p;
+                        uint8_t lenb = strlen(screen_buf);
+                        end = screen_buf + lenb;
+                        lenb = FONT_5x7_SCREEN_WIDTH - lenb;
+                        if(len > lenb) {
+                            if(view_x < len) {
+                                strncpy(end, p + view_x, len = MIN(lenb, len - view_x));
+                                end[len] = '\0';
+                            }
+                        } else {
+                            strncpy(end, p, len);
+                            end[len] = '\0';
+                        }
+                    }
+                }
+            }
+            canvas_draw_str(canvas, 0, 7, screen_buf);
+            if(Log_Total) {
+                char* p;
+                uint16_t y, page = view_Batch & ~7;
+                uint8_t vx;
+                for(uint8_t i = 0; i < 8 && page + i < Log_Total; i++) {
+                    p = (char*)furi_string_get_cstr(Log[page + i]);
+                    y = 14 + i * 7;
+                    vx = MIN(view_x, strlen(p));
+                    if((view_Batch & 7) == i) {
+                        canvas_draw_str(canvas, 0, y, ">");
+                        canvas_draw_str(canvas, -1, y, ">");
+                        if(Edit) {
+                            int n = Edit_pos - p - vx - (FONT_5x7_SCREEN_WIDTH - 4);
+                            if(n > 0) vx += n; // fix out of screen
+                            int x = 6 + (Edit_pos - p - vx) * 5;
+                            canvas_draw_line(canvas, x - 1, y, x - 1, y - 1);
+                            canvas_draw_line(canvas, x - 1, y, n = x + 1 * 5, y);
+                            canvas_draw_line(canvas, n, y, n, y - 1);
+                        }
+                    }
+                    strncpy(screen_buf, p + vx, FONT_5x7_SCREEN_WIDTH + 2);
+                    screen_buf[FONT_5x7_SCREEN_WIDTH + 2] = '\0';
+                    display_remove_asterisk(p, vx);
+                    canvas_draw_str(canvas, 6, y, screen_buf);
+                }
+            }
+        }
+    }
+    furi_mutex_release(plugin_state->mutex);
+}
 
-void work_timer_callback(void* ctx)
-{
-	if(ctx == NULL) return;
-	if(rw_type == rwt_listen && (pwr_read_timer += WORK_PERIOD) >= POWER_READ_PERIOD) {
-		pwr_read_timer = 0;
-		update_power();
-	}
-	if(what_doing == 2) {
-		const PluginState* plugin_state = ctx;
-		if(furi_mutex_acquire(plugin_state->mutex, 0) != FuriStatusOk) return;
-		if(rw_type == rwt_write_batch || rw_type == rwt_set_batch) {
-			uint16_t *cmd_curr = rw_type == rwt_set_batch ? &SetBatch_cmd_curr : &WriteBatch_cmd_curr;
-			if(ERR == 0 && furi_get_tick() - NRF_time >= delay_between_pkt) {
-				if(send_status == sst_ok) {
-					if(ERR == 0 && *cmd_curr < Log_Total) {
-						if(++(*cmd_curr) < Log_Total) Run_WriteBatch_cmd(); 
-						else { // finished ok
-							if(rw_type == rwt_set_batch) what_doing = 1;
-							Edited = false;
-						}
-					}
-				} else if(send_status == sst_sending) {
-					if(NRF_repeat++ < NRF_resend) nrf24_send_packet(); 
-					else {
-						view_Batch = *cmd_curr;
-						send_status = sst_error; // error NO_ACK
-					}
-				}
-			}
-			if((ERR || send_status == sst_error) && rw_type == rwt_set_batch) {
-				what_doing = 1;
-			}
-		// ReadBatch or ReadCmd
-		} else if(send_status == sst_sending) { // sending
-			if(furi_get_tick() - NRF_time > delay_between_pkt) {
-				if(NRF_repeat++ < NRF_resend) {
-					nrf24_resend_read_packet();
-				} else send_status = sst_error; // error NO_ACK
-			}
-		} else if(send_status == sst_receiving) { // receiving
-			for(uint8_t i = 0; i < 3; i++) {
-				if(nrf24_read_newpacket()) {
-					if(rw_type == rwt_listen) {
-						ListenPrev = ListenLast;
-						furi_hal_rtc_get_datetime(&ListenLastTime);
-						ListenLast = furi_hal_rtc_datetime_to_timestamp(&ListenLastTime);
-						ListenNew = true;
-					} else if(send_status != sst_receiving) break;
-				} else {
-					if(rw_type != rwt_listen && furi_get_tick() - NRF_time > NRF_READ_TIMEOUT) {
-						if(NRF_repeat++ < NRF_resend) {
-							send_status = sst_sending;
-							nrf24_resend_read_packet();
-						} else {
-							FURI_LOG_D(TAG, "TIMEOUT: %lu", furi_get_tick() - NRF_time);
-							send_status = sst_timeout;
-						}
-					}
-					break;
-				}
-			}
-		} else if(send_status == sst_ok) {
-			if(rw_type == rwt_read_batch) {
-				if((uint32_t)ReadBatch_cmd_curr != 0xFFFFFFFF && ERR == 0 && furi_get_tick() - NRF_time >= delay_between_pkt) {
-					Run_ReadBatch_cmd(NULL);
-				}
-			}
-		}
-		furi_mutex_release(plugin_state->mutex);
-	}
+void work_timer_callback(void* ctx) {
+    if(ctx == NULL) return;
+    if(rw_type == rwt_listen && (pwr_read_timer += WORK_PERIOD) >= POWER_READ_PERIOD) {
+        pwr_read_timer = 0;
+        update_power();
+    }
+    if(what_doing == 2) {
+        const PluginState* plugin_state = ctx;
+        if(furi_mutex_acquire(plugin_state->mutex, 0) != FuriStatusOk) return;
+        if(rw_type == rwt_write_batch || rw_type == rwt_set_batch) {
+            uint16_t* cmd_curr = rw_type == rwt_set_batch ? &SetBatch_cmd_curr :
+                                                            &WriteBatch_cmd_curr;
+            if(ERR == 0 && furi_get_tick() - NRF_time >= delay_between_pkt) {
+                if(send_status == sst_ok) {
+                    if(ERR == 0 && *cmd_curr < Log_Total) {
+                        if(++(*cmd_curr) < Log_Total)
+                            Run_WriteBatch_cmd();
+                        else { // finished ok
+                            if(rw_type == rwt_set_batch) what_doing = 1;
+                            Edited = false;
+                        }
+                    }
+                } else if(send_status == sst_sending) {
+                    if(NRF_repeat++ < NRF_resend)
+                        nrf24_send_packet();
+                    else {
+                        view_Batch = *cmd_curr;
+                        send_status = sst_error; // error NO_ACK
+                    }
+                }
+            }
+            if((ERR || send_status == sst_error) && rw_type == rwt_set_batch) {
+                what_doing = 1;
+            }
+            // ReadBatch or ReadCmd
+        } else if(send_status == sst_sending) { // sending
+            if(furi_get_tick() - NRF_time > delay_between_pkt) {
+                if(NRF_repeat++ < NRF_resend) {
+                    nrf24_resend_read_packet();
+                } else
+                    send_status = sst_error; // error NO_ACK
+            }
+        } else if(send_status == sst_receiving) { // receiving
+            for(uint8_t i = 0; i < 3; i++) {
+                if(nrf24_read_newpacket()) {
+                    if(rw_type == rwt_listen) {
+                        ListenPrev = ListenLast;
+                        furi_hal_rtc_get_datetime(&ListenLastTime);
+                        ListenLast = furi_hal_rtc_datetime_to_timestamp(&ListenLastTime);
+                        ListenNew = true;
+                    } else if(send_status != sst_receiving)
+                        break;
+                } else {
+                    if(rw_type != rwt_listen && furi_get_tick() - NRF_time > NRF_READ_TIMEOUT) {
+                        if(NRF_repeat++ < NRF_resend) {
+                            send_status = sst_sending;
+                            nrf24_resend_read_packet();
+                        } else {
+                            FURI_LOG_D(TAG, "TIMEOUT: %lu", furi_get_tick() - NRF_time);
+                            send_status = sst_timeout;
+                        }
+                    }
+                    break;
+                }
+            }
+        } else if(send_status == sst_ok) {
+            if(rw_type == rwt_read_batch) {
+                if((uint32_t)ReadBatch_cmd_curr != 0xFFFFFFFF && ERR == 0 &&
+                   furi_get_tick() - NRF_time >= delay_between_pkt) {
+                    Run_ReadBatch_cmd(NULL);
+                }
+            }
+        }
+        furi_mutex_release(plugin_state->mutex);
+    }
 }
 
-void next_rw_type(int8_t add)
-{
-	do {
-		rw_type += add;
-		if(rw_type >= rwt_max) {
-			if(add > 0) rw_type = 0; else rw_type = rwt_max - 1;
-		}
-		if(rw_type == rwt_set_batch && SetBatch_cmd_Total) break;
-		if(rw_type == rwt_read_batch && ReadBatch_cmd_Total) break;
-		if(rw_type == rwt_read_cmd && Read_cmd_Total) break;
-		if(rw_type == rwt_write_batch && WriteBatch_cmd_Total) break;
-	} while(rw_type != rwt_listen);
-	send_status = sst_none;
+void next_rw_type(int8_t add) {
+    do {
+        rw_type += add;
+        if(rw_type >= rwt_max) {
+            if(add > 0)
+                rw_type = 0;
+            else
+                rw_type = rwt_max - 1;
+        }
+        if(rw_type == rwt_set_batch && SetBatch_cmd_Total) break;
+        if(rw_type == rwt_read_batch && ReadBatch_cmd_Total) break;
+        if(rw_type == rwt_read_cmd && Read_cmd_Total) break;
+        if(rw_type == rwt_write_batch && WriteBatch_cmd_Total) break;
+    } while(rw_type != rwt_listen);
+    send_status = sst_none;
 }
 
-void next_view_cmd(int8_t add)
-{
-	if(rw_type == rwt_listen) return;
-	uint16_t max = (rw_type == rwt_read_batch ? ReadBatch_cmd_Total : 
-					rw_type == rwt_read_cmd ? Read_cmd_Total : 
-					rw_type == rwt_set_batch ? SetBatch_cmd_Total : WriteBatch_cmd_Total);
-	if((view_cmd[rw_type] += add) >= max) view_cmd[rw_type] = add > 0 ? 0 : max - 1;
+void next_view_cmd(int8_t add) {
+    if(rw_type == rwt_listen) return;
+    uint16_t max =
+        (rw_type == rwt_read_batch ? ReadBatch_cmd_Total :
+         rw_type == rwt_read_cmd   ? Read_cmd_Total :
+         rw_type == rwt_set_batch  ? SetBatch_cmd_Total :
+                                     WriteBatch_cmd_Total);
+    if((view_cmd[rw_type] += add) >= max) view_cmd[rw_type] = add > 0 ? 0 : max - 1;
 }
 
 int32_t nrf24batch_app(void* p) {
-	UNUSED(p);
-	APP = malloc(sizeof(nRF24Batch));
-	FuriMessageQueue* event_queue = furi_message_queue_alloc(8, sizeof(PluginEvent));
-	APP->plugin_state = malloc(sizeof(PluginState));
-	APP->plugin_state->mutex = furi_mutex_alloc(FuriMutexTypeNormal);
-	if(!APP->plugin_state->mutex) {
-		furi_message_queue_free(event_queue);
-		FURI_LOG_E(TAG, "cannot create mutex");
-		free(APP->plugin_state);
-		return 255;
-	}
-	// Set system callbacks
-	ViewPort* view_port = view_port_alloc();
-	view_port_draw_callback_set(view_port, render_callback, APP->plugin_state);
-	view_port_input_callback_set(view_port, input_callback, event_queue);
+    UNUSED(p);
+    APP = malloc(sizeof(nRF24Batch));
+    FuriMessageQueue* event_queue = furi_message_queue_alloc(8, sizeof(PluginEvent));
+    APP->plugin_state = malloc(sizeof(PluginState));
+    APP->plugin_state->mutex = furi_mutex_alloc(FuriMutexTypeNormal);
+    if(!APP->plugin_state->mutex) {
+        furi_message_queue_free(event_queue);
+        FURI_LOG_E(TAG, "cannot create mutex");
+        free(APP->plugin_state);
+        return 255;
+    }
+    // Set system callbacks
+    ViewPort* view_port = view_port_alloc();
+    view_port_draw_callback_set(view_port, render_callback, APP->plugin_state);
+    view_port_input_callback_set(view_port, input_callback, event_queue);
+
+    // Open GUI and register view_port
+    APP->gui = furi_record_open(RECORD_GUI);
+    gui_add_view_port(APP->gui, view_port, GuiLayerFullscreen);
+    APP->notification = furi_record_open(RECORD_NOTIFICATION);
+    APP->storage = furi_record_open(RECORD_STORAGE);
+    storage_common_mkdir(APP->storage, SCAN_APP_PATH_FOLDER);
+    file_stream = file_stream_alloc(APP->storage);
+    FuriTimer* work_timer =
+        furi_timer_alloc(work_timer_callback, FuriTimerTypePeriodic, APP->plugin_state);
+    furi_timer_start(work_timer, WORK_PERIOD);
+    nrf24_init();
+    check_en_power_5V();
 
-	// Open GUI and register view_port
-	APP->gui = furi_record_open(RECORD_GUI);
-	gui_add_view_port(APP->gui, view_port, GuiLayerFullscreen);
-	APP->notification = furi_record_open(RECORD_NOTIFICATION);
-	APP->storage = furi_record_open(RECORD_STORAGE);
-	storage_common_mkdir(APP->storage, SCAN_APP_PATH_FOLDER);
-	file_stream = file_stream_alloc(APP->storage);
-	FuriTimer *work_timer = furi_timer_alloc(work_timer_callback, FuriTimerTypePeriodic, APP->plugin_state);
-	furi_timer_start(work_timer, WORK_PERIOD);
-	nrf24_init();
-	check_en_power_5V();
+    PluginEvent event;
+    for(bool processing = true; processing;) {
+        FuriStatus event_status = furi_message_queue_get(event_queue, &event, 100);
+        furi_mutex_acquire(APP->plugin_state->mutex, FuriWaitForever);
 
-	PluginEvent event;
-	for(bool processing = true; processing;) {
-		FuriStatus event_status = furi_message_queue_get(event_queue, &event, 100);
-		furi_mutex_acquire(APP->plugin_state->mutex, FuriWaitForever);
-		
-		static FuriLogLevel FuriLogLevel = FuriLogLevelDefault;
-		if(furi_log_get_level() != FuriLogLevel) {
-		 	FuriLogLevel = furi_log_get_level();
-		 	if(FuriLogLevel == FuriLogLevelDebug) furi_hal_uart_set_br(FuriHalUartIdUSART1, 1843200);
-		}
-		if(what_doing == 2 && rw_type == rwt_read_cmd && ReadRepeat && furi_get_tick() - NRF_time > (uint32_t)(ReadCmdRepeatPeriod * 1000)) {
-			ERR = 0;
-			free_Log();
-			Run_Read_cmd(Read_cmd[view_cmd[rwt_read_cmd]]);
-			notification_message(APP->notification, &sequence_blink_blue_100);
-		}
+        static FuriLogLevel FuriLogLevel = FuriLogLevelDefault;
+        if(furi_log_get_level() != FuriLogLevel) {
+            FuriLogLevel = furi_log_get_level();
+            if(FuriLogLevel == FuriLogLevelDebug)
+                furi_hal_uart_set_br(FuriHalUartIdUSART1, 1843200);
+        }
+        if(what_doing == 2 && rw_type == rwt_read_cmd && ReadRepeat &&
+           furi_get_tick() - NRF_time > (uint32_t)(ReadCmdRepeatPeriod * 1000)) {
+            ERR = 0;
+            free_Log();
+            Run_Read_cmd(Read_cmd[view_cmd[rwt_read_cmd]]);
+            notification_message(APP->notification, &sequence_blink_blue_100);
+        }
 
-		if(event_status == FuriStatusOk) {
-			// press events
-			if(event.type == EventTypeKey) {
-				switch(event.input.key) {
-				case InputKeyUp:
-					if(event.input.type == InputTypeShort || event.input.type == InputTypeRepeat) {
-						if(!ask_question) {
-							if(Edit) {
-								char c = *Edit_pos;
-								if(Edit_hex) {
-									if(c == '9') *Edit_pos = 'A';
-									else if(c < 'F' || c < '9') *Edit_pos = c + 1;
-								} else {
-									if(c == '-') *Edit_pos = '0';
-									else if(c < '9') *Edit_pos = c + 1;
-									else {
-										c = *(Edit_pos - 1);
-										if(Edit_pos > Edit_start && c < '9' && c >= '0') {
-											*Edit_pos = '0';
-											(*(Edit_pos - 1)) = c + 1;
-										}
-									}
-								}	
-							} else if(what_doing == 0) {
-								if(addr_len) {
-									if(setup_cursor > 0) setup_cursor--; else setup_cursor = 2;
-								}
-							} else if(what_doing == 1) next_view_cmd(-1);
-							else if(what_doing == 2) if(view_Batch) view_Batch--;
-						}
-					}
-					break;
-				case InputKeyDown:
-					if(event.input.type == InputTypeShort || event.input.type == InputTypeRepeat) {
-						if(!ask_question) {
-							if(Edit) {
-								if(*Edit_pos != '-') {
-									if(Edit_hex && *Edit_pos == 'A') (*Edit_pos) = '9';
-									else if(*Edit_pos > '0') (*Edit_pos)--;
-									else if(!Edit_hex) {
-										if(Edit_pos > Edit_start) {
-											if(*(Edit_pos - 1) > '0' && *(Edit_pos - 1) <= '9') {
-												*Edit_pos = '9';
-												(*(Edit_pos - 1))--;
-											}
-										} else Edit_insert_digit('-'); // negative
-									}
-								}
-							} else if(what_doing == 0) {
-								if(addr_len) {
-									if(setup_cursor < 2) setup_cursor++; else setup_cursor = 0;
-								}
-							} else if(what_doing == 1) next_view_cmd(+1);
-							else if(what_doing == 2) if(view_Batch < Log_Total - 1) view_Batch++;
-						}
-					}
-					break;
-				case InputKeyLeft:
-					if(event.input.type == InputTypeShort || event.input.type == InputTypeRepeat) {
-						if(ask_question) {
-							if(event.input.type == InputTypeShort) ask_question_answer ^= 1;
-						} else if(Edit) {
-							if(Edit_pos > Edit_start) {
-								if(is_digit(Edit_pos - 1, Edit_hex)) Edit_pos--;
-								else if(*(Edit_pos - 1) == 'x' && *(Edit_pos - 3) == ',') Edit_pos -= 4;
-								else if(*(Edit_pos - 1) == ',') Edit_pos -= 2;
-							}
-						} else if(what_doing == 0) {
-							if(addr_len) {
-								rw_type = rwt_listen;
-								what_doing = 1;
-							}
-						} else if(what_doing == 1) {
-							if(event.input.type == InputTypeShort) next_rw_type(-1); else if(view_x) view_x--;
-						} else if(what_doing == 2) if(view_x) view_x--;
-					} else if(event.input.type == InputTypeLong) {
-						if(!ask_question && view_x == 0 && what_doing == 2 && (rw_type == rwt_write_batch || rw_type == rwt_read_batch) 
-								&& Log_Total && Log[view_Batch] != NULL) {
-							ask_question = ask_skip_cmd;
-							ask_question_answer = 1;
-						}
-					}
-					break;
-				case InputKeyRight:
-					if(event.input.type == InputTypeShort || event.input.type == InputTypeRepeat) {
-						if(ask_question) {
-							ask_question_answer ^= 1;
-						} else if(Edit) {
-							if(is_digit(Edit_pos + 1, Edit_hex)) Edit_pos++;
-							else if(*(Edit_pos + 1) == ',') {
-								Edit_pos += 2;
-								if(*(Edit_pos + 1) == 'x') Edit_pos += 2;
-							}
-						} else if(what_doing == 0) {
-							if(addr_len) {
-								rw_type = rwt_set_batch;
-								what_doing = 1;
-							}
-						} else if(what_doing == 1) {
-							if(event.input.type == InputTypeShort) next_rw_type(+1); else view_x++;
-						} else if(what_doing == 2) view_x++;
-					}
-					break;
-				case InputKeyOk:
-					if(event.input.type == InputTypeShort) {
-						if(ask_question) {
-							if(ask_question_answer) {
-								if(ask_question == ask_save_batch) {
-									save_batch();
-								} else if(ask_question == ask_write_batch) {
-									if(WriteBatch_cmd_Total) {
-										if(what_doing == 1) {
-											Prepare_Write_cmd(WriteBatch_cmd[view_cmd[rwt_write_batch]]);
-											send_status = sst_none;
-											Edited = false;
-											view_x = 0;
-											view_Batch = 0;
-										}
-										if(Log_Total) {
-											ERR = 0;
-											WriteBatch_cmd_curr = 0;
-											Run_WriteBatch_cmd();
-											what_doing = 2;
-										}
-									}
-								} else if(ask_question == ask_skip_cmd) {
-									if(rw_type == rwt_write_batch || rw_type == rwt_read_batch) {
-										furi_string_free(Log[view_Batch]);
-										if(view_Batch < Log_Total - 1) memmove(&Log[view_Batch], &Log[view_Batch + 1], sizeof(Log) * (Log_Total - view_Batch - 1));
-										else view_Batch--;
-										Log_Total--;
-									}
-								} else if(ask_question == ask_exit) {
-									processing = false;
-								} else if(ask_question == ask_return) {
-									if(what_doing == 2) {
-										ERR = 0;
-										send_status = sst_none;
-										Edited = false;
-										what_doing--;
-									}
-								}
-							}
-							ask_question = 0;
-						} else if(Edit) { // insert digit
-							Edit_insert_digit('0');
-						} else if(what_doing == 0) {
-							if(setup_cursor == 0) { // open file
-								file_stream_close(file_stream);
-								if(select_settings_file()) {
-									uint8_t err = load_settings_file();
-									if(err) snprintf(file_name, sizeof(file_name), "LOAD ERROR #%d", err);
-								}
-							} else if(setup_cursor == 1) { // change address
-								char *ebuf = (char*)payload;
-								ebuf[0] = '\0';
-								add_to_str_hex_bytes(ebuf, addr, addr_len);
-								Edit_hex = true;
-								Edit_pos = ebuf + strlen(ebuf) - 1;
-								Edit_start = ebuf;
-								Edit = 1;
-								NRF_INITED = 0;
-							} else if(setup_cursor == 2) { // change channel
-								char *ebuf = (char*)payload;
-								snprintf(ebuf, sizeof(payload), "%d", NRF_channel);
-								Edit_hex = false;
-								Edit_pos = ebuf + strlen(ebuf) - 1;
-								Edit_start = ebuf;
-								Edit = 1;
-								NRF_INITED = 0;
-							}
-						} else if(what_doing == 1) {
-							if(rw_type == rwt_set_batch) {
-								if(SetBatch_cmd_Total) {
-									ERR = 0;
-									send_status = sst_none;
-									Prepare_Write_cmd(SetBatch_cmd[view_cmd[rwt_set_batch]]);
-									if(!ERR) {
-										SetBatch_cmd_curr = 0;
-										Run_WriteBatch_cmd();
-										what_doing = 2;
-									}
-									Edited = false;
-								}
-							} else if(rw_type == rwt_read_batch) {
-								if(ReadBatch_cmd_Total) {
-									ERR = 0;
-									Run_ReadBatch_cmd(ReadBatch_cmd[view_cmd[rwt_read_batch]]);
-									view_x = 0;
-									view_Batch = 0;
-									what_doing = 2;
-								}
-							} else if(rw_type == rwt_read_cmd) {
-								if(Read_cmd_Total) {
-									ERR = 0;
-									free_Log();
-									Run_Read_cmd(Read_cmd[view_cmd[rwt_read_cmd]]);
-									view_x = 0;
-									what_doing = 2;
-								}
-							} else if(rw_type == rwt_write_batch) {
-								if(WriteBatch_cmd_Total) {
-									ERR = 0;
-									Prepare_Write_cmd(WriteBatch_cmd[view_cmd[rwt_write_batch]]);
-									send_status = sst_none;
-									Edited = false;
-									view_x = 0;
-									view_Batch = 0;
-									what_doing = 2;
-								}
-							} else if(rw_type == rwt_listen) {
-								if(listen_addr_len) {
-									free_Log();
-									prepare_nrf24();
-									if(!NRF_ERROR) {
-										nrf24_set_rx_mode(nrf24_HANDLE);
-										ListenNew = false;
-										send_status = sst_receiving; // receiving
-									}
-									what_doing = 2;
-								}
-							}
-						} else if(what_doing == 2) {		
-							if(rw_type == rwt_read_cmd) {
-								ERR = 0;
-								free_Log();
-								Run_Read_cmd(Read_cmd[view_cmd[rwt_read_cmd]]);
-							} else if(Log_Total) {
-								if(rw_type == rwt_read_batch) {
-									ask_question = ask_save_batch;
-									ask_question_answer = 0;
-								} else if(rw_type == rwt_write_batch) {
-									ask_question = ask_write_batch;
-									ask_question_answer = 0;
-								}
-							}
-						}
-					} else if(event.input.type == InputTypeLong) {
-						if(Edit) { // delete
-							if(what_doing <= 1) {
-								if(strlen(Edit_start) > 1) {
-									memmove(Edit_pos, Edit_pos + 1, strlen(Edit_pos));
-									if(*Edit_pos == '\0') Edit_pos--;
-								}
-							} else {
-								FuriString *fs = Log[view_Batch];
-								if(is_digit(Edit_pos + 1, Edit_hex) || (Edit_pos > Edit_start && is_digit(Edit_pos - 1, Edit_hex))) { 
-									memmove(Edit_pos, Edit_pos + 1, strlen(Edit_pos));
-									if(*Edit_pos == '\0') Edit_pos--;
-									furi_string_left(fs, furi_string_size(fs) - 1);
-								}
-							}
-						} else if(what_doing == 1) {
-							if(rw_type == rwt_listen) {
-								if(listen_addr_len) {
-									char *ebuf = (char*)payload;
-									ebuf[0] = '\0';
-									add_to_str_hex_bytes(ebuf, listen_addr, listen_addr_len);
-									Edit_hex = true;
-									Edit_pos = ebuf + strlen(ebuf) - 1;
-									Edit_start = ebuf;
-									Edit = 1;
-									NRF_INITED = 0;
-								}
-							} else if(rw_type == rwt_read_batch) {
-								if(ReadBatch_cmd_Total) {
-									ERR = 0;
-									Run_ReadBatch_cmd(ReadBatch_cmd[view_cmd[rwt_read_batch]]);
-									view_x = 0;
-									view_Batch = 0;
-									what_doing = 2;
-								}
-							} else if(rw_type == rwt_write_batch) {
-								ask_question = ask_write_batch;
-								ask_question_answer = 0;
-							}
-						} else if(what_doing == 2) {
-							if(rw_type == rwt_read_cmd) {
-								ReadRepeat = !ReadRepeat;
-							} else if(Log_Total) {
-								if(rw_type == rwt_write_batch) {
-									if(!Edit) {
-										Edit = 0;
-										Edit_hex = 0;
-										char *s = (char*)furi_string_get_cstr(Log[view_Batch]);
-										char *p = strchr(s, '=');
-										if(p) {
-											p++;
-											if(*p == '{') p++; // array
-											if(*(p + 1) == 'x') { 
-												p += 2;
-												Edit_hex = 1; // hex
-											}
-											if(is_digit(p, Edit_hex)) {
-												Edit_start = p;
-												while(is_digit(p, Edit_hex)) p++;
-												Edit_pos = p - 1;
-												Edited = true;
-												Edit = 1;
-											}
-										}
-									}
-								} else if(rw_type == rwt_read_batch) {
-									ask_question = ask_save_batch;
-									ask_question_answer = 0;
-								}
-							}
-						}
-					}
-					break;
-				case InputKeyBack:
-					if(event.input.type == InputTypeLong) {
-						if(what_doing == 2 && Edited) {
-							if(!ask_question) ask_question_answer = 1;
-							ask_question = ask_exit;
-						} else processing = false;
-					} else if(event.input.type == InputTypeShort) {
-						if(ask_question) ask_question = 0;
-						else if(Edit) {
-							if(what_doing == 0) {
-								if(setup_cursor == 1) {
-									addr_len = ConvertHexToArray((char*)payload, addr, 5);
-								} else if(setup_cursor == 2) {
-									NRF_channel = str_to_int((char*)payload);
-									if(NRF_channel > MAX_CHANNEL) NRF_channel = MAX_CHANNEL;
-								}
-							} else if(what_doing == 1 && rw_type == rwt_listen) {
-								listen_addr_len = ConvertHexToArray((char*)payload, listen_addr, 5);
-							}
-							Edit = 0;
-						} else {
-							if(what_doing == 2 && Edited) {
-								ask_question = ask_return;
-								ask_question_answer = 1;
-							} else if(what_doing != 0) {
-								if(what_doing) what_doing--;
-								if(what_doing == 0) rw_type = rwt_read_batch;
-								if(what_doing <= 1) view_x = 0;
-								ERR = 0;
-								send_status = sst_none;
-							}
-						}
-					}
-					break;
-				default:
-					break;
-				}
-			}
-		}
+        if(event_status == FuriStatusOk) {
+            // press events
+            if(event.type == EventTypeKey) {
+                switch(event.input.key) {
+                case InputKeyUp:
+                    if(event.input.type == InputTypeShort || event.input.type == InputTypeRepeat) {
+                        if(!ask_question) {
+                            if(Edit) {
+                                char c = *Edit_pos;
+                                if(Edit_hex) {
+                                    if(c == '9')
+                                        *Edit_pos = 'A';
+                                    else if(c < 'F' || c < '9')
+                                        *Edit_pos = c + 1;
+                                } else {
+                                    if(c == '-')
+                                        *Edit_pos = '0';
+                                    else if(c < '9')
+                                        *Edit_pos = c + 1;
+                                    else {
+                                        c = *(Edit_pos - 1);
+                                        if(Edit_pos > Edit_start && c < '9' && c >= '0') {
+                                            *Edit_pos = '0';
+                                            (*(Edit_pos - 1)) = c + 1;
+                                        }
+                                    }
+                                }
+                            } else if(what_doing == 0) {
+                                if(addr_len) {
+                                    if(setup_cursor > 0)
+                                        setup_cursor--;
+                                    else
+                                        setup_cursor = 2;
+                                }
+                            } else if(what_doing == 1)
+                                next_view_cmd(-1);
+                            else if(what_doing == 2)
+                                if(view_Batch) view_Batch--;
+                        }
+                    }
+                    break;
+                case InputKeyDown:
+                    if(event.input.type == InputTypeShort || event.input.type == InputTypeRepeat) {
+                        if(!ask_question) {
+                            if(Edit) {
+                                if(*Edit_pos != '-') {
+                                    if(Edit_hex && *Edit_pos == 'A')
+                                        (*Edit_pos) = '9';
+                                    else if(*Edit_pos > '0')
+                                        (*Edit_pos)--;
+                                    else if(!Edit_hex) {
+                                        if(Edit_pos > Edit_start) {
+                                            if(*(Edit_pos - 1) > '0' && *(Edit_pos - 1) <= '9') {
+                                                *Edit_pos = '9';
+                                                (*(Edit_pos - 1))--;
+                                            }
+                                        } else
+                                            Edit_insert_digit('-'); // negative
+                                    }
+                                }
+                            } else if(what_doing == 0) {
+                                if(addr_len) {
+                                    if(setup_cursor < 2)
+                                        setup_cursor++;
+                                    else
+                                        setup_cursor = 0;
+                                }
+                            } else if(what_doing == 1)
+                                next_view_cmd(+1);
+                            else if(what_doing == 2)
+                                if(view_Batch < Log_Total - 1) view_Batch++;
+                        }
+                    }
+                    break;
+                case InputKeyLeft:
+                    if(event.input.type == InputTypeShort || event.input.type == InputTypeRepeat) {
+                        if(ask_question) {
+                            if(event.input.type == InputTypeShort) ask_question_answer ^= 1;
+                        } else if(Edit) {
+                            if(Edit_pos > Edit_start) {
+                                if(is_digit(Edit_pos - 1, Edit_hex))
+                                    Edit_pos--;
+                                else if(*(Edit_pos - 1) == 'x' && *(Edit_pos - 3) == ',')
+                                    Edit_pos -= 4;
+                                else if(*(Edit_pos - 1) == ',')
+                                    Edit_pos -= 2;
+                            }
+                        } else if(what_doing == 0) {
+                            if(addr_len) {
+                                rw_type = rwt_listen;
+                                what_doing = 1;
+                            }
+                        } else if(what_doing == 1) {
+                            if(event.input.type == InputTypeShort)
+                                next_rw_type(-1);
+                            else if(view_x)
+                                view_x--;
+                        } else if(what_doing == 2)
+                            if(view_x) view_x--;
+                    } else if(event.input.type == InputTypeLong) {
+                        if(!ask_question && view_x == 0 && what_doing == 2 &&
+                           (rw_type == rwt_write_batch || rw_type == rwt_read_batch) &&
+                           Log_Total && Log[view_Batch] != NULL) {
+                            ask_question = ask_skip_cmd;
+                            ask_question_answer = 1;
+                        }
+                    }
+                    break;
+                case InputKeyRight:
+                    if(event.input.type == InputTypeShort || event.input.type == InputTypeRepeat) {
+                        if(ask_question) {
+                            ask_question_answer ^= 1;
+                        } else if(Edit) {
+                            if(is_digit(Edit_pos + 1, Edit_hex))
+                                Edit_pos++;
+                            else if(*(Edit_pos + 1) == ',') {
+                                Edit_pos += 2;
+                                if(*(Edit_pos + 1) == 'x') Edit_pos += 2;
+                            }
+                        } else if(what_doing == 0) {
+                            if(addr_len) {
+                                rw_type = rwt_set_batch;
+                                what_doing = 1;
+                            }
+                        } else if(what_doing == 1) {
+                            if(event.input.type == InputTypeShort)
+                                next_rw_type(+1);
+                            else
+                                view_x++;
+                        } else if(what_doing == 2)
+                            view_x++;
+                    }
+                    break;
+                case InputKeyOk:
+                    if(event.input.type == InputTypeShort) {
+                        if(ask_question) {
+                            if(ask_question_answer) {
+                                if(ask_question == ask_save_batch) {
+                                    save_batch();
+                                } else if(ask_question == ask_write_batch) {
+                                    if(WriteBatch_cmd_Total) {
+                                        if(what_doing == 1) {
+                                            Prepare_Write_cmd(
+                                                WriteBatch_cmd[view_cmd[rwt_write_batch]]);
+                                            send_status = sst_none;
+                                            Edited = false;
+                                            view_x = 0;
+                                            view_Batch = 0;
+                                        }
+                                        if(Log_Total) {
+                                            ERR = 0;
+                                            WriteBatch_cmd_curr = 0;
+                                            Run_WriteBatch_cmd();
+                                            what_doing = 2;
+                                        }
+                                    }
+                                } else if(ask_question == ask_skip_cmd) {
+                                    if(rw_type == rwt_write_batch || rw_type == rwt_read_batch) {
+                                        furi_string_free(Log[view_Batch]);
+                                        if(view_Batch < Log_Total - 1)
+                                            memmove(
+                                                &Log[view_Batch],
+                                                &Log[view_Batch + 1],
+                                                sizeof(Log) * (Log_Total - view_Batch - 1));
+                                        else
+                                            view_Batch--;
+                                        Log_Total--;
+                                    }
+                                } else if(ask_question == ask_exit) {
+                                    processing = false;
+                                } else if(ask_question == ask_return) {
+                                    if(what_doing == 2) {
+                                        ERR = 0;
+                                        send_status = sst_none;
+                                        Edited = false;
+                                        what_doing--;
+                                    }
+                                }
+                            }
+                            ask_question = 0;
+                        } else if(Edit) { // insert digit
+                            Edit_insert_digit('0');
+                        } else if(what_doing == 0) {
+                            if(setup_cursor == 0) { // open file
+                                file_stream_close(file_stream);
+                                if(select_settings_file()) {
+                                    uint8_t err = load_settings_file();
+                                    if(err)
+                                        snprintf(
+                                            file_name, sizeof(file_name), "LOAD ERROR #%d", err);
+                                }
+                            } else if(setup_cursor == 1) { // change address
+                                char* ebuf = (char*)payload;
+                                ebuf[0] = '\0';
+                                add_to_str_hex_bytes(ebuf, addr, addr_len);
+                                Edit_hex = true;
+                                Edit_pos = ebuf + strlen(ebuf) - 1;
+                                Edit_start = ebuf;
+                                Edit = 1;
+                                NRF_INITED = 0;
+                            } else if(setup_cursor == 2) { // change channel
+                                char* ebuf = (char*)payload;
+                                snprintf(ebuf, sizeof(payload), "%d", NRF_channel);
+                                Edit_hex = false;
+                                Edit_pos = ebuf + strlen(ebuf) - 1;
+                                Edit_start = ebuf;
+                                Edit = 1;
+                                NRF_INITED = 0;
+                            }
+                        } else if(what_doing == 1) {
+                            if(rw_type == rwt_set_batch) {
+                                if(SetBatch_cmd_Total) {
+                                    ERR = 0;
+                                    send_status = sst_none;
+                                    Prepare_Write_cmd(SetBatch_cmd[view_cmd[rwt_set_batch]]);
+                                    if(!ERR) {
+                                        SetBatch_cmd_curr = 0;
+                                        Run_WriteBatch_cmd();
+                                        what_doing = 2;
+                                    }
+                                    Edited = false;
+                                }
+                            } else if(rw_type == rwt_read_batch) {
+                                if(ReadBatch_cmd_Total) {
+                                    ERR = 0;
+                                    Run_ReadBatch_cmd(ReadBatch_cmd[view_cmd[rwt_read_batch]]);
+                                    view_x = 0;
+                                    view_Batch = 0;
+                                    what_doing = 2;
+                                }
+                            } else if(rw_type == rwt_read_cmd) {
+                                if(Read_cmd_Total) {
+                                    ERR = 0;
+                                    free_Log();
+                                    Run_Read_cmd(Read_cmd[view_cmd[rwt_read_cmd]]);
+                                    view_x = 0;
+                                    what_doing = 2;
+                                }
+                            } else if(rw_type == rwt_write_batch) {
+                                if(WriteBatch_cmd_Total) {
+                                    ERR = 0;
+                                    Prepare_Write_cmd(WriteBatch_cmd[view_cmd[rwt_write_batch]]);
+                                    send_status = sst_none;
+                                    Edited = false;
+                                    view_x = 0;
+                                    view_Batch = 0;
+                                    what_doing = 2;
+                                }
+                            } else if(rw_type == rwt_listen) {
+                                if(listen_addr_len) {
+                                    free_Log();
+                                    prepare_nrf24();
+                                    if(!NRF_ERROR) {
+                                        nrf24_set_rx_mode(nrf24_HANDLE);
+                                        ListenNew = false;
+                                        send_status = sst_receiving; // receiving
+                                    }
+                                    what_doing = 2;
+                                }
+                            }
+                        } else if(what_doing == 2) {
+                            if(rw_type == rwt_read_cmd) {
+                                ERR = 0;
+                                free_Log();
+                                Run_Read_cmd(Read_cmd[view_cmd[rwt_read_cmd]]);
+                            } else if(Log_Total) {
+                                if(rw_type == rwt_read_batch) {
+                                    ask_question = ask_save_batch;
+                                    ask_question_answer = 0;
+                                } else if(rw_type == rwt_write_batch) {
+                                    ask_question = ask_write_batch;
+                                    ask_question_answer = 0;
+                                }
+                            }
+                        }
+                    } else if(event.input.type == InputTypeLong) {
+                        if(Edit) { // delete
+                            if(what_doing <= 1) {
+                                if(strlen(Edit_start) > 1) {
+                                    memmove(Edit_pos, Edit_pos + 1, strlen(Edit_pos));
+                                    if(*Edit_pos == '\0') Edit_pos--;
+                                }
+                            } else {
+                                FuriString* fs = Log[view_Batch];
+                                if(is_digit(Edit_pos + 1, Edit_hex) ||
+                                   (Edit_pos > Edit_start && is_digit(Edit_pos - 1, Edit_hex))) {
+                                    memmove(Edit_pos, Edit_pos + 1, strlen(Edit_pos));
+                                    if(*Edit_pos == '\0') Edit_pos--;
+                                    furi_string_left(fs, furi_string_size(fs) - 1);
+                                }
+                            }
+                        } else if(what_doing == 1) {
+                            if(rw_type == rwt_listen) {
+                                if(listen_addr_len) {
+                                    char* ebuf = (char*)payload;
+                                    ebuf[0] = '\0';
+                                    add_to_str_hex_bytes(ebuf, listen_addr, listen_addr_len);
+                                    Edit_hex = true;
+                                    Edit_pos = ebuf + strlen(ebuf) - 1;
+                                    Edit_start = ebuf;
+                                    Edit = 1;
+                                    NRF_INITED = 0;
+                                }
+                            } else if(rw_type == rwt_read_batch) {
+                                if(ReadBatch_cmd_Total) {
+                                    ERR = 0;
+                                    Run_ReadBatch_cmd(ReadBatch_cmd[view_cmd[rwt_read_batch]]);
+                                    view_x = 0;
+                                    view_Batch = 0;
+                                    what_doing = 2;
+                                }
+                            } else if(rw_type == rwt_write_batch) {
+                                ask_question = ask_write_batch;
+                                ask_question_answer = 0;
+                            }
+                        } else if(what_doing == 2) {
+                            if(rw_type == rwt_read_cmd) {
+                                ReadRepeat = !ReadRepeat;
+                            } else if(Log_Total) {
+                                if(rw_type == rwt_write_batch) {
+                                    if(!Edit) {
+                                        Edit = 0;
+                                        Edit_hex = 0;
+                                        char* s = (char*)furi_string_get_cstr(Log[view_Batch]);
+                                        char* p = strchr(s, '=');
+                                        if(p) {
+                                            p++;
+                                            if(*p == '{') p++; // array
+                                            if(*(p + 1) == 'x') {
+                                                p += 2;
+                                                Edit_hex = 1; // hex
+                                            }
+                                            if(is_digit(p, Edit_hex)) {
+                                                Edit_start = p;
+                                                while(is_digit(p, Edit_hex)) p++;
+                                                Edit_pos = p - 1;
+                                                Edited = true;
+                                                Edit = 1;
+                                            }
+                                        }
+                                    }
+                                } else if(rw_type == rwt_read_batch) {
+                                    ask_question = ask_save_batch;
+                                    ask_question_answer = 0;
+                                }
+                            }
+                        }
+                    }
+                    break;
+                case InputKeyBack:
+                    if(event.input.type == InputTypeLong) {
+                        if(what_doing == 2 && Edited) {
+                            if(!ask_question) ask_question_answer = 1;
+                            ask_question = ask_exit;
+                        } else
+                            processing = false;
+                    } else if(event.input.type == InputTypeShort) {
+                        if(ask_question)
+                            ask_question = 0;
+                        else if(Edit) {
+                            if(what_doing == 0) {
+                                if(setup_cursor == 1) {
+                                    addr_len = ConvertHexToArray((char*)payload, addr, 5);
+                                } else if(setup_cursor == 2) {
+                                    NRF_channel = str_to_int((char*)payload);
+                                    if(NRF_channel > MAX_CHANNEL) NRF_channel = MAX_CHANNEL;
+                                }
+                            } else if(what_doing == 1 && rw_type == rwt_listen) {
+                                listen_addr_len =
+                                    ConvertHexToArray((char*)payload, listen_addr, 5);
+                            }
+                            Edit = 0;
+                        } else {
+                            if(what_doing == 2 && Edited) {
+                                ask_question = ask_return;
+                                ask_question_answer = 1;
+                            } else if(what_doing != 0) {
+                                if(what_doing) what_doing--;
+                                if(what_doing == 0) rw_type = rwt_read_batch;
+                                if(what_doing <= 1) view_x = 0;
+                                ERR = 0;
+                                send_status = sst_none;
+                            }
+                        }
+                    }
+                    break;
+                default:
+                    break;
+                }
+            }
+        }
 
-		view_port_update(view_port);
-		furi_mutex_release(APP->plugin_state->mutex);
-	}
-	nrf24_set_idle(nrf24_HANDLE);
-	nrf24_deinit();
-	if(NRF_BOARD_POWER_5V) furi_hal_power_disable_otg();
+        view_port_update(view_port);
+        furi_mutex_release(APP->plugin_state->mutex);
+    }
+    nrf24_set_idle(nrf24_HANDLE);
+    nrf24_deinit();
+    if(NRF_BOARD_POWER_5V) furi_hal_power_disable_otg();
 
-	view_port_enabled_set(view_port, false);
-	gui_remove_view_port(APP->gui, view_port);
-	furi_record_close(RECORD_GUI);
-	furi_record_close(RECORD_NOTIFICATION);
-	furi_record_close(RECORD_STORAGE);
-	if(file_stream) {
-		file_stream_close(file_stream);
-		stream_free(file_stream);
-	}
-	view_port_free(view_port);
-	furi_message_queue_free(event_queue);
-	free_store();
-	furi_timer_stop(work_timer);
-	furi_timer_free(work_timer);
-	furi_mutex_free(APP->plugin_state->mutex);
-	free(APP->plugin_state);
-	free(APP);
-	return 0;
+    view_port_enabled_set(view_port, false);
+    gui_remove_view_port(APP->gui, view_port);
+    furi_record_close(RECORD_GUI);
+    furi_record_close(RECORD_NOTIFICATION);
+    furi_record_close(RECORD_STORAGE);
+    if(file_stream) {
+        file_stream_close(file_stream);
+        stream_free(file_stream);
+    }
+    view_port_free(view_port);
+    furi_message_queue_free(event_queue);
+    free_store();
+    furi_timer_stop(work_timer);
+    furi_timer_free(work_timer);
+    furi_mutex_free(APP->plugin_state->mutex);
+    free(APP->plugin_state);
+    free(APP);
+    return 0;
 }

+ 8 - 9
apps_source_code/nrf24-batch/nrf24batch.h

@@ -11,23 +11,22 @@
 #include <power/power_service/power_i.h>
 
 typedef enum {
-	EventTypeTick,
-	EventTypeKey,
+    EventTypeTick,
+    EventTypeKey,
 } EventType;
 
 typedef struct {
-	EventType type;
-	InputEvent input;
+    EventType type;
+    InputEvent input;
 } PluginEvent;
 
 typedef struct {
-	FuriMutex* mutex;
+    FuriMutex* mutex;
 } PluginState;
 
 typedef struct {
     Gui* gui;
-	Storage* storage;
-	NotificationApp* notification;
-	PluginState* plugin_state;
+    Storage* storage;
+    NotificationApp* notification;
+    PluginState* plugin_state;
 } nRF24Batch;
-

Разлика између датотеке није приказан због своје велике величине
+ 710 - 604
apps_source_code/nrf24scan/nrf24scan.c


+ 11 - 12
apps_source_code/nrf24scan/nrf24scan.h

@@ -9,32 +9,31 @@
 #include <notification/notification_messages.h>
 
 typedef enum {
-	EventTypeTick,
-	EventTypeKey,
+    EventTypeTick,
+    EventTypeKey,
 } EventType;
 
 typedef struct {
-	EventType type;
-	InputEvent input;
+    EventType type;
+    InputEvent input;
 } PluginEvent;
 
 typedef struct {
-	FuriMutex* mutex;
+    FuriMutex* mutex;
 } PluginState;
 
 struct FOUND {
-	uint8_t addr_size;
-	uint8_t addr[5];
-	uint16_t total;
+    uint8_t addr_size;
+    uint8_t addr[5];
+    uint16_t total;
 };
 
 typedef struct {
     Gui* gui;
     FuriMessageQueue* event_queue;
     ViewPort* view_port;
-	Storage* storage;
-	NotificationApp* notification;
+    Storage* storage;
+    NotificationApp* notification;
     uint8_t* log_arr;
-	struct FOUND *found;
+    struct FOUND* found;
 } Nrf24Scan;
-

+ 98 - 129
apps_source_code/racegame/race.c

@@ -9,7 +9,6 @@
 #include <furi_hal_gpio.h>
 #include <notification/notification_messages.h>
 
-
 #define BORDER_OFFSET 1
 #define MARGIN_OFFSET 3
 #define BLOCK_HEIGHT 6
@@ -19,19 +18,14 @@
 #define FIELD_HEIGHT 24
 #define PARALLEL_OBSTACLES 3
 
-typedef enum {
-    GameStatePlaying,
-    GameStateGameOver
-} GameState;
+typedef enum { GameStatePlaying, GameStateGameOver } GameState;
 
 typedef struct Point {
     // Also used for offset data, which is sometimes negative
     int8_t x, y;
 } Point;
 
-typedef enum {
-    CarObstacle
-} ObstacleType;
+typedef enum { CarObstacle } ObstacleType;
 
 typedef struct Obstacle {
     ObstacleType type;
@@ -45,7 +39,7 @@ typedef struct {
     Obstacle obstacles[PARALLEL_OBSTACLES];
     int8_t roadStart;
     int8_t level;
-    Point headPosition;    
+    Point headPosition;
     uint16_t motionSpeed;
     GameState gameState;
     FuriTimer* timer;
@@ -61,39 +55,34 @@ typedef struct {
     InputEvent input;
 } RaceGameEvent;
 
-
 static void race_game_draw_playfield(Canvas* const canvas, RaceState* race_state) {
     // Playfield: 11 x 24
 
-    for (int y = 0; y < FIELD_HEIGHT; y++) {
-        for (int x = 0; x < FIELD_WIDTH; x++) {
-            if (race_state->playField[y][x]) {
+    for(int y = 0; y < FIELD_HEIGHT; y++) {
+        for(int x = 0; x < FIELD_WIDTH; x++) {
+            if(race_state->playField[y][x]) {
                 uint16_t xOffset = x * 5;
                 uint16_t yOffset = y * 5;
 
                 canvas_draw_rframe(
-                    canvas, 
-                    BORDER_OFFSET + MARGIN_OFFSET + xOffset, 
-                    BORDER_OFFSET + MARGIN_OFFSET + yOffset - 1, 
-                    BLOCK_WIDTH, 
+                    canvas,
+                    BORDER_OFFSET + MARGIN_OFFSET + xOffset,
+                    BORDER_OFFSET + MARGIN_OFFSET + yOffset - 1,
+                    BLOCK_WIDTH,
                     BLOCK_HEIGHT,
-                    1
-                );
+                    1);
                 canvas_draw_dot(
-                    canvas, 
+                    canvas,
                     BORDER_OFFSET + MARGIN_OFFSET + xOffset + 2,
-                    BORDER_OFFSET + MARGIN_OFFSET + yOffset + 1
-                );
+                    BORDER_OFFSET + MARGIN_OFFSET + yOffset + 1);
                 canvas_draw_dot(
-                    canvas, 
+                    canvas,
                     BORDER_OFFSET + MARGIN_OFFSET + xOffset + 3,
-                    BORDER_OFFSET + MARGIN_OFFSET + yOffset + 1
-                );
+                    BORDER_OFFSET + MARGIN_OFFSET + yOffset + 1);
                 canvas_draw_dot(
-                    canvas, 
+                    canvas,
                     BORDER_OFFSET + MARGIN_OFFSET + xOffset + 2,
-                    BORDER_OFFSET + MARGIN_OFFSET + yOffset + 2
-                ); 
+                    BORDER_OFFSET + MARGIN_OFFSET + yOffset + 2);
             }
         }
     }
@@ -109,23 +98,21 @@ static void race_game_draw_border(Canvas* canvas) {
     canvas_draw_line(canvas, 61, 125, 61, 0);
 }
 
-static void race_game_init_road( RaceState* race_state) {
+static void race_game_init_road(RaceState* race_state) {
     int leftRoad = race_state->roadStart;
-    int rightRoad = race_state->roadStart+1;
-    if (rightRoad == 4) rightRoad=0;    
-    for (int y = 0; y < FIELD_HEIGHT; y++) {
+    int rightRoad = race_state->roadStart + 1;
+    if(rightRoad == 4) rightRoad = 0;
+    for(int y = 0; y < FIELD_HEIGHT; y++) {
         leftRoad++;
         rightRoad++;
-        if (leftRoad<4) {
+        if(leftRoad < 4) {
             race_state->playField[y][0] = true;
         }
-        if (rightRoad<4) {
+        if(rightRoad < 4) {
             race_state->playField[y][10] = true;
         }
-        if (rightRoad==4)
-            rightRoad=0;
-        if (leftRoad==4)
-            leftRoad=0;
+        if(rightRoad == 4) rightRoad = 0;
+        if(leftRoad == 4) leftRoad = 0;
     }
 }
 
@@ -136,11 +123,9 @@ static void draw_callback(Canvas* canvas, void* ctx) {
         return;
     }
 
-
     canvas_clear(canvas);
-    
 
-    race_game_draw_border(canvas);    
+    race_game_draw_border(canvas);
     race_game_draw_playfield(canvas, race_state);
     /*
     // output player score, looks not good
@@ -166,11 +151,8 @@ static void draw_callback(Canvas* canvas, void* ctx) {
         canvas_set_font(canvas, FontSecondary);
         canvas_draw_str_aligned(canvas, 32, 73, AlignCenter, AlignBottom, buffer);
     }
-
 }
 
-
-
 static void input_callback(InputEvent* input_event, void* ctx) {
     furi_assert(ctx);
     FuriMessageQueue* event_queue = ctx;
@@ -188,102 +170,97 @@ static void race_game_init_state(RaceState* race_state) {
     race_state->gameState = GameStatePlaying;
     race_state->score = 0;
     race_state->level = 0;
-    race_state->roadStart=0;
+    race_state->roadStart = 0;
     race_state->motionSpeed = 500;
     Point p = {.x = 5, .y = 20};
-    race_state->headPosition = p;    
-    for (int i=0; i<PARALLEL_OBSTACLES; i++) {
-        Obstacle obstacle = {.type = CarObstacle, .isAlive = false, .position = {.x=0, .y=0}};
+    race_state->headPosition = p;
+    for(int i = 0; i < PARALLEL_OBSTACLES; i++) {
+        Obstacle obstacle = {.type = CarObstacle, .isAlive = false, .position = {.x = 0, .y = 0}};
         race_state->obstacles[i] = obstacle;
     }
     memset(race_state->playField, 0, sizeof(race_state->playField));
     furi_timer_start(race_state->timer, race_state->motionSpeed);
 }
 
-static void race_game_draw_car(RaceState* race_state,Point p, bool changeState) {
-    static Point pointsToCheck[] = {
-        {0, 0}, {0,1}, {-1,1}, {1,1},
-        {0, 2}, {-1, 3}, {1, 3}
-    };
-    for (int i = 0; i<7; i++) {
-        if (p.x+pointsToCheck[i].x>-1 && p.y+pointsToCheck[i].y>-1 && p.x+pointsToCheck[i].x<FIELD_WIDTH && p.y+pointsToCheck[i].y<FIELD_HEIGHT) {
-            if (changeState && race_state->playField[p.y+pointsToCheck[i].y][p.x+pointsToCheck[i].x] ) {
+static void race_game_draw_car(RaceState* race_state, Point p, bool changeState) {
+    static Point pointsToCheck[] = {{0, 0}, {0, 1}, {-1, 1}, {1, 1}, {0, 2}, {-1, 3}, {1, 3}};
+    for(int i = 0; i < 7; i++) {
+        if(p.x + pointsToCheck[i].x > -1 && p.y + pointsToCheck[i].y > -1 &&
+           p.x + pointsToCheck[i].x < FIELD_WIDTH && p.y + pointsToCheck[i].y < FIELD_HEIGHT) {
+            if(changeState &&
+               race_state->playField[p.y + pointsToCheck[i].y][p.x + pointsToCheck[i].x]) {
                 race_state->gameState = GameStateGameOver;
             }
-            race_state->playField[p.y+pointsToCheck[i].y][p.x+pointsToCheck[i].x] = true;
+            race_state->playField[p.y + pointsToCheck[i].y][p.x + pointsToCheck[i].x] = true;
         }
-    }    
+    }
 }
 static void race_game_move_obstacles(RaceState* race_state) {
-    
-    for (int i=0; i<PARALLEL_OBSTACLES; i++) {
-        if (race_state->obstacles[i].isAlive) {
+    for(int i = 0; i < PARALLEL_OBSTACLES; i++) {
+        if(race_state->obstacles[i].isAlive) {
             race_state->obstacles[i].position.y++;
-            if (race_state->obstacles[i].position.y>(FIELD_HEIGHT-1))
+            if(race_state->obstacles[i].position.y > (FIELD_HEIGHT - 1))
                 race_state->obstacles[i].isAlive = false;
-        }            
+        }
     }
-        
 }
 static void race_game_spawn_obstacles(RaceState* race_state) {
-    if (race_state->score % 90 == 0) {
+    if(race_state->score % 90 == 0) {
         int aliveObjects = 0;
 
-        for (int i=0; i<PARALLEL_OBSTACLES; i++) {
-            if (race_state->obstacles[i].isAlive) {
+        for(int i = 0; i < PARALLEL_OBSTACLES; i++) {
+            if(race_state->obstacles[i].isAlive) {
                 aliveObjects++;
-            }            
+            }
         }
-        if (aliveObjects<PARALLEL_OBSTACLES) {
-            for (int i=0; i<PARALLEL_OBSTACLES; i++) {
-                if (!race_state->obstacles[i].isAlive) {
+        if(aliveObjects < PARALLEL_OBSTACLES) {
+            for(int i = 0; i < PARALLEL_OBSTACLES; i++) {
+                if(!race_state->obstacles[i].isAlive) {
                     race_state->obstacles[i].isAlive = true;
                     race_state->obstacles[i].position.y = -4;
                     race_state->obstacles[i].position.x = (rand() % 3) * 3 + 2;
                     break;
-                }            
-            }   
+                }
+            }
         }
     }
 }
 static void race_game_process_step(RaceState* race_state, bool moveRoad) {
-    if(race_state->gameState == GameStateGameOver)
-        return;
-
+    if(race_state->gameState == GameStateGameOver) return;
 
-    
     // calculate field boundaries
-    if (race_state->headPosition.x < 2) race_state->headPosition.x=2;
-    if (race_state->headPosition.x > (FIELD_WIDTH-3)) race_state->headPosition.x=(FIELD_WIDTH-3);
-    if (race_state->headPosition.y < 0) race_state->headPosition.y=0;
-    if (race_state->headPosition.y > (FIELD_HEIGHT-4)) race_state->headPosition.y=(FIELD_HEIGHT-4);
-    for (int y = 0; y < FIELD_HEIGHT; y++) {
-        for (int x = 0; x < FIELD_WIDTH; x++) {
+    if(race_state->headPosition.x < 2) race_state->headPosition.x = 2;
+    if(race_state->headPosition.x > (FIELD_WIDTH - 3))
+        race_state->headPosition.x = (FIELD_WIDTH - 3);
+    if(race_state->headPosition.y < 0) race_state->headPosition.y = 0;
+    if(race_state->headPosition.y > (FIELD_HEIGHT - 4))
+        race_state->headPosition.y = (FIELD_HEIGHT - 4);
+    for(int y = 0; y < FIELD_HEIGHT; y++) {
+        for(int x = 0; x < FIELD_WIDTH; x++) {
             race_state->playField[y][x] = false;
         }
     }
-    
-    if (moveRoad) {
+
+    if(moveRoad) {
         race_state->score += 10;
         race_state->roadStart++;
-        if (race_state->roadStart == 4)
-            race_state->roadStart = 0;      
+        if(race_state->roadStart == 4) race_state->roadStart = 0;
         race_game_spawn_obstacles(race_state);
-        race_game_move_obstacles(race_state);        
-        if (race_state->score % 500 == 0) {
-            if (race_state->level<9) {
+        race_game_move_obstacles(race_state);
+        if(race_state->score % 500 == 0) {
+            if(race_state->level < 9) {
                 race_state->level++;
-                race_state->motionSpeed=race_state->motionSpeed-50;
+                race_state->motionSpeed = race_state->motionSpeed - 50;
                 furi_timer_stop(race_state->timer);
                 furi_timer_start(race_state->timer, race_state->motionSpeed);
             }
         }
     }
 
-    for (int i=0; i<PARALLEL_OBSTACLES; i++) {
-         if (race_state->obstacles[i].isAlive) {
-             race_game_draw_car(race_state, race_state->obstacles[i].position, false);
-        }            
+    for(int i = 0; i < PARALLEL_OBSTACLES; i++) {
+        if(race_state->obstacles[i].isAlive) {
+            race_game_draw_car(race_state, race_state->obstacles[i].position, false);
+        }
     }
     race_game_draw_car(race_state, race_state->headPosition, true);
     race_game_init_road(race_state);
@@ -291,26 +268,22 @@ static void race_game_process_step(RaceState* race_state, bool moveRoad) {
 
 int32_t race_app(void* p) {
     UNUSED(p);
-    
+
     srand(DWT->CYCCNT);
-    
+
     // current custom event element
     RaceGameEvent event;
 
     RaceState* race_state = malloc(sizeof(RaceState));
     FuriMutex* state_mutex = furi_mutex_alloc(FuriMutexTypeRecursive);
-    
+
     // Queue on 8 events
     FuriMessageQueue* event_queue = furi_message_queue_alloc(8, sizeof(RaceGameEvent));
 
-
     race_state->timer = furi_timer_alloc(timer_callback, FuriTimerTypePeriodic, event_queue);
 
-
     race_game_init_state(race_state);
 
-    
-
     // Creating viewport
     ViewPort* view_port = view_port_alloc();
     // Set viewpoint orientation to vertical
@@ -327,14 +300,11 @@ int32_t race_app(void* p) {
     Gui* gui = furi_record_open(RECORD_GUI);
     // adding our view port to gui in full screen mode
     gui_add_view_port(gui, view_port, GuiLayerFullscreen);
-    
-    
 
     // Бесконечный цикл обработки очереди событий
     for(bool processing = true; processing;) {
-
         furi_mutex_acquire(state_mutex, 1000);
-//         RaceState* race_state = (RaceState*)furi_mutex_block(&state_mutex, 1000);
+        //         RaceState* race_state = (RaceState*)furi_mutex_block(&state_mutex, 1000);
 
         // Выбираем событие из очереди в переменную event (ждем бесконечно долго, если очередь пуста)
         // и проверяем, что у нас получилось это сделать
@@ -343,28 +313,28 @@ int32_t race_app(void* p) {
         if(event.type == EventTypeKey) {
             // Если нажата кнопка "назад", то выходим из цикла, а следовательно и из приложения
             switch(event.input.key) {
-                case InputKeyBack:
-                    processing = false;
-                    break;
-                case InputKeyOk:
-                    if(race_state->gameState == GameStateGameOver) {
-                        race_game_init_state(race_state);
-                    }
-                    break;
-                case InputKeyUp:
-                    race_state->headPosition.y -= 1;
-                    break;
-                case InputKeyDown:    
-                    race_state->headPosition.y += 1;
-                    break;
-                case InputKeyRight:
-                    race_state->headPosition.x += 1;
-                    break;
-                case InputKeyLeft:    
-                    race_state->headPosition.x -= 1;
-                    break;
-                default:
-                    break;
+            case InputKeyBack:
+                processing = false;
+                break;
+            case InputKeyOk:
+                if(race_state->gameState == GameStateGameOver) {
+                    race_game_init_state(race_state);
+                }
+                break;
+            case InputKeyUp:
+                race_state->headPosition.y -= 1;
+                break;
+            case InputKeyDown:
+                race_state->headPosition.y += 1;
+                break;
+            case InputKeyRight:
+                race_state->headPosition.x += 1;
+                break;
+            case InputKeyLeft:
+                race_state->headPosition.x -= 1;
+                break;
+            default:
+                break;
             }
             // Наше событие — это сработавший таймер
         } else if(event.type == EventTypeTick) {
@@ -374,7 +344,6 @@ int32_t race_app(void* p) {
         race_game_process_step(race_state, moveRoad);
         view_port_update(view_port);
         furi_mutex_release(state_mutex);
-
     }
     // clearing everything on game exit
 

+ 7 - 11
apps_source_code/rcwl_0516/rcwl_0516.c

@@ -9,28 +9,25 @@
 #include <notification/notification_messages.h>
 
 static void rcwl_0516_draw_callback(Canvas* canvas, void* ctx) {
-    
     furi_assert(ctx);
     Rcwl_0516* app = ctx;
 
     canvas_clear(canvas);
     canvas_set_font(canvas, FontPrimary);
     elements_multiline_text_aligned(canvas, 60, 17, AlignCenter, AlignTop, "Motion Status");
-    
+
     canvas_set_font(canvas, FontSecondary);
 
-    if(app->input_value){
+    if(app->input_value) {
         furi_hal_light_set(LightRed, 255);
         furi_hal_light_set(LightBlue, 0);
         furi_hal_light_set(LightGreen, 0);
 
-        elements_multiline_text_aligned(
-            canvas, 60, 32, AlignCenter, AlignTop,"Motion Detection");
+        elements_multiline_text_aligned(canvas, 60, 32, AlignCenter, AlignTop, "Motion Detection");
         notification_message(app->notifications, &sequence_display_backlight_on);
 
-    }else {
-        elements_multiline_text_aligned(
-        canvas, 60, 32, AlignCenter, AlignTop,"No Motion");
+    } else {
+        elements_multiline_text_aligned(canvas, 60, 32, AlignCenter, AlignTop, "No Motion");
         notification_message(app->notifications, &sequence_display_backlight_off);
         furi_hal_light_set(LightBlue, 255);
         furi_hal_light_set(LightRed, 0);
@@ -90,12 +87,11 @@ int32_t rcwl_0516(void* p) {
 
     while(1) {
         app->input_value = furi_hal_gpio_read(app->input_pin);
-        
+
         if(furi_message_queue_get(app->event_queue, &event, 100) == FuriStatusOk) {
             if(event.key == InputKeyBack) {
                 if(event.type == InputTypePress) break;
-
-            } 
+            }
         }
     }
 

+ 0 - 1
apps_source_code/rcwl_0516/rcwl_0516.h

@@ -17,7 +17,6 @@ struct Rcwl_0516 {
     bool output_value;
 
     NotificationApp* notifications;
-
 };
 
 typedef struct Rcwl_0516 Rcwl_0516;

+ 331 - 331
apps_source_code/schip/schip.c

@@ -22,32 +22,32 @@
 #define RPL_COUNT 8
 
 const uint8_t font[FONT_SIZE] = {
-	0xF0, 0x90, 0x90, 0x90, 0xF0, // 0
-	0x20, 0x60, 0x20, 0x20, 0x70, // 1
-	0xF0, 0x10, 0xF0, 0x80, 0xF0, // 2
-	0xF0, 0x10, 0xF0, 0x10, 0xF0, // 3
-	0x90, 0x90, 0xF0, 0x10, 0x10, // 4
-	0xF0, 0x80, 0xF0, 0x10, 0xF0, // 5
-	0xF0, 0x80, 0xF0, 0x90, 0xF0, // 6
-	0xF0, 0x10, 0x20, 0x40, 0x40, // 7
-	0xF0, 0x90, 0xF0, 0x90, 0xF0, // 8
-	0xF0, 0x90, 0xF0, 0x10, 0xF0, // 9
-	0xF0, 0x90, 0xF0, 0x90, 0x90, // A
-	0xE0, 0x90, 0xE0, 0x90, 0xE0, // B
-	0xF0, 0x80, 0x80, 0x80, 0xF0, // C
-	0xE0, 0x90, 0x90, 0x90, 0xE0, // D
-	0xF0, 0x80, 0xF0, 0x80, 0xF0, // E
-	0xF0, 0x80, 0xF0, 0x80, 0x80, // F
-	0x3C, 0x7E, 0xE7, 0xC3, 0xC3, 0xC3, 0xC3, 0xE7, 0x7E, 0x3C, // 0h
-        0x18, 0x38, 0x58, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3C, // 1h
-        0x3E, 0x7F, 0xC3, 0x06, 0x0C, 0x18, 0x30, 0x60, 0xFF, 0xFF, // 2h
-        0x3C, 0x7E, 0xC3, 0x03, 0x0E, 0x0E, 0x03, 0xC3, 0x7E, 0x3C, // 3h
-        0x06, 0x0E, 0x1E, 0x36, 0x66, 0xC6, 0xFF, 0xFF, 0x06, 0x06, // 4h
-        0xFF, 0xFF, 0xC0, 0xC0, 0xFC, 0xFE, 0x03, 0xC3, 0x7E, 0x3C, // 5h
-        0x3E, 0x7C, 0xC0, 0xC0, 0xFC, 0xFE, 0xC3, 0xC3, 0x7E, 0x3C, // 6h
-        0xFF, 0xFF, 0x03, 0x06, 0x0C, 0x18, 0x30, 0x60, 0x60, 0x60, // 7h
-        0x3C, 0x7E, 0xC3, 0xC3, 0x7E, 0x7E, 0xC3, 0xC3, 0x7E, 0x3C, // 8h
-        0x3C, 0x7E, 0xC3, 0xC3, 0x7F, 0x3F, 0x03, 0x03, 0x3E, 0x7C  // 9h
+    0xF0, 0x90, 0x90, 0x90, 0xF0, // 0
+    0x20, 0x60, 0x20, 0x20, 0x70, // 1
+    0xF0, 0x10, 0xF0, 0x80, 0xF0, // 2
+    0xF0, 0x10, 0xF0, 0x10, 0xF0, // 3
+    0x90, 0x90, 0xF0, 0x10, 0x10, // 4
+    0xF0, 0x80, 0xF0, 0x10, 0xF0, // 5
+    0xF0, 0x80, 0xF0, 0x90, 0xF0, // 6
+    0xF0, 0x10, 0x20, 0x40, 0x40, // 7
+    0xF0, 0x90, 0xF0, 0x90, 0xF0, // 8
+    0xF0, 0x90, 0xF0, 0x10, 0xF0, // 9
+    0xF0, 0x90, 0xF0, 0x90, 0x90, // A
+    0xE0, 0x90, 0xE0, 0x90, 0xE0, // B
+    0xF0, 0x80, 0x80, 0x80, 0xF0, // C
+    0xE0, 0x90, 0x90, 0x90, 0xE0, // D
+    0xF0, 0x80, 0xF0, 0x80, 0xF0, // E
+    0xF0, 0x80, 0xF0, 0x80, 0x80, // F
+    0x3C, 0x7E, 0xE7, 0xC3, 0xC3, 0xC3, 0xC3, 0xE7, 0x7E, 0x3C, // 0h
+    0x18, 0x38, 0x58, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3C, // 1h
+    0x3E, 0x7F, 0xC3, 0x06, 0x0C, 0x18, 0x30, 0x60, 0xFF, 0xFF, // 2h
+    0x3C, 0x7E, 0xC3, 0x03, 0x0E, 0x0E, 0x03, 0xC3, 0x7E, 0x3C, // 3h
+    0x06, 0x0E, 0x1E, 0x36, 0x66, 0xC6, 0xFF, 0xFF, 0x06, 0x06, // 4h
+    0xFF, 0xFF, 0xC0, 0xC0, 0xFC, 0xFE, 0x03, 0xC3, 0x7E, 0x3C, // 5h
+    0x3E, 0x7C, 0xC0, 0xC0, 0xFC, 0xFE, 0xC3, 0xC3, 0x7E, 0x3C, // 6h
+    0xFF, 0xFF, 0x03, 0x06, 0x0C, 0x18, 0x30, 0x60, 0x60, 0x60, // 7h
+    0x3C, 0x7E, 0xC3, 0xC3, 0x7E, 0x7E, 0xC3, 0xC3, 0x7E, 0x3C, // 8h
+    0x3C, 0x7E, 0xC3, 0xC3, 0x7F, 0x3F, 0x03, 0x03, 0x3E, 0x7C // 9h
 };
 uint8_t memory[MEM_SIZE];
 bool screen[SCREEN_WIDTH][SCREEN_HEIGHT];
@@ -66,75 +66,70 @@ uint8_t keyboard_x = 0;
 uint8_t keyboard_y = 0;
 
 bool buttons[BUTTONS_COUNT];
-uint8_t keypad[BUTTONS_COUNT] = {
-	1,  2,  3,  12,
-	4,  5,  6,  13,
-	7,  8,  9,  14,
-	10, 0,  11, 15
-};
+uint8_t keypad[BUTTONS_COUNT] = {1, 2, 3, 12, 4, 5, 6, 13, 7, 8, 9, 14, 10, 0, 11, 15};
 
 bool run = true;
 
 FuriString* file_path;
 
 static void app_draw_callback(Canvas* canvas, void* ctx) {
-	UNUSED(ctx);
-
-	canvas_clear(canvas);
-	canvas_set_font(canvas, FontSecondary);
-	if(keyboard_open) {
-		for(uint8_t x = 0; x < KEYPAD_WIDTH; x++)
-			for(uint8_t y = 0; y < KEYPAD_HEIGHT; y++)
-				canvas_draw_frame(canvas, 32 + x * 16, y * 16, 16, 16);
-		canvas_draw_frame(canvas, 33 + keyboard_x * 16, 1 + keyboard_y * 16, 14, 14);
-		
-		canvas_draw_str(canvas, 38 + 16 * 0, 12 + 16 * 0, "1");
-		canvas_draw_str(canvas, 38 + 16 * 1, 12 + 16 * 0, "2");
-		canvas_draw_str(canvas, 38 + 16 * 2, 12 + 16 * 0, "3");
-		canvas_draw_str(canvas, 38 + 16 * 3, 12 + 16 * 0, "C");
-		canvas_draw_str(canvas, 38 + 16 * 0, 12 + 16 * 1, "4");
-		canvas_draw_str(canvas, 38 + 16 * 1, 12 + 16 * 1, "5");
-		canvas_draw_str(canvas, 38 + 16 * 2, 12 + 16 * 1, "6");
-		canvas_draw_str(canvas, 38 + 16 * 3, 12 + 16 * 1, "D");
-		canvas_draw_str(canvas, 38 + 16 * 0, 12 + 16 * 2, "7");
-		canvas_draw_str(canvas, 38 + 16 * 1, 12 + 16 * 2, "8");
-		canvas_draw_str(canvas, 38 + 16 * 2, 12 + 16 * 2, "9");
-		canvas_draw_str(canvas, 38 + 16 * 3, 12 + 16 * 2, "E");
-		canvas_draw_str(canvas, 38 + 16 * 0, 12 + 16 * 3, "A");
-		canvas_draw_str(canvas, 38 + 16 * 1, 12 + 16 * 3, "0");
-		canvas_draw_str(canvas, 38 + 16 * 2, 12 + 16 * 3, "B");
-		canvas_draw_str(canvas, 38 + 16 * 3, 12 + 16 * 3, "F");
-	} else {
-		for(uint8_t x = 0; x < SCREEN_WIDTH; x++)
-			for(uint8_t y = 0; y < SCREEN_HEIGHT; y++)
-				if(screen[x][y]) canvas_draw_dot(canvas, x, y);
-	}
+    UNUSED(ctx);
+
+    canvas_clear(canvas);
+    canvas_set_font(canvas, FontSecondary);
+    if(keyboard_open) {
+        for(uint8_t x = 0; x < KEYPAD_WIDTH; x++)
+            for(uint8_t y = 0; y < KEYPAD_HEIGHT; y++)
+                canvas_draw_frame(canvas, 32 + x * 16, y * 16, 16, 16);
+        canvas_draw_frame(canvas, 33 + keyboard_x * 16, 1 + keyboard_y * 16, 14, 14);
+
+        canvas_draw_str(canvas, 38 + 16 * 0, 12 + 16 * 0, "1");
+        canvas_draw_str(canvas, 38 + 16 * 1, 12 + 16 * 0, "2");
+        canvas_draw_str(canvas, 38 + 16 * 2, 12 + 16 * 0, "3");
+        canvas_draw_str(canvas, 38 + 16 * 3, 12 + 16 * 0, "C");
+        canvas_draw_str(canvas, 38 + 16 * 0, 12 + 16 * 1, "4");
+        canvas_draw_str(canvas, 38 + 16 * 1, 12 + 16 * 1, "5");
+        canvas_draw_str(canvas, 38 + 16 * 2, 12 + 16 * 1, "6");
+        canvas_draw_str(canvas, 38 + 16 * 3, 12 + 16 * 1, "D");
+        canvas_draw_str(canvas, 38 + 16 * 0, 12 + 16 * 2, "7");
+        canvas_draw_str(canvas, 38 + 16 * 1, 12 + 16 * 2, "8");
+        canvas_draw_str(canvas, 38 + 16 * 2, 12 + 16 * 2, "9");
+        canvas_draw_str(canvas, 38 + 16 * 3, 12 + 16 * 2, "E");
+        canvas_draw_str(canvas, 38 + 16 * 0, 12 + 16 * 3, "A");
+        canvas_draw_str(canvas, 38 + 16 * 1, 12 + 16 * 3, "0");
+        canvas_draw_str(canvas, 38 + 16 * 2, 12 + 16 * 3, "B");
+        canvas_draw_str(canvas, 38 + 16 * 3, 12 + 16 * 3, "F");
+    } else {
+        for(uint8_t x = 0; x < SCREEN_WIDTH; x++)
+            for(uint8_t y = 0; y < SCREEN_HEIGHT; y++)
+                if(screen[x][y]) canvas_draw_dot(canvas, x, y);
+    }
 }
 
 static void app_input_callback(InputEvent* input_event, void* ctx) {
-	furi_assert(ctx);
+    furi_assert(ctx);
 
-	FuriMessageQueue* event_queue = ctx;
-	furi_message_queue_put(event_queue, input_event, FuriWaitForever);
+    FuriMessageQueue* event_queue = ctx;
+    furi_message_queue_put(event_queue, input_event, FuriWaitForever);
 }
 
 static bool nthbit(uint8_t n, uint8_t k) {
-	return (n & ( 1 << k )) >> k == 1;
+    return (n & (1 << k)) >> k == 1;
 }
 
 static bool toggle_pixel(uint8_t x, uint8_t y) {
-	bool collision = false;
-	if(hires) {
-		collision = screen[x][y];
-		screen[x][y] = !screen[x][y];
-	} else {
-		collision = screen[x * 2][y * 2];
-		screen[x * 2][y * 2] = !screen[x * 2][y * 2];
-		screen[x * 2 + 1][y * 2] = !screen[x * 2 + 1][y * 2];
-		screen[x * 2][y * 2 + 1] = !screen[x * 2][y * 2 + 1];
-		screen[x * 2 + 1][y * 2 + 1] = !screen[x * 2 + 1][y * 2 + 1];
-	}
-	return collision;
+    bool collision = false;
+    if(hires) {
+        collision = screen[x][y];
+        screen[x][y] = !screen[x][y];
+    } else {
+        collision = screen[x * 2][y * 2];
+        screen[x * 2][y * 2] = !screen[x * 2][y * 2];
+        screen[x * 2 + 1][y * 2] = !screen[x * 2 + 1][y * 2];
+        screen[x * 2][y * 2 + 1] = !screen[x * 2][y * 2 + 1];
+        screen[x * 2 + 1][y * 2 + 1] = !screen[x * 2 + 1][y * 2 + 1];
+    }
+    return collision;
 }
 
 // TODO fix this:
@@ -158,148 +153,149 @@ static bool toggle_pixel(uint8_t x, uint8_t y) {
 
 FuriTimer* timer;
 static void tick(void* context) {
-	UNUSED(context);
-	if(!run) return;
-	furi_check(PC < MEM_SIZE - 1);
-	uint8_t d1 = memory[PC] / 16;
-	uint8_t d2 = memory[PC] % 16;
-	uint8_t d3 = memory[PC + 1] / 16;
-	uint8_t d4 = memory[PC + 1] % 16;
-	uint16_t d5 = d2 * 256 + d3 * 16 + d4; // I
-	uint16_t d6 = d1 * 4096 + d2 * 256 + d3 * 16 + d4; // Whole instruction
-	// FURI_LOG_T(TAG, "Executing instruction %x at address %x", d6, PC);
-	uint8_t d7 = d3 * 16 + d4; // Byte
-	bool next = true;
-	
-	if(d1 == 0x0 && d2 == 0x0 && d3 == 0xc) {
-		// TODO: scroll down d4 px
-	} else if(d6 == 0x00e0) {
-		for(uint8_t x = 0; x < SCREEN_WIDTH; x++)
-			for(uint8_t y = 0; y < SCREEN_HEIGHT; y++)
-				screen[x][y] = false;
-	} else if(d6 == 0x00ee) {
-		PC = stack[stack_pointer--];
-	} else if(d6 == 0x00fb) {
-		// TODO: scroll right 4 px
-	} else if(d6 == 0x00fc) {
-		// TODO: scroll left 4 px
-	} else if(d6 == 0x00fd) {
-		run = false;
-	} else if(d6 == 0x00fe) {
-		hires = false;
-	} else if(d6 == 0x00ff) {
-		hires = true;
-	} else if(d1 == 0x0 || d1 == 0x1) {
-		PC = d5;
-		next = false;
-	} else if(d1 == 0x2) {
-		stack[++stack_pointer] = PC;
-		PC = d5;
-		next = false;
-	} else if(d1 == 0x3) {
-		if(registers[d2] == d7) PC += 2;
-	} else if(d1 == 0x4) {
-		if(registers[d2] != d7) PC += 2;
-	} else if(d1 == 0x5) {
-		if(registers[d2] == registers[d3]) PC += 2;
-	} else if(d1 == 0x6) {
-		registers[d2] = d7;
-	} else if(d1 == 0x7) {
-		registers[d2] += d7;
-	} else if(d1 == 0x8 && d4 == 0x0) {
-		registers[d2] = registers[d3];
-	} else if(d1 == 0x8 && d4 == 0x1) {
-		registers[d2] |= registers[d3];
-	} else if(d1 == 0x8 && d4 == 0x2) {
-		registers[d2] &= registers[d3];
-	} else if(d1 == 0x8 && d4 == 0x3) {
-		registers[d2] ^= registers[d3];
-	} else if(d1 == 0x8 && d4 == 0x4) {
-		uint16_t v = registers[d2] + registers[d3];
-		registers[0xf] = v > 0xff;
-		registers[d2] = v % 0x100;
-	} else if(d1 == 0x8 && d4 == 0x5) {
-		registers[0xf] = registers[d2] > registers[d3];
-		registers[d2] -= registers[d3];
-	} else if(d1 == 0x8 && d4 == 0x6) {
-		registers[0xf] = registers[d2] % 2 == 1;
-		registers[d2] >>= 1;
-	} else if(d1 == 0x8 && d4 == 0x7) {
-		registers[0xf] = registers[d3] > registers[d2];
-		registers[d2] = registers[d3] - registers[d2];
-	} else if(d1 == 0x8 && d4 == 0xe) {
-		registers[0xf] = registers[d2] / 128 == 1;
-		registers[d2] <<= 1;
-	} else if(d1 == 0x9) {
-		if(registers[d2] != registers[d3]) PC += 2;
-	} else if(d1 == 0xa) {
-		I = d5;
-	} else if(d1 == 0xb) {
-		PC = d5 + registers[0x0];
-		next = false;
-	} else if(d1 == 0xc) {
-		registers[d2] = (rand() % 0x100) & d7;
-	} else if(d1 == 0xd) {
-		bool collision = false;
-		if(d4 == 0) for(uint8_t i = 0; i < 16; i++) {
-			for(uint8_t j = 0; j < 8; j++)
-				if(nthbit(memory[I + i * 2], 7 - j)) collision |= toggle_pixel(registers[d2] + j, registers[d3] + i);
-			for(uint8_t j = 0; j < 8; j++)
-				if(nthbit(memory[I + i * 2 + 1], 7 - j)) collision |= toggle_pixel(registers[d2] + 8 + j, registers[d3] + i);
-		} else for(uint8_t i = 0; i < d4; i++) {
-			for(uint8_t j = 0; j < 8; j++)
-				if(nthbit(memory[I + i], 7 - j)) collision |= toggle_pixel(registers[d2] + j, registers[d3] + i);
-		}
-		registers[0xf] = collision;
-	} else if(d1 == 0xe && d7 == 0x9e) {
-		if(buttons[registers[d2]]) PC += 2;
-	} else if(d1 == 0xe && d7 == 0xa1) {
-		if(!buttons[registers[d2]]) PC += 2;
-	} else if(d1 == 0xf && d7 == 0x07) {
-		registers[d2] = time_delay;
-	} else if(d1 == 0xf && d7 == 0x0a) {
-		next = false;
-		for(uint8_t i = 0; i < BUTTONS_COUNT; i++)
-			if(buttons[i]) {
-				next = true;
-				registers[d2] = i;
-				break;
-			}
-	} else if(d1 == 0xf && d7 == 0x15) {
-		time_delay = registers[d2];
-	} else if(d1 == 0xf && d7 == 0x18) {
-		time_sound = registers[d2];
-	} else if(d1 == 0xf && d7 == 0x1e) {
-		I += registers[d2];
-	} else if(d1 == 0xf && d7 == 0x29) {
-		I = 5 * registers[d2];
-	} else if(d1 == 0xf && d7 == 0x30) {
-		I = 10 * (registers[d2] - 0x10) + 80;
-	} else if(d1 == 0xf && d7 == 0x33) {
-		memory[I] = registers[d2] / 100;
-		memory[I + 1] = (registers[d2] / 10) % 10;
-		memory[I + 2] = registers[d2] % 10;
-	} else if(d1 == 0xf && d7 == 0x55) {
-		for(uint8_t i = 0; i <= d2; i++)
-			memory[I + i] = registers[i];
-	} else if(d1 == 0xf && d7 == 0x65) {
-		for(uint8_t i = 0; i <= d2; i++)
-			registers[i] = memory[I + i];
-	} else if(d1 == 0xf && d7 == 0x75) {
-		for(uint8_t i = 0; i <= d2; i++)
-			rpl[I + i] = registers[i];
-	} else if(d1 == 0xf && d7 == 0x85) {
-		for(uint8_t i = 0; i <= d2; i++)
-			registers[i] = rpl[I + i];
-	} 
-	
-	if(next) PC += 2;
+    UNUSED(context);
+    if(!run) return;
+    furi_check(PC < MEM_SIZE - 1);
+    uint8_t d1 = memory[PC] / 16;
+    uint8_t d2 = memory[PC] % 16;
+    uint8_t d3 = memory[PC + 1] / 16;
+    uint8_t d4 = memory[PC + 1] % 16;
+    uint16_t d5 = d2 * 256 + d3 * 16 + d4; // I
+    uint16_t d6 = d1 * 4096 + d2 * 256 + d3 * 16 + d4; // Whole instruction
+    // FURI_LOG_T(TAG, "Executing instruction %x at address %x", d6, PC);
+    uint8_t d7 = d3 * 16 + d4; // Byte
+    bool next = true;
+
+    if(d1 == 0x0 && d2 == 0x0 && d3 == 0xc) {
+        // TODO: scroll down d4 px
+    } else if(d6 == 0x00e0) {
+        for(uint8_t x = 0; x < SCREEN_WIDTH; x++)
+            for(uint8_t y = 0; y < SCREEN_HEIGHT; y++) screen[x][y] = false;
+    } else if(d6 == 0x00ee) {
+        PC = stack[stack_pointer--];
+    } else if(d6 == 0x00fb) {
+        // TODO: scroll right 4 px
+    } else if(d6 == 0x00fc) {
+        // TODO: scroll left 4 px
+    } else if(d6 == 0x00fd) {
+        run = false;
+    } else if(d6 == 0x00fe) {
+        hires = false;
+    } else if(d6 == 0x00ff) {
+        hires = true;
+    } else if(d1 == 0x0 || d1 == 0x1) {
+        PC = d5;
+        next = false;
+    } else if(d1 == 0x2) {
+        stack[++stack_pointer] = PC;
+        PC = d5;
+        next = false;
+    } else if(d1 == 0x3) {
+        if(registers[d2] == d7) PC += 2;
+    } else if(d1 == 0x4) {
+        if(registers[d2] != d7) PC += 2;
+    } else if(d1 == 0x5) {
+        if(registers[d2] == registers[d3]) PC += 2;
+    } else if(d1 == 0x6) {
+        registers[d2] = d7;
+    } else if(d1 == 0x7) {
+        registers[d2] += d7;
+    } else if(d1 == 0x8 && d4 == 0x0) {
+        registers[d2] = registers[d3];
+    } else if(d1 == 0x8 && d4 == 0x1) {
+        registers[d2] |= registers[d3];
+    } else if(d1 == 0x8 && d4 == 0x2) {
+        registers[d2] &= registers[d3];
+    } else if(d1 == 0x8 && d4 == 0x3) {
+        registers[d2] ^= registers[d3];
+    } else if(d1 == 0x8 && d4 == 0x4) {
+        uint16_t v = registers[d2] + registers[d3];
+        registers[0xf] = v > 0xff;
+        registers[d2] = v % 0x100;
+    } else if(d1 == 0x8 && d4 == 0x5) {
+        registers[0xf] = registers[d2] > registers[d3];
+        registers[d2] -= registers[d3];
+    } else if(d1 == 0x8 && d4 == 0x6) {
+        registers[0xf] = registers[d2] % 2 == 1;
+        registers[d2] >>= 1;
+    } else if(d1 == 0x8 && d4 == 0x7) {
+        registers[0xf] = registers[d3] > registers[d2];
+        registers[d2] = registers[d3] - registers[d2];
+    } else if(d1 == 0x8 && d4 == 0xe) {
+        registers[0xf] = registers[d2] / 128 == 1;
+        registers[d2] <<= 1;
+    } else if(d1 == 0x9) {
+        if(registers[d2] != registers[d3]) PC += 2;
+    } else if(d1 == 0xa) {
+        I = d5;
+    } else if(d1 == 0xb) {
+        PC = d5 + registers[0x0];
+        next = false;
+    } else if(d1 == 0xc) {
+        registers[d2] = (rand() % 0x100) & d7;
+    } else if(d1 == 0xd) {
+        bool collision = false;
+        if(d4 == 0)
+            for(uint8_t i = 0; i < 16; i++) {
+                for(uint8_t j = 0; j < 8; j++)
+                    if(nthbit(memory[I + i * 2], 7 - j))
+                        collision |= toggle_pixel(registers[d2] + j, registers[d3] + i);
+                for(uint8_t j = 0; j < 8; j++)
+                    if(nthbit(memory[I + i * 2 + 1], 7 - j))
+                        collision |= toggle_pixel(registers[d2] + 8 + j, registers[d3] + i);
+            }
+        else
+            for(uint8_t i = 0; i < d4; i++) {
+                for(uint8_t j = 0; j < 8; j++)
+                    if(nthbit(memory[I + i], 7 - j))
+                        collision |= toggle_pixel(registers[d2] + j, registers[d3] + i);
+            }
+        registers[0xf] = collision;
+    } else if(d1 == 0xe && d7 == 0x9e) {
+        if(buttons[registers[d2]]) PC += 2;
+    } else if(d1 == 0xe && d7 == 0xa1) {
+        if(!buttons[registers[d2]]) PC += 2;
+    } else if(d1 == 0xf && d7 == 0x07) {
+        registers[d2] = time_delay;
+    } else if(d1 == 0xf && d7 == 0x0a) {
+        next = false;
+        for(uint8_t i = 0; i < BUTTONS_COUNT; i++)
+            if(buttons[i]) {
+                next = true;
+                registers[d2] = i;
+                break;
+            }
+    } else if(d1 == 0xf && d7 == 0x15) {
+        time_delay = registers[d2];
+    } else if(d1 == 0xf && d7 == 0x18) {
+        time_sound = registers[d2];
+    } else if(d1 == 0xf && d7 == 0x1e) {
+        I += registers[d2];
+    } else if(d1 == 0xf && d7 == 0x29) {
+        I = 5 * registers[d2];
+    } else if(d1 == 0xf && d7 == 0x30) {
+        I = 10 * (registers[d2] - 0x10) + 80;
+    } else if(d1 == 0xf && d7 == 0x33) {
+        memory[I] = registers[d2] / 100;
+        memory[I + 1] = (registers[d2] / 10) % 10;
+        memory[I + 2] = registers[d2] % 10;
+    } else if(d1 == 0xf && d7 == 0x55) {
+        for(uint8_t i = 0; i <= d2; i++) memory[I + i] = registers[i];
+    } else if(d1 == 0xf && d7 == 0x65) {
+        for(uint8_t i = 0; i <= d2; i++) registers[i] = memory[I + i];
+    } else if(d1 == 0xf && d7 == 0x75) {
+        for(uint8_t i = 0; i <= d2; i++) rpl[I + i] = registers[i];
+    } else if(d1 == 0xf && d7 == 0x85) {
+        for(uint8_t i = 0; i <= d2; i++) registers[i] = rpl[I + i];
+    }
+
+    if(next) PC += 2;
 }
 
 FuriTimer* timer_delay;
 static void tick_delay(void* context) {
-	UNUSED(context);
-	if(time_delay > 0) time_delay--;
+    UNUSED(context);
+    if(time_delay > 0) time_delay--;
 }
 
 FuriTimer* timer_sound;
@@ -317,122 +313,126 @@ static void tick_sound(void* context) {
 	}
 }*/
 static void tick_sound(void* context) {
-	UNUSED(context);
-	if(time_sound > 0) time_sound--;
-	if(time_sound > 0)
-		furi_hal_vibro_on(true);
-	else
-		furi_hal_vibro_on(false);
+    UNUSED(context);
+    if(time_sound > 0) time_sound--;
+    if(time_sound > 0)
+        furi_hal_vibro_on(true);
+    else
+        furi_hal_vibro_on(false);
 }
 
 int32_t schip_main(void* p) {
-	for(int i = 0; i < FONT_SIZE; i++)
-		memory[i] = font[i];
-
-	UNUSED(p);
-	FuriMessageQueue* event_queue = furi_message_queue_alloc(8, sizeof(InputEvent));
-
-	// Configure view port
-	ViewPort* view_port = view_port_alloc();
-	view_port_draw_callback_set(view_port, app_draw_callback, view_port);
-	view_port_input_callback_set(view_port, app_input_callback, event_queue);
-
-	// Register view port in GUI
-	Gui* gui = furi_record_open(RECORD_GUI);
-	gui_add_view_port(gui, view_port, GuiLayerFullscreen);
-
-	InputEvent event;
-	
-	// void* speaker = (void*)furi_hal_speaker_acquire(1000);
-	
-	Storage* storage = furi_record_open(RECORD_STORAGE);
-	storage_simply_mkdir(storage, FILES_PATH);
-	
-	file_path = furi_string_alloc_set_str(FILES_PATH);
-	DialogsFileBrowserOptions browser_options;
-	dialog_file_browser_set_basic_options(&browser_options, FILE_EXTENSION, NULL);
-	browser_options.base_path = FILES_PATH;
-	DialogsApp* dialogs = furi_record_open(RECORD_DIALOGS);
-	bool running = dialog_file_browser_show(dialogs, file_path, file_path, &browser_options);
-	furi_record_close(RECORD_DIALOGS);
-	
-	if(running) {
-		File* file = storage_file_alloc(storage);
-		furi_check(storage_file_open(file, furi_string_get_cstr(file_path), FSAM_READ, FSOM_OPEN_EXISTING));
-		uint8_t read_byte;
-		uint16_t read_size;
-		uint16_t p = ROM_START;
-		do {
-			read_size = storage_file_read(file, &read_byte, 1);
-			memory[p] = read_byte;
-			p++;
-			
-		} while(read_size > 0);
-		storage_file_close(file);
-		storage_file_free(file);
-	}
-	
-	furi_record_close(RECORD_STORAGE);
-	
-	// We have to round up to 17 here
-	
-	timer = furi_timer_alloc(tick, FuriTimerTypePeriodic, NULL);
-	furi_timer_start(timer, 1);
-	
-	timer_delay = furi_timer_alloc(tick_delay, FuriTimerTypePeriodic, NULL);
-	furi_timer_start(timer_delay, 17);
-	
-	timer_sound = furi_timer_alloc(tick_sound, FuriTimerTypePeriodic, NULL);
-	furi_timer_start(timer_sound, 17);
-
-	while(running) {
-		if(furi_message_queue_get(event_queue, &event, 100) == FuriStatusOk) {
-			if(event.type == InputTypeLong && event.key == InputKeyBack) running = false;
-			if(event.type == InputTypePress && event.key == InputKeyBack) keyboard_open = !keyboard_open;
-			if(keyboard_open) {
-				if(event.type == InputTypePress && event.key == InputKeyLeft) keyboard_x--;
-				if(event.type == InputTypePress && event.key == InputKeyDown) keyboard_y++;
-				if(event.type == InputTypePress && event.key == InputKeyRight) keyboard_x++;
-				if(event.type == InputTypePress && event.key == InputKeyUp) keyboard_y--;
-				
-				keyboard_x %= KEYPAD_WIDTH;
-				keyboard_y %= KEYPAD_HEIGHT;
-				
-				if(event.type == InputTypePress && event.key == InputKeyOk) buttons[keypad[keyboard_y * 4 + keyboard_x]] = true;
-				if(event.type == InputTypeRelease && event.key == InputKeyOk) buttons[keypad[keyboard_y * 4 + keyboard_x]] = false;
-			} else {
-				if(event.type == InputTypePress && event.key == InputKeyUp) buttons[5] = true;
-				if(event.type == InputTypeRelease && event.key == InputKeyUp) buttons[5] = false;
-				if(event.type == InputTypePress && event.key == InputKeyLeft) buttons[7] = true;
-				if(event.type == InputTypeRelease && event.key == InputKeyLeft) buttons[7] = false;
-				if(event.type == InputTypePress && event.key == InputKeyDown) buttons[8] = true;
-				if(event.type == InputTypeRelease && event.key == InputKeyDown) buttons[8] = false;
-				if(event.type == InputTypePress && event.key == InputKeyRight) buttons[9] = true;
-				if(event.type == InputTypeRelease && event.key == InputKeyRight) buttons[9] = false;
-				if(event.type == InputTypePress && event.key == InputKeyOk) buttons[6] = true;
-				if(event.type == InputTypeRelease && event.key == InputKeyOk) buttons[6] = false;
-			}
-		}
-		view_port_update(view_port);
-	}
+    for(int i = 0; i < FONT_SIZE; i++) memory[i] = font[i];
+
+    UNUSED(p);
+    FuriMessageQueue* event_queue = furi_message_queue_alloc(8, sizeof(InputEvent));
+
+    // Configure view port
+    ViewPort* view_port = view_port_alloc();
+    view_port_draw_callback_set(view_port, app_draw_callback, view_port);
+    view_port_input_callback_set(view_port, app_input_callback, event_queue);
+
+    // Register view port in GUI
+    Gui* gui = furi_record_open(RECORD_GUI);
+    gui_add_view_port(gui, view_port, GuiLayerFullscreen);
+
+    InputEvent event;
+
+    // void* speaker = (void*)furi_hal_speaker_acquire(1000);
+
+    Storage* storage = furi_record_open(RECORD_STORAGE);
+    storage_simply_mkdir(storage, FILES_PATH);
+
+    file_path = furi_string_alloc_set_str(FILES_PATH);
+    DialogsFileBrowserOptions browser_options;
+    dialog_file_browser_set_basic_options(&browser_options, FILE_EXTENSION, NULL);
+    browser_options.base_path = FILES_PATH;
+    DialogsApp* dialogs = furi_record_open(RECORD_DIALOGS);
+    bool running = dialog_file_browser_show(dialogs, file_path, file_path, &browser_options);
+    furi_record_close(RECORD_DIALOGS);
+
+    if(running) {
+        File* file = storage_file_alloc(storage);
+        furi_check(storage_file_open(
+            file, furi_string_get_cstr(file_path), FSAM_READ, FSOM_OPEN_EXISTING));
+        uint8_t read_byte;
+        uint16_t read_size;
+        uint16_t p = ROM_START;
+        do {
+            read_size = storage_file_read(file, &read_byte, 1);
+            memory[p] = read_byte;
+            p++;
+
+        } while(read_size > 0);
+        storage_file_close(file);
+        storage_file_free(file);
+    }
+
+    furi_record_close(RECORD_STORAGE);
+
+    // We have to round up to 17 here
+
+    timer = furi_timer_alloc(tick, FuriTimerTypePeriodic, NULL);
+    furi_timer_start(timer, 1);
+
+    timer_delay = furi_timer_alloc(tick_delay, FuriTimerTypePeriodic, NULL);
+    furi_timer_start(timer_delay, 17);
+
+    timer_sound = furi_timer_alloc(tick_sound, FuriTimerTypePeriodic, NULL);
+    furi_timer_start(timer_sound, 17);
+
+    while(running) {
+        if(furi_message_queue_get(event_queue, &event, 100) == FuriStatusOk) {
+            if(event.type == InputTypeLong && event.key == InputKeyBack) running = false;
+            if(event.type == InputTypePress && event.key == InputKeyBack)
+                keyboard_open = !keyboard_open;
+            if(keyboard_open) {
+                if(event.type == InputTypePress && event.key == InputKeyLeft) keyboard_x--;
+                if(event.type == InputTypePress && event.key == InputKeyDown) keyboard_y++;
+                if(event.type == InputTypePress && event.key == InputKeyRight) keyboard_x++;
+                if(event.type == InputTypePress && event.key == InputKeyUp) keyboard_y--;
+
+                keyboard_x %= KEYPAD_WIDTH;
+                keyboard_y %= KEYPAD_HEIGHT;
+
+                if(event.type == InputTypePress && event.key == InputKeyOk)
+                    buttons[keypad[keyboard_y * 4 + keyboard_x]] = true;
+                if(event.type == InputTypeRelease && event.key == InputKeyOk)
+                    buttons[keypad[keyboard_y * 4 + keyboard_x]] = false;
+            } else {
+                if(event.type == InputTypePress && event.key == InputKeyUp) buttons[5] = true;
+                if(event.type == InputTypeRelease && event.key == InputKeyUp) buttons[5] = false;
+                if(event.type == InputTypePress && event.key == InputKeyLeft) buttons[7] = true;
+                if(event.type == InputTypeRelease && event.key == InputKeyLeft) buttons[7] = false;
+                if(event.type == InputTypePress && event.key == InputKeyDown) buttons[8] = true;
+                if(event.type == InputTypeRelease && event.key == InputKeyDown) buttons[8] = false;
+                if(event.type == InputTypePress && event.key == InputKeyRight) buttons[9] = true;
+                if(event.type == InputTypeRelease && event.key == InputKeyRight)
+                    buttons[9] = false;
+                if(event.type == InputTypePress && event.key == InputKeyOk) buttons[6] = true;
+                if(event.type == InputTypeRelease && event.key == InputKeyOk) buttons[6] = false;
+            }
+        }
+        view_port_update(view_port);
+    }
+
+    furi_timer_stop(timer);
+    furi_timer_free(timer);
+
+    furi_timer_stop(timer_delay);
+    furi_timer_free(timer_delay);
+
+    furi_timer_stop(timer_sound);
+    furi_timer_free(timer_sound);
+
+    // furi_hal_speaker_release(speaker);
+
+    view_port_enabled_set(view_port, false);
+    gui_remove_view_port(gui, view_port);
+    view_port_free(view_port);
+    furi_message_queue_free(event_queue);
+
+    furi_record_close(RECORD_GUI);
 
-	furi_timer_stop(timer);
-	furi_timer_free(timer);
-	
-	furi_timer_stop(timer_delay);
-	furi_timer_free(timer_delay);
-	
-	furi_timer_stop(timer_sound);
-	furi_timer_free(timer_sound);
-	
-	// furi_hal_speaker_release(speaker);
-	
-	view_port_enabled_set(view_port, false);
-	gui_remove_view_port(gui, view_port);
-	view_port_free(view_port);
-	furi_message_queue_free(event_queue);
-
-	furi_record_close(RECORD_GUI);
-
-	return 0;
+    return 0;
 }

+ 0 - 2
apps_source_code/sony-intervalometer/intervalometer.h

@@ -1,6 +1,4 @@
 #ifndef INTERVALOMETER_H
 #define INTERVALOMETER_H
 
-
-
 #endif /* !INTERVALOMETER_H */

+ 1 - 8
apps_source_code/usping/usping.c

@@ -143,23 +143,16 @@ static void usping_measure(PluginState* const plugin_state) {
     furi_hal_gpio_write(&gpio_usart_tx, false);
     furi_hal_gpio_init(&gpio_usart_tx, GpioModeOutputPushPull, GpioPullNo, GpioSpeedVeryHigh);
 
-
-
-
-
     //FURI_CRITICAL_ENTER();
     // 10 ms pulse on TX
     furi_hal_gpio_write(&gpio_usart_tx, true);
     furi_delay_ms(10);
     furi_hal_gpio_write(&gpio_usart_tx, false);
 
-
-
     // change TX > RX
     furi_hal_gpio_write(&gpio_usart_tx, false);
     furi_hal_gpio_init(&gpio_usart_tx, GpioModeInput, GpioPullNo, GpioSpeedVeryHigh);
 
-
     const uint32_t start = furi_get_tick();
 
     while(furi_get_tick() - start < timeout_ms && furi_hal_gpio_read(&gpio_usart_tx))
@@ -263,7 +256,7 @@ int32_t usping_app() {
         GpioPullUp,
         GpioSpeedVeryHigh,
         GpioAltFn7USART1);
- 
+
     furi_hal_console_enable();
 
     view_port_enabled_set(view_port, false);

+ 1 - 2
apps_source_code/video_player/init_deinit.c

@@ -57,8 +57,7 @@ void deinit_player(VideoPlayerApp* player) {
     stream_free(player->stream);
     furi_record_close(RECORD_STORAGE);
 
-    if(player->buffer)
-    {
+    if(player->buffer) {
         free(player->buffer);
     }
 

+ 1 - 1
apps_source_code/video_player/video_player.h

@@ -70,7 +70,7 @@ typedef struct {
     uint32_t frames_played;
 
     bool playing;
-    
+
     bool quit;
 } VideoPlayerApp;
 

+ 11 - 11
apps_source_code/wifi-map/wifi_map.c

@@ -56,7 +56,7 @@ const NotificationSequence sequence_notification = {
     NULL,
 };
 
-File* open_file(){
+File* open_file() {
     Storage* storage = furi_record_open(RECORD_STORAGE);
     File* file = storage_file_alloc(storage);
 
@@ -66,8 +66,8 @@ File* open_file(){
     return file;
 }
 
-int32_t write_to_file(char data_line, File *file) {
-    char *data = (char *)malloc(sizeof(char) + 1);
+int32_t write_to_file(char data_line, File* file) {
+    char* data = (char*)malloc(sizeof(char) + 1);
     data[0] = data_line;
     if(!storage_file_write(file, data, (uint16_t)strlen(data))) {
         FURI_LOG_E(TAG, "Failed to write to file");
@@ -76,7 +76,7 @@ int32_t write_to_file(char data_line, File *file) {
     return 0;
 }
 
-int32_t close_file(File *file) {
+int32_t close_file(File* file) {
     storage_file_close(file);
     storage_file_free(file);
     furi_record_close(RECORD_STORAGE);
@@ -133,7 +133,7 @@ static void uart_echo_on_irq_cb(UartIrqEvent ev, uint8_t data, void* context) {
     }
 }
 
-static void uart_echo_push_to_list(UartDumpModel* model, const char data , WiFiMapApp* app) {
+static void uart_echo_push_to_list(UartDumpModel* model, const char data, WiFiMapApp* app) {
     if(model->escape) {
         // escape code end with letter
         if((data >= 'a' && data <= 'z') || (data >= 'A' && data <= 'Z')) {
@@ -143,7 +143,7 @@ static void uart_echo_push_to_list(UartDumpModel* model, const char data , WiFiM
         // "Esc[" is a escape code
         model->escape = true;
     } else if((data >= ' ' && data <= '~') || (data == '\n' || data == '\r')) {
-        write_to_file((char) data,  app->file);
+        write_to_file((char)data, app->file);
         bool new_string_needed = false;
         if(furi_string_size(model->list[model->line]->text) >= COLUMNS_ON_SCREEN) {
             new_string_needed = true;
@@ -301,11 +301,11 @@ static void uart_echo_app_free(WiFiMapApp* app) {
     free(app);
 }
 
-int32_t wifi_map_app(void *p){
-	UNUSED(p);
-	FURI_LOG_D(TAG, "wifi_map_app");
-	WiFiMapApp* app = uart_echo_app_alloc();
+int32_t wifi_map_app(void* p) {
+    UNUSED(p);
+    FURI_LOG_D(TAG, "wifi_map_app");
+    WiFiMapApp* app = uart_echo_app_alloc();
     view_dispatcher_run(app->view_dispatcher);
     uart_echo_app_free(app);
-	return 0;
+    return 0;
 }

Неке датотеке нису приказане због велике количине промена