|
@@ -127,17 +127,16 @@ static void dtmf_dolphin_dialer_draw_callback(Canvas* canvas, void* _model) {
|
|
|
|
|
|
|
|
draw_dialer(canvas, model);
|
|
draw_dialer(canvas, model);
|
|
|
|
|
|
|
|
- string_t output;
|
|
|
|
|
- string_init(output);
|
|
|
|
|
|
|
+ FuriString *output = furi_string_alloc();
|
|
|
|
|
|
|
|
if (model->freq1 && model->freq2) {
|
|
if (model->freq1 && model->freq2) {
|
|
|
- string_cat_printf(
|
|
|
|
|
|
|
+ furi_string_cat_printf(
|
|
|
output,
|
|
output,
|
|
|
"Dual Tone\nF1: %u Hz\nF2: %u Hz\n",
|
|
"Dual Tone\nF1: %u Hz\nF2: %u Hz\n",
|
|
|
(unsigned int) model->freq1,
|
|
(unsigned int) model->freq1,
|
|
|
(unsigned int) model->freq2);
|
|
(unsigned int) model->freq2);
|
|
|
} else if (model->freq1) {
|
|
} else if (model->freq1) {
|
|
|
- string_cat_printf(
|
|
|
|
|
|
|
+ furi_string_cat_printf(
|
|
|
output,
|
|
output,
|
|
|
"Single Tone\nF: %u Hz\n",
|
|
"Single Tone\nF: %u Hz\n",
|
|
|
(unsigned int) model->freq1);
|
|
(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_font(canvas, FontSecondary);
|
|
|
canvas_set_color(canvas, ColorBlack);
|
|
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) {
|
|
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) {
|
|
static bool dtmf_dolphin_dialer_process_up(DTMFDolphinDialer* dtmf_dolphin_dialer) {
|
|
|
with_view_model(
|
|
with_view_model(
|
|
|
- dtmf_dolphin_dialer->view, (DTMFDolphinDialerModel * model) {
|
|
|
|
|
|
|
+ dtmf_dolphin_dialer->view,
|
|
|
|
|
+ DTMFDolphinDialerModel * model,
|
|
|
|
|
+ {
|
|
|
uint8_t span = 0;
|
|
uint8_t span = 0;
|
|
|
uint8_t cursor = model->row;
|
|
uint8_t cursor = model->row;
|
|
|
while (span == 0 && cursor > 0) {
|
|
while (span == 0 && cursor > 0) {
|
|
@@ -185,8 +186,8 @@ static bool dtmf_dolphin_dialer_process_up(DTMFDolphinDialer* dtmf_dolphin_diale
|
|
|
if (span != 0) {
|
|
if (span != 0) {
|
|
|
model->row = cursor;
|
|
model->row = cursor;
|
|
|
}
|
|
}
|
|
|
- return true;
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ },
|
|
|
|
|
+ true);
|
|
|
return 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);
|
|
dtmf_dolphin_tone_get_max_pos(&max_rows, &max_cols, &max_span);
|
|
|
|
|
|
|
|
with_view_model(
|
|
with_view_model(
|
|
|
- dtmf_dolphin_dialer->view, (DTMFDolphinDialerModel * model) {
|
|
|
|
|
|
|
+ dtmf_dolphin_dialer->view,
|
|
|
|
|
+ DTMFDolphinDialerModel * model,
|
|
|
|
|
+ {
|
|
|
uint8_t span = 0;
|
|
uint8_t span = 0;
|
|
|
uint8_t cursor = model->row;
|
|
uint8_t cursor = model->row;
|
|
|
while(span == 0 && cursor < max_rows - 1) {
|
|
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) {
|
|
if (span != 0) {
|
|
|
model->row = cursor;
|
|
model->row = cursor;
|
|
|
}
|
|
}
|
|
|
- return true;
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ },
|
|
|
|
|
+ true);
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
static bool dtmf_dolphin_dialer_process_left(DTMFDolphinDialer* dtmf_dolphin_dialer) {
|
|
static bool dtmf_dolphin_dialer_process_left(DTMFDolphinDialer* dtmf_dolphin_dialer) {
|
|
|
with_view_model(
|
|
with_view_model(
|
|
|
- dtmf_dolphin_dialer->view, (DTMFDolphinDialerModel * model) {
|
|
|
|
|
|
|
+ dtmf_dolphin_dialer->view,
|
|
|
|
|
+ DTMFDolphinDialerModel * model,
|
|
|
|
|
+ {
|
|
|
uint8_t span = 0;
|
|
uint8_t span = 0;
|
|
|
uint8_t cursor = model->col;
|
|
uint8_t cursor = model->col;
|
|
|
while (span == 0 && cursor > 0) {
|
|
while (span == 0 && cursor > 0) {
|
|
@@ -224,8 +229,8 @@ static bool dtmf_dolphin_dialer_process_left(DTMFDolphinDialer* dtmf_dolphin_dia
|
|
|
if (span != 0) {
|
|
if (span != 0) {
|
|
|
model->col = cursor;
|
|
model->col = cursor;
|
|
|
}
|
|
}
|
|
|
- return true;
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ },
|
|
|
|
|
+ true);
|
|
|
return 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);
|
|
dtmf_dolphin_tone_get_max_pos(&max_rows, &max_cols, &max_span);
|
|
|
|
|
|
|
|
with_view_model(
|
|
with_view_model(
|
|
|
- dtmf_dolphin_dialer->view, (DTMFDolphinDialerModel * model) {
|
|
|
|
|
|
|
+ dtmf_dolphin_dialer->view,
|
|
|
|
|
+ DTMFDolphinDialerModel * model,
|
|
|
|
|
+ {
|
|
|
uint8_t span = 0;
|
|
uint8_t span = 0;
|
|
|
uint8_t cursor = model->col;
|
|
uint8_t cursor = model->col;
|
|
|
while(span == 0 && cursor < max_cols - 1) {
|
|
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) {
|
|
if (span != 0) {
|
|
|
model->col = cursor;
|
|
model->col = cursor;
|
|
|
}
|
|
}
|
|
|
- return true;
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ },
|
|
|
|
|
+ true);
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -255,15 +262,16 @@ static bool dtmf_dolphin_dialer_process_ok(DTMFDolphinDialer* dtmf_dolphin_diale
|
|
|
bool consumed = false;
|
|
bool consumed = false;
|
|
|
|
|
|
|
|
with_view_model(
|
|
with_view_model(
|
|
|
- dtmf_dolphin_dialer->view, (DTMFDolphinDialerModel * model) {
|
|
|
|
|
|
|
+ dtmf_dolphin_dialer->view,
|
|
|
|
|
+ DTMFDolphinDialerModel * model,
|
|
|
|
|
+ {
|
|
|
if (event->type == InputTypePress) {
|
|
if (event->type == InputTypePress) {
|
|
|
model->playing = dtmf_dolphin_audio_play_tones(model->freq1, model->freq2);
|
|
model->playing = dtmf_dolphin_audio_play_tones(model->freq1, model->freq2);
|
|
|
} else if (event->type == InputTypeRelease) {
|
|
} else if (event->type == InputTypeRelease) {
|
|
|
model->playing = !dtmf_dolphin_audio_stop_tones();
|
|
model->playing = !dtmf_dolphin_audio_stop_tones();
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- return true;
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ },
|
|
|
|
|
+ true);
|
|
|
|
|
|
|
|
return consumed;
|
|
return consumed;
|
|
|
}
|
|
}
|
|
@@ -273,15 +281,17 @@ static void dtmf_dolphin_dialer_enter_callback(void* context) {
|
|
|
DTMFDolphinDialer* dtmf_dolphin_dialer = context;
|
|
DTMFDolphinDialer* dtmf_dolphin_dialer = context;
|
|
|
|
|
|
|
|
with_view_model(
|
|
with_view_model(
|
|
|
- dtmf_dolphin_dialer->view, (DTMFDolphinDialerModel * model) {
|
|
|
|
|
|
|
+ dtmf_dolphin_dialer->view,
|
|
|
|
|
+ DTMFDolphinDialerModel * model,
|
|
|
|
|
+ {
|
|
|
model->col = 0;
|
|
model->col = 0;
|
|
|
model->row = 0;
|
|
model->row = 0;
|
|
|
model->section = 0;
|
|
model->section = 0;
|
|
|
model->freq1 = 0.0;
|
|
model->freq1 = 0.0;
|
|
|
model->freq2 = 0.0;
|
|
model->freq2 = 0.0;
|
|
|
model->playing = false;
|
|
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));
|
|
view_allocate_model(dtmf_dolphin_dialer->view, ViewModelTypeLocking, sizeof(DTMFDolphinDialerModel));
|
|
|
|
|
|
|
|
with_view_model(
|
|
with_view_model(
|
|
|
- dtmf_dolphin_dialer->view, (DTMFDolphinDialerModel * model) {
|
|
|
|
|
|
|
+ dtmf_dolphin_dialer->view,
|
|
|
|
|
+ DTMFDolphinDialerModel * model,
|
|
|
|
|
+ {
|
|
|
model->col = 0;
|
|
model->col = 0;
|
|
|
model->row = 0;
|
|
model->row = 0;
|
|
|
model->section = 0;
|
|
model->section = 0;
|
|
|
model->freq1 = 0.0;
|
|
model->freq1 = 0.0;
|
|
|
model->freq2 = 0.0;
|
|
model->freq2 = 0.0;
|
|
|
model->playing = false;
|
|
model->playing = false;
|
|
|
- return true;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ },
|
|
|
|
|
+ true
|
|
|
);
|
|
);
|
|
|
|
|
|
|
|
view_set_context(dtmf_dolphin_dialer->view, dtmf_dolphin_dialer);
|
|
view_set_context(dtmf_dolphin_dialer->view, dtmf_dolphin_dialer);
|