# Color argument explanation uint16_t color

Can some one please help me by explaining how to use the color argument in this function.......

Void drawBitmap(int8_t X, uint8_t y, const uint8_t *bitmap, uint16_t color)

The type def is

Uint16_t color.

I understand the rest but I cannot figure that out. Please I don't know what to put and I'm having problems because of it.

The parameters name is color, ist type is uint16_t. So, the Parameter accepts a value from 0 to 65535. That is 16 bits of color. When using 16 bits of color, usually R, G, and B are divided equally giving 3 * 5 = 15 bits and the additional bit is allocated to Green.

Here's an app that will give you a color in 16bit.

Ok I think I'm starting to understand but how do transform the hex code to an integer that the function asks for?

just use the 0x notation and input the code in hex directly (eg, 0xa5).

Well yea, in the top of my sketch I do a

# define green 0x07E0

But I still have to put it in the right conversion. I did find an online app that will convert my hex to uint16_t color.

http://hex.colorrrs.com

Would it be possible to do the #define for the colors in the library files? Like a pre-defined set of 16 colors?

You don't need to convert it. Hex or decimal is just notation. You could even write that in binary. The function expects a number. It doesn't care what base system you write it in.

To make up the 16 bit number you can use bit shifts, if you know the R G and B values you want

RGB = (G << 10) & (R << 5) & (B)

or whatever the order they have to be in. The RGB can be in any notation you like.

Duhjoker: Would it be possible to do the #define for the colors in the library files? Like a pre-defined set of 16 colors?

