Skip to content

Commit 6a56928

Browse files
committed
Always RX except when shooting
1 parent fb3160c commit 6a56928

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

infrared_controller.c

+22-5
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ const NotificationSequence sequence_hit = {
1818
struct InfraredController {
1919
LaserTagTeam team;
2020
InfraredWorker* worker;
21+
bool worker_rx_active;
2122
InfraredSignal* signal;
2223
NotificationApp* notification;
2324
bool hit_received;
@@ -104,6 +105,11 @@ void infrared_controller_free(InfraredController* controller) {
104105
FURI_LOG_I(TAG, "Freeing InfraredController");
105106

106107
if(controller) {
108+
if(controller->worker_rx_active) {
109+
FURI_LOG_I(TAG, "Stopping RX worker");
110+
infrared_worker_rx_stop(controller->worker);
111+
}
112+
107113
FURI_LOG_I(TAG, "Freeing InfraredWorker and InfraredSignal");
108114
infrared_worker_free(controller->worker);
109115
infrared_signal_free(controller->signal);
@@ -139,12 +145,23 @@ void infrared_controller_send(InfraredController* controller) {
139145
(unsigned long)message.address,
140146
(unsigned long)message.command);
141147

148+
if(controller->worker_rx_active) {
149+
FURI_LOG_I(TAG, "Stopping RX worker");
150+
infrared_worker_rx_stop(controller->worker);
151+
controller->worker_rx_active = false;
152+
}
153+
142154
FURI_LOG_I(TAG, "Setting message for infrared signal");
143155
infrared_signal_set_message(controller->signal, &message);
144156

145157
FURI_LOG_I(TAG, "Starting infrared signal transmission");
146158
infrared_signal_transmit(controller->signal);
147159

160+
if(!controller->worker_rx_active) {
161+
infrared_worker_rx_start(controller->worker);
162+
controller->worker_rx_active = true;
163+
}
164+
148165
FURI_LOG_I(TAG, "Infrared signal transmission completed");
149166
}
150167

@@ -156,11 +173,11 @@ bool infrared_controller_receive(InfraredController* controller) {
156173
return false;
157174
}
158175

159-
infrared_worker_rx_start(controller->worker);
160-
161-
furi_delay_ms(250);
162-
163-
infrared_worker_rx_stop(controller->worker);
176+
if(!controller->worker_rx_active) {
177+
infrared_worker_rx_start(controller->worker);
178+
controller->worker_rx_active = true;
179+
furi_delay_ms(250);
180+
}
164181

165182
bool hit = controller->hit_received;
166183

0 commit comments

Comments
 (0)