Преглед изворни кода

Merge subghz_bruteforcer from https://github.com/DarkFlippers/flipperzero-subbrute

# Conflicts:
#	subghz_bruteforcer/helpers/gui_top_buttons.c
#	subghz_bruteforcer/helpers/gui_top_buttons.h
Willy-JL пре 1 година
родитељ
комит
c3f99ee918

+ 7 - 0
subghz_bruteforcer/.deepsource.toml

@@ -0,0 +1,7 @@
+version = 1
+
+[[analyzers]]
+name = "cxx"
+
+[[transformers]]
+name = "clang-format"

+ 0 - 59
subghz_bruteforcer/helpers/gui_top_buttons.c

@@ -1,59 +0,0 @@
-#include "gui_top_buttons.h"
-
-void elements_button_top_left(Canvas* canvas, const char* str) {
-    const Icon* icon = &I_ButtonUp_7x4;
-
-    const uint8_t button_height = 12;
-    const uint8_t vertical_offset = 3;
-    const uint8_t horizontal_offset = 3;
-    const uint8_t string_width = canvas_string_width(canvas, str);
-    const uint8_t icon_h_offset = 3;
-    const uint8_t icon_width_with_offset = icon_get_width(icon) + icon_h_offset;
-    const uint8_t icon_v_offset = icon_get_height(icon) + vertical_offset;
-    const uint8_t button_width = string_width + horizontal_offset * 2 + icon_width_with_offset;
-
-    const uint8_t x = 0;
-    const uint8_t y = 0 + button_height;
-
-    uint8_t line_x = x + button_width;
-    uint8_t line_y = y - button_height;
-    canvas_draw_box(canvas, x, line_y, button_width, button_height);
-    canvas_draw_line(canvas, line_x + 0, line_y, line_x + 0, y - 1);
-    canvas_draw_line(canvas, line_x + 1, line_y, line_x + 1, y - 2);
-    canvas_draw_line(canvas, line_x + 2, line_y, line_x + 2, y - 3);
-
-    canvas_invert_color(canvas);
-    canvas_draw_icon(canvas, x + horizontal_offset, y - icon_v_offset, icon);
-    canvas_draw_str(
-        canvas, x + horizontal_offset + icon_width_with_offset, y - vertical_offset, str);
-    canvas_invert_color(canvas);
-}
-
-void elements_button_top_right(Canvas* canvas, const char* str) {
-    const Icon* icon = &I_ButtonDown_7x4;
-
-    const uint8_t button_height = 12;
-    const uint8_t vertical_offset = 3;
-    const uint8_t horizontal_offset = 3;
-    const uint8_t string_width = canvas_string_width(canvas, str);
-    const uint8_t icon_h_offset = 3;
-    const uint8_t icon_width_with_offset = icon_get_width(icon) + icon_h_offset;
-    const uint8_t icon_v_offset = icon_get_height(icon) + vertical_offset + 1;
-    const uint8_t button_width = string_width + horizontal_offset * 2 + icon_width_with_offset;
-
-    const uint8_t x = canvas_width(canvas);
-    const uint8_t y = 0 + button_height;
-
-    uint8_t line_x = x - button_width;
-    uint8_t line_y = y - button_height;
-    canvas_draw_box(canvas, line_x, line_y, button_width, button_height);
-    canvas_draw_line(canvas, line_x - 1, line_y, line_x - 1, y - 1);
-    canvas_draw_line(canvas, line_x - 2, line_y, line_x - 2, y - 2);
-    canvas_draw_line(canvas, line_x - 3, line_y, line_x - 3, y - 3);
-
-    canvas_invert_color(canvas);
-    canvas_draw_str(canvas, x - button_width + horizontal_offset, y - vertical_offset, str);
-    canvas_draw_icon(
-        canvas, x - horizontal_offset - icon_get_width(icon), y - icon_v_offset, icon);
-    canvas_invert_color(canvas);
-}

