Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Infrared worker blink on send. #4068

Open
wants to merge 4 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 2 additions & 10 deletions applications/main/infrared/infrared_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,8 @@ void infrared_tx_start(InfraredApp* infrared) {
}

dolphin_deed(DolphinDeedIrSend);
infrared_play_notification_message(infrared, InfraredNotificationMessageBlinkStartSend);

infrared_worker_tx_enable_blink_on_sending(infrared->worker, true);

infrared_worker_tx_set_get_signal_callback(
infrared->worker, infrared_worker_tx_get_signal_steady_callback, infrared);
Expand Down Expand Up @@ -418,8 +419,6 @@ void infrared_tx_stop(InfraredApp* infrared) {
infrared_worker_tx_stop(infrared->worker);
infrared_worker_tx_set_get_signal_callback(infrared->worker, NULL, NULL);

infrared_play_notification_message(infrared, InfraredNotificationMessageBlinkStop);

infrared->app_state.is_transmitting = false;
infrared->app_state.last_transmit_time = furi_get_tick();
}
Expand Down Expand Up @@ -468,13 +467,6 @@ void infrared_text_store_clear(InfraredApp* infrared, uint32_t bank) {
memset(infrared->text_store[bank], 0, INFRARED_TEXT_STORE_SIZE + 1);
}

void infrared_play_notification_message(
const InfraredApp* infrared,
InfraredNotificationMessage message) {
furi_assert(message < InfraredNotificationMessageCount);
notification_message(infrared->notifications, infrared_notification_sequences[message]);
}

