Skip to content

Instantly share code, notes, and snippets.

@maciekmm
Created March 26, 2019 12:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maciekmm/d2b2af8ccc1708fc32e490b9cca4f7be to your computer and use it in GitHub Desktop.
Save maciekmm/d2b2af8ccc1708fc32e490b9cca4f7be to your computer and use it in GitHub Desktop.
ts.c
BSP_LCD_SelectLayer(0);
srand(time(NULL));
for (int i = 0; i < 3; i++) {
BSP_LCD_SetTextColor((((uint32_t) rand()) & 0x00FFFFFF) + 0xFF000000);
int x1 = rand() % LCD_X_SIZE;
int x2 = rand() % LCD_X_SIZE;
int y1 = rand() % LCD_Y_SIZE;
int y2 = rand() % LCD_Y_SIZE;
int xl = min(x1, x2);
int xr = max(x1, x2);
int yt = min(y1, y2);
int yb = max(x1, x2);
BSP_LCD_FillRect(xl, yt, xr-xl, yb-yt);
}
Point points[4] = { {50, 50}, {200, 50}, {200, 100}, {80, 100} };
BSP_LCD_FillPolygon(points, 4);
TS_StateTypeDef TS_State;
BSP_TS_GetState(&TS_State);
for (int i = 0; i < TS_State.touchDetected; i++) {
uint16_t x = TS_State.touchX[i];
uint16_t y = TS_State.touchY[i];
BSP_LCD_FillCircle(x, y, 6);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment