Sim GUI: Add support for LED displays (#2138)

LED displays connect the LEDs in various ways (column major vs row major,
different starting locations, serpentine connection order), so add
configuration parameters for these options.
This commit is contained in:
Peter Johnson
2019-12-01 21:28:02 -08:00
committed by GitHub
parent 57c5523d67
commit e37ecd33ae
3 changed files with 158 additions and 34 deletions

View File

@@ -11,6 +11,33 @@
namespace halsimgui {
/**
* DrawLEDs() configuration for 2D arrays.
*/
struct LEDConfig {
/**
* Whether the major order is serpentined (e.g. the first row goes left to
* right, the second row right to left, the third row left to right, and so
* on).
*/
bool serpentine = false;
/**
* The input array order (row-major or column-major).
*/
enum Order { RowMajor = 0, ColumnMajor } order = RowMajor;
/**
* The starting location of the array (0 location).
*/
enum Start {
UpperLeft = 0,
LowerLeft,
UpperRight,
LowerRight
} start = UpperLeft;
};
/**
* Draw a 2D array of LEDs.
*
@@ -27,8 +54,10 @@ namespace halsimgui {
* if 0, defaults to 1/2 of font size
* @param spacing spacing between each LED (both horizontal and vertical);
* if 0, defaults to 1/3 of font size
* @param config 2D array configuration
*/
void DrawLEDs(const int* values, int numValues, int cols, const ImU32* colors,
float size = 0.0f, float spacing = 0.0f);
float size = 0.0f, float spacing = 0.0f,
const LEDConfig& config = LEDConfig{});
} // namespace halsimgui