Пример #1
0
static ucg_int_t ucg_handle_ld50t6160_l90tc(ucg_t *ucg)
{
  if ( ucg_clip_l90tc(ucg) != 0 )
  {
    uint8_t buf[3];
    ucg_int_t dx, dy;
    ucg_int_t i;
    const uint8_t *seq;
    unsigned char pixmap;
    uint8_t bitcnt;
    ucg_com_SetCSLineStatus(ucg, 0);		/* enable chip */
    switch(ucg->arg.dir)
    {
      case 0: 
	dx = 1; dy = 0; 
	seq = ucg_ld50t6160_set_pos_dir0_seq;
	break;
      case 1: 
	dx = 0; dy = 1; 
	seq = ucg_ld50t6160_set_pos_dir1_seq;
	break;
      case 2: 
	dx = -1; dy = 0; 
	seq = ucg_ld50t6160_set_pos_dir2_seq;
	break;
      case 3: 
      default:
	dx = 0; dy = -1; 
	seq = ucg_ld50t6160_set_pos_dir3_seq;
	break;
    }
    pixmap = ucg_pgm_read(ucg->arg.bitmap);
    bitcnt = ucg->arg.pixel_skip;
    pixmap <<= bitcnt;
    buf[0] = ucg->arg.pixel.rgb.color[0]>>2;
    buf[1] = ucg->arg.pixel.rgb.color[1]>>2;
    buf[2] = ucg->arg.pixel.rgb.color[2]>>2;
    
    for( i = 0; i < ucg->arg.len; i++ )
    {
      if ( (pixmap & 128) != 0 )
      {
	ucg_com_SendCmdSeq(ucg, seq);	
	ucg_com_SendRepeat3Bytes(ucg, 1, buf);
      }
      pixmap<<=1;
      ucg->arg.pixel.pos.x+=dx;
      ucg->arg.pixel.pos.y+=dy;
      bitcnt++;
      if ( bitcnt >= 8 )
      {
	ucg->arg.bitmap++;
	pixmap = ucg_pgm_read(ucg->arg.bitmap);
	bitcnt = 0;
      }
    }
    ucg_com_SetCSLineStatus(ucg, 1);		/* disable chip */
    return 1;
  }
Пример #2
0
/*
  handle UCG_MSG_DRAW_L90FB message and make calls to "dev_cb" with UCG_MSG_DRAW_PIXEL
  return 1 if something has been drawn
*/
ucg_int_t ICACHE_FLASH_ATTR ucg_handle_l90bf(ucg_t *ucg, ucg_dev_fnptr dev_cb)
{
  if ( ucg_clip_l90tc(ucg) != 0 )
  {
    ucg_int_t dx, dy;
    ucg_int_t i, y;
    unsigned char pixmap;
    uint8_t bitcnt;
    switch(ucg->arg.dir)
    {
      case 0: dx = 1; dy = 0; break;
      case 1: dx = 0; dy = 1; break;
      case 2: dx = -1; dy = 0; break;
      case 3: dx = 0; dy = -1; break;
      default: dx = 1; dy = 0; break;	/* avoid compiler warning */
    }
    pixmap = ucg_pgm_read(ucg->arg.bitmap);
    bitcnt = ucg->arg.pixel_skip;
    pixmap <<= bitcnt;
    for( i = 0; i < ucg->arg.len; i++ )
    {
      for( y = 0; y < ucg->arg.scale; y++ )
      {
	if ( (pixmap & 128) == 0 )
	{
	  ucg->arg.pixel.rgb = ucg->arg.rgb[1];
	  dev_cb(ucg, UCG_MSG_DRAW_PIXEL, NULL);
	}
	else
	{
	  ucg->arg.pixel.rgb = ucg->arg.rgb[0];
	  dev_cb(ucg, UCG_MSG_DRAW_PIXEL, NULL);
	}
	ucg->arg.pixel.pos.x+=dx;
	ucg->arg.pixel.pos.y+=dy;
      }
      pixmap<<=1;
      bitcnt++;
      if ( bitcnt >= 8 )
      {
	ucg->arg.bitmap++;
	pixmap = ucg_pgm_read(ucg->arg.bitmap);
	bitcnt = 0;
      }
    }
    return 1;
  }
  return 0;
}
Пример #3
0
/* with CmdDataSequence */ 
ucg_int_t ICACHE_FLASH_ATTR ucg_handle_st7735_l90tc(ucg_t *ucg)
{
  if ( ucg_clip_l90tc(ucg) != 0 )
  {
    uint8_t buf[16];
    ucg_int_t dx, dy;
    ucg_int_t i;
    unsigned char pixmap;
    uint8_t bitcnt;
    ucg_com_SetCSLineStatus(ucg, 0);		/* enable chip */
    ucg_com_SendCmdSeq(ucg, ucg_st7735_set_pos_seq);	

    buf[0] = 0x001;	// change to 0 (cmd mode)
    buf[1] = 0x02a;	// set x
    buf[2] = 0x002;	// change to 1 (arg mode)
    buf[3] = 0x000;	// upper part x
    buf[4] = 0x000;	// no change
    buf[5] = 0x000;	// will be overwritten by x value
    buf[6] = 0x001;	// change to 0 (cmd mode)
    buf[7] = 0x02c;	// write data
    buf[8] = 0x002;	// change to 1 (data mode)
    buf[9] = 0x000;	// red value
    buf[10] = 0x000;	// no change
    buf[11] = 0x000;	// green value
    buf[12] = 0x000;	// no change
    buf[13] = 0x000;	// blue value      
    
    switch(ucg->arg.dir)
    {
      case 0: 
	dx = 1; dy = 0; 
	buf[1] = 0x02a;	// set x
	break;
      case 1: 	
	dx = 0; dy = 1; 
        buf[1] = 0x02b;	// set y
	break;
      case 2: 
	dx = -1; dy = 0; 
        buf[1] = 0x02a;	// set x
	break;
      case 3: 
      default:
	dx = 0; dy = -1; 
        buf[1] = 0x02b;	// set y
	break;
    }
    pixmap = ucg_pgm_read(ucg->arg.bitmap);
    bitcnt = ucg->arg.pixel_skip;
    pixmap <<= bitcnt;
    buf[9] = ucg->arg.pixel.rgb.color[0];
    buf[11] = ucg->arg.pixel.rgb.color[1];
    buf[13] = ucg->arg.pixel.rgb.color[2];
    //ucg_com_SetCSLineStatus(ucg, 0);		/* enable chip */
    
    for( i = 0; i < ucg->arg.len; i++ )
    {
      if ( (pixmap & 128) != 0 )
      {
	if ( (ucg->arg.dir&1) == 0 )
	{
	  buf[5] = ucg->arg.pixel.pos.x;
	}
	else
	{
	  buf[3] = ucg->arg.pixel.pos.y>>8;
	  buf[5] = ucg->arg.pixel.pos.y&255;
	}
	ucg_com_SendCmdDataSequence(ucg, 7, buf, 0);
      }
      pixmap<<=1;
      ucg->arg.pixel.pos.x+=dx;
      ucg->arg.pixel.pos.y+=dy;
      bitcnt++;
      if ( bitcnt >= 8 )
      {
	ucg->arg.bitmap++;
	pixmap = ucg_pgm_read(ucg->arg.bitmap);
	bitcnt = 0;
      }
    }
    ucg_com_SetCSLineStatus(ucg, 1);		/* disable chip */
    return 1;
  }