The C API documentation 6.5 Graphics > Supporting types lists LCDColor as "Either an LCDSolidColor or an LCDPattern*."
Using SDK version 1.9.1 C API on Mac, I am having trouble passing patterns into functions that accept LCDColor.
src/main.c
#include "pd_api.h"
LCDPattern gray50_data = {
0, 1, 0 ,1,
1, 0, 1, 0,
0, 1, 0 ,1,
1, 0, 1, 0,
};
LCDPattern *gray50 = &gray50_data;
static int update(void* userdata)
{
PlaydateAPI* pd = userdata;
pd->graphics->fillRect(0, 0, LCD_COLUMNS, LCD_ROWS, gray50);
return 1;
}
// eventHandler() setup omitted
warning: incompatible pointer to integer conversion passing 'LCDPattern *' (aka 'uint8_t (*)[16]') to parameter of type 'LCDColor' (aka 'unsigned long') [-Wint-conversion]
If I am confused as to how to call something that should be obvious, an example of using an LCDPattern-based LCDColor would be appreciated. If this is a documentation oversight, it should be fixed.
Note that setColorToPattern() looks promising, but it appears to work with LCDBitmap *. Therefore, I simply decided to post because the C API LCDPattern documentation is unclear.
EDIT: Also, LCDColor does not appear to be a tagged union. To the best of my recollection, implicitly casting pointers to integer types and vice versa is not generally considered a best practice in C. Low values could, however, be used as an implicit tag based on the assumption that user allocated patterns will not be located at a memory address less that 5 (or whatever the value of the final LCDSolidColor is). Having said that, an explicit cast eliminates the warning without solving the problem.