Ejemplo n.º 1
0
static void ili9341_set_window (unsigned short col_l,   // 
                                unsigned short col_h,	// col_l <= col_h < 320 --> x
								unsigned short row_l,	// row_l <= row_h < 240	--> y
								unsigned short row_h) {

/*
	0 ----------> X (max 319)
	|
	|
	|
	|
	Y (max 239)	
*/

	wr_cmd(0x2A);              // Collum area set  (collum max = 320)
	
	wr_dat((col_l>>8)& 0xFF);  // Colum high byte (lower collum)
	wr_dat(col_l & 0xFF);      // Colum low byte  (lower collum)

	wr_dat((col_h>>8)& 0xFF);  // Colum high byte (upper collum)
	wr_dat(col_h & 0xFF);      // Colum low byte  (upper collum)
    
		
	wr_cmd(0x2B);              // Row area set	  (row max = 240)

	wr_dat((row_l>>8)& 0xFF);  // Row high byte   (lower row)
	wr_dat(row_l & 0xFF);      // Row low byte    (lower row)

	wr_dat((row_h>>8)& 0xFF);  // Row high byte   (upper row)
	wr_dat(row_h & 0xFF);      // Row low byte    (upper row)
		  
	wr_cmd(0x2c);

}
Ejemplo n.º 2
0
void S6B33BG_Fill(uint8_t x0,uint8_t y0,uint8_t x1,uint8_t y1,uint32_t color) {

  uint32_t i,j=(x1-x0+1)*(y1-y0+1);
  uint8_t b1,b2,r,g,b;

  S6B33BG_SetWindow(x0,y0,x1,y1);

  r=color>>16;
  g=color>>8;
  b=color;

  switch(S6B33BG_color_mode) {
    case COLOR_12BIT:
      b1=(r&0xF0)>>4;
      b2=(g&0xF0)|((b&0xF0)>>4);
      break;
    case COLOR_16BIT:
      b1=(r&0xF8)|((g&0xE0)>>5);
      b2=((g&0x1C)<<3)|((b&0xF8)>>3);
      break;
  }

  for(i=0;i<j;i++) {
    wr_dat(b1);
    wr_dat(b2);
  }
}
Ejemplo n.º 3
0
void GLCD_bitmap (unsigned int x, unsigned int y, unsigned int w, unsigned int h, const unsigned short *bitmap) {
  unsigned int   i;
  unsigned int   len = w*h;
  const unsigned short *bitmap_ptr = (const unsigned short *)bitmap;

#ifdef ILI9341
  ili9341_set_window (x, x + w-1, y, y + h - 1);
  for (i = 0; i < len; i++) {
    wr_dat(*bitmap_ptr++);
  }
#else
  wr_reg(0x50, y);                      /* Horizontal GRAM Start Address      */
  wr_reg(0x51, y+h-1);                  /* Horizontal GRAM End   Address (-1) */
  wr_reg(0x52, x);                      /* Vertical   GRAM Start Address      */
  wr_reg(0x53, x+w-1);                  /* Vertical   GRAM End   Address (-1) */

  wr_reg(0x20, y);
  wr_reg(0x21, x);

  Clr_Cs;
  wr_cmd(0x22);
  for (i = 0; i < len; i++) {
    wr_dat(*bitmap_ptr++);
  }
  Set_Cs;
#endif
}
Ejemplo n.º 4
0
void NokiaN70_SetPixel(uint16_t x, uint16_t y, uint32_t color) {

  uint8_t r,g,b;

  NokiaN70_SetWriteWindow(x,y,x,y);

  r=color>>16;
  g=color>>8;
  b=color;

  switch(NokiaN70_color_mode) {
    case COLOR_12BIT:
      wr_dat((r&0xF0)|(g>>4));
      wr_dat((b&0xF0)|(r>>4));
      wr_dat((g&0xF0)|(b>>4));
      break;
    case COLOR_16BIT:
      wr_dat((r&0xF8)|((g>>5)&0x07));
      wr_dat(((g<<3)&0xE0)|((b>>3)&0x1F));
      break;
    case COLOR_18BIT:
      wr_dat(r&0xFC);
      wr_dat(g&0xFC);
      wr_dat(b&0xFC);
      break;
  }
}
Ejemplo n.º 5
0
void NokiaN70_PartialArea(uint16_t y0,uint16_t y1) {
  wr_cmd(PARTIAL_AREA);
  wr_dat(y0>>8);
  wr_dat(y0);
  wr_dat(y1>>8);
  wr_dat(y1);
}
Ejemplo n.º 6
0
/*******************************************************************************
* Draw character on given position (line, coloum                               *
*   Parameter:     x :        horizontal position                              *
*                  y :        vertical position                                *
*                  c*:        pointer to color value                           *
*   Return:                                                                    *
*******************************************************************************/
void GLCD_drawChar(unsigned int x, unsigned int y, unsigned short *c) {
    unsigned int index = 0;
    int  i = 0;
    unsigned int Xaddress = 0;

    Xaddress = x;

    wr_reg(0x20, Xaddress);
    wr_reg(0x21, y);

    for(index = 0; index < 24; index++)
    {
        wr_cmd(0x22);              /* Prepare to write GRAM */
        for(i = 15; i >= 0; i--)
//    for(i = 0; i < 16; i++)
        {
            if((c[index] & (1 << i)) == 0x00) {
                wr_dat(BackColor);
            } else {
                wr_dat(TextColor);
            }
        }
        Xaddress++;
        wr_reg(0x20, Xaddress);
        wr_reg(0x21, y);
    }
}
Ejemplo n.º 7
0
/*******************************************************************************
* Draw character on given position (line, coloum                               *
*   Parameter:     x :        horizontal position                              *
*                  y :        vertical position                                *
*                  c*:        pointer to color value                           *
*   Return:                                                                    *
*******************************************************************************/
void GLCD_drawChar(unsigned int x, unsigned int y, unsigned short *c) {

#ifdef ILI9341

  unsigned int index = 0;
  int  i = 0;

  ili9341_set_window (y, y + 15, x, x + 23);  

  for(index = 0; index < 24; index++)
  {
    for(i = 0; i < 16; i++)
    {
      if((c[index] & (1 << i)) == 0x00) {
         wr_dat(BackColor);
      } else {
         wr_dat(TextColor);
      }
    }
  } 	

#else /* ILI9341 */

  unsigned int index = 0;
  int  i = 0;
  unsigned int Xaddress = 0;   

  Xaddress = x;

  wr_reg(0x21, y);
  wr_reg(0x20, Xaddress);


  for(index = 0; index < 24; index++)
  {
  	Clr_Cs;
    wr_cmd(0x22);              /* Prepare to write GRAM */

    for(i = 0; i <= 15; i++)
    {
      if((c[index] & (1 << i)) == 0x00) {
         wr_dat(BackColor);
      } else {
         wr_dat(TextColor);
      }
    }

	Set_Cs;

    Xaddress++;

	wr_reg(0x21, y);
    wr_reg(0x20, Xaddress);
  }

#endif /* ILI9341 */

}
Ejemplo n.º 8
0
void NokiaN70_ScrollArea(uint16_t y,uint16_t pos) {
  uint16_t bfa=208-pos-y;
  wr_cmd(VERTICAL_SCROLLING_DEFINITION);
  wr_dat(y>>8);
  wr_dat(y);
  wr_dat(pos>>8);
  wr_dat(pos);
  wr_dat(bfa>>8);
  wr_dat(bfa);
}
Ejemplo n.º 9
0
void NokiaN70_FillFromBuffer(uint16_t x0,uint16_t y0,uint16_t x1,uint16_t y1,uint8_t *data) {

  uint32_t i,j=(x1-x0+1)*(y1-y0+1);

  NokiaN70_SetWriteWindow(x0,y0,x1,y1);

  switch(NokiaN70_color_mode) {
    case COLOR_12BIT:
      // always writing even count of pixels
      for(i=0;i<j;i+=2) {
        wr_dat(*data++);
        wr_dat(*data++);
        wr_dat(*data++);
      }
      break;
    case COLOR_16BIT:
      for(i=0;i<j;i++) {
        wr_dat(*data++);
        wr_dat(*data++);
      }
      break;
    case COLOR_18BIT:
      for(i=0;i<j;i++) {
        wr_dat(*data++);
        wr_dat(*data++);
        wr_dat(*data++);
      }
      break;
  }
}
Ejemplo n.º 10
0
void NokiaN70_SetWindow(uint16_t x0,uint16_t y0,uint16_t x1,uint16_t y1) {

  wr_cmd(COLUMN_ADDRESS_SET);
  wr_dat(x0>>8);
  wr_dat(x0);
  wr_dat(x1>>8);
  wr_dat(x1);

  wr_cmd(PAGE_ADDRESS_SET);
  wr_dat(y0>>8);
  wr_dat(y0);
  wr_dat(y1>>8);
  wr_dat(y1);
}
Ejemplo n.º 11
0
Archivo: lcd.c Proyecto: epffpe/Atmel
static inline void wr_reg (unsigned char reg, unsigned short val) {

  LCD_CS(0)
  wr_cmd(reg);
  wr_dat(val);
  LCD_CS(1)
}
Ejemplo n.º 12
0
void NokiaN70_SetPixel16(uint16_t x, uint16_t y, uint16_t color) {

  NokiaN70_SetWriteWindow(x,y,x,y);

  wr_dat(color>>8);
  wr_dat(color);
}
Ejemplo n.º 13
0
void NokiaN70_FillPixel(uint16_t x0,uint16_t y0,uint16_t x1,uint16_t y1,uint32_t *color) {

  uint32_t i,j=(x1-x0+1)*(y1-y0+1);

  NokiaN70_SetWriteWindow(x0,y0,x1,y1);

  switch(NokiaN70_color_mode) {
    case COLOR_12BIT:
      for(i=0;i<j;i+=2) {
        wr_dat(((color[i]>>16)&0xF0)|((color[i]>>12)&0x0F));
        wr_dat(((color[i])&0xF0)|((color[i+1]>>16)&0x0F));
        wr_dat(((color[i+1]>>8)&0xF0)|((color[i+1]>>4)&0x0F));
      }
      break;
    case COLOR_16BIT:
      for(i=0;i<j;i++) {
        wr_dat(((color[i]>>16)&0xF8)|(((color[i]>>13)&0x07)));
        wr_dat(((color[i]>>5)&0xE0)|((color[i]>>3)&0x1F));
      }
      break;
    case COLOR_18BIT:
      for(i=0;i<j;i++) {
        wr_dat((color[i]>>16)&0xFC);
        wr_dat((color[i]>>8)&0xFC);
        wr_dat((color[i])&0xFC);
      }
      break;
  }
}
Ejemplo n.º 14
0
static __inline void wr_reg (unsigned char reg, unsigned short val) {

  	Clr_Cs;
	wr_cmd(reg);      
	wr_dat(val);    
	Set_Cs; 
}
Ejemplo n.º 15
0
void GLCD_clear (unsigned short color) {
    unsigned int   i;

    wr_reg(0x20, 0);
    wr_reg(0x21, 0);
    wr_cmd(0x22);
    for(i = 0; i < (WIDTH*HEIGHT); i++)
        wr_dat(color);
}
Ejemplo n.º 16
0
Archivo: lcd.c Proyecto: epffpe/Atmel
void GLCD_PutPixel (unsigned int x, unsigned int y) {

  wr_reg(0x20, y);
  wr_reg(0x21, WIDTH-1-x);
  LCD_CS(0)
  wr_cmd(0x22);
  wr_dat(TextColor);
  LCD_CS(1)
}
Ejemplo n.º 17
0
Archivo: GLCD.c Proyecto: Nihilus89/ECG
/**
  * @brief  Displays a line.
  * @param  Xpos: specifies the X position.
  * @param  Ypos: specifies the Y position.
  * @param  Length: line length.
  * @param  Direction: line direction.
  *   This parameter can be one of the following values: Vertical or Horizontal.
  * @retval None
  */
