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

Updated for upstream flipperzero 0.69. Nice.

Aria Burrell 3 лет назад
Родитель
Сommit
90cc9b0b33
2 измененных файлов с 42 добавлено и 28 удалено
  1. 2 0
      application.fam
  2. 40 28
      views/dtmf_dolphin_dialer.c

+ 2 - 0
application.fam

@@ -5,9 +5,11 @@ App(
     entry_point="dtmf_dolphin_app",
     cdefines=["DTMF_DOLPHIN"],
     requires=[
+        "storage",
         "gui",
         "dialogs",
     ],
     stack_size=8 * 1024,
     order=20,
+    fap_category="Tools",
 )

+ 40 - 28
views/dtmf_dolphin_dialer.c

@@ -127,17 +127,16 @@ static void dtmf_dolphin_dialer_draw_callback(Canvas* canvas, void* _model) {
 
     draw_dialer(canvas, model);
 
-    string_t output;
-    string_init(output);
+    FuriString *output = furi_string_alloc();
 
     if (model->freq1 && model->freq2) {
-        string_cat_printf(
+        furi_string_cat_printf(
             output,
             "Dual Tone\nF1: %u Hz\nF2: %u Hz\n",
             (unsigned int) model->freq1,
             (unsigned int) model->freq2);
     } else if (model->freq1) {
-        string_cat_printf(
+        furi_string_cat_printf(
             output,
             "Single Tone\nF: %u Hz\n",
             (unsigned int) model->freq1);
@@ -145,9 +144,9 @@ static void dtmf_dolphin_dialer_draw_callback(Canvas* canvas, void* _model) {
 
     canvas_set_font(canvas, FontSecondary);
     canvas_set_color(canvas, ColorBlack);
-    elements_multiline_text(canvas, (max_span * DTMF_DOLPHIN_BUTTON_WIDTH) + 4, 21, string_get_cstr(output));
+    elements_multiline_text(canvas, (max_span * DTMF_DOLPHIN_BUTTON_WIDTH) + 4, 21, furi_string_get_cstr(output));
 
-    string_clear(output);
+    furi_string_free(output);
 }
 
 static bool dtmf_dolphin_dialer_input_callback(InputEvent* event, void* context) {
@@ -175,7 +174,9 @@ static bool dtmf_dolphin_dialer_input_callback(InputEvent* event, void* context)
 
 static bool dtmf_dolphin_dialer_process_up(DTMFDolphinDialer* dtmf_dolphin_dialer) {
     with_view_model(
-        dtmf_dolphin_dialer->view, (DTMFDolphinDialerModel * model) {
+        dtmf_dolphin_dialer->view,
+        DTMFDolphinDialerModel * model,
+        {
             uint8_t span = 0;
             uint8_t cursor = model->row;
             while (span == 0 && cursor > 0) {
@@ -185,8 +186,8 @@ static bool dtmf_dolphin_dialer_process_up(DTMFDolphinDialer* dtmf_dolphin_diale
             if (span != 0) {
                 model->row = cursor;
             }
-            return true;
-        });
+        },
+        true);
     return true;
 }
 
@@ -197,7 +198,9 @@ static bool dtmf_dolphin_dialer_process_down(DTMFDolphinDialer* dtmf_dolphin_dia
     dtmf_dolphin_tone_get_max_pos(&max_rows, &max_cols, &max_span);
 
     with_view_model(
-        dtmf_dolphin_dialer->view, (DTMFDolphinDialerModel * model) {
+        dtmf_dolphin_dialer->view,
+        DTMFDolphinDialerModel * model,
+        {
             uint8_t span = 0;
             uint8_t cursor = model->row;
             while(span == 0 && cursor < max_rows - 1) {
@@ -207,14 +210,16 @@ static bool dtmf_dolphin_dialer_process_down(DTMFDolphinDialer* dtmf_dolphin_dia
             if (span != 0) {
                 model->row = cursor;
             }
-            return true;
-        });
+        },
+        true);
     return true;
 }
 
 static bool dtmf_dolphin_dialer_process_left(DTMFDolphinDialer* dtmf_dolphin_dialer) {
     with_view_model(
-        dtmf_dolphin_dialer->view, (DTMFDolphinDialerModel * model) {
+        dtmf_dolphin_dialer->view,
+        DTMFDolphinDialerModel * model,
+        {
             uint8_t span = 0;
             uint8_t cursor = model->col;
             while (span == 0 && cursor > 0) {
@@ -224,8 +229,8 @@ static bool dtmf_dolphin_dialer_process_left(DTMFDolphinDialer* dtmf_dolphin_dia
             if (span != 0) {
                 model->col = cursor;
             }
-            return true;
-        });
+        },
+        true);
     return true;
 }
 
@@ -236,7 +241,9 @@ static bool dtmf_dolphin_dialer_process_right(DTMFDolphinDialer* dtmf_dolphin_di
     dtmf_dolphin_tone_get_max_pos(&max_rows, &max_cols, &max_span);
 
     with_view_model(
-        dtmf_dolphin_dialer->view, (DTMFDolphinDialerModel * model) {
+        dtmf_dolphin_dialer->view,
+        DTMFDolphinDialerModel * model,
+        {
             uint8_t span = 0;
             uint8_t cursor = model->col;
             while(span == 0 && cursor < max_cols - 1) {
@@ -246,8 +253,8 @@ static bool dtmf_dolphin_dialer_process_right(DTMFDolphinDialer* dtmf_dolphin_di
             if (span != 0) {
                 model->col = cursor;
             }
-            return true;
-        });
+        },
+        true);
     return true;
 }
 
@@ -255,15 +262,16 @@ static bool dtmf_dolphin_dialer_process_ok(DTMFDolphinDialer* dtmf_dolphin_diale
     bool consumed = false;
 
     with_view_model(
-        dtmf_dolphin_dialer->view, (DTMFDolphinDialerModel * model) {
+        dtmf_dolphin_dialer->view,
+        DTMFDolphinDialerModel * model,
+        {
             if (event->type == InputTypePress) {
                 model->playing = dtmf_dolphin_audio_play_tones(model->freq1, model->freq2);
             } else if (event->type == InputTypeRelease) {
                 model->playing = !dtmf_dolphin_audio_stop_tones();
             }
-
-            return true;
-        });
+        },
+        true);
 
     return consumed;
 }
@@ -273,15 +281,17 @@ static void dtmf_dolphin_dialer_enter_callback(void* context) {
     DTMFDolphinDialer* dtmf_dolphin_dialer = context;
 
     with_view_model(
-        dtmf_dolphin_dialer->view, (DTMFDolphinDialerModel * model) {
+        dtmf_dolphin_dialer->view,
+        DTMFDolphinDialerModel * model,
+        {
             model->col = 0;
             model->row = 0;
             model->section = 0;
             model->freq1 = 0.0;
             model->freq2 = 0.0;
             model->playing = false;
-            return true;
-        }
+        },
+        true
     );
 }
 
@@ -292,15 +302,17 @@ DTMFDolphinDialer* dtmf_dolphin_dialer_alloc() {
     view_allocate_model(dtmf_dolphin_dialer->view, ViewModelTypeLocking, sizeof(DTMFDolphinDialerModel));
 
     with_view_model(
-        dtmf_dolphin_dialer->view, (DTMFDolphinDialerModel * model) {
+        dtmf_dolphin_dialer->view,
+        DTMFDolphinDialerModel * model,
+        {
             model->col = 0;
             model->row = 0;
             model->section = 0;
             model->freq1 = 0.0;
             model->freq2 = 0.0;
             model->playing = false;
-            return true;
-        }
+        },
+        true
     );
 
     view_set_context(dtmf_dolphin_dialer->view, dtmf_dolphin_dialer);