Skip to content

Commit 437dc95

Browse files
authored
Merge pull request #26 from miccayo/main
Add 'Loop Transmit' setting, repeats transmission of commands indefinitely
2 parents 9643376 + 8caf8b4 commit 437dc95

7 files changed

+80
-21
lines changed

.gitignore

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
dist/*
2+
.vscode
3+
.clang-format
4+
.clangd
5+
.editorconfig
6+
.env
7+
.ufbt
8+
.clang-format
9+
.vscode/settings.json

helpers/xremote_storage.c

+2
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ void xremote_save_settings(void* context) {
5959
fff_file, XREMOTE_SETTINGS_KEY_SAVE_SETTINGS, &app->save_settings, 1);
6060
flipper_format_write_uint32(fff_file, XREMOTE_SETTINGS_KEY_IR_TIMING, &app->ir_timing, 1);
6161
flipper_format_write_uint32(fff_file, XREMOTE_SETTINGS_KEY_SG_TIMING, &app->sg_timing, 1);
62+
flipper_format_write_uint32(fff_file, XREMOTE_SETTINGS_KEY_LOOP_TRANSMIT, &app->loop_transmit, 1);
6263

6364
if(!flipper_format_rewind(fff_file)) {
6465
xremote_close_config_file(fff_file);
@@ -112,6 +113,7 @@ void xremote_read_settings(void* context) {
112113
fff_file, XREMOTE_SETTINGS_KEY_SAVE_SETTINGS, &app->save_settings, 1);
113114
flipper_format_read_uint32(fff_file, XREMOTE_SETTINGS_KEY_IR_TIMING, &app->ir_timing, 1);
114115
flipper_format_read_uint32(fff_file, XREMOTE_SETTINGS_KEY_SG_TIMING, &app->sg_timing, 1);
116+
flipper_format_read_uint32(fff_file, XREMOTE_SETTINGS_KEY_LOOP_TRANSMIT, &app->loop_transmit, 1);
115117

116118
flipper_format_rewind(fff_file);
117119

helpers/xremote_storage.h

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#define XREMOTE_SETTINGS_KEY_SAVE_SETTINGS "SaveSettings"
1414
#define XREMOTE_SETTINGS_KEY_IR_TIMING "IRTiming"
1515
#define XREMOTE_SETTINGS_KEY_SG_TIMING "SGTiming"
16+
#define XREMOTE_SETTINGS_KEY_LOOP_TRANSMIT "LoopTransmit"
1617

1718
void xremote_save_settings(void* context);
1819
void xremote_read_settings(void* context);

scenes/xremote_scene_settings.c

+23-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,14 @@ const uint32_t led_value[2] = {
3333
XRemoteLedOff,
3434
XRemoteLedOn,
3535
};
36-
36+
const char* const loop_text[2] = {
37+
"OFF",
38+
"ON",
39+
};
40+
const uint32_t loop_value[2] = {
41+
XRemoteLoopOff,
42+
XRemoteLoopOn,
43+
};
3744
const char* const settings_text[2] = {
3845
"OFF",
3946
"ON",
@@ -72,6 +79,13 @@ static void xremote_scene_settings_set_save_settings(VariableItem* item) {
7279
app->save_settings = settings_value[index];
7380
}
7481

82+
static void xremote_scene_settings_set_loop(VariableItem* item) {
83+
XRemote* app = variable_item_get_context(item);
84+
uint8_t index = variable_item_get_current_value_index(item);
85+
variable_item_set_current_value_text(item, loop_text[index]);
86+
app->loop_transmit = loop_value[index];
87+
}
88+
7589
static void xremote_scene_settings_set_ir_timing(VariableItem* item) {
7690
XRemote* app = variable_item_get_context(item);
7791
uint32_t index = variable_item_get_current_value_index(item);
@@ -116,11 +130,18 @@ void xremote_scene_settings_on_enter(void* context) {
116130

117131
// LED Effects on/off
118132
item = variable_item_list_add(
119-
app->variable_item_list, "LED FX:", 2, xremote_scene_settings_set_led, app);
133+
app->variable_item_list, "LED FX", 2, xremote_scene_settings_set_led, app);
120134
value_index = value_index_uint32(app->led, led_value, 2);
121135
variable_item_set_current_value_index(item, value_index);
122136
variable_item_set_current_value_text(item, led_text[value_index]);
123137

138+
/* NEW: Loop saved command functionality */
139+
item = variable_item_list_add(
140+
app->variable_item_list, "Loop Transmit", 2, xremote_scene_settings_set_loop, app);
141+
value_index = value_index_uint32(app->loop_transmit, loop_value, 2);
142+
variable_item_set_current_value_index(item, value_index);
143+
variable_item_set_current_value_text(item, loop_text[value_index]);
144+
124145
// Save Settings to File
125146
item = variable_item_list_add(
126147
app->variable_item_list, "Save Settings", 2, xremote_scene_settings_set_save_settings, app);

scenes/xremote_scene_transmit.c

