2023-Robot
Robot code for 2023 FRC season by Argos, FRC team #1756
Loading...
Searching...
No Matches
argos_lib::led Namespace Reference

Namespaces

namespace  animation
 

Classes

struct  Animation
 A representation of a custom LED animation. More...
 
class  Array2D
 Array2D representation where origin is at bottom left. More...
 
struct  PanelScanParams
 
struct  Sprite
 https://en.wikipedia.org/wiki/Sprite_(computer_graphics) More...
 

Typedefs

using AnimatedSprite = std::function< Sprite()>
 Callable to get dynamic sprite.
 
using Panel = Array2D< frc::AddressableLED::LEDData >
 Pixels in a panel.
 
using Mask = Array2D< float >
 
using Strip = std::vector< frc::AddressableLED::LEDData >
 A strip of LEDs.
 

Enumerations

enum class  PrimaryScanDirection { Vertical , Horizontal }
 When representing a panel as a strip, sequential addresses are in this direction. Note that the actual scan direction will alternate on every row/column in the secondary scan direction. For example, if the primary scan direction is vertical, adjacent columns will alternate between up and down. More...
 
enum class  FirstPixelPosition { TopRight , TopLeft , BottomLeft , BottomRight }
 When representing a panel as a strip, which pixel is the first address. More...
 

Functions

units::degree_t FlipHorizontal (units::degree_t incidentAngle)
 Flip an angle horizontally as though a ray bounces off a horizontal surface.
 
units::degree_t FlipVertical (units::degree_t inicidentAngle)
 Flip an angle vertically as though a ray bounces off a vertical surface.
 
bool PointInBox (float corner1X, float corner1Y, float corner2X, float corner2Y, float pointX, float pointY)
 Determine if a point (pointX, pointY) is within the bounds of an axis-aligned bounding box with opposite corners (corner1X, corner1Y) and (corner2X, corner2Y)
 
std::optional< std::pair< float, float > > SegmentIntersection (float s1x1, float s1y1, float s1x2, float s1y2, float s2x1, float s2y1, float s2x2, float s2y2)
 Finds the intersection point of two lines – [(s1x1, s1y1), (s1x2, s1y2)] and [(s2x1, s2y1), (s2x2, s2y2)] – if it exists. If the two lines are colinear, no intersection point is returned.
 
Strip Serialize (const Panel &panel, const PanelScanParams &params)
 Convert a panel to a 1D vector of pixels in addressing order. This is a helper function because many panel animations are easier to design in 2D space then convert back to address order when it comes time to display.
 

Typedef Documentation

◆ AnimatedSprite

using argos_lib::led::AnimatedSprite = typedef std::function<Sprite()>

Callable to get dynamic sprite.

◆ Mask

using argos_lib::led::Mask = typedef Array2D<float>

Transparency mask (alpha channel) for a panel. Range [0,1] where 0 is fully transparent and 1 is fully opaque.

◆ Panel

using argos_lib::led::Panel = typedef Array2D<frc::AddressableLED::LEDData>

Pixels in a panel.

◆ Strip

using argos_lib::led::Strip = typedef std::vector<frc::AddressableLED::LEDData>

A strip of LEDs.

Enumeration Type Documentation

◆ FirstPixelPosition

When representing a panel as a strip, which pixel is the first address.

Enumerator
TopRight 
TopLeft 
BottomLeft 
BottomRight 

◆ PrimaryScanDirection

When representing a panel as a strip, sequential addresses are in this direction. Note that the actual scan direction will alternate on every row/column in the secondary scan direction. For example, if the primary scan direction is vertical, adjacent columns will alternate between up and down.

Enumerator
Vertical 
Horizontal 

Function Documentation

◆ FlipHorizontal()

units::degree_t argos_lib::led::FlipHorizontal ( units::degree_t  incidentAngle)

Flip an angle horizontally as though a ray bounces off a horizontal surface.

Parameters
incidentAngleAngle of original motion
Returns
Reflected angle

◆ FlipVertical()

units::degree_t argos_lib::led::FlipVertical ( units::degree_t  inicidentAngle)

Flip an angle vertically as though a ray bounces off a vertical surface.

Parameters
incidentAngleAngle of original motion
Returns
Reflected angle

◆ PointInBox()

bool argos_lib::led::PointInBox ( float  corner1X,
float  corner1Y,
float  corner2X,
float  corner2Y,
float  pointX,
float  pointY 
)

Determine if a point (pointX, pointY) is within the bounds of an axis-aligned bounding box with opposite corners (corner1X, corner1Y) and (corner2X, corner2Y)

Parameters
corner1XFirst corner X coordinate
corner1YFirst corner Y coordinate
corner2XSecond corner X coordinate
corner2YSecond corner Y coordinate
pointXTest point X coordinate
pointYTest point Y coordinate
Returns
true if point is in bounding box

◆ SegmentIntersection()

std::optional< std::pair< float, float > > argos_lib::led::SegmentIntersection ( float  s1x1,
float  s1y1,
float  s1x2,
float  s1y2,
float  s2x1,
float  s2y1,
float  s2x2,
float  s2y2 
)

Finds the intersection point of two lines – [(s1x1, s1y1), (s1x2, s1y2)] and [(s2x1, s2y1), (s2x2, s2y2)] – if it exists. If the two lines are colinear, no intersection point is returned.

Parameters
s1x1First point of first segment x coordinate
s1y1First point of first segment y coordinate
s1x2Second point of first segment x coordinate
s1y2Second point of first segment y coordinate
s2x1First point of second segment x coordinate
s2y1First point of second segment y coordinate
s2x2Second point of second segment x coordinate
s2y2Second point of second segment y coordinate
Returns
(x,y) pair indicating intersection point if it exists, std::nullopt otherwise

◆ Serialize()

argos_lib::led::Strip argos_lib::led::Serialize ( const Panel panel,
const PanelScanParams params 
)

Convert a panel to a 1D vector of pixels in addressing order. This is a helper function because many panel animations are easier to design in 2D space then convert back to address order when it comes time to display.

Parameters
panelPanel to serialize
paramsParameters describing panel addressing and orientation
Returns
A strip representation of panel with all pixels in address order