TinyCircuits Forum
TinyCircuits Products => TinyDuino Processors & TinyShields => Topic started by: fodderzone on February 22, 2015, 05:35:14 PM
-
I just got a TinyScreen and have started playing around with it and came across a basic question.
What are the constants for colors? Or more to the point, the color appears to be set using a uint8_t, but the values I see defined as constants for colors don't make sense to me. Can someone help me understand how colors are represented using uint8_t? Like RGB... or is there some set of defines I can use?
Here are some of the constants I see in examples:
#define BLACK 0x00
#define BLUE 0xE0
#define RED 0x03
#define GREEN 0x1C
#define DGREEN 0x0C
#define YELLOW 0x1F
I could figure it out on my own, but boy that's a lot values to test and figure out.
Thanks!!
-
Take a look in TinyScreen.cpp - there's a version of drawRect() which extracts rgb from a byte:
uint8_t r=(color&0x03)<<4;//two bits
uint8_t g=(color&0x1C)<<1;//three bits
uint8_t b=(color&0xE0)>>2;//three bits
...
So it looks like RGB 2:3:3 is the color format.
-
I created a small html/javascript page to have a colortable ready:
http://zetsgames.com/colortable.html (http://zetsgames.com/colortable.html)