+ 0 - 37
subghz_bruteforcer/helpers/gui_top_buttons.h

@@ -1,37 +0,0 @@
-#pragma once
-
-#include <subghz_bruteforcer_icons.h>
-#include <input/input.h>
-#include <gui/elements.h>
-#include <gui/icon.h>
-#include <gui/icon_animation.h>
-
-#include <assets_icons.h>
-
-/**
- * @brief This function draws a button in the top left corner of the canvas with icon and string.
- *
- * The design and layout of the button is defined within this function.
- *
- *
- * @param[in] canvas This is a pointer to the @c Canvas structure where the button will be drawn.
- * @param[in] str This is a pointer to the character string that will be drawn within the button.
- *
- * @note Thanks to the author of metronome @see https://github.com/panki27/Metronome
- *
- */
-void elements_button_top_left(Canvas* canvas, const char* str);
-
-/**
- * @brief This function draws a button in the top right corner of the canvas with icon and string.
- *
- * The design and layout of the button is defined within this function.
- *
- *
- * @param[in] canvas This is a pointer to the @c Canvas structure where the button will be drawn.
- * @param[in] str This is a pointer to the character string that will be drawn within the button.
- *
- * @note Thanks to the author of metronome @see https://github.com/panki27/Metronome
- *
- */
-void elements_button_top_right(Canvas* canvas, const char* str);

+ 1 - 1
subghz_bruteforcer/scenes/subbrute_scene_load_file.c

@@ -56,7 +56,7 @@ void subbrute_scene_load_file_on_enter(void* context) {
                 }
                 // Ready to run!
                 FURI_LOG_I(TAG, "Ready to run");
-                res = true;
+                load_result = true;
             }
         }
 

+ 1 - 1
subghz_bruteforcer/subbrute_i.h

@@ -33,7 +33,7 @@
 #include "views/subbrute_attack_view.h"
 #include "views/subbrute_main_view.h"
 
-#define SUB_BRUTE_FORCER_VERSION "Sub-GHz BruteForcer 3.E"
+#define SUB_BRUTE_FORCER_VERSION "Sub-GHz BruteForcer 3.F"
 
 #ifdef FURI_DEBUG
 //#define SUBBRUTE_FAST_TRACK false

+ 2 - 3
subghz_bruteforcer/views/subbrute_attack_view.c

@@ -1,6 +1,5 @@
 #include "subbrute_attack_view.h"
 #include "../subbrute_i.h"
-#include "../helpers/gui_top_buttons.h"
 
 #include <input/input.h>
 #include <gui/elements.h>
@@ -312,8 +311,8 @@ void subbrute_attack_view_draw(Canvas* canvas, void* context) {
         elements_button_left(canvas, "-1");
         elements_button_right(canvas, "+1");
         elements_button_center(canvas, "Start");
-        elements_button_top_left(canvas, "Save");
-        elements_button_top_right(canvas, "Resend");
+        elements_button_up(canvas, "Save");
+        elements_button_down(canvas, "Resend");
     } else {
         // canvas_draw_icon_animation
         const uint8_t icon_h_offset = 0;

+ 2 - 3
subghz_bruteforcer/views/subbrute_main_view.c

@@ -1,6 +1,5 @@
 #include "subbrute_main_view.h"
 #include "../subbrute_i.h"
-#include "../helpers/gui_top_buttons.h"
 
 #include <input/input.h>
 #include <gui/elements.h>
@@ -126,9 +125,9 @@ void subbrute_main_view_draw_is_byte_selected(Canvas* canvas, SubBruteMainViewMo
 
     // Switch to another mode
     if(model->two_bytes) {
-        elements_button_top_left(canvas, "One byte");
+        elements_button_up(canvas, "One byte");
     } else {
-        elements_button_top_left(canvas, "Two bytes");
+        elements_button_up(canvas, "Two bytes");
     }
 }