Post by jeffs on Aug 7, 2018 11:10:15 GMT -8
I am using an 800x480 7" display with an FT812. my project uses an Atmel SAME70 ARM processor, and I'm developing under Atmel Studio 7. I'm attempting to use portions of the library with my project, but I'm not having full success. At the moment I'm only trying to work with the "Poly" class. I've made what appear to be obvious modifications in the code, that being width and height in the "restart" method, and values in the "paint" method. The polygon appears to draw correctly and fill with the correct color. When I call the "outline" method, I do not get an outline drawn, and all subsequent attempts to write objects to the screen (such as text) do nothing. From examining the code, it appears that either a scissors rectangle is still active, and/or the stencil function is still active preventing the outline and other writes from appearing. I tried making what seem like proper modifications to cancel the scissor and stencil operation but what appears on the screen is really messed up. I'm going to attach some code and some photos of what I'm seeing in the hopes that someone can provide the correct modifications to get this working.
First, here is the Poly class as I've modified it for my environment
Note that in my environment class "Graphics" is my hook to the FT812 and contains my SPI transport code. Basically those are the Display List commands being send to the processor via the command Fifo, and are the same commands and variables from the original code.
Attached in three images is what appears on the screen before and after the above modification. Something is wrong with the outline as it's not drawn exactly over the polygon in several areas (specifically along the diagonal). It's like it's offset by something. Also, note the strange yellow line below the text. I hope somebody can provide some answers here. I've just started working with the FT812 and my intended application is an industrial machine interface.
First, here is the Poly class as I've modified it for my environment
class Poly
{
int x0, y0, x1, y1;
int x[16], y[16];
uint8_t n;
void restart()
{
n = 0;
x0 = 16 * 800;
x1 = 0;
y0 = 16 * 480;
y1 = 0;
}
void perim()
{
for (uint8_t i = 0; i < n; i++)
Graphics.Copro_SendCmd(VERTEX2F(x[i], y[i]));
Graphics.Copro_SendCmd(VERTEX2F(x[0], y[0]));
}
public:
void begin()
{
restart();
Graphics.Copro_SendCmd(COLOR_MASK(0,0,0,0));
Graphics.Copro_SendCmd(STENCIL_OP(KEEP, INVERT));
Graphics.Copro_SendCmd(STENCIL_FUNC(ALWAYS, 255, 255));
}
void v(int _x, int _y)
{
x0 = min(x0, _x >> 4);
x1 = max(x1, _x >> 4);
y0 = min(y0, _y >> 4);
y1 = max(y1, _y >> 4);
x[n] = _x;
y[n] = _y;
n++;
}
void paint()
{
x0 = max(0, x0);
y0 = max(0, y0);
x1 = min(16 * 800, x1);
y1 = min(16 * 480, y1);
Graphics.Copro_SendCmd(BEGIN(EDGE_STRIP_B));
perim();
}
void finish()
{
Graphics.Copro_SendCmd(COLOR_MASK(1, 1, 1, 1));
Graphics.Copro_SendCmd(STENCIL_FUNC(EQUAL, 255, 255));
Graphics.Copro_SendCmd(BEGIN(EDGE_STRIP_R));
Graphics.Copro_SendCmd(VERTEX2F(0, 0));
Graphics.Copro_SendCmd(VERTEX2F(0, 480*16));
}
void draw()
{
paint();
finish();
}
void outline()
{
Graphics.Copro_SendCmd(BEGIN(LINE_STRIP));
perim();
}
};
Note that in my environment class "Graphics" is my hook to the FT812 and contains my SPI transport code. Basically those are the Display List commands being send to the processor via the command Fifo, and are the same commands and variables from the original code.
Here is the code I'm using to create the display:
#define poly_points 15
uint16_t Shape[poly_points] = // These are the absolute X,Y coordinates of the polygonal shape
{
{425, 50},
{625, 50},
{625, 180},
{745, 180},
{745, 215},
{700, 215},
{700, 465},
{100, 465},
{100, 420},
{650, 420},
{650, 215},
{625, 215},
{625, 280},
{525, 400},
{425, 280},
};
Graphics.Copro_SendCmd(COLOR_RGB(0xF3, 0xD4, 0x17));
Poly PolygonDraw;
PolygonDraw.begin();
for (uint8_t lp = 0; lp < poly_points; lp++)
PolygonDraw.v(16 * Shape[lp][Xp], 16 * Shape[lp][Yp]); //Xp = 0, Yp = 1
PolygonDraw.draw();
Graphics.Copro_SendCmd(COLOR_RGB(0, 0, 0));
Graphics.Copro_SendCmd(LINE_WIDTH(2 * 16));
PolygonDraw.outline();
Graphics.Copro_SendCmd(COLOR_RGB(0, 255, 0));
Graphics.CoCmd_Text_b(FT_DispWidth/2, 30, 28, OPT_CENTERX|OPT_CENTERY, "FT812 Color TFT 800x480");
Graphics.Copro_SendCmd(DISPLAY());
Graphics.CoCmd_Swap()
Adding the following to the "draw" method to reset the scissor area and turn off the stencil function (I think. I am NO expert whatsoever in this area): void draw()
{
paint();
finish();
Graphics.Copro_SendCmd(STENCIL_FUNC(ALWAYS, 0, 255));
Graphics.Copro_SendCmd(SCISSOR_XY(0, 0));
Graphics.Copro_SendCmd(SCISSOR_SIZE(2048, 2048));
}
Attached in three images is what appears on the screen before and after the above modification. Something is wrong with the outline as it's not drawn exactly over the polygon in several areas (specifically along the diagonal). It's like it's offset by something. Also, note the strange yellow line below the text. I hope somebody can provide some answers here. I've just started working with the FT812 and my intended application is an industrial machine interface.