``````#define ALICEBLUE 0xF7DF
#define ANTIQUEWHITE 0xFF5A
#define AQUA 0x07FF
#define AQUAMARINE 0x7FFA
#define AZURE 0xF7FF
#define BEIGE 0xF7BB
#define BISQUE 0xFF38
#define BLACK 0x0000
#define BLANCHEDALMOND 0xFF59
#define BLUE 0x001F
#define BLUEVIOLET 0x895C
#define BROWN 0xA145
#define BURLYWOOD 0xDDD0
#define CHARTREUSE 0x7FE0
#define CHOCOLATE 0xD343
#define CORAL 0xFBEA
#define CORNFLOWERBLUE 0x64BD
#define CORNSILK 0xFFDB
#define CRIMSON 0xD8A7
#define CYAN 0x07FF
#define DARKBLUE 0x0011
#define DARKCYAN 0x0451
#define DARKGOLDENROD 0xBC21
#define DARKGREEN 0x0320
#define DARKMAGENTA 0x8811
#define DARKOLIVEGREEN 0x5345
#define DARKORANGE 0xFC60
#define DARKORCHID 0x9999
#define DARKRED 0x8800
#define DARKSALMON 0xECAF
#define DARKSEAGREEN 0x8DF1
#define DARKSLATEBLUE 0x49F1
#define DARKSLATEGRAY 0x2A69
#define DARKTURQUOISE 0x067A
#define DARKVIOLET 0x901A
#define DEEPPINK 0xF8B2
#define DEEPSKYBLUE 0x05FF
#define DIMGRAY 0x6B4D
#define DODGERBLUE 0x1C9F
#define FIREBRICK 0xB104
#define FLORALWHITE 0xFFDE
#define FORESTGREEN 0x2444
#define FUCHSIA 0xF81F
#define GAINSBORO 0xDEFB
#define GHOSTWHITE 0xFFDF
#define GOLD 0xFEA0
#define GOLDENROD 0xDD24
#define GRAY 0x8410
#define GREEN 0x0400
#define GREENYELLOW 0xAFE5
#define HONEYDEW 0xF7FE
#define HOTPINK 0xFB56
#define INDIANRED 0xCAEB
#define INDIGO 0x4810
#define IVORY 0xFFFE
#define KHAKI 0xF731
#define LAVENDER 0xE73F
#define LAVENDERBLUSH 0xFF9E
#define LAWNGREEN 0x7FE0
#define LEMONCHIFFON 0xFFD9
#define LIGHTBLUE 0xAEDC
#define LIGHTCORAL 0xF410
#define LIGHTCYAN 0xE7FF
#define LIGHTGOLDENRODYELLOW 0xFFDA
#define LIGHTGREEN 0x9772
#define LIGHTGREY 0xD69A
#define LIGHTPINK 0xFDB8
#define LIGHTSALMON 0xFD0F
#define LIGHTSEAGREEN 0x2595
#define LIGHTSKYBLUE 0x867F
#define LIGHTSLATEGRAY 0x7453
#define LIGHTSTEELBLUE 0xB63B
#define LIGHTYELLOW 0xFFFC
#define LIME 0x07E0
#define LIMEGREEN 0x3666
#define LINEN 0xFF9C
#define MAGENTA 0xF81F
#define MAROON 0x8000
#define MEDIUMAQUAMARINE 0x6675
#define MEDIUMBLUE 0x0019
#define MEDIUMORCHID 0xBABA
#define MEDIUMPURPLE 0x939B
#define MEDIUMSEAGREEN 0x3D8E
#define MEDIUMSLATEBLUE 0x7B5D
#define MEDIUMSPRINGGREEN 0x07D3
#define MEDIUMTURQUOISE 0x4E99
#define MEDIUMVIOLETRED 0xC0B0
#define MIDNIGHTBLUE 0x18CE
#define MINTCREAM 0xF7FF
#define MISTYROSE 0xFF3C
#define MOCCASIN 0xFF36
#define NAVAJOWHITE 0xFEF5
#define NAVY 0x0010
#define OLDLACE 0xFFBC
#define OLIVE 0x8400
#define OLIVEDRAB 0x6C64
#define ORANGE 0xFD20
#define ORANGERED 0xFA20
#define ORCHID 0xDB9A
#define PALEGOLDENROD 0xEF55
#define PALEGREEN 0x9FD3
#define PALETURQUOISE 0xAF7D
#define PALEVIOLETRED 0xDB92
#define PAPAYAWHIP 0xFF7A
#define PEACHPUFF 0xFED7
#define PERU 0xCC27
#define PINK 0xFE19
#define PLUM 0xDD1B
#define POWDERBLUE 0xB71C
#define PURPLE 0x8010
#define RED 0xF800
#define ROSYBROWN 0xBC71
#define ROYALBLUE 0x435C
#define SALMON 0xFC0E
#define SANDYBROWN 0xF52C
#define SEAGREEN 0x2C4A
#define SEASHELL 0xFFBD
#define SIENNA 0xA285
#define SILVER 0xC618
#define SKYBLUE 0x867D
#define SLATEGRAY 0x7412
#define SNOW 0xFFDF
#define SPRINGGREEN 0x07EF
#define STEELBLUE 0x4416
#define TAN 0xD5B1
#define TEAL 0x0410
#define THISTLE 0xDDFB
#define TOMATO 0xFB08
#define TURQUOISE 0x471A
#define VIOLET 0xEC1D
#define WHEAT 0xF6F6
#define WHITE 0xFFFF
#define WHITESMOKE 0xF7BE
#define YELLOW 0xFFE0
#define YELLOWGREEN 0x9E66
``````

i take that as a yes!!! do I need to do an extern or will it automatically get it from the display file.

ok here is my real problem. I cannot get my bitmaps to compile. I transferred the fuctions from the gamebuino file and added the color arguments in both the .cpp and .h files but no matter how I try to put in the arguments in the sketch example they wont compile.

.h version

`````` void drawBitmap(int8_t x, int8_t y, const uint8_t *bitmap, uint16_t color);
void drawBitmap(int8_t x, int8_t y, const uint8_t *bitmap, uint8_t rotation, uint8_t flip, uint16_t color);
void drawBitmap(int8_t x, int8_t y, int8_t w, int8_t h, const uint8_t *bitmap, uint8_t dx, uint8_t dy, uint8_t dw, uint8_t dh, uint16_t color);
boolean getBitmapPixel(const uint8_t* bitmap, uint8_t x, uint8_t y);
``````

.cpp

``````void Adafruit_GFX::drawBitmap(int8_t x, int8_t y, const uint8_t *bitmap, uint16_t color) {
int8_t h = pgm_read_byte(bitmap + 1);
bitmap = bitmap + 2; //add an offset to the pointer to start after the width and height
drawBitmap(x, y, w, h, bitmap, color);
}

void Adafruit_GFX::drawBitmap(int8_t x, int8_t y, int8_t w, int8_t h, const uint8_t *bitmap, uint8_t dx, uint8_t dy, uint8_t dw, uint8_t dh, uint16_t color) {
int8_t i, j, byteWidth = (w + 7) / 8;
dw += dx;
dh += dy;
int8_t largest = 0;
int8_t largesty = 0;
for (j = 0; j < h; j++) {
for (i = 0; i < w; i++) {
if (pgm_read_byte(bitmap + j * byteWidth + i / 8) & (B10000000 >> (i % 8))) {
int8_t drawX = x + i;
int8_t drawY = y + j;

if (drawX >= dx && drawX < dw && drawY >= dy && drawY < dh) {
drawPixel(drawX, drawY, color);
}
}
}
}
}

boolean Adafruit_GFX::getBitmapPixel(const uint8_t* bitmap, uint8_t x, uint8_t y) {
return pgm_read_byte(bitmap + 2 + y * ((pgm_read_byte(bitmap) + 7) / 8) + (x >> 3)) & (B10000000 >> (x % 8));
}

void Adafruit_GFX::drawBitmap(int8_t x, int8_t y, const uint8_t *bitmap,
uint8_t rotation, uint8_t flip, uint16_t color) {
if ((rotation == NOROT) && (flip == NOFLIP)) {
drawBitmap(x, y, bitmap, color); //use the faster algorithm
return;
}
uint8_t h = pgm_read_byte(bitmap + 1);
bitmap = bitmap + 2; //add an offset to the pointer to start after the width and height
#if (ENABLE_BITMAPS > 0)
int8_t i, j, //coordinates in the raw bitmap
k, l, //coordinates in the rotated/flipped bitmap
byteNum, bitNum, byteWidth = (w + 7) >> 3;

rotation %= 4;

for (i = 0; i < w; i++) {
byteNum = i / 8;
bitNum = i % 8;
for (j = 0; j < h; j++) {
if (pgm_read_byte(bitmap + j * byteWidth + byteNum) & (B10000000 >> bitNum)) {
switch (rotation) {
case NOROT: //no rotation
k = i;
l = j;
break;
case ROTCCW: //90° counter-clockwise
k = j;
l = w - i - 1;
break;
case ROT180: //180°
k = w - i - 1;
l = h - j - 1;
break;
case ROTCW: //90° clockwise
k = h - j - 1;
l = i;
break;
}
if (flip) {
flip %= 4;
if (flip & B00000001) { //horizontal flip
k = w - k - 1;
}
if (flip & B00000010) { //vertical flip
l = h - l;
}
}
k += x; //place the bitmap on the screen
l += y;
drawPixel(k, l);
}
}
}
#else
drawRect(x, y, w, h);
#endif
}
``````

LCD_2000_7775_TEENSY2.zip (289 KB)

heres the sketch

``````/*
Arduino LCD-2000-7775 TFT text example For UNO

This example demonstrates how to draw text on the
TFT with an Arduino. The Arduino reads the value
of an analog sensor attached to pin A0, and writes
the value to the LCD screen, updating every
quarter second.

This example code is in the public domain

Created 30 April 2014 by INHAOS

http://www.inhaos.com

*/
#include <LCD_2000_7775.h>

#define GREEN  0x07E0

// pin definition for the UNO
#define cs   11
#define wr   10
#define rs   12
//#define le   13

//#define D0	 9
//#define D1	 8
//#define D2	 7
//#define D3	 6
//#define D4	 5
//#define D5	 4
//#define D6	 3
//#define D7	 2

//LCD_2000_7775 TFTscreen(cs,wr,rs,le);
LCD_2000_7775 TFTscreen(cs,wr,rs);

// position of the line on screen
//int xPos = 0;

