From ba7598c750fee4ce60d140283545ef5801e856db Mon Sep 17 00:00:00 2001 From: "David Todd (c0de)" Date: Tue, 24 Jul 2018 21:19:05 -0500 Subject: [PATCH] Add optional color selection defined via the PXL structure This can be useful for using the same icon with a different color to indicate various states --- FIRMWARE/pixo-display/pixo-display-helper.ino | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/FIRMWARE/pixo-display/pixo-display-helper.ino b/FIRMWARE/pixo-display/pixo-display-helper.ino index 7b09cdb..6b86cd1 100644 --- a/FIRMWARE/pixo-display/pixo-display-helper.ino +++ b/FIRMWARE/pixo-display/pixo-display-helper.ino @@ -62,12 +62,26 @@ void resetActiveState() { * args: * - pxl[TOTALPXLS][3] - Standard Pixol image * - dlytime - The amount of time (in ms) to keep the image on the display + * - color (optional) - Whether or not to set the active pixel's color to its stored value */ -void showPxl(int pxl[256][3], int dlytime) { - matrix.fillScreen(0); +void showPxl(int pxl[TOTALPXLS][3], int dlytime, bool color=false) { + resetActiveState(); - for (int i=0; i<256; i++){ - matrix.setPixelColor(i, pxl[i][0], pxl[i][1], pxl[i][2]); + for (int i=0; i < TOTALPXLS; i++){ + if (pxl[i][0] != 0 && pxl[i][1] != 0 && pxl[i][2] != 0) { + pixols[i].active = true; + } + + if (!color) { + matrix.setPixelColor(i, pxl[i][0], pxl[i][1], pxl[i][2]); + }else { + if (pixols[i].active) { + matrix.setPixelColor(i, pxl[i][pixols[i].r], + pxl[i][pixols[i].g], + pxl[i][pixols[i].b]); + } + + } } matrix.show();