Skip to content

Commit

Permalink
feature to compensate for Red/Green invert on Mkr
Browse files Browse the repository at this point in the history
  • Loading branch information
naylom committed Feb 6, 2023
1 parent b6ffcc9 commit 537ed7e
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/MNRGBLEDBaseLib.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,19 @@
// Also uses the MNTimerLib library for flash functionality
#pragma once
#include <arduino.h>

/*
Some Mkr wifi 1010 boards have the built in LED red and green pins inverted, so if MKR_RGB_INVERT is defined *BEFORE* this include, the macros below will compensate
*/
#if defined ARDUINO_ARCH_SAMD && defined (MKR_RGB_INVERT)
#define RGB( G, R, B ) ( ( ( R & 0xff ) << 16 ) | ( ( G & 0xff ) << 8 ) | ( B & 0xff ) ) // takes three values each 0 - 255 to determine strength of RGB colour ands returns a combined value
#define RGB_RED( RGBValue ) ( ( RGBValue & 0x00ff00 ) >> 8 ) // extracts RED value from RGB value
#define RGB_GREEN( RGBValue ) ( ( RGBValue & 0xff0000 ) >> 16 ) // extracts GREEN value from RGB value
#else
#define RGB( R, G, B ) ( ( ( R & 0xff ) << 16 ) | ( ( G & 0xff ) << 8 ) | ( B & 0xff ) ) // takes three values each 0 - 255 to determine strength of RGB colour ands returns a combined value
#define RGB_RED( RGBValue ) ( ( RGBValue & 0xff0000 ) >> 16 ) // extracts RED value from RGB value
#define RGB_GREEN( RGBValue ) ( ( RGBValue & 0x00ff00 ) >> 8 ) // extracts GREEN value from RGB value
#endif

#define RGB_BLUE( RGBValue ) ( RGBValue & 0x0000ff ) // extract BLUE value from RGB Value
typedef uint32_t RGBType;

Expand Down

0 comments on commit 537ed7e

Please sign in to comment.