Skip to content

Commit

Permalink
New remote design by @Svaarich
Browse files Browse the repository at this point in the history
* New remote UI
* Fix typo
  • Loading branch information
gid9798 authored Sep 11, 2023
1 parent a905d70 commit fb508ea
Show file tree
Hide file tree
Showing 31 changed files with 97 additions and 81 deletions.
Binary file added icons/remote_scene/Dpad/down.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/remote_scene/Dpad/down_hover.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/remote_scene/Dpad/left.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/remote_scene/Dpad/left_hover.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/remote_scene/Dpad/ok.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/remote_scene/Dpad/ok_hover.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/remote_scene/Dpad/right.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/remote_scene/Dpad/right_hover.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/remote_scene/Dpad/up.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/remote_scene/Dpad/up_hover.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed icons/remote_scene/Pin_cell_13x13.png
Binary file not shown.
Binary file removed icons/remote_scene/Pin_star_7x7.png
Binary file not shown.
Binary file removed icons/remote_scene/back_10px.png
Binary file not shown.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
Binary file added icons/remote_scene/statusbar/Status_cube_14x14.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/remote_scene/statusbar/status_bar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions scenes/subrem_scene_edit_label.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ void subrem_scene_edit_label_widget_callback(GuiButtonType result, InputType typ
void subrem_scene_edit_label_on_enter(void* context) {
SubGhzRemoteApp* app = context;

SubRemSubFilePreset* sub_preset = app->map_preset->subs_preset[app->chusen_sub];
SubRemSubFilePreset* sub_preset = app->map_preset->subs_preset[app->chosen_sub];

FuriString* temp_str = furi_string_alloc();

Expand Down Expand Up @@ -76,7 +76,7 @@ void subrem_scene_edit_label_on_enter(void* context) {
bool subrem_scene_edit_label_on_event(void* context, SceneManagerEvent event) {
SubGhzRemoteApp* app = context;

FuriString* label = app->map_preset->subs_preset[app->chusen_sub]->label;
FuriString* label = app->map_preset->subs_preset[app->chosen_sub]->label;

if(event.type == SceneManagerEventTypeBack) {
if(scene_manager_get_scene_state(app->scene_manager, SubRemSceneEditLabel) ==
Expand Down
2 changes: 1 addition & 1 deletion scenes/subrem_scene_edit_menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ bool subrem_scene_edit_menu_on_event(void* context, SceneManagerEvent event) {

return true;
} else if(event.event == SubRemCustomEventViewEditMenuEdit) {
app->chusen_sub = subrem_view_edit_menu_get_index(app->subrem_edit_menu);
app->chosen_sub = subrem_view_edit_menu_get_index(app->subrem_edit_menu);
scene_manager_set_scene_state(
app->scene_manager, SubRemSceneEditSubMenu, EditSubmenuIndexEditLabel);
scene_manager_next_scene(app->scene_manager, SubRemSceneEditSubMenu);
Expand Down
6 changes: 3 additions & 3 deletions scenes/subrem_scene_open_sub_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ void subrem_scene_open_sub_file_error_popup_callback(void* context) {
SubRemLoadSubState subrem_scene_open_sub_file_dialog(SubGhzRemoteApp* app) {
furi_assert(app);

SubRemSubFilePreset* sub = app->map_preset->subs_preset[app->chusen_sub];
SubRemSubFilePreset* sub = app->map_preset->subs_preset[app->chosen_sub];

FuriString* temp_file_path = furi_string_alloc();

Expand Down Expand Up @@ -47,8 +47,8 @@ SubRemLoadSubState subrem_scene_open_sub_file_dialog(SubGhzRemoteApp* app) {
furi_record_close(RECORD_STORAGE);

if(ret == SubRemLoadSubStateOK) {
subrem_sub_file_preset_free(app->map_preset->subs_preset[app->chusen_sub]);
app->map_preset->subs_preset[app->chusen_sub] = sub_candidate;
subrem_sub_file_preset_free(app->map_preset->subs_preset[app->chosen_sub]);
app->map_preset->subs_preset[app->chosen_sub] = sub_candidate;
app->map_not_saved = true;
} else {
subrem_sub_file_preset_free(sub_candidate);
Expand Down
12 changes: 6 additions & 6 deletions scenes/subrem_scene_remote.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,19 +66,19 @@ bool subrem_scene_remote_on_event(void* context, SceneManagerEvent event) {
// Start sending sub
subrem_tx_stop_sub(app, true);

uint8_t chusen_sub = subrem_scene_remote_event_to_index(event.event);
app->chusen_sub = chusen_sub;
uint8_t chosen_sub = subrem_scene_remote_event_to_index(event.event);
app->chosen_sub = chosen_sub;

subrem_view_remote_set_state(
app->subrem_remote_view, SubRemViewRemoteStateLoading, chusen_sub);
app->subrem_remote_view, SubRemViewRemoteStateLoading, chosen_sub);

if(subrem_tx_start_sub(app, app->map_preset->subs_preset[chusen_sub])) {
if(app->map_preset->subs_preset[chusen_sub]->type == SubGhzProtocolTypeRAW) {
if(subrem_tx_start_sub(app, app->map_preset->subs_preset[chosen_sub])) {
if(app->map_preset->subs_preset[chosen_sub]->type == SubGhzProtocolTypeRAW) {
subghz_txrx_set_raw_file_encoder_worker_callback_end(
app->txrx, subrem_scene_remote_raw_callback_end_tx, app);
}
subrem_view_remote_set_state(
app->subrem_remote_view, SubRemViewRemoteStateSending, chusen_sub);
app->subrem_remote_view, SubRemViewRemoteStateSending, chosen_sub);
notification_message(app->notifications, &sequence_blink_start_magenta);
} else {
subrem_view_remote_set_state(
Expand Down
4 changes: 2 additions & 2 deletions subghz_remote_app_i.c
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ void subrem_save_active_sub(void* context) {
furi_assert(context);
SubGhzRemoteApp* app = context;

SubRemSubFilePreset* sub_preset = app->map_preset->subs_preset[app->chusen_sub];
SubRemSubFilePreset* sub_preset = app->map_preset->subs_preset[app->chosen_sub];
subrem_save_protocol_to_file(
sub_preset->fff_data, furi_string_get_cstr(sub_preset->file_path));
}
Expand Down Expand Up @@ -235,7 +235,7 @@ bool subrem_tx_start_sub(SubGhzRemoteApp* app, SubRemSubFilePreset* sub_preset)

bool subrem_tx_stop_sub(SubGhzRemoteApp* app, bool forced) {
furi_assert(app);
SubRemSubFilePreset* sub_preset = app->map_preset->subs_preset[app->chusen_sub];
SubRemSubFilePreset* sub_preset = app->map_preset->subs_preset[app->chosen_sub];

if(forced || (sub_preset->type != SubGhzProtocolTypeRAW)) {
subghz_txrx_stop(app->txrx);
Expand Down
2 changes: 1 addition & 1 deletion subghz_remote_app_i.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ typedef struct {

bool map_not_saved;

uint8_t chusen_sub;
uint8_t chosen_sub;
} SubGhzRemoteApp;

SubRemLoadMapState subrem_load_from_file(SubGhzRemoteApp* app);
Expand Down
22 changes: 11 additions & 11 deletions views/edit_menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ typedef struct {
FuriString* file_path;
SubRemLoadSubState sub_state;

uint8_t chusen;
uint8_t chosen;
} SubRemViewEditMenuModel;

void subrem_view_edit_menu_set_callback(
Expand All @@ -44,7 +44,7 @@ void subrem_view_edit_menu_add_data_to_show(
subrem_view_edit_remote->view,
SubRemViewEditMenuModel * model,
{
model->chusen = index;
model->chosen = index;
if(!furi_string_empty(label)) {
furi_string_set(model->label, label);
} else {
Expand All @@ -63,7 +63,7 @@ uint8_t subrem_view_edit_menu_get_index(SubRemViewEditMenu* subrem_view_edit_rem
with_view_model(
subrem_view_edit_remote->view,
SubRemViewEditMenuModel * model,
{ index = model->chusen; },
{ index = model->chosen; },
true);
return index;
}
Expand All @@ -89,7 +89,7 @@ void subrem_view_edit_menu_draw(Canvas* canvas, SubRemViewEditMenuModel* model)

// Draw btn name
canvas_set_font(canvas, FontPrimary);
switch(model->chusen) {
switch(model->chosen) {
case SubRemSubKeyNameUp:
canvas_draw_str(canvas, 3, FRAME_HEIGHT - 2, "UP");
break;
Expand Down Expand Up @@ -129,10 +129,10 @@ void subrem_view_edit_menu_draw(Canvas* canvas, SubRemViewEditMenuModel* model)

// Draw arrow
canvas_set_color(canvas, ColorBlack);
if(model->chusen != 0) {
if(model->chosen != 0) {
canvas_draw_icon(canvas, 119, 13, &I_Pin_arrow_up_7x9);
}
if(model->chusen != 4) {
if(model->chosen != 4) {
canvas_draw_icon_ex(canvas, 119, 42, &I_Pin_arrow_up_7x9, IconRotation180);
}

Expand Down Expand Up @@ -200,8 +200,8 @@ bool subrem_view_edit_menu_input(InputEvent* event, void* context) {
subrem_view_edit_menu->view,
SubRemViewEditMenuModel * model,
{
if(model->chusen > 0) {
model->chusen -= 1;
if(model->chosen > 0) {
model->chosen -= 1;
};
},
true);
Expand All @@ -213,8 +213,8 @@ bool subrem_view_edit_menu_input(InputEvent* event, void* context) {
subrem_view_edit_menu->view,
SubRemViewEditMenuModel * model,
{
if(model->chusen < 4) {
model->chusen += 1;
if(model->chosen < 4) {
model->chosen += 1;
};
},
true);
Expand Down Expand Up @@ -263,7 +263,7 @@ SubRemViewEditMenu* subrem_view_edit_menu_alloc() {
model->label = furi_string_alloc(); // furi_string_alloc_set_str("LABEL");
model->file_path = furi_string_alloc(); // furi_string_alloc_set_str("FILE_PATH");

model->chusen = 0;
model->chosen = 0;
},
true);
return subrem_view_edit_menu;
Expand Down
126 changes: 71 additions & 55 deletions views/remote.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#define SUBREM_VIEW_REMOTE_MAX_LABEL_LENGTH 30
#define SUBREM_VIEW_REMOTE_LEFT_OFFSET 10
#define SUBREM_VIEW_REMOTE_RIGHT_OFFSET 22
#define SUBREM_VIEW_REMOTE_RIGHT_OFFSET 0

struct SubRemViewRemote {
View* view;
Expand Down Expand Up @@ -120,26 +120,43 @@ void subrem_view_remote_draw(Canvas* canvas, SubRemViewRemoteModel* model) {
canvas_clear(canvas);
canvas_set_color(canvas, ColorBlack);

canvas_clear(canvas);
// Statusbar
canvas_draw_icon(canvas, 0, 0, &I_status_bar);
if(model->state == SubRemViewRemoteStateOFF) {
canvas_invert_color(canvas);
canvas_draw_rbox(canvas, 12, 0, 52 - 12, 13, 2);
canvas_invert_color(canvas);
canvas_draw_rframe(canvas, 12, 0, 52 - 12, 13, 2);
canvas_draw_str_aligned(canvas, 32, 3, AlignCenter, AlignTop, "Preview");
} else {
canvas_draw_icon(
canvas,
0,
2,
(model->is_external) ? &I_External_antenna_20x12 : &I_Internal_antenna_20x12);
canvas_draw_icon(canvas, 50, 0, &I_Status_cube_14x14);
if(model->state == SubRemViewRemoteStateSending) {
canvas_draw_icon_ex(canvas, 52, 3, &I_Pin_arrow_up_7x9, IconRotation90);
}
}

//Icons for Labels
//canvas_draw_icon(canvas, 0, 0, &I_SubGHzRemote_LeftAlignedButtons_9x64);
canvas_draw_icon(canvas, 1, 5, &I_ButtonUp_7x4);
canvas_draw_icon(canvas, 1, 15, &I_ButtonDown_7x4);
canvas_draw_icon(canvas, 2, 23, &I_ButtonLeft_4x7);
canvas_draw_icon(canvas, 2, 33, &I_ButtonRight_4x7);
canvas_draw_icon(canvas, 0, 42, &I_Ok_btn_9x9);
canvas_draw_icon(canvas, 0, 53, &I_back_10px);
const uint8_t list_y = 14;
canvas_draw_icon(canvas, 1, list_y + 5, &I_ButtonUp_7x4);
canvas_draw_icon(canvas, 1, list_y + 15, &I_ButtonDown_7x4);
canvas_draw_icon(canvas, 2, list_y + 23, &I_ButtonLeft_4x7);
canvas_draw_icon(canvas, 2, list_y + 33, &I_ButtonRight_4x7);
canvas_draw_icon(canvas, 0, list_y + 42, &I_Ok_btn_9x9);

//Labels
canvas_set_font(canvas, FontSecondary);
uint8_t y = 0;
uint8_t y = list_y;
for(uint8_t i = 0; i < SubRemSubKeyNameMaxCount; i++) {
elements_text_box(
canvas,
SUBREM_VIEW_REMOTE_LEFT_OFFSET,
y + 2,
126 - SUBREM_VIEW_REMOTE_LEFT_OFFSET - SUBREM_VIEW_REMOTE_RIGHT_OFFSET,
64 - SUBREM_VIEW_REMOTE_LEFT_OFFSET - SUBREM_VIEW_REMOTE_RIGHT_OFFSET,
12,
AlignLeft,
AlignBottom,
Expand All @@ -148,52 +165,50 @@ void subrem_view_remote_draw(Canvas* canvas, SubRemViewRemoteModel* model) {
y += 10;
}

if(model->state == SubRemViewRemoteStateOFF) {
elements_button_left(canvas, "Back");
elements_button_right(canvas, "Save");
} else {
canvas_draw_str_aligned(canvas, 11, 62, AlignLeft, AlignBottom, "Hold=Exit.");
canvas_draw_str_aligned(
canvas, 126, 62, AlignRight, AlignBottom, ((model->is_external) ? "Ext" : "Int"));
}

//Status text and indicator
canvas_draw_icon(canvas, 113, 15, &I_Pin_cell_13x13);

if(model->state == SubRemViewRemoteStateIdle || model->state == SubRemViewRemoteStateOFF) {
canvas_draw_str_aligned(canvas, 126, 10, AlignRight, AlignBottom, "Idle");
} else {
switch(model->state) {
case SubRemViewRemoteStateSending:
canvas_draw_str_aligned(canvas, 126, 10, AlignRight, AlignBottom, "Send");
break;
case SubRemViewRemoteStateLoading:
canvas_draw_str_aligned(canvas, 126, 10, AlignRight, AlignBottom, "Load");
break;
default:
#if FURI_DEBUG
canvas_draw_str_aligned(canvas, 126, 10, AlignRight, AlignBottom, "Wrong_state");
#endif
break;
if(model->state != SubRemViewRemoteStateOFF) {
// D-pad 59x62
const uint8_t d_pad_x = 3;
const uint8_t d_pad_y = 66;

canvas_draw_icon(canvas, d_pad_x + 1 * (19 + 1), d_pad_y + 0 * (20 + 1), &I_up);

canvas_draw_icon(canvas, d_pad_x + 0 * (19 + 1), d_pad_y + 1 * (20 + 1), &I_left);
canvas_draw_icon(canvas, d_pad_x + 1 * (19 + 1), d_pad_y + 1 * (20 + 1), &I_ok);
canvas_draw_icon(canvas, d_pad_x + 2 * (19 + 1), d_pad_y + 1 * (20 + 1), &I_right);

canvas_draw_icon(canvas, d_pad_x + 1 * (19 + 1), d_pad_y + 2 * (20 + 1), &I_down);
if(model->state == SubRemViewRemoteStateSending) {
switch(model->pressed_btn) {
case SubRemSubKeyNameUp:
canvas_draw_icon(
canvas, d_pad_x + 1 * (19 + 1), d_pad_y + 0 * (20 + 1), &I_up_hover);
break;
case SubRemSubKeyNameDown:
canvas_draw_icon(
canvas, d_pad_x + 1 * (19 + 1), d_pad_y + 2 * (20 + 1), &I_down_hover);
break;
case SubRemSubKeyNameLeft:
canvas_draw_icon(
canvas, d_pad_x + 0 * (19 + 1), d_pad_y + 1 * (20 + 1), &I_left_hover);
break;
case SubRemSubKeyNameRight:
canvas_draw_icon(
canvas, d_pad_x + 2 * (19 + 1), d_pad_y + 1 * (20 + 1), &I_right_hover);
break;
case SubRemSubKeyNameOk:
canvas_draw_icon(
canvas, d_pad_x + 1 * (19 + 1), d_pad_y + 1 * (20 + 1), &I_ok_hover);
break;
default:
break;
}
}
} else {
canvas_draw_icon(canvas, 2, 128 - 11, &I_ButtonLeft_4x7);
canvas_draw_str_aligned(canvas, 8, 128 - 4, AlignLeft, AlignBottom, "Back");

switch(model->pressed_btn) {
case SubRemSubKeyNameUp:
canvas_draw_icon(canvas, 116, 17, &I_Pin_arrow_up_7x9);
break;
case SubRemSubKeyNameDown:
canvas_draw_icon_ex(canvas, 116, 17, &I_Pin_arrow_up_7x9, IconRotation180);
break;
case SubRemSubKeyNameLeft:
canvas_draw_icon_ex(canvas, 115, 18, &I_Pin_arrow_up_7x9, IconRotation270);
break;
case SubRemSubKeyNameRight:
canvas_draw_icon_ex(canvas, 115, 18, &I_Pin_arrow_up_7x9, IconRotation90);
break;
case SubRemSubKeyNameOk:
canvas_draw_icon(canvas, 116, 18, &I_Pin_star_7x7);
break;
}
canvas_draw_icon(canvas, 58, 128 - 11, &I_ButtonRight_4x7);
canvas_draw_str_aligned(canvas, 56, 128 - 4, AlignRight, AlignBottom, "Save");
}
}

Expand Down Expand Up @@ -262,6 +277,7 @@ SubRemViewRemote* subrem_view_remote_alloc() {
view_allocate_model(
subrem_view_remote->view, ViewModelTypeLocking, sizeof(SubRemViewRemoteModel));
view_set_context(subrem_view_remote->view, subrem_view_remote);
view_set_orientation(subrem_view_remote->view, ViewOrientationVertical);
view_set_draw_callback(subrem_view_remote->view, (ViewDrawCallback)subrem_view_remote_draw);
view_set_input_callback(subrem_view_remote->view, subrem_view_remote_input);
view_set_enter_callback(subrem_view_remote->view, subrem_view_remote_enter);
Expand Down

0 comments on commit fb508ea

Please sign in to comment.