You could make a strict that holds the three values but you'd have to rewrite that function to accept it as an argument. I'd do some digging around the documentation for whatever library you're using. It appears to already have some sort of Color object defined that you could use. You didn't tell what library and only gave one line of code so I can't tell which library you're using. So I can't really help you look through it.
Something like this would make a good starting point.
// Color definitions
static const uint16_t BLACK = 0x0000;
static const uint16_t WHITE = 0xFFFF;
static const uint16_t NAVY = 0x000F;
static const uint16_t DARKGREEN = 0x03E0;
static const uint16_t DARKCYAN = 0x03EF;
static const uint16_t MAROON = 0x7800;
static const uint16_t PURPLE = 0x780F;
static const uint16_t ORANGE = 0xFD20;
static const uint16_t PINK = 0xF81F;
static const uint16_t OLIVE = 0x7BE0;
static const uint16_t BLUE = 0x001F;
static const uint16_t RED = 0xF800;
static const uint16_t GREEN = 0x07E0;
static const uint16_t CYAN = 0x07FF;
static const uint16_t MAGENTA = 0xF81F;
static const uint16_t YELLOW = 0xFFE0;
static const uint16_t BRIGHT_RED = 0xF810;
static const uint16_t LIGHT_GREY = 0xC618;//0x8410;
static const uint16_t DARK_GREY = 0x7BEF;//0x4208;
static const uint16_t GREENYELLOW = 0xAFE5;
class colorObj {
public:
colorObj(byte inRed, byte inGreen, byte inBlue);
colorObj(word color16);
colorObj(void);
void setColor(byte inRed, byte inGreen, byte inBlue);
void setColor(word color16);
void setColor(colorObj* inColor);
word getColor16(void);
byte getRed(void);
byte getGreen(void);
byte getBlue(void);
private :
byte red;
byte green;
byte blue;
};
// ****** colorObj ******
colorObj::colorObj(byte inRed, byte inGreen, byte inBlue) { setColor(inRed,inGreen,inBlue); }
//colorObj::colorObj(colorObj* inColor) { setColor(inColor); }
colorObj::colorObj(word inColor16) { setColor(inColor16); }
colorObj::colorObj(void) { setColor(0,0,0); }
void colorObj::setColor(byte inRed, byte inGreen, byte inBlue) {
red = inRed;
green = inGreen;
blue = inBlue;
}
void colorObj::setColor(word color16) {
switch(color16) {
case BLACK : //0x0000
red = 0;
green = 0;
blue = 0;
break;
case BLUE : //0x001F
red = 0;
green = 0;
blue = 255;
break;
case RED : //0xF800
red = 255;
green = 0;
blue = 0;
break;
case GREEN : //0x07E0
red = 0;
green = 255;
blue = 0;
break;
case CYAN : //0x07FF
red = 0;
green = 255;
blue = 255;
break;
case MAGENTA : //0xF81F
red = 255;
green = 0;
blue = 255;
break;
case YELLOW : //0xFFE0
red = 255;
green = 255;
blue = 0;
break;
case WHITE : //0xFFFF
red = 255;
green = 255;
blue = 255;
break;
default :
red = highByte(color16);
green = lowByte(color16>>5);
blue = lowByte(color16)<<3;
}
}
void colorObj::setColor(colorObj* inColor) {
red =inColor->getRed();
green =inColor->getGreen();
blue = inColor->getBlue();
}
// Copied from Adafruit'
word colorObj::getColor16(void) {
return ((red & 0xF8) << 8) | ((green & 0xFC) << 3) | (blue >> 3);
}
byte colorObj::getRed(void) { return red; }
byte colorObj::getGreen(void) { return green; }
byte colorObj::getBlue(void) { return blue; }
This is a simplified version of what I use. Extremely handy when you extend Adafruit's set & get pixleColor() to use colorObjects.
Actually mine includes this..
//Changes yourself by blending in some new color.
void colorObj::blend(colorObj* mixinColor,byte mixPercent) {
if (mixPercent>=100) { // If >= 100 means totally mixin color.
setColor(mixinColor);
} else if (mixPercent>0) { // So its NOT >= 100 but it is > 0.. Blend it.
mixMapper.setColors(this,mixinColor);
colorObj temp = mixMapper.Map(mixPercent);
setColor(&temp);
} // Otherwise, there is no change.
}
if(digitalRead(buttonPin) == LOW) { // if the button is pressed
red = someNewValue;
green = someOtherValue;
blue = whateverBlueNeedsToBe;
noseJewel.setPixelColor(4, noseJewel.Color(red, green, blue));
}
When you have got that working have a look at the StateChangeDetection example in the IDE. It will show you how to detect when the button becomes pressed rather than when it is pressed which will allow you to cycle through several colour combinations.