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

Sending IR command multiple times when holding a button #4

Merged
merged 2 commits into from
May 4, 2023
Merged

Sending IR command multiple times when holding a button #4

merged 2 commits into from
May 4, 2023

Conversation

d4ve10
Copy link
Contributor

@d4ve10 d4ve10 commented May 2, 2023

Implemented the option to send the IR command multiple times when long pressing. Useful if you use volume or brightness control for UPHOLD and DOWNHOLD.
This uses the same library as the normal IR App and should therefore work the same as long pressing the button in that App

@Hong5489
Copy link
Owner

Hong5489 commented May 4, 2023

Thank you for the code, I tested with my flipper notice it got error when sending raw signal so you need to change your code before merging

You need to add a check to check the signal is raw, like the code below:

if(active_signal != NULL && (event.type == InputTypeShort || event.type == InputTypeLong)) {
	if (is_transmitting) {
		infrared_worker_tx_stop(app->infrared_worker);
	}
	// Check the signal is raw
	if(active_signal->is_raw){
		InfraredRawSignal* raw_signal = infrared_signal_get_raw_signal(active_signal);
		infrared_worker_set_raw_signal(app->infrared_worker,raw_signal->timings,raw_signal->timings_size);
	}else{
		InfraredMessage* message = infrared_signal_get_message(active_signal);
		infrared_worker_set_decoded_signal(app->infrared_worker, message);
	}

	infrared_worker_tx_set_get_signal_callback(app->infrared_worker, infrared_worker_tx_get_signal_steady_callback, app);

	infrared_worker_tx_start(app->infrared_worker);
	notification_message(notification, &sequence_blink_start_magenta);
	is_transmitting = true;
}

And need to add the declaration of InfraredSignal in global variable

struct InfraredSignal {
    bool is_raw;
    union {
        InfraredMessage message;
        InfraredRawSignal raw;
    } payload;
};

@d4ve10
Copy link
Contributor Author

d4ve10 commented May 4, 2023

yes, I forgot about raw signals. But it should also be fine to call infrared_signal_is_raw() instead of declaring InfraredSignal as a global Variable.

@Hong5489 Hong5489 merged commit c9d98ae into Hong5489:main May 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants