I am programming a M5Paper, so really an ESP2 with a capacitive, E-Ink touchscreen. I can print icons of the form:
// array size is 8192
static const int8_t Arrow_circle_down[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,.........};
using the following command and function:
DrawIcon(20, 20, (uint16_t *)Arrow_circle_down, 64, 64);
void DrawIcon(int x, int y, const uint16_t *icon, int dx, int dy) {
for (int yi = 0; yi < dy; yi++) {
for (int xi = 0; xi < dx; xi++) {
uint16_t pixel = icon[yi * dx + xi];
canvasIcon.drawPixel(x + xi, y + yi, 15 - (pixel / 4096));
}
}
}
I am keeping the ,y coordinates of selection boxes together with the name of the icon in a structure;
struct coords {
String icon;
int x;
int y;
};
// Create an array of Coordinates structs
coords box[numBoxes];
void makeBoxes() {
for (int i = 1; i < numBoxes; i++) {
box[i].x = 20;
box[i].y = i * 100;
}
box[1].icon = "Arrow_circle_down";
box[2].icon = "Arrow_circle_up";
box[3].icon = "Arrow_circle_left";
box[4].icon = "Grin_small";
for (int i = 1; i < numBoxes; i++) {
//Draw each box
canvas.drawRect(box[i].x, box[i].y, 50, 50, 15);
canvas.drawString(box[i].icon, 100, box[i].y);
}
}
This is my first time working with pointers and I need some help. Although "DrawIcon(20, 20, (uint16_t *)Arrow_circle_right, 64, 64);" works fine if I replace the "Arrow_circle_right" with "box[1].icon" the IDE complains about converting a string to an integer. I have tried changing the "String icon" to "int16_t *icon" in the struct but that didn't help. I've tried changing the structure and the make boxes function ( box[1].icon = &Arrow_circle_down;, for instance) but nothing seems to work.
How can I save the pointer to the icon array into the coords structure?