void infrared_show_error_message(const InfraredApp* infrared, const char* fmt, ...) {
va_list args;
va_start(args, fmt);
Expand Down
27 changes: 21 additions & 6 deletions lib/infrared/worker/infrared_worker.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ struct InfraredWorker {
InfraredEncoderHandler* infrared_encoder;
InfraredDecoderHandler* infrared_decoder;
NotificationApp* notification;
bool blink_enable;
bool rx_blink_enable;
bool tx_blink_enable;
bool decode_enable;

union {
Expand Down Expand Up @@ -172,7 +173,7 @@ static int32_t infrared_worker_rx_thread(void* thread_context) {
furi_check(events & INFRARED_WORKER_ALL_RX_EVENTS); /* at least one caught */

if(events & INFRARED_WORKER_RX_RECEIVED) {
if(!instance->rx.overrun && instance->blink_enable &&
if(!instance->rx.overrun && instance->rx_blink_enable &&
((furi_get_tick() - last_blink_time) > 80)) {
last_blink_time = furi_get_tick();
notification_message(instance->notification, &sequence_blink_blue_10);
Expand All @@ -193,14 +194,14 @@ static int32_t infrared_worker_rx_thread(void* thread_context) {
printf("#");
infrared_reset_decoder(instance->infrared_decoder);
instance->signal.timings_cnt = 0;
if(instance->blink_enable)
if(instance->rx_blink_enable)
notification_message(instance->notification, &sequence_set_red_255);
}
if(events & INFRARED_WORKER_RX_TIMEOUT_RECEIVED) {
if(instance->rx.overrun) {
printf("\nOVERRUN, max samples: %d\n", MAX_TIMINGS_AMOUNT);
instance->rx.overrun = false;
if(instance->blink_enable)
if(instance->rx_blink_enable)
notification_message(instance->notification, &sequence_reset_red);
} else {
infrared_worker_process_timeout(instance);
Expand Down Expand Up @@ -234,7 +235,8 @@ InfraredWorker* infrared_worker_alloc(void) {
instance->stream = furi_stream_buffer_alloc(buffer_size, sizeof(InfraredWorkerTiming));
instance->infrared_decoder = infrared_alloc_decoder();
instance->infrared_encoder = infrared_alloc_encoder();
instance->blink_enable = false;
instance->rx_blink_enable = false;
instance->tx_blink_enable = false;
instance->decode_enable = true;
instance->notification = furi_record_open(RECORD_NOTIFICATION);
instance->state = InfraredWorkerStateIdle;
Expand Down Expand Up @@ -317,7 +319,13 @@ const InfraredMessage* infrared_worker_get_decoded_signal(const InfraredWorkerSi
void infrared_worker_rx_enable_blink_on_receiving(InfraredWorker* instance, bool enable) {
furi_check(instance);

instance->blink_enable = enable;
instance->rx_blink_enable = enable;
}

void infrared_worker_tx_enable_blink_on_sending(InfraredWorker* instance, bool enable) {
furi_check(instance);

instance->tx_blink_enable = enable;
}

void infrared_worker_rx_enable_signal_decoding(InfraredWorker* instance, bool enable) {
Expand All @@ -344,6 +352,11 @@ void infrared_worker_tx_start(InfraredWorker* instance) {
infrared_worker_furi_hal_message_sent_isr_callback, instance);

instance->state = InfraredWorkerStateStartTx;

if(instance->tx_blink_enable) {
notification_message(instance->notification, &sequence_blink_start_magenta);
}

furi_thread_start(instance->thread);
}

Expand Down Expand Up @@ -588,6 +601,8 @@ void infrared_worker_tx_stop(InfraredWorker* instance) {
furi_hal_infrared_async_tx_set_data_isr_callback(NULL, NULL);
furi_hal_infrared_async_tx_set_signal_sent_isr_callback(NULL, NULL);

notification_message(instance->notification, &sequence_blink_stop);

instance->signal.timings_cnt = 0;
furi_check(furi_stream_buffer_reset(instance->stream) == FuriStatusOk);

Expand Down
7 changes: 7 additions & 0 deletions lib/infrared/worker/infrared_worker.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,13 @@ void infrared_worker_rx_set_received_signal_callback(
*/
void infrared_worker_rx_enable_blink_on_receiving(InfraredWorker* instance, bool enable);

/** Enable blinking while sending any signal on IR port
*
* @param[in] instance - instance of InfraredWorker
* @param[in] enable - true if you want to enable blinking /false otherwise
*/
void infrared_worker_tx_enable_blink_on_sending(InfraredWorker* instance, bool enable);

/** Enable decoding of received infrared signals.
*
* @param[in] instance - instance of InfraredWorker
Expand Down
5 changes: 3 additions & 2 deletions targets/f7/api_symbols.csv
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
entry,status,name,type,params
Version,+,79.2,,
Version,+,79.3,,
Header,+,applications/drivers/subghz/cc1101_ext/cc1101_ext_interconnect.h,,
Header,+,applications/services/bt/bt_service/bt.h,,
Header,+,applications/services/bt/bt_service/bt_keys_storage.h,,
Expand Down Expand Up @@ -2058,6 +2058,7 @@ Function,+,infrared_worker_rx_stop,void,InfraredWorker*
Function,+,infrared_worker_set_decoded_signal,void,"InfraredWorker*, const InfraredMessage*"
Function,+,infrared_worker_set_raw_signal,void,"InfraredWorker*, const uint32_t*, size_t, uint32_t, float"
Function,+,infrared_worker_signal_is_decoded,_Bool,const InfraredWorkerSignal*
Function,+,infrared_worker_tx_enable_blink_on_sending,void,"InfraredWorker*, _Bool"
Function,+,infrared_worker_tx_get_signal_steady_callback,InfraredWorkerGetSignalResponse,"void*, InfraredWorker*"
Function,+,infrared_worker_tx_set_get_signal_callback,void,"InfraredWorker*, InfraredWorkerGetSignalCallback, void*"
Function,+,infrared_worker_tx_set_signal_sent_callback,void,"InfraredWorker*, InfraredWorkerMessageSentCallback, void*"
Expand Down Expand Up @@ -2938,9 +2939,9 @@ Function,+,pipe_install_as_stdio,void,PipeSide*
Function,+,pipe_receive,size_t,"PipeSide*, void*, size_t, FuriWait"
Function,+,pipe_role,PipeRole,PipeSide*
Function,+,pipe_send,size_t,"PipeSide*, const void*, size_t, FuriWait"
Function,+,pipe_set_broken_callback,void,"PipeSide*, PipeSideBrokenCallback, FuriEventLoopEvent"
Function,+,pipe_set_callback_context,void,"PipeSide*, void*"
Function,+,pipe_set_data_arrived_callback,void,"PipeSide*, PipeSideDataArrivedCallback, FuriEventLoopEvent"
Function,+,pipe_set_broken_callback,void,"PipeSide*, PipeSideBrokenCallback, FuriEventLoopEvent"
Function,+,pipe_set_space_freed_callback,void,"PipeSide*, PipeSideSpaceFreedCallback, FuriEventLoopEvent"
Function,+,pipe_spaces_available,size_t,PipeSide*
Function,+,pipe_state,PipeState,PipeSide*
Expand Down