Colours¶
Configure¶
No configuration is required, as the object myColours
provides the colours.
Colours are coded internally on 16 bits, with 5 bits for red, 6 bits for green and 5 bits for blue, or called RGB565.
rrrrr gggggg bbbbb
43210 543210 43210
The Red-Green-Blue components are 8-bit sized and 0x00
..0xff
scaled.
The monochrome e-paper screens provides two basic colours. Combining those two basic colours gives an additional shade, totalling three colours.
-
white: basic colour;
-
black: basic colour;
-
grey: combined colour, one pixel black, another pixel white.
The colour e-paper screens provides three basic colours. Combining those three basic colours gives two additional shades, totalling six colours.
-
white: basic colour;
-
black: basic colour;
-
red: basic colour.
and
-
grey: combined colour, one pixel black, another pixel white;
-
light red: combined colour, one pixel red, another pixel white;
-
dark red: combined colour, one pixel red, another pixel black.
The red and yellow colours e-paper screens provides four basic colours. Combining those four basic colours gives six additional shades, totalling ten colours.
-
white: basic colour;
-
black: basic colour;
-
red: basic colour;
-
yellow: basic colour.
and
-
grey: combined colour, one pixel black, another pixel white;
-
light red: combined colour, one pixel red, another pixel white;
-
light yellow: combined colour, one pixel yellow, another pixel white;
-
dark red: combined colour, one pixel red, another pixel black;
-
dark yellow: combined colour, one pixel yellow, another pixel black;
-
orange: combined colour, one pixel red, another pixel yellow.
Use¶
The monochrome or black-and-white screens feature three colours:
-
myColours.white
for white; -
myColours.black
for black; -
myColours.grey
for grey, with one pixel black and another white.
The colour screens bring three more colours:
-
myColours.red
for red; -
myColours.lightRed
for light red, with one pixel red and another white; -
myColours.darkRed
for dark red, with one pixel black and another red.
The red and yellow colours e-paper screens bring three more colours:
-
myColours.lightYellow
for light yellow, with one yellow and another white; -
myColours.darkYellow
for dark yellow, with one pixel yellow and another red; -
myColours.darkOrange
for orange, with one pixel red and another yellow.
Example¶
This is the core of the code from example Common_Colours.ino
.
void displayPalette()
{
displayRGB(myColours.blue);
myScreen.setOrientation(myOrientation);
myScreen.setPenSolid(false);
uint16_t x0, y0, dx, dy, dz;
dz = min((myScreen.screenSizeX() * 10 / 50), (myScreen.screenSizeY() * 10 / 35));
dx = (myScreen.screenSizeX() - dz * 50 / 10) / 2;
dy = (myScreen.screenSizeY() - dz * 35 / 10) / 2;
y0 = dy + dz / 2;
x0 = dx + dz / 2;
myScreen.dRectangle(x0 - 2, y0 - 2, dz + 4, dz + 4, myColours.red);
x0 = dx + dz * 4 / 2;
myScreen.dRectangle(x0 - 2, y0 - 2, dz + 4, dz + 4, myColours.red);
x0 = dx + dz * 7 / 2;
myScreen.dRectangle(x0 - 2, y0 - 2, dz + 4, dz + 4, myColours.red);
y0 = dy + dz * 4 / 2;
x0 = dx + dz / 2;
myScreen.dRectangle(x0 - 2, y0 - 2, dz + 4, dz + 4, myColours.black);
x0 = dx + dz * 4 / 2;
myScreen.dRectangle(x0 - 2, y0 - 2, dz + 4, dz + 4, myColours.black);
x0 = dx + dz * 7 / 2;
myScreen.dRectangle(x0 - 2, y0 - 2, dz + 4, dz + 4, myColours.black);
myScreen.setPenSolid(true);
myScreen.selectFont(fontSmall);
// Light red
x0 = dx + dz / 2;
y0 = dy + dz / 2;
myScreen.dRectangle(x0, y0, dz, dz, myColours.lightRed);
myScreen.gText(x0, y0 + dz + 6, "light", myColours.red);
// Red
x0 = dx + dz * 4 / 2;
y0 = dy + dz / 2;
myScreen.dRectangle(x0, y0, dz, dz, myColours.red);
myScreen.gText(x0, y0 + dz + 6, "colour", myColours.red);
// Dark-red
x0 = dx + dz * 7 / 2;
y0 = dy + dz / 2;
myScreen.dRectangle(x0, y0, dz, dz, myColours.darkRed);
myScreen.gText(x0, y0 + dz + 6, "dark", myColours.red);
// White
x0 = dx + dz / 2;
y0 = dy + dz * 4 / 2;
myScreen.dRectangle(x0, y0, dz, dz, myColours.white);
myScreen.gText(x0, y0 + dz + 6, "white", myColours.black);
// Grey
x0 = dx + dz * 4 / 2;
y0 = dy + dz * 4 / 2;
myScreen.dRectangle(x0, y0, dz, dz, myColours.grey);
myScreen.gText(x0, y0 + dz + 6, "grey", myColours.black);
// Black
x0 = dx + dz * 7 / 2;
y0 = dy + dz * 4 / 2;
myScreen.dRectangle(x0, y0, dz, dz, myColours.black);
myScreen.gText(x0, y0 + dz + 6, "black", myColours.black);
myScreen.gText(0, 0, myScreen.WhoAmI(), myColours.black);
myScreen.flush();
}