EVNMatrixLED#
This class provides the following features and functionalities for our LED Matrix Standard Peripheral (HT16K33/VK16K33 IC):
Controllable 8-by-8 matrix of red LEDs
16 adjustable levels of display brightness
Note
This class does I2C port selection automatically, so users do not need to call setPort() using their EVNAlpha objects.
Wiring (I2C)#
Host |
Peripheral |
Description |
|---|---|---|
SCL |
C |
I2C Serial Clock |
SDA |
D |
I2C Serial Data |
GND |
Ground (0V) |
|
3V3 |
3.3V Power |
Constructor#
- class EVNMatrixLED(uint8_t port)#
- Parameters
port – I2C port the sensor is connected to (1-16)
Functions#
- bool begin()
Initializes display. Call this function before using the other functions.
- Returns
Boolean indicating whether the sensor was successfully initialized. If
falseis returned, all other functions may fail.
Set Functions#
- void setDisplayMode(mode mode)
Set mode of display (off, on, or blinking at given frequency)
- Parameters
mode – Mode to run display in
EVNSevenSegmentLED::mode::OFF(Off)EVNSevenSegmentLED::mode::ON(On)EVNSevenSegmentLED::mode::BLINK_HZ_0_5(Blinking at 0.5Hz)EVNSevenSegmentLED::mode::BLINK_HZ_1(Blinking at 1Hz)EVNSevenSegmentLED::mode::BLINK_HZ_2(Blinking at 2Hz)
- void setBrightness(uint8_t brightness)
Set brightness level of display (1-16)
- Parameters
brightness – Brightness level from 1 to 16
- void setSwapXY(bool enable)
When enabled, swaps X and Y axes (e.g. the pixel at X = 0, Y = 7 becomes X = 7, Y = 0)
- Parameters
enable – Boolean indicating whether X and Y axes should be swapped
- void setInvertY(bool enable)
When enabled, inverts order of Y axis (e.g. when set to
true, the row Y = 0 becomes X = 7)- Parameters
enable – Boolean indicating whether Y axis should be inverted
- void setInvertX(bool enable)
When enabled, inverts order of X axis (e.g. when set to
true, the column X = 0 becomes X = 7)- Parameters
enable – Boolean indicating whether X axis should be inverted
Get Functions#
- EVNMatrixLED::mode getDisplayMode()
Get mode of display (off, on, or blinking at given frequency)
- Parameters
mode – Mode that display is set to
EVNMatrixLED::mode::OFF(Off)EVNMatrixLED::mode::ON(On)EVNMatrixLED::mode::BLINK_HZ_0_5(Blinking at 0.5Hz)EVNMatrixLED::mode::BLINK_HZ_1(Blinking at 1Hz)EVNMatrixLED::mode::BLINK_HZ_2(Blinking at 2Hz)
- uint8_t getBrightness()
Get brightness level of display (1-16)
- Parameters
brightness – Brightness level from 1 to 16
- bool getSwapXY()
- Returns
Whether X and Y axes are swapped
- bool getInvertY()
- Returns
Whether Y axis is inverted
- bool getInvertX()
- Returns
Whether X axis is inverted
Display Functions#
- void writeOne(uint8_t x, uint8_t y, bool on = true, bool show = true)
Set one LED at given XY coordinate to given state
on. Ifshowistrue, write buffer to display.- Parameters
x – X-coordinate (or column) of pixel
y – Y-coordinate (or row) of pixel
on – State of LED to be set in buffer (
truemeans on). Defaults totrueshow – Whether to write buffer to matrix. Defaults to
true
- void clearOne(uint8_t x, uint8_t y, bool show = true)
Set one LED at given XY coordinate to be turned off. If
showistrue, write buffer to display.Same as
clearOne()but specified pixels are turned off and theoninput field is removed.- Parameters
x – X-coordinate (or column) of pixel
y – Y-coordinate (or row) of pixel
show – Whether to write buffer to matrix. Defaults to
true
- void writeVLine(uint8_t x, uint8_t start_y, uint8_t end_y, bool on = true, bool show = true)
Set vertical line of LEDs with given X-coordinate and within given range of Y-coordinates to given state
on. Ifshowistrue, write buffer to display.- Parameters
x – X-coordinate (or column) of line
start_y – start Y-coordinate (or row) of line
end_y – ending Y-coordinate (or row) of line
on – State of LEDs to be set in buffer (
truemeans on). Defaults totrueshow – Whether to write buffer to matrix. Defaults to
true
- void clearVLine(uint8_t x, uint8_t start_row, uint8_t end_row, bool show = true)
Set vertical line of LEDs with given X-coordinate and within given range of Y-coordinates to be turned off. If
showistrue, write buffer to display.Same as
writeVLine()but specified pixels are turned off and theoninput field is removed.- Parameters
x – X-coordinate (or column) of line
start_y – start Y-coordinate (or row) of line
end_y – ending Y-coordinate (or row) of line
show – Whether to write buffer to matrix. Defaults to
true
- void writeHLine(uint8_t y, uint8_t start_x, uint8_t end_x, bool on = true, bool show = true)
Set horizontal line of LEDs with given Y-coordinate and within given range of X-coordinates to given state
on. Ifshowistrue, write buffer to display.- Parameters
y – Y-coordinate (or row) of line
start_x – start X-coordinate (or column) of line
end_x – ending X-coordinate (or column) of line
on – State of LEDs to be set in buffer (
truemeans on). Defaults totrueshow – Whether to write buffer to matrix. Defaults to
true
- void clearHLine(uint8_t y, uint8_t start_x, uint8_t end_x, bool on = true, bool show = true)
Set horizontal line of LEDs with given Y-coordinate and within given range of X-coordinates to be turned off. If
showistrue, write buffer to display.Same as
writeHLine()but specified pixels are turned off and theoninput field is removed.- Parameters
y – Y-coordinate (or row) of line
start_x – start X-coordinate (or column) of line
end_x – ending X-coordinate (or column) of line
show – Whether to write buffer to matrix. Defaults to
true
- void writeY(uint8_t y, bool on = true, bool show = true)
Set entire row of LEDs with given Y-coordinate to given state
on. Ifshowistrue, write buffer to display.- Parameters
y – Y-coordinate (or row) of line
on – State of LEDs to be set in buffer (
truemeans on). Defaults totrueshow – Whether to write buffer to matrix. Defaults to
true
- void clearY(uint8_t y, bool show = true)
Set entire row of LEDs with given Y-coordinate to be turned off. If
showistrue, write buffer to display.Same as
writeRow()but specified pixels are turned off and theoninput field is removed.- Parameters
y – Y-coordinate (or row) of line
show – Whether to write buffer to matrix. Defaults to
true
- void writeX(uint8_t x, bool on = true, bool show = true)
Set entire column of LEDs with given X-coordinate to given state
on. Ifshowistrue, write buffer to display.- Parameters
x – X-coordinate (or column) of line
on – State of LEDs to be set in buffer (
truemeans on). Defaults totrueshow – Whether to write buffer to matrix. Defaults to
true
- void clearX(uint8_t x, bool show = true)
Set entire column of LEDs with given X-coordinate to be turned off. If
showistrue, write buffer to display.Same as
writeX()but specified pixels are turned off and theoninput field is removed.- Parameters
x – X-coordinate (or column) of line
show – Whether to write buffer to matrix. Defaults to
true
- void clearRectangle(uint8_t start_x, uint8_t end_x, uint8_t start_y, uint8_t end_y, bool on = true, bool show = true)
Set rectanglular region of LEDs within given range of X and Y coordinates to given state
on. Ifshowistrue, write buffer to display.- Parameters
start_x – start X-coordinate (leftmost column) of region
end_x – ending X-coordinate (rightmost column) of region
start_y – start Y-coordinate (top column) of region
end_y – ending Y-coordinate (bottom column) of region
on – State of LEDs to be set in buffer (
truemeans on). Defaults totrueshow – Whether to write buffer to matrix. Defaults to
true
- void clearRectangle(uint8_t start_x, uint8_t end_x, uint8_t start_y, uint8_t end_y, bool show = true)
Set rectanglular region of LEDs within given range of X and Y coordinates to be turned off. If
showistrue, write buffer to display.Same as
writeRectangle()but specified pixels are turned off and theoninput field is removed.- Parameters
start_x – start X-coordinate (leftmost column) of region
end_x – ending X-coordinate (rightmost column) of region
start_y – start Y-coordinate (top column) of region
end_y – ending Y-coordinate (bottom column) of region
show – Whether to write buffer to matrix. Defaults to
true
- void writeAll(bool show = true)
Set all LEDs to be turned on in buffer. If
showistrue, write buffer to display.- Parameters
show – Whether to write buffer to matrix. Defaults to
true
- void clearAll(bool show = true)
Set all LEDs to be turned off in buffer. If
showistrue, write buffer to display.- Parameters
show – Whether to write buffer to matrix. Defaults to
true
- void update()
Write buffer to display