Segment Class Notes - AlbertGBarber/PixelSpork GitHub Wiki
See the Documentation Guide for help understanding each page section.
Description:
This page contains the raw technical specs for Segments for reference. Note that segments only contain a pointer to a section array, information about that array, and the segment's direction. While the direction can be modified, the section array cannot.
For a full description and tutorial of segments, see segment basics and advanced segment usage.
Constructor Definitions:
//Constructor for creating a segment with a continuous section
SegmentPS(const segmentSecCont *segSecContArr, uint8_t NumSec, bool Direct = true);
//Constructor for creating a segment with a mixed section
SegmentPS(const segmentSecMix *segSecMixArr, uint8_t NumSec, bool Direct = true);
Constructor Inputs:
-
segSecContArr or segSecMixArr -- Pointer to an array of either continuous or mixed sections. A segment set can either have continuous or mixed sections, but not both. See section notes.
-
uint8_t numSec -- The number of sections in the section array. Usually you use
SIZE(yourSectionArray)
to getnumSections
. -
bool direct (defaults to true) -- The direction of the segment set.
true
means the segment set starts at the first section and ends at the last,false
means the opposite.
Class Functions:
Note, these functions deal with the nitty-gritty of managing segments. Using these functions should be uncommon. Instead you should try to use the segment drawing functions here if possible.
Common Function Arguments:
secNum
is a section's position in a segment's section array;
Functions for Getting Pixel Locations:
-
int16_t getSecLength( uint8_t secNum );
Returns the length of the specified section. Will return 1 if the section is "single". Works for both continuous and mixed sections.
-
uint16_t getSecStartPixel( uint8_t secNum );
Returns the physical address of the first pixel in the specified section. (ie
getSecStartPixel(0)
would return the address of the first pixel of the first section). (ONLY works for segments with continuous type sections!). -
uint16_t getSecMixPixel( uint8_t secNum, uint16_t pixelNum );
Returns the physical address of the specified pixel in a mixed section. (ONLY works for segments with mixed type sections!).
advanced segment usage)
Functions for Handling "single" Segments: (See-
int16_t getSecTrueLength( uint8_t secNum );
Returns the real length of the section, ignoring if the segment is "single".
-
bool getSecIsSingle( uint8_t secNum );
Returns true if the specified section is "single".
Functions for Setting Reference Vars:
You only need to call these if you change the sections in the segment.
-
Calculates thevoid getSegTotLen();
totalLength
of the segment. Treats "single" segments as length 1.
Reference Vars:
-
bool hasSingle -- Is true if the segment has any "single" sections.
-
uint16_t totalLength --Returns the total length of all sections, treating "single" sections as length 1. Set using
getSegTotLen()
. -
segmentSecCont secContPtr -- Pointer the segment's continuous type section array. If the segment has mixed sections this will be null.
-
segmentSecMix secMixPtr -- Pointer the segment's mixed type section array. If the segment has continuous sections this will be null.