+37-18
Original file line numberDiff line numberDiff line change
@@ -120,29 +120,48 @@ void xremote_scene_transmit_run_remote(void* context) {
120120
CrossRemote* remote = app->cross_remote;
121121

122122
size_t item_count = xremote_cross_remote_get_item_count(remote);
123-
for(size_t i = 0; i < item_count;) {
124-
if(xremote_cross_remote_get_transmitting(remote) == XRemoteTransmittingIdle) {
125-
xremote_cross_remote_set_transmitting(remote, XRemoteTransmittingStart);
126-
CrossRemoteItem* item = xremote_cross_remote_get_item(remote, i);
127-
xremote_scene_transmit_send_signal(app, item);
128-
//furi_thread_flags_wait(0, FuriFlagWaitAny, 1000);
129-
} else if(xremote_cross_remote_get_transmitting(remote) == XRemoteTransmittingStopSubghz) {
130-
i++;
131-
app->state_notifications = SubGhzNotificationStateIDLE;
132-
app->transmitting = false;
133-
subghz_txrx_stop(app->subghz->txrx);
134-
xremote_scene_ir_notification_message(app, SubGhzNotificationMessageBlinkStop);
135-
xremote_cross_remote_set_transmitting(remote, XRemoteTransmittingIdle);
136-
//furi_thread_flags_wait(0, FuriFlagWaitAny, 1000);
137-
} else if(xremote_cross_remote_get_transmitting(remote) == XRemoteTransmittingStop) {
138-
i++;
139-
xremote_cross_remote_set_transmitting(remote, XRemoteTransmittingIdle);
123+
if (app->loop_transmit) {
124+
while (true) {
125+
for (size_t i = 0; i < item_count;) {
126+
if (xremote_cross_remote_get_transmitting(remote) == XRemoteTransmittingIdle) {
127+
xremote_cross_remote_set_transmitting(remote, XRemoteTransmittingStart);
128+
CrossRemoteItem* item = xremote_cross_remote_get_item(remote, i);
129+
xremote_scene_transmit_send_signal(app, item);
130+
} else if (xremote_cross_remote_get_transmitting(remote) == XRemoteTransmittingStopSubghz) {
131+
i++;
132+
app->state_notifications = SubGhzNotificationStateIDLE;
133+
app->transmitting = false;
134+
subghz_txrx_stop(app->subghz->txrx);
135+
xremote_scene_ir_notification_message(app, SubGhzNotificationMessageBlinkStop);
136+
xremote_cross_remote_set_transmitting(remote, XRemoteTransmittingIdle);
137+
} else if (xremote_cross_remote_get_transmitting(remote) == XRemoteTransmittingStop) {
138+
i++;
139+
xremote_cross_remote_set_transmitting(remote, XRemoteTransmittingIdle);
140+
}
141+
}
140142
}
143+
} else {
144+
for (size_t i = 0; i < item_count;) {
145+
if (xremote_cross_remote_get_transmitting(remote) == XRemoteTransmittingIdle) {
146+
xremote_cross_remote_set_transmitting(remote, XRemoteTransmittingStart);
147+
CrossRemoteItem* item = xremote_cross_remote_get_item(remote, i);
148+
xremote_scene_transmit_send_signal(app, item);
149+
} else if (xremote_cross_remote_get_transmitting(remote) == XRemoteTransmittingStopSubghz) {
150+
i++;
151+
app->state_notifications = SubGhzNotificationStateIDLE;
152+
app->transmitting = false;
153+
subghz_txrx_stop(app->subghz->txrx);
154+
xremote_scene_ir_notification_message(app, SubGhzNotificationMessageBlinkStop);
155+
xremote_cross_remote_set_transmitting(remote, XRemoteTransmittingIdle);
156+
} else if (xremote_cross_remote_get_transmitting(remote) == XRemoteTransmittingStop) {
157+
i++;
158+
xremote_cross_remote_set_transmitting(remote, XRemoteTransmittingIdle);
159+
}
160+
}
141161
}
142162
xremote_scene_ir_notification_message(app, InfraredNotificationMessageBlinkStop);
143163

144164
scene_manager_previous_scene(app->scene_manager);
145-
//xremote_transmit_model_set_name(app->xremote_transmit, xremote_cross_remote_get_name(remote));
146165
}
147166

148167
void xremote_scene_transmit_on_enter(void* context) {

xremote.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ XRemote* xremote_app_alloc() {
2929

3030
//Scene additions
3131
app->view_dispatcher = view_dispatcher_alloc();
32-
32+
3333
app->scene_manager = scene_manager_alloc(&xremote_scene_handlers, app);
3434
view_dispatcher_set_event_callback_context(app->view_dispatcher, app);
3535
view_dispatcher_set_navigation_event_callback(
@@ -51,6 +51,7 @@ XRemote* xremote_app_alloc() {
5151
app->sg_timing = 500;
5252
app->sg_timing_char = "500";
5353
app->stop_transmit = false;
54+
app->loop_transmit = 0;
5455

5556
// Load configs
5657
xremote_read_settings(app);

xremote.h

+6
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ typedef struct {
4242
uint32_t speaker;
4343
uint32_t led;
4444
uint32_t save_settings;
45+
uint32_t loop_transmit;
4546
uint32_t edit_item;
4647
uint32_t ir_timing;
4748
char* ir_timing_char;
@@ -85,6 +86,11 @@ typedef enum {
8586
XRemoteLedOn,
8687
} XRemoteLedState;
8788

89+
typedef enum {
90+
XRemoteLoopOff,
91+
XRemoteLoopOn,
92+
} XRemoteLoopState;
93+
8894
typedef enum {
8995
XRemoteSettingsOff,
9096
XRemoteSettingsOn,

0 commit comments

Comments
 (0)