void GLCD_drawLine(uint8_t Xpos, uint16_t Ypos, uint16_t Length, uint8_t Direction) {
  u16 i;

  wr_reg(0x21, Ypos);

  if (Direction == Horizontal) {
    wr_reg(0x20, Xpos);
    wr_cmd(0x22);
    for(i = 0; i < Length; i++)
      wr_dat(TextColor);
  } else {
    for(i = 0; i < Length; i++) {
      wr_reg(0x20, Xpos);
      wr_cmd(0x22);
      wr_dat(TextColor);
	  ++Xpos;
    }
  }
}
Ejemplo n.º 18
0
void GLCD_putPixel(unsigned int x, unsigned int y) {

#ifdef ILI9341
    GLCD_SetCursor(x, y);
	wr_dat(TextColor);
#else
    wr_reg(0x20, x);
    wr_reg(0x21, y);
    wr_reg(0x22,Red);
#endif
}
Ejemplo n.º 19
0
static void ili9341_display_color (unsigned short data)
{
    unsigned int i, j;

    // ili9341_set_window(50, 50 + 16, 50, 50 + 24);

    for(i = 0; i < (WIDTH*HEIGHT); i++)
    {
  	  wr_dat(BackColor);
    }
}
Ejemplo n.º 20
0
void S6B33BG_SetPixel(uint8_t x, uint8_t y, uint32_t color) {

  uint8_t r,g,b,b1,b2;

  S6B33BG_SetWindow(x,y,x,y);

  r=color>>16;
  g=color>>8;
  b=color;

  switch(S6B33BG_color_mode) {
    case COLOR_12BIT:
      b1=(r&0xF0)>>4;
      b2=(g&0xF0)|((b&0xF0)>>4);
      break;
    case COLOR_16BIT:
      b1=(r&0xF8)|((g>>5)&0x07);
      b2=((g<<3)&0x0E)|((b>>3)&0x1F);
      break;
  }
  wr_dat(b1);
  wr_dat(b2);
}
Ejemplo n.º 21
0
void GLCD_clear (unsigned short color) {
  unsigned int   i;

#ifdef ILI9341

    ili9341_set_window(0, WIDTH, 0, HEIGHT);

    for(i = 0; i < (WIDTH*HEIGHT); i++)
    {
  	  wr_dat(color);
    }

#else
  wr_reg(0x20, 0);
  wr_reg(0x21, 0);
  Clr_Cs;
  wr_cmd(0x22);
  for(i = 0; i < (WIDTH*HEIGHT); i++)
  {
  	wr_dat(color);
  }
  Set_Cs;
#endif    
}
Ejemplo n.º 22
0
void NokiaN70_ColorMode(COLOR_MODE color_mode) {

  uint32_t i;

  NokiaN70_color_mode=color_mode;
  wr_reg(INTERFACE_PIXEL_FORMAT,NokiaN70_color_mode);

  switch(NokiaN70_color_mode) {
    case COLOR_12BIT:
      wr_cmd(COLOUR_SET);
      for(i=0;i<128;i++) {
        wr_dat(RGB12bit[i]);
      }
      break;
    case COLOR_16BIT:
      wr_cmd(COLOUR_SET);
      for(i=0;i<128;i++) {
        wr_dat(RGB16bit[i]);
      }
      break;
    case COLOR_18BIT:
      break;
  }
}
Ejemplo n.º 23
0
void S65L2F50::setOrientation(uint_least16_t o)
{
  uint_least8_t p;

       if((o ==   9) || 
          (o ==  90))
  {
    //not implemented
    p = 0;
  }

  else if((o ==  18) || 
          (o == 180))
  {
    lcd_orientation = 180;
    lcd_width  = LCD_WIDTH;
    lcd_height = LCD_HEIGHT;
    p = 0x2A; //565 mode, 0x2A=normal, 0x2B=180
  }

  else if((o ==  27) || 
          (o ==  14) || 
          (o == 270))
  {
    //not implemented
    p = 0;
  }

  else
  {
    lcd_orientation = 0;
    lcd_width  = LCD_WIDTH;
    lcd_height = LCD_HEIGHT;
    p = 0x2B; //565 mode, 0x2A=normal, 0x2B=180
  }

  if(p != 0)
  {
    wr_cmd(0xBC); //data control
    wr_dat(p); //565 mode, 0x2A=normal, 0x2B=180
  }

  setArea(0, 0, lcd_width-1, lcd_height-1);

  return;
}
Ejemplo n.º 24
0
void GLCD_bitmap (unsigned int x, unsigned int y, unsigned int w, unsigned int h, unsigned char *bitmap) {
    unsigned int   i;
    unsigned int   len = w*h;
    unsigned short *bitmap_ptr = (unsigned short *)bitmap;

    wr_reg(0x50, y);                      /* Horizontal GRAM Start Address      */
    wr_reg(0x51, y+h-1);                  /* Horizontal GRAM End   Address (-1) */
    wr_reg(0x52, x);                      /* Vertical   GRAM Start Address      */
    wr_reg(0x53, x+w-1);                  /* Vertical   GRAM End   Address (-1) */

    wr_reg(0x20, y);
    wr_reg(0x21, x);

    wr_cmd(0x22);
    for (i = 0; i < len; i++) {
        wr_dat(*bitmap_ptr++);
    }
}
Ejemplo n.º 25
0
void NokiaN70_Fill(uint16_t x0,uint16_t y0,uint16_t x1,uint16_t y1,uint32_t color) {

  uint32_t i,j=(x1-x0+1)*(y1-y0+1);
  uint8_t b1,b2,b3,r,g,b;

  NokiaN70_SetWriteWindow(x0,y0,x1,y1);

  r=color>>16;
  g=color>>8;
  b=color;

  switch(NokiaN70_color_mode) {
    case COLOR_12BIT:
      b1=(r&0xF0)|(g>>4);
      b2=(b&0xF0)|(r>>4);
      b3=(g&0xF0)|(b>>4);
      for(i=0;i<j;i+=2) {
        wr_dat(b1);
        wr_dat(b2);
        wr_dat(b3);
      }
      break;
    case COLOR_16BIT:
      b1=(r&0xF8)|((g&0xE0)>>5);
      b2=((g&0x1C)<<3)|((b&0xF8)>>3);
      for(i=0;i<j;i++) {
        wr_dat(b1);
        wr_dat(b2);
      }
      break;
    case COLOR_18BIT:
      for(i=0;i<j;i++) {
        wr_dat(r&0xFC);
        wr_dat(g&0xFC);
        wr_dat(b&0xFC);
      }
      break;
  }
}
Ejemplo n.º 26
0
/****************************************************************************
* 名    称:void GLCD_Test(void)
* 功    能:测试液晶屏
* 入口参数:无
* 出口参数:无
* 说    明:显示彩条,测试液晶屏是否正常工作
* 调用方法:GLCD_Test();
****************************************************************************/
void GLCD_Test(void)
{
    u16 i,j;
    wr_reg(0x20, 0);
    wr_reg(0x21, 0);

    Clr_Cs;
    wr_cmd(0x22);

    for(i=0; i<320; i++)
        for(j=0; j<240; j++)
        {
            if(i>279)wr_dat(0x0000);
            else if(i>239)wr_dat(0x001f);
            else if(i>199)wr_dat(0x07e0);
            else if(i>159)wr_dat(0x07ff);
            else if(i>119)wr_dat(0xf800);
            else if(i>79)wr_dat(0xf81f);
            else if(i>39)wr_dat(0xffe0);
            else wr_dat(0xffff);
        }
    Set_Cs;
}
Ejemplo n.º 27
0
void TFT_ILI9325::wr_reg(uint8_t reg, uint16_t val) {
	wr_cmd(reg);
	wr_dat(val);
}
Ejemplo n.º 28
0
void S65L2F50::setArea(int_least16_t x0, int_least16_t y0, int_least16_t x1, int_least16_t y1)
{
  switch(lcd_orientation)
  {
    default:
    case 0:
      wr_cmd(0x15);                   //column address set 
      wr_dat(0x08+y0);                //start column
      wr_dat(0x01);                   //start column
      wr_dat(0x08+y1);                //end column
      wr_dat(0x01);                   //end column
      wr_cmd(0x75);                   //page address set 
      wr_dat(x0);                     //start page
      wr_dat(x1);                     //end page
      break;
    //case 90:
      //not implemented
    //  break;
    case 180:
      wr_cmd(0x15);                   //column address set 
      wr_dat(0x08+(LCD_HEIGHT-1)-y1); //start column
      wr_dat(0x01);                   //start column
      wr_dat(0x08+(LCD_HEIGHT-1)-y0); //end column
      wr_dat(0x01);                   //end column
      wr_cmd(0x75);                   //page address set 
      wr_dat(x0);                     //start page
      wr_dat(x1);                     //end page
      break;
    //case 270:
      //not implemented
    //  break;
  }

  return;
}
Ejemplo n.º 29
0
void GLCD_putPixel(unsigned int x, unsigned int y) {
    wr_reg(0x20, x);
    wr_reg(0x21, y);
    wr_cmd(0x22);
    wr_dat(TextColor);
}
Ejemplo n.º 30
0
static __inline void wr_reg (unsigned char reg, unsigned short val) {

    wr_cmd(reg);
    wr_dat(val);
}