ErrorStatus TM_ILI9341_Button_Draw(uint8_t id) { uint16_t fontWidth, fontHeight, x, y, i, j; if ((TM_ILI9341_Buttons[id].flags & TM_BUTTON_FLAG_USED) == 0) { //Button not enabled return ERROR; } //Draw label if (TM_ILI9341_Buttons[id].flags & TM_BUTTON_FLAG_IMAGE) { //Draw picture for (i = 0; i < TM_ILI9341_Buttons[id].width; i++) { for (j = 0; j < TM_ILI9341_Buttons[id].height; j++) { TM_ILI9341_DrawPixel( TM_ILI9341_Buttons[id].x + i, TM_ILI9341_Buttons[id].y + j, *(uint16_t *)(TM_ILI9341_Buttons[id].image + j * TM_ILI9341_Buttons[id].width + i) ); } } } else { //Background TM_ILI9341_DrawFilledRectangle( TM_ILI9341_Buttons[id].x, TM_ILI9341_Buttons[id].y, TM_ILI9341_Buttons[id].x + TM_ILI9341_Buttons[id].width, TM_ILI9341_Buttons[id].y + TM_ILI9341_Buttons[id].height, TM_ILI9341_Buttons[id].background ); } //Display label if ((TM_ILI9341_Buttons[id].flags & TM_BUTTON_FLAG_NOLABEL) == 0) { TM_ILI9341_GetStringSize(TM_ILI9341_Buttons[id].label, TM_ILI9341_Buttons[id].font, &fontWidth, &fontHeight); x = TM_ILI9341_Buttons[id].x + TM_ILI9341_Buttons[id].width / 2 - (fontWidth / 2); y = TM_ILI9341_Buttons[id].y + TM_ILI9341_Buttons[id].height / 2 - (fontHeight / 2); TM_ILI9341_Puts(x, y, TM_ILI9341_Buttons[id].label, TM_ILI9341_Buttons[id].font, TM_ILI9341_Buttons[id].color, TM_ILI9341_Buttons[id].background); } //Border if ((TM_ILI9341_Buttons[id].flags & TM_BUTTON_FLAG_NOBORDER) == 0) { //Border enabled TM_ILI9341_DrawRectangle( TM_ILI9341_Buttons[id].x, TM_ILI9341_Buttons[id].y, TM_ILI9341_Buttons[id].x + TM_ILI9341_Buttons[id].width, TM_ILI9341_Buttons[id].y + TM_ILI9341_Buttons[id].height, TM_ILI9341_Buttons[id].borderColor ); } return SUCCESS; }
void TM_SNAKE_DrawArea(void) { /* Draw filled rectangle */ TM_ILI9341_DrawFilledRectangle( SNAKE_BACK_START_X, SNAKE_BACK_START_Y, SNAKE_BACK_START_X + SNAKE_PIXELS * (SNAKE_PIXEL_SIZE + 1) + 2, SNAKE_BACK_START_Y + SNAKE_PIXELS * (SNAKE_PIXEL_SIZE + 1) + 2, SNAKE_COLOR_GAME_BCK); /* Draw border */ TM_ILI9341_DrawRectangle( SNAKE_BACK_START_X, SNAKE_BACK_START_Y, SNAKE_BACK_START_X + SNAKE_PIXELS * (SNAKE_PIXEL_SIZE + 1) + 2, SNAKE_BACK_START_Y + SNAKE_PIXELS * (SNAKE_PIXEL_SIZE + 1) + 2, SNAKE_COLOR_BORDER ); }
/* Draw snake pixel */ void TM_SNAKE_DrawPixel(uint8_t x, uint8_t y, uint16_t value) { uint16_t color; /* Get pixel color */ if (value == 0) { color = SNAKE_COLOR_GAME_BCK; /* Clear pixel */ } else if (value == 1) { color = SNAKE_COLOR_PIXEL; /* Set snake pixel */ } else if (value == 2) { color = SNAKE_COLOR_TARGET; /* Set target pixel */ } else if (value == 3) { color = SNAKE_COLOR_HEAD; /* Set head pixel for snake */ } /* Draw Filled rectangle */ TM_ILI9341_DrawFilledRectangle( SNAKE_BACK_START_X + 2 + x * (SNAKE_PIXEL_SIZE + 1), SNAKE_BACK_START_Y + 2 + y * (SNAKE_PIXEL_SIZE + 1), SNAKE_BACK_START_X + 1 + x * (SNAKE_PIXEL_SIZE + 1) + SNAKE_PIXEL_SIZE, SNAKE_BACK_START_Y + 2 + y * (SNAKE_PIXEL_SIZE + 1) + SNAKE_PIXEL_SIZE, color ); }
void ekran(int nr){ switch(nr){ case 1: //Rotate LCD for 90 degrees TM_ILI9341_Rotate(TM_ILI9341_Orientation_Portrait_2); //FIll lcd with color TM_ILI9341_Fill(ILI9341_COLOR_ORANGE); //Draw white circle //TM_ILI9341_DrawCircle(0, 0, 10, ILI9341_COLOR_GREEN); //Draw red filled circle TM_ILI9341_DrawFilledCircle(60, 40, 35, ILI9341_COLOR_RED); //Draw blue rectangle //TM_ILI9341_DrawRectangle(120, 20, 220, 100, ILI9341_COLOR_BLUE); //Draw black filled rectangle TM_ILI9341_DrawFilledRectangle(70, 200, 160, 240, ILI9341_COLOR_RED); TM_ILI9341_Puts(85, 215, "START", &TM_Font_11x18, ILI9341_COLOR_BLACK, ILI9341_COLOR_RED); //Draw line with custom color 0x0005 TM_ILI9341_DrawLine(20, 120, 220, 120, 0x0005); //Put string with black foreground color and blue background with 11x18px font TM_ILI9341_Puts(40, 110, " STEP DRIVER ", &TM_Font_11x18, ILI9341_COLOR_BLACK, ILI9341_COLOR_ORANGE); //Put string with black foreground color and blue background with 11x18px font TM_ILI9341_Puts(10, 140, "Press START to begin", &TM_Font_11x18, ILI9341_COLOR_BLACK, ILI9341_COLOR_ORANGE); //Put string with black foreground color and red background with 11x18px font TM_ILI9341_Puts(1, 310, "LB", &TM_Font_7x10, ILI9341_COLOR_BLACK, ILI9341_COLOR_ORANGE); return; case 2: //Rotate LCD for 90 degrees TM_ILI9341_Rotate(TM_ILI9341_Orientation_Portrait_2); //FIll lcd with color TM_ILI9341_Fill(ILI9341_COLOR_BLUE2); //Draw blue rectangle //TM_ILI9341_DrawRectangle(120, 20, 220, 100, ILI9341_COLOR_BLUE); //Draw black filled rectangle TM_ILI9341_DrawFilledRectangle(10, 10, 50, 210, ILI9341_COLOR_WHITE); TM_ILI9341_DrawFilledRectangle(70, 10, 110, 210, ILI9341_COLOR_WHITE); TM_ILI9341_DrawFilledRectangle(130, 10, 170, 210, ILI9341_COLOR_WHITE); TM_ILI9341_DrawFilledRectangle(10, 220, 50, 260, ILI9341_COLOR_RED); TM_ILI9341_Puts(15, 230, "STOP", &TM_Font_7x10, ILI9341_COLOR_BLACK, ILI9341_COLOR_RED); TM_ILI9341_DrawFilledRectangle(70, 220, 110, 260, ILI9341_COLOR_RED); TM_ILI9341_Puts(75, 230, "STOP", &TM_Font_7x10, ILI9341_COLOR_BLACK, ILI9341_COLOR_RED); TM_ILI9341_DrawFilledRectangle(130, 220, 170, 260, ILI9341_COLOR_RED); TM_ILI9341_Puts(135, 230, "STOP", &TM_Font_7x10, ILI9341_COLOR_BLACK, ILI9341_COLOR_RED); TM_ILI9341_DrawFilledRectangle(10, 270, 50, 310, ILI9341_COLOR_YELLOW); TM_ILI9341_Puts(15, 280, "CW", &TM_Font_7x10, ILI9341_COLOR_BLACK, ILI9341_COLOR_YELLOW); TM_ILI9341_DrawFilledRectangle(70, 270, 110, 310, ILI9341_COLOR_YELLOW); TM_ILI9341_Puts(75, 280, "CW", &TM_Font_7x10, ILI9341_COLOR_BLACK, ILI9341_COLOR_YELLOW); TM_ILI9341_DrawFilledRectangle(130, 270, 170, 310, ILI9341_COLOR_YELLOW); TM_ILI9341_Puts(135, 280, "CW", &TM_Font_7x10, ILI9341_COLOR_BLACK, ILI9341_COLOR_YELLOW); TM_ILI9341_DrawFilledRectangle(180, 100, 235, 125, ILI9341_COLOR_BLUE); TM_ILI9341_Puts(185, 105, "FULL", &TM_Font_11x18, ILI9341_COLOR_WHITE, ILI9341_COLOR_BLUE); TM_ILI9341_DrawFilledRectangle(180, 130, 235, 155, ILI9341_COLOR_WHITE); TM_ILI9341_Puts(185, 135, "1/2", &TM_Font_11x18, ILI9341_COLOR_BLACK, ILI9341_COLOR_WHITE); TM_ILI9341_DrawFilledRectangle(180, 160, 235, 185, ILI9341_COLOR_WHITE); TM_ILI9341_Puts(185, 165, "1/4", &TM_Font_11x18, ILI9341_COLOR_BLACK, ILI9341_COLOR_WHITE); TM_ILI9341_DrawFilledRectangle(180, 190, 235, 215, ILI9341_COLOR_WHITE); TM_ILI9341_Puts(185, 195, "1/8", &TM_Font_11x18, ILI9341_COLOR_BLACK, ILI9341_COLOR_WHITE); TM_ILI9341_DrawFilledRectangle(180, 220, 235, 245, ILI9341_COLOR_WHITE); TM_ILI9341_Puts(185, 225, "1/16", &TM_Font_11x18, ILI9341_COLOR_BLACK, ILI9341_COLOR_WHITE); TM_ILI9341_DrawFilledRectangle(180, 260, 235, 315, ILI9341_COLOR_MAGENTA); TM_ILI9341_Puts(185, 280, "DOWN", &TM_Font_11x18, ILI9341_COLOR_BLACK, ILI9341_COLOR_MAGENTA); return; default: //Rotate LCD for 90 degrees TM_ILI9341_Rotate(TM_ILI9341_Orientation_Portrait_2); //FIll lcd with color TM_ILI9341_Fill(ILI9341_COLOR_GREEN); //Draw white circle //TM_ILI9341_DrawCircle(0, 0, 10, ILI9341_COLOR_GREEN); //Draw red filled circle TM_ILI9341_DrawFilledCircle(60, 60, 35, ILI9341_COLOR_RED); //Draw blue rectangle //TM_ILI9341_DrawRectangle(120, 20, 220, 100, ILI9341_COLOR_BLUE); //Draw black filled rectangle TM_ILI9341_DrawFilledRectangle(120, 200, 220, 230, ILI9341_COLOR_RED); return; } }