C API 1.9.1: How to use an LCDPattern-based LCDColor?

mmmh interesting question.

I never used LCDPattern but like LCDBitmap, the data format is not really explained in the doc.

1 bit is basically 1 pixel so one byte is a row of 8 pixels.
For LCDPattern there is two parts: the first one is the black and white bitmap and the second one is the mask (1 is opaque, 0 is transparent)

LCDPattern grey50 = {
	0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, // Bitmap, each byte is a row of pixel
	0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // Mask, here fully opaque
};

pd->graphics->fillRect(0, 0, LCD_COLUMNS, LCD_ROWS, grey50);

But if you use binary representation this is a bit easier to edit

LCDPattern grey50 = {
	// Bitmap
	0b10101010,
	0b01010101,
	0b10101010,
	0b01010101,
	0b10101010,
	0b01010101,
	0b10101010,
	0b01010101,

	// Mask
	0b11111111,
	0b11111111,
	0b11111111,
	0b11111111,
	0b11111111,
	0b11111111,
	0b11111111,
	0b11111111,
};
3 Likes