I'm thinking this could be a lot simpler, but i don't really know how. I have 1 decimal 0-255 integer. I need to convert it to HEX, and repeat it 3 times in one string that's 6 characters long, so even if the original integer is 0, it eventually needs to be 000000. And if the original integer is 10, it needs to be 0A0A0A.
It doesn't matter whether your code uses Hex, Dec, Binary, as the compiler converts it all the binary anyway (the language the microcontroller speaks).
I gather what you are trying to do is to send a number to the Serial port as a series of characters which represent the hexadecimal form of the number. Something like this:
byte R,G,B;
R = something.
G = something.
B = something.
char hex[7] = {0};
sprintf(hex,"%02X%02X%02X",R,G,B); //convert to an hexadecimal string. Lookup sprintf for what %02X means.
Serial.println(hex); //Print the string.
I really think you need to explain what you are trying to do. Tom gave you a way to output, to serial, a hex representation of your three bytes, by generating a string, because that is what you appeared to want. If you need to do anything else with it, then the long variable in an earlier post will be needed.
The 'Rectangle' function in a uOLED library, this is what the manual says:
void uOLED::Rectangle ( char x1,
char y1,
char x2,
char y2,
int color,
char filled
)
Draw a rectangle.
Draw a rectangle with upper-left corner at x1,y1 and the bottom-right corner at x2,y2. Lines will have 16bit color. filled=true -> fill the rectangle with the color given.
Note that the sides of the rectangle can not be diagonal on the screen.
What i'm trying to generate, is the HEX color int.
Where does it mention hex? The color parameter is only 16 bits wide, you can't pass three bytes to it. You need to know how colour is represented in that library.
If you'd mentioned this at the beginning, a lot of time could have been saved.