Loading...
Searching...
No Matches
infrared_signal.h File Reference

Infrared signal library. More...

#include "infrared_error_code.h"
#include <flipper_format/flipper_format.h>
#include <infrared.h>

Go to the source code of this file.

Data Structures

struct  InfraredRawSignal
 Raw signal type definition. More...
 

Typedefs

typedef struct InfraredSignal InfraredSignal
 InfraredSignal opaque type declaration.
 

Functions

InfraredSignalinfrared_signal_alloc (void)
 Create a new InfraredSignal instance.
 
void infrared_signal_free (InfraredSignal *signal)
 Delete an InfraredSignal instance.
 
bool infrared_signal_is_raw (const InfraredSignal *signal)
 Test whether an InfraredSignal instance holds a raw signal.
 
bool infrared_signal_is_valid (const InfraredSignal *signal)
 Test whether an InfraredSignal instance holds any signal.
 
void infrared_signal_set_signal (InfraredSignal *signal, const InfraredSignal *other)
 Set an InfraredInstance to hold the signal from another one.
 
void infrared_signal_set_raw_signal (InfraredSignal *signal, const uint32_t *timings, size_t timings_size, uint32_t frequency, float duty_cycle)
 Set an InfraredInstance to hold a raw signal.
 
const InfraredRawSignalinfrared_signal_get_raw_signal (const InfraredSignal *signal)
 Get the raw signal held by an InfraredSignal instance.
 
void infrared_signal_set_message (InfraredSignal *signal, const InfraredMessage *message)
 Set an InfraredInstance to hold a parsed signal.
 
const InfraredMessageinfrared_signal_get_message (const InfraredSignal *signal)
 Get the parsed signal held by an InfraredSignal instance.
 
InfraredErrorCode infrared_signal_read (InfraredSignal *signal, FlipperFormat *ff, FuriString *name)
 Read a signal and its name from a FlipperFormat file into an InfraredSignal instance.
 
InfraredErrorCode infrared_signal_read_name (FlipperFormat *ff, FuriString *name)
 Read a signal name from a FlipperFormat file.
 
InfraredErrorCode infrared_signal_read_body (InfraredSignal *signal, FlipperFormat *ff)
 Read a signal from a FlipperFormat file.
 
InfraredErrorCode infrared_signal_search_by_name_and_read (InfraredSignal *signal, FlipperFormat *ff, const char *name)
 Read a signal with a particular name from a FlipperFormat file into an InfraredSignal instance.
 
InfraredErrorCode infrared_signal_search_by_index_and_read (InfraredSignal *signal, FlipperFormat *ff, size_t index)
 Read a signal with a particular index from a FlipperFormat file into an InfraredSignal instance.
 
InfraredErrorCode infrared_signal_save (const InfraredSignal *signal, FlipperFormat *ff, const char *name)
 Save a signal contained in an InfraredSignal instance to a FlipperFormat file.
 
void infrared_signal_transmit (const InfraredSignal *signal)
 Transmit a signal contained in an InfraredSignal instance.
 

Detailed Description

Infrared signal library.

Infrared signals may be of two types:

  • known to the infrared signal decoder, or parsed signals
  • the rest, or raw signals, which are treated merely as a set of timings.

Function Documentation

◆ infrared_signal_alloc()

InfraredSignal * infrared_signal_alloc ( void )

Create a new InfraredSignal instance.

Returns
pointer to the instance created.

◆ infrared_signal_free()

void infrared_signal_free ( InfraredSignal * signal)

Delete an InfraredSignal instance.

Parameters
[in,out]signalpointer to the instance to be deleted.

◆ infrared_signal_get_message()

const InfraredMessage * infrared_signal_get_message ( const InfraredSignal * signal)

Get the parsed signal held by an InfraredSignal instance.

Warning
the instance MUST hold a parsed signal, otherwise undefined behaviour will occur.
Parameters
[in]signalpointer to the instance to be queried.
Returns
pointer to the parsed signal structure held by the instance.

◆ infrared_signal_get_raw_signal()

const InfraredRawSignal * infrared_signal_get_raw_signal ( const InfraredSignal * signal)

Get the raw signal held by an InfraredSignal instance.

Warning
the instance MUST hold a raw signal, otherwise undefined behaviour will occur.
Parameters
[in]signalpointer to the instance to be queried.
Returns
pointer to the raw signal structure held by the instance.

◆ infrared_signal_is_raw()

bool infrared_signal_is_raw ( const InfraredSignal * signal)

Test whether an InfraredSignal instance holds a raw signal.

Parameters
[in]signalpointer to the instance to be tested.
Returns
true if the instance holds a raw signal, false otherwise.

◆ infrared_signal_is_valid()

bool infrared_signal_is_valid ( const InfraredSignal * signal)

Test whether an InfraredSignal instance holds any signal.

Parameters
[in]signalpointer to the instance to be tested.
Returns
true if the instance holds raw signal, false otherwise.

◆ infrared_signal_read()

InfraredErrorCode infrared_signal_read ( InfraredSignal * signal,
FlipperFormat * ff,
FuriString * name )

Read a signal and its name from a FlipperFormat file into an InfraredSignal instance.

