Example #1
0
void TEST_fillPrimitives(u16 step) {
    LCD_fillScreen(BLACK);

    u16 halfStep      = (u16) (step / 2),
        quartStep     = (u16) (halfStep / 2),
        halfQuartStep = (u16) (quartStep / 2);

    u16 w = LCD_getWidth(),
        h = LCD_getHeight();

    for (u16 x = 0; x < w; x += step) {
        LCD_drawFastVLine(x, 0, h, DGRAY);
    }

    for (u16 y = 0; y < h; y += step) {
        LCD_drawFastHLine(0, y, w, DGRAY);
    }

    for (u16 x = 0; x < w; x += step) {
        for (u16 y = 0; y < h; y += step) {
            LCD_drawRect(x, y, halfStep, halfStep, DGREEN);
            LCD_fillRect(x + halfStep, y + halfStep, halfStep, halfStep, GREENYELLOW);
            LCD_drawCircle(x + quartStep, y + quartStep, halfQuartStep, GREENYELLOW);
            LCD_fillCircle(x + halfStep + quartStep, y + halfStep + quartStep, halfQuartStep, DGREEN);
            LCD_putPixel(x + quartStep, y + quartStep, YELLOW);

            LCD_drawLine(x + halfStep, y + halfStep, x + step, y + step, WHITE);
        }
    }
}
// Imprime una linea horizontal de dos pixeles de ancho, con (x,y) siendo  la coordenada superios izquierda.
void LCD_fatHline(GLCD *glcd_p, uint8_t x, uint8_t y, uint8_t width){

    LCD_drawRect(glcd_p, x, y, x+width, y+1, 1);
}
// Imprime una linea vertical de dos pixeles de ancho, con (x,y) siendo  la coordenada superios izquierda.
void LCD_fatVline(GLCD *glcd_p, uint8_t x, uint8_t y, uint8_t height){

    LCD_drawRect(glcd_p, x, y, x+1, y+height, 1);
}
//Imprime un pixel de 2x2 en la coordenada (x,y), esquina superior izuierda del pixel.
void LCD_fatPixel(GLCD *glcd_p, uint8_t x, uint8_t y, uint8_t color){

    if (color) LCD_drawRect(glcd_p, x, y, x+1, y+1, 1);
    else LCD_eraseRect(glcd_p, x, y, x+1, y+1);

}
Example #5
0
void drawTest(int type){
  uint8_t i,j;
  
  uint8_t menuStrings[5][8] = {"Menu1\0","Menu2\0","Menu3\0","Menu4\0","Menu5\0"};
  
  switch (type){

  case 0: //simple text on screen
    LCD_clr();
    LCD_setCursorXY(15,0);
    LCD_puts ((uint8_t*)"Hello AVR world!\0");
    LCD_putsp((uint8_t*)"This LCD uses KS0107\0",3,3);
    LCD_putsp((uint8_t*)"Too long paged text is wrapped automatically\0",5,3);
    wait_100x_ms(30);
    break;

  case 1: //some of the drawing functions
    LCD_clr();
    LCD_drawLine(0,0,127,63);
    LCD_drawLine(0,63,127,0);
    LCD_drawRect(10,10,117,53);
    LCD_fillCirc(63,31,15);
    wait_100x_ms(20);

    break;

  case 2: //write on screen byte by byte
     for(j=0;j<8;j++){
	LCD_setCursorXY(0,j*8);
	for(i=0;i<LCD_LINE_LENGTH/4;i++){	  
	  LCD_writeByte(0b00110011);
	  LCD_writeByte(0b00110011);
	  LCD_writeByte(0b11001100);
	  LCD_writeByte(0b11001100);
	}
     }
    wait_100x_ms(20);
    break;

  case 3: //scrolling text up->down
    LCD_clr();
    LCD_setCursorXY(0,0);
    LCD_puts((uint8_t*)"Scrolling text\n goes here..!\0");      
    i=63;
    j=110;
    while(j>0){
      _delay_ms(30);      
      LCD_selectLeftChip();
      LCD_setInitialLineAddress(i);
      LCD_selectRightChip();
      LCD_setInitialLineAddress(i);
      if (i==0) i=63;
      else i--;
      j--;
    }
    LCD_clr();
    LCD_selectLeftChip();
    LCD_setInitialLineAddress(0);
    LCD_selectRightChip();
    LCD_setInitialLineAddress(0);
    break;

  case 4:  //using invert for menus
    
    for(i=0;i<5;i++){
      LCD_putsp(menuStrings[i],i+1,25);
    }
    j=2;
    while(j--){
      LCD_invertPage(1,20,58);
      wait_100x_ms(3);
      for(i=0;i<5;i++){      
	wait_100x_ms(3);
	LCD_invertPage(i+1,20,58);
	if(i<4)
	  LCD_invertPage(i+2,20,58);
	wait_100x_ms(3);
      }
    }
    break;

  case 5: //read status (on /off)
    j=4;
    while(j--){
      LCD_clr();
      if(!LCD_isOff()){
	LCD_putsp((uint8_t*)"LCD is On\0",1,10);
	wait_100x_ms(5);
	LCD_off();
      }
      else {
	wait_100x_ms(5);
	LCD_on();
	LCD_putsp((uint8_t*)"LCD was Off\0",1,10);
	wait_100x_ms(5);
      }
    }
    break;

  case 6: //"progress bar"
    LCD_clr();
    LCD_drawRect(5,5,122,58);
    LCD_putsp((uint8_t*)"Prosessing...\0",2,16);
    LCD_drawRect(10,30,113,41);

    for(j=0;j<100;j++){     
      LCD_setCursorXY(12+j,32);
      LCD_writeByte(0xff);
      wait_100x_ms(1); 
    }
    LCD_putsp((uint8_t*)"Done!        \0",2,16);
    wait_100x_ms(10);
    break;

  case 7:
    LCD_clr();
    LCD_drawFullBMP(girl_1_glcd_bmp);
    wait_100x_ms(20);
    break;

  case 8:
    i=0b10101010;
    LCD_clr();
    LCD_drawBMP((uint8_t*)atmel_glcd_bmp, 12, 12, 
		  ATMEL_GLCD_WIDTH,ATMEL_GLCD_HEIGHT);

    wait_100x_ms(20);
    break;

  case 9:
    LCD_clr();
    
    LCD_putgstr((uint8_t*)"Corsiva 12 test", Corsiva_12,10,10);
    LCD_putgstr((uint8_t*)"qwertyhjkl12345", Corsiva_12,12,30);
    
    //    LCD_putgstr((uint8_t*)"putgstr() test",Arial_Bold_14,10,10);
    //LCD_putgstr((uint8_t*)"1q2w3e4r5t6y8u9i0l",Arial_Bold_14,10,30);

    wait_100x_ms(20);
  }
}
int main(void)
{

  /* USER CODE BEGIN 1 */

  /* USER CODE END 1 */

  /* MCU Configuration----------------------------------------------------------*/

  /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
  HAL_Init();

  /* Configure the system clock */
  SystemClock_Config();

  /* Initialize all configured peripherals */
  MX_GPIO_Init();
  MX_FSMC_Init();
  MX_SPI1_Init();
  MX_USART1_UART_Init();

  /* USER CODE BEGIN 2 */
  LCD_Init(LCD_ORIENTATION_PORTRAIT);
  LCD_setFont(SmallFont);
  LCD_setBackColor(VGA_BLACK);
  LCD_fillScr(VGA_BLACK);

  TSC2046_Init();
  TSC2046_Calibration();
  LCD_fillScr(VGA_BLACK);
  /* USER CODE END 2 */

  /* Infinite loop */
  /* USER CODE BEGIN WHILE */
  char buf[100];
  int16_t xpos, ypos;

  while (1)
  {
  /* USER CODE END WHILE */

  /* USER CODE BEGIN 3 */
    LCD_setColor(VGA_BLUE);
    LCD_drawRect(0, 0, 10, 10);

    while(!Is_Touhcing());

    while (Is_Touhcing())
    {
      // read
      xpos = TSC2046_Get_Position_X();
      ypos = TSC2046_Get_Position_Y();

      // clear
      if (xpos > LCD_WIDTH - 20 && ypos > LCD_HEIGHT - 20)
      {
        LCD_fillScr(VGA_BLACK);
      }

      // print
      sprintf(buf, "(x,y)=(%04d, %04d)", xpos, ypos);
      LCD_setColor(VGA_RED);
      LCD_setBackColor(VGA_BLACK);
      LCD_print(buf, 20, 300, 0);

      // draw pen
      LCD_setColor(rand() | 0b0111101111101111);
      LCD_fillCircle(xpos, ypos, 3);

      // clear button
      LCD_setColor(VGA_WHITE);
      LCD_fillRect(LCD_WIDTH - 20, LCD_HEIGHT - 20, LCD_WIDTH - 1, LCD_HEIGHT - 1);

      // pen indicator
      LCD_setColor(VGA_GREEN);
      LCD_drawRect(0, 0, 10, 10);
    }

  }
  /* USER CODE END 3 */

}