const byte green_square[] PROGMEM = {
B11111111,B11111111,
B11111111,B11111111,
B11111111,B11111111,
B11111111,B11111111,
B11111111,B11111111,
B11111111,B11111111,
B11111111,B11111111,
B11111111,B11111111,
B11111111,B11111111,
B11111111,B11111111,
B11111111,B11111111,
B11111111,B11111111,
B11111111,B11111111,
B11111111,B11111111,
B11111111,B11111111,
B11111111,B11111111,};

// const byte *bitmap[] = {green_square};

void setup(){
// initialize the serial port
//TFTscreen.setdatapin(D0,D1,D2,D3,D4,D5,D6,D7);
TFTscreen.begin();

// initialize the display
TFTscreen.begin();

// clear the screen with a pretty color
//TFTscreen.background(250,16,200);
}

void loop(){

TFTscreen.drawBitmap(70, 70, green_square, 0x07E0);
}
``````
``````Arduino: 1.6.11 (Windows 7), TD: 1.30-beta3, Board: "Teensy 3.2 / 3.1, Serial, 96 MHz optimize speed (overclock), US English"

In file included from C:\Users\duhjoker\Documents\Arduino\libraries\LCD_2000_7775_TEENSY2\src/LCD_2000_7775.h:14:0,

from C:\Users\duhjoker\Documents\Arduino\BITMAP\BITMAP.ino:19:

C:\Users\duhjoker\Documents\Arduino\libraries\LCD_2000_7775_TEENSY2\src/Sound.h:44:25: error: 'NUM_CHANNELS' was not declared in this scope

boolean trackIsPlaying[NUM_CHANNELS];

^

C:\Users\duhjoker\Documents\Arduino\libraries\LCD_2000_7775_TEENSY2\src/Sound.h:53:27: error: 'NUM_CHANNELS' was not declared in this scope

boolean patternIsPlaying[NUM_CHANNELS];

^

C:\Users\duhjoker\Documents\Arduino\libraries\LCD_2000_7775_TEENSY2\src/Sound.h:62:22: error: 'NUM_CHANNELS' was not declared in this scope

uint8_t outputPitch[NUM_CHANNELS];

^

C:\Users\duhjoker\Documents\Arduino\libraries\LCD_2000_7775_TEENSY2\src/Sound.h:63:22: error: 'NUM_CHANNELS' was not declared in this scope

int8_t outputVolume[NUM_CHANNELS];

^

BITMAP: In function 'void loop()':
BITMAP:80: error: no matching function for call to 'LCD_2000_7775::drawBitmap(int, int, const byte [32], int)'
TFTscreen.drawBitmap(70, 70, green_square, 0x07E0);

^

C:\Users\duhjoker\Documents\Arduino\BITMAP\BITMAP.ino:80:50: note: candidates are:

In file included from C:\Users\duhjoker\Documents\Arduino\BITMAP\BITMAP.ino:18:0:

drawBitmap(int16_t x, int16_t y, const uint8_t *bitmap,

^

drawBitmap(int16_t x, int16_t y, const uint8_t *bitmap,

^

drawBitmap(int16_t x, int16_t y, uint8_t *bitmap,

^

drawBitmap(int16_t x, int16_t y, uint8_t *bitmap,

^

no matching function for call to 'LCD_2000_7775::drawBitmap(int, int, const byte [32], int)'

"Show verbose output during compilation"
option enabled in File -> Preferences.
``````

im still working on the sound stuff But maybe I forgot to add a definition or something to the source code?

All right guys can some one please help me figure out what I'm doing wrong with trying to simply display a bitmap.

I've tried everything and it's really getting frustrating. All I did was add the color arguments to the functions I've been using for months. I've tried colors letters hex integers what ever.

Seriously I've been trying for more than a couple and asking the whole time what I'm doing wrong. What is so secretive about using these commands? Do I need to join a club or buy the information I need. Adafruits doing the same thing. Answering the lil questions with out actually telling me how to solve the problem.

Not trying to be rude or trollish but I'm about ready to give up and that's a shame since I spent a month fixing the display files to work with the teensy. I can't even test my work properly since it needs the whole of the arguments in order to compile properly.