Skip to content

Commit e6a83b1

Browse files
author
Sandro Kalatozishvili
committed
Fixed back button behavior in control page
1 parent e1add54 commit e6a83b1

File tree

8 files changed

+37
-38
lines changed

8 files changed

+37
-38
lines changed

views/xremote_common_view.c

Lines changed: 10 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,6 @@ struct XRemoteView {
1616
void *context;
1717
};
1818

19-
const NotificationSequence g_sequence_blink_purple_50 = {
20-
&message_red_255,
21-
&message_blue_255,
22-
&message_delay_50,
23-
NULL,
24-
};
25-
2619
XRemoteView* xremote_view_alloc(void* app_ctx, ViewInputCallback input_cb, ViewDrawCallback draw_cb)
2720
{
2821
XRemoteView* remote_view = malloc(sizeof(XRemoteView));
@@ -95,33 +88,24 @@ InfraredRemoteButton* xremote_view_get_button_by_name(XRemoteView *rview, const
9588
return infrared_remote_get_button_by_name(remote, name);
9689
}
9790

98-
bool xremote_view_send_ir_by_name(XRemoteView *rview, const char *name)
91+
bool xremote_view_press_button(XRemoteView *rview, InfraredRemoteButton* button)
9992
{
100-
InfraredRemoteButton* button = xremote_view_get_button_by_name(rview, name);
10193
xremote_app_assert(button, false);
94+
XRemoteAppSettings* settings = rview->app_ctx->app_settings;
10295

10396
InfraredSignal* signal = infrared_remote_button_get_signal(button);
10497
xremote_app_assert(signal, false);
10598

106-
infrared_signal_transmit(signal);
107-
NotificationApp* notifications = rview->app_ctx->notifications;
108-
notification_message(notifications, &g_sequence_blink_purple_50);
99+
infrared_signal_transmit_times(signal, settings->repeat_count);
100+
xremote_app_context_notify_led(rview->app_ctx);
109101

110102
return true;
111103
}
112104

113-
bool xremote_view_press_button(XRemoteView *rview, InfraredRemoteButton* button)
105+
bool xremote_view_send_ir_msg_by_name(XRemoteView *rview, const char *name)
114106
{
115-
xremote_app_assert(button, false);
116-
117-
InfraredSignal* signal = infrared_remote_button_get_signal(button);
118-
xremote_app_assert(signal, false);
119-
120-
infrared_signal_transmit(signal);
121-
NotificationApp* notifications = rview->app_ctx->notifications;
122-
notification_message(notifications, &g_sequence_blink_purple_50);
123-
124-
return true;
107+
InfraredRemoteButton* button = xremote_view_get_button_by_name(rview, name);
108+
return (button != NULL) ? xremote_view_press_button(rview, button) : false;
125109
}
126110

127111
void xremote_canvas_draw_icon(Canvas* canvas, uint8_t x, uint8_t y, XRemoteIcon icon)
@@ -241,7 +225,8 @@ void xremote_canvas_draw_exit_footer(Canvas* canvas, ViewOrientation orient, con
241225
}
242226
else
243227
{
244-
xremote_canvas_draw_icon(canvas, 71, 60, XRemoteIconBack);
228+
uint8_t x = strncmp(text, "Hold", 4) ? 71 : 76;
229+
xremote_canvas_draw_icon(canvas, x, 60, XRemoteIconBack);
245230
elements_multiline_text_aligned(canvas, 128, 64, AlignRight, AlignBottom, text);
246231
}
247232
}
@@ -276,7 +261,6 @@ void xremote_canvas_draw_button_png(Canvas* canvas, bool pressed, uint8_t x, uin
276261

277262
void xremote_canvas_draw_button_wide(Canvas* canvas, bool pressed, uint8_t x, uint8_t y, char* text, XRemoteIcon icon)
278263
{
279-
(void)icon;
280264
elements_slightly_rounded_frame(canvas, x + 4, y, 56, 15);
281265

282266
if (pressed)
@@ -292,7 +276,6 @@ void xremote_canvas_draw_button_wide(Canvas* canvas, bool pressed, uint8_t x, ui
292276

293277
void xremote_canvas_draw_button_size(Canvas* canvas, bool pressed, uint8_t x, uint8_t y, uint8_t xy, char* text, XRemoteIcon icon)
294278
{
295-
(void)icon;
296279
elements_slightly_rounded_frame(canvas, x + 4, y, xy, 15);
297280

298281
if (pressed)
@@ -318,4 +301,4 @@ void xremote_canvas_draw_frame(Canvas* canvas, bool pressed, uint8_t x, uint8_t
318301

319302
canvas_draw_str(canvas, x + 3, y + 11, text);
320303
canvas_set_color(canvas, ColorBlack);
321-
}
304+
}

views/xremote_common_view.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,13 +114,12 @@ void xremote_canvas_draw_frame(Canvas* canvas, bool pressed, uint8_t x, uint8_t
114114
XRemoteView* xremote_view_alloc(void *app_ctx, ViewInputCallback input_cb, ViewDrawCallback draw_cb);
115115
void xremote_view_free(XRemoteView* rview);
116116

117-
View* xremote_view_get_view(XRemoteView* rview);
118-
bool xremote_view_send_ir_by_name(XRemoteView *rview, const char *name);
119-
120117
InfraredRemoteButton* xremote_view_get_button_by_name(XRemoteView *rview, const char* name);
121118
bool xremote_view_press_button(XRemoteView *rview, InfraredRemoteButton* button);
119+
bool xremote_view_send_ir_msg_by_name(XRemoteView *rview, const char *name);
122120

123121
void xremote_view_set_context(XRemoteView* rview, void *context, XRemoteViewClearCallback on_clear);
124122
void* xremote_view_get_context(XRemoteView* rview);
125123
void xremote_view_clear_context(XRemoteView* rview);
126-
void* xremote_view_get_app_context(XRemoteView* rview);
124+
void* xremote_view_get_app_context(XRemoteView* rview);
125+
View* xremote_view_get_view(XRemoteView* rview);

views/xremote_control_view.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,16 @@ static void xremote_control_view_draw_callback(Canvas* canvas, void* context)
4444
furi_assert(context);
4545
XRemoteViewModel* model = context;
4646
XRemoteAppContext *app_ctx = model->context;
47-
XRemoteViewDrawFunction xremote_control_view_draw_body;
48-
4947
ViewOrientation orientation = app_ctx->app_settings->orientation;
48+
const char *exit_str = xremote_app_context_get_exit_str(app_ctx);
49+
50+
XRemoteViewDrawFunction xremote_control_view_draw_body;
5051
xremote_control_view_draw_body = orientation == ViewOrientationVertical ?
5152
xremote_control_view_draw_vertical : xremote_control_view_draw_horizontal;
5253

5354
xremote_canvas_draw_header(canvas, orientation, "Control");
5455
xremote_control_view_draw_body(canvas, model);
55-
xremote_canvas_draw_exit_footer(canvas, orientation, "Press to exit");
56+
xremote_canvas_draw_exit_footer(canvas, orientation, exit_str);
5657
}
5758

5859
static void xremote_control_view_process(XRemoteView* view, InputEvent* event)

views/xremote_learn_view.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,4 @@ XRemoteView* xremote_learn_view_alloc(void* app_ctx)
3737
);
3838

3939
return view;
40-
}
40+
}

