fplayer
C99 Falcon Sequence (fseq) file player for Light-O-Rama hardware (like xLights)
Loading...
Searching...
No Matches
cell.c File Reference

Cell table for tracking output states. More...

#include "cell.h"
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include "crmap.h"
#include "std2/errcode.h"
Include dependency graph for cell.c:

Data Structures

struct  cell_s
 A single cell in the cell table, repesenting a single output channel. More...
 
struct  ctable_s
 Represents a table of cells that map raw FSEQ sequence indexes to a known unit and channel number. More...
 

Macros

#define MAX_MATCHES   16
 Maximum number of matching cells to find in a single group.
 
#define CHANNEL_BIT(i)
 Returns a bitmask for the given channel index.
 

Functions

int CT_init (const struct cr_s *cmap, const uint32_t size, struct ctable_s **table)
 Initializes table that maps the raw fseq sequence indexes to a known LOR unit and channel number using the provided channel map. The lookup is cached into the table for faster access. The table is dynamically allocated and must be freed with CT_free.
 
void CT_set (struct ctable_s *table, const uint32_t index, const uint8_t output)
 Sets the output intensity for the cell at the given index. This marks the cell as modified, regardless if the new output intensity is the same as the current value.
 
void CT_change (struct ctable_s *table, const uint32_t index, const uint8_t output)
 Changes the output intensity for the cell at the given index. This only marks the cell as modified if the new output intensity is different from the current value.
 
static int CT_matches (const struct cell_s *a, const struct cell_s *b)
 Checks if two cells match, which indicates they are addressed to the same hardware controller (unit+section), and have a matching output intensity.
 
static int CT_findMatches (struct ctable_s *table, const uint32_t start, const struct cell_s *cmp, struct cell_s *matches[MAX_MATCHES])
 Finds all cells in the table that match the provided reference cell. The reference cell must be valid and modified. The matching cells are stored in the provided array, up to a maximum of MAX_MATCHES.
 
int CT_groupof (struct ctable_s *table, uint32_t at, struct ctgroup_s *group)
 Returns a group of linked cells starting at the given index. The group is identified by the unit number, channel section, and output intensity value. Any cells that have not been modified, or do not match, are excluded from the grouping. Assuming the cell at at is valid and modified, group should always contain at least one cell.
 
void CT_free (struct ctable_s *table)
 Frees the table and any held resources.
 

Detailed Description

Cell table for tracking output states.

Macro Definition Documentation

◆ CHANNEL_BIT

#define CHANNEL_BIT ( i)
Value:
(1 << (i))

Returns a bitmask for the given channel index.

Parameters
ichannel index
Returns
bitmask for the channel index

◆ MAX_MATCHES

#define MAX_MATCHES   16

Maximum number of matching cells to find in a single group.

Note
This is derived from the maximum value supported by the protocol. It is not a software limitation.

Function Documentation

◆ CT_change()

void CT_change ( struct ctable_s * table,
uint32_t index,
uint8_t output )

Changes the output intensity for the cell at the given index. This only marks the cell as modified if the new output intensity is different from the current value.

Parameters
tabletable to change the output on
indexindex of the cell to change
outputintensity to change to
Here is the caller graph for this function:

◆ CT_findMatches()

static int CT_findMatches ( struct ctable_s * table,
const uint32_t start,
const struct cell_s * cmp,
struct cell_s * matches[MAX_MATCHES] )
static

Finds all cells in the table that match the provided reference cell. The reference cell must be valid and modified. The matching cells are stored in the provided array, up to a maximum of MAX_MATCHES.

Parameters
tabletable to search
startindex to start searching from
cmpreference cell to match against
matchesarray to store matching cells
Returns
the number of matching cells found
Here is the call graph for this function:
Here is the caller graph for this function:

◆ CT_free()

void CT_free ( struct ctable_s * table)

Frees the table and any held resources.

Parameters
tabletable to free
Here is the caller graph for this function:

◆ CT_groupof()

int CT_groupof ( struct ctable_s * table,
uint32_t at,
struct ctgroup_s * group )

Returns a group of linked cells starting at the given index. The group is identified by the unit number, channel section, and output intensity value. Any cells that have not been modified, or do not match, are excluded from the grouping. Assuming the cell at at is valid and modified, group should always contain at least one cell.

Parameters
tabletable to search
atindex to start the group search
grouppointer to store the group
Returns
1 if a group was found, 0 if no group was found
Here is the call graph for this function:
Here is the caller graph for this function:

◆ CT_init()

int CT_init ( const struct cr_s * cmap,
uint32_t size,
struct ctable_s ** table )

Initializes table that maps the raw fseq sequence indexes to a known LOR unit and channel number using the provided channel map. The lookup is cached into the table for faster access. The table is dynamically allocated and must be freed with CT_free.

Parameters
cmapchannel map to use for lookup
sizenumber of indexes to map
tablepointer to store the table
Returns
0 on success, or a negative error code on failure
Here is the call graph for this function:
Here is the caller graph for this function:

◆ CT_matches()

static int CT_matches ( const struct cell_s * a,
const struct cell_s * b )
inlinestatic

Checks if two cells match, which indicates they are addressed to the same hardware controller (unit+section), and have a matching output intensity.

Parameters
afirst cell to compare
bsecond cell to compare
Returns
true if the cells match, false otherwise
Here is the caller graph for this function:

◆ CT_set()

void CT_set ( struct ctable_s * table,
uint32_t index,
uint8_t output )

Sets the output intensity for the cell at the given index. This marks the cell as modified, regardless if the new output intensity is the same as the current value.

Parameters
tabletable to set the output on
indexindex of the cell to set
outputintensity to set