The file must be allocated and open prior to this call. The seek position determines which signal will be read (if there is more than one in the file). Calling this function repeatedly will result in all signals in the file to be read until no more are left.

Parameters
[in,out]signalpointer to the instance to be read into.
[in,out]ffpointer to the FlipperFormat file instance to read from.
[out]namepointer to the string to hold the signal name. Must be properly allocated.
Returns
InfraredErrorCodeNone if a signal was successfully read, otherwise error code

◆ infrared_signal_read_body()

InfraredErrorCode infrared_signal_read_body ( InfraredSignal * signal,
FlipperFormat * ff )

Read a signal from a FlipperFormat file.

Same behaviour as infrared_signal_read(), but only the body is read.

Parameters
[in,out]ffpointer to the FlipperFormat file instance to read from.
[out]signalpointer to the InfraredSignal instance to hold the signal body. Must be properly allocated.
Returns
InfraredErrorCodeNone if a signal body was successfully read, otherwise error code.

◆ infrared_signal_read_name()

InfraredErrorCode infrared_signal_read_name ( FlipperFormat * ff,
FuriString * name )

Read a signal name from a FlipperFormat file.

Same behaviour as infrared_signal_read(), but only the name is read.

Parameters
[in,out]ffpointer to the FlipperFormat file instance to read from.
[out]namepointer to the string to hold the signal name. Must be properly allocated.
Returns
InfraredErrorCodeNone if a signal name was successfully read, otherwise error code

◆ infrared_signal_save()

InfraredErrorCode infrared_signal_save ( const InfraredSignal * signal,
FlipperFormat * ff,
const char * name )

Save a signal contained in an InfraredSignal instance to a FlipperFormat file.

The file must be allocated and open prior to this call. Additionally, an appropriate header must be already written into the file.

Parameters
[in]signalpointer to the instance holding the signal to be saved.
[in,out]ffpointer to the FlipperFormat file instance to write to.
[in]namepointer to a zero-terminated string contating the name of the signal.
Returns
InfraredErrorCodeNone if a signal was successfully saved, otherwise error code

◆ infrared_signal_search_by_index_and_read()

InfraredErrorCode infrared_signal_search_by_index_and_read ( InfraredSignal * signal,
FlipperFormat * ff,
size_t index )

Read a signal with a particular index from a FlipperFormat file into an InfraredSignal instance.

This function will look for a signal with the given index and if found, attempt to read it. Same considerations apply as to infrared_signal_read().

Parameters
[in,out]signalpointer to the instance to be read into.
[in,out]ffpointer to the FlipperFormat file instance to read from.
[in]indexthe requested signal index.
Returns
InfraredErrorCodeNone if a signal was found and successfully read, otherwise error code.

◆ infrared_signal_search_by_name_and_read()

InfraredErrorCode infrared_signal_search_by_name_and_read ( InfraredSignal * signal,
FlipperFormat * ff,
const char * name )

Read a signal with a particular name from a FlipperFormat file into an InfraredSignal instance.

This function will look for a signal with the given name and if found, attempt to read it. Same considerations apply as to infrared_signal_read().

Parameters
[in,out]signalpointer to the instance to be read into.
[in,out]ffpointer to the FlipperFormat file instance to read from.
[in]namepointer to a zero-terminated string containing the requested signal name.
Returns
InfraredErrorCodeNone if a signal was found and successfully read, otherwise error code.

◆ infrared_signal_set_message()

void infrared_signal_set_message ( InfraredSignal * signal,
const InfraredMessage * message )

Set an InfraredInstance to hold a parsed signal.

Any instance's previous contents will be automatically deleted before copying the raw signal.

After this call, infrared_signal_is_raw() will return false.

Parameters
[in,out]signalpointer to the destination instance.
[in]messagepointer to the message containing the parsed signal.

◆ infrared_signal_set_raw_signal()

void infrared_signal_set_raw_signal ( InfraredSignal * signal,
const uint32_t * timings,
size_t timings_size,
uint32_t frequency,
float duty_cycle )

Set an InfraredInstance to hold a raw signal.

Any instance's previous contents will be automatically deleted before copying the raw signal.

After this call, infrared_signal_is_raw() will return true.

Parameters
[in,out]signalpointer to the destination instance.
[in]timingspointer to an array containing the raw signal timings.
[in]timings_sizenumber of elements in the timings array.
[in]frequencysignal carrier frequency, in Hertz.
[in]duty_cyclesignal duty cycle, fraction between 0 and 1.

◆ infrared_signal_set_signal()

void infrared_signal_set_signal ( InfraredSignal * signal,
const InfraredSignal * other )

Set an InfraredInstance to hold the signal from another one.

Any instance's previous contents will be automatically deleted before copying the source instance's contents.

Parameters
[in,out]signalpointer to the destination instance.
[in]otherpointer to the source instance.

◆ infrared_signal_transmit()

void infrared_signal_transmit ( const InfraredSignal * signal)

Transmit a signal contained in an InfraredSignal instance.

The transmission happens once per call using the built-in hardware (via HAL calls).

Parameters
[in]signalpointer to the instance holding the signal to be transmitted.