xremote.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@
1010

1111
#define XREMOTE_VERSION_MAJOR 0
1212
#define XREMOTE_VERSION_MINOR 9
13-
#define XREMOTE_BUILD_NUMBER 24
13+
#define XREMOTE_BUILD_NUMBER 26
1414

15-
void xremote_get_version(char *version, size_t length);
15+
void xremote_get_version(char *version, size_t length);

xremote_app.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@
1212
#define XREMOTE_APP_SETTINGS ANY_PATH("infrared/assets/xremote.cfg")
1313
#define TAG "XRemoteApp"
1414

15+
const NotificationSequence g_sequence_blink_purple_50 = {
16+
&message_red_255,
17+
&message_blue_255,
18+
&message_delay_50,
19+
NULL,
20+
};
21+
1522
XRemoteAppSettings* xremote_app_settings_alloc()
1623
{
1724
XRemoteAppSettings* settings = malloc(sizeof(XRemoteAppSettings));
@@ -137,6 +144,13 @@ const char* xremote_app_context_get_exit_str(XRemoteAppContext* ctx)
137144
return exit_behavior == XRemoteAppExitHold ? "Hold to exit" : "Press to exit";
138145
}
139146

147+
void xremote_app_context_notify_led(XRemoteAppContext* app_ctx)
148+
{
149+
xremote_app_assert_void(app_ctx);
150+
NotificationApp* notifications = app_ctx->notifications;
151+
notification_message(notifications, &g_sequence_blink_purple_50);
152+
}
153+
140154
void xremote_app_view_alloc(XRemoteApp *app, uint32_t view_id, XRemoteViewAllocator allocator)
141155
{
142156
furi_assert(app);

xremote_app.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,9 @@ typedef struct {
6060

6161
XRemoteAppContext* xremote_app_context_alloc(void* arg);
6262
void xremote_app_context_free(XRemoteAppContext* ctx);
63+
6364
const char* xremote_app_context_get_exit_str(XRemoteAppContext* ctx);
65+
void xremote_app_context_notify_led(XRemoteAppContext* app_ctx);
6466

6567
typedef XRemoteView* (*XRemoteViewAllocator)(void* app_ctx);
6668
typedef void (*XRemoteAppClearCallback)(void *context);

xremote_learn.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include "xremote_learn.h"
1010
#include "views/xremote_learn_view.h"
1111

12-
uint32_t xremote_learn_view_exit_callback(void* context)
12+
static uint32_t xremote_learn_view_exit_callback(void* context)
1313
{
1414
UNUSED(context);
1515
return XRemoteViewSubmenu;

0 commit comments

Comments
 (0)