/*=====================================================================================================*/
void LCD_DrawLineY( u16 CoordiX, u16 CoordiY, u16 Length, u16 Color )
{
  LCD_SetWindow(CoordiX, CoordiY, CoordiX, CoordiY+Length-1);

  while(Length--)
    LCD_WriteColor(Color);
}
Пример #2
0
void LCD_PutPixel_HX8347A(uint16_t x, uint16_t y)
{
	LCD_SetWindow(x, y, x, y);
	LCD_WriteRAM_Prepare();
	LCD_WriteRAM(TextColor>>16);
	LCD_WriteRAM(TextColor);
}
Пример #3
0
void LCD_Rectangle(u16 x0, u16 y0, u16 x1, u16 y1,u16 color, u16 fillColor)
{
	if(x0>x1){
		x0 = x0 + x1;
		x1 = x0 - x1;
		x0 = x0 - x1;
	}
	if(y0>y1){
			y0 = y0 + y1;
			y1 = y0 - y1;
			y0 = y0 - y1;
	}
	if(fillColor!=Transparent){
		if(color==Transparent) {
			x0++;x1--;y0++;y1--;
		}
		LCD_SetWindow(x0,y0,x1,y1);
		u32 i;
		LCD_PrepareWrite();
		u32 c = (x1-x0+1)*(y1-y0+1);
		for(i=0; i<c; i++)
			LCD_WriteWord(fillColor);
		LCD_ResetWindow();
		if(color==fillColor || color==Transparent)
			return;
	}

	LCD_Line(x0,y0,x0,y1,color);
	LCD_Line(x0,y1,x1,y1,color);
	LCD_Line(x1,y1,x1,y0,color);
	LCD_Line(x1,y0,x0,y0,color);
}
/*=====================================================================================================*/
void LCD_DrawRectangleFill( u16 CoordiX, u16 CoordiY, u16 Width, u16 Height, u16 Color )
{
  u32 Area = Width*Height;

  LCD_SetWindow(CoordiX, CoordiY, CoordiX+Width-1, CoordiY+Height-1);

	while(Area--)
		LCD_WriteColor(Color);
}
/*=====================================================================================================*/
void LCD_Clear( u16 Color )
{
  u32 Area = LCD_W*LCD_H;

  LCD_SetWindow(0, 0, LCD_W-1, LCD_H-1);

	while(Area--)
		LCD_WriteColor(Color);
}
/*=====================================================================================================*/
void LCD_Clear( u16 Color )
{
  u32 Point = LCD_W*LCD_H;

  LCD_SetWindow(0, 0, LCD_W-1, LCD_H-1);

	while(Point--)
		LCD_WriteColor(Color);
}
/*====================================================================================================*/
void LCD_Clear( uint16_t Color )
{
  uint32_t Point = LCD_W * LCD_H;

  LCD_SetWindow(0, 0, LCD_W-1, LCD_H-1);

  while(Point--)
    LCD_WriteColor(Color);
}
/*=====================================================================================================*/
void LCD_DrawPicture( u16 CoordiX, u16 CoordiY, u16 Width, u16 Height, uc8 *Pic )
{
  u16* readPixel = (u16*)Pic;
  u32 i = 0, j = Height*Width;

  LCD_SetWindow(CoordiX, CoordiY, CoordiX+Width-1, CoordiY+Height-1);

  for(i=0; i<j; i++)
    LCD_WriteColor(readPixel[i]);
}
/*====================================================================================================*/
void LCD_DrawPicture( uint16_t CoordiX, uint16_t CoordiY, uint16_t Width, uint16_t Height, const uint8_t *Pic )
{
  uint16_t *readPixel = (uint16_t*)Pic;
  uint32_t i = 0, j = Height * Width;

  LCD_SetWindow(CoordiX, CoordiY, CoordiX+Width-1, CoordiY+Height-1);

  for(i = 0; i < j; i++)
    LCD_WriteColor(readPixel[i]);
}
Пример #10
0
/**
 *  A routine that very slowly fills the screen with a color
 */
void paint(unsigned int color) {
    int i,j;
    LCD_SetWindow(0,0,239,400);

    for(i = 0; i < 400; i++) {
        for(j = 0; j < 240; j++) {
            LCD_Write_Data(color);
        }
    }
}
Пример #11
0
void LCD_DrawChar_HX8347A(uint16_t Xpos, uint16_t Ypos, uint16_t codeChar)
{
	uint32_t index = 0, i = 0, numByte, width, bitCounter, ptrByte;
	// Symbol width
	if (codeChar > LCD_Currentfonts->NumSymb) codeChar = 0;
	if (LCD_Currentfonts->Width)
	{
		width = LCD_Currentfonts->Width;
		LCD_SetWindow(Xpos, Ypos, Xpos+width-1, Ypos+LCD_Currentfonts->Height-1);
	}
	else
	{
		width = LCD_Currentfonts->tableSymbWidth[codeChar];
		LCD_SetWindow(Xpos, Ypos, Xpos+width+LCD_Currentfonts->SymbolSpace-1, Ypos+LCD_Currentfonts->Height-1);
	}
	numByte = LCD_Currentfonts->Height * ((width+7)/8);

	LCD_WriteRAM_Prepare(); /* Prepare to write GRAM */
	// Draw Char
	for(index = 0; index < numByte; index++)
	{
		bitCounter = 0;
		for(i = 0; i < width; i++)
		{

			if (bitCounter > 7)
			{
				bitCounter = 0;
				index++;
			}
			ptrByte = LCD_Currentfonts->table[LCD_Currentfonts->tableSymbIndex[codeChar]+index];
			if(ptrByte & (1<<bitCounter))
			{
				LCD_WriteRAM(TextColor>>16);
				LCD_WriteRAM(TextColor);
			}
			else
			{
				LCD_WriteRAM(BackColor>>16);
				LCD_WriteRAM(BackColor);
			}
			bitCounter++;
		}
Пример #12
0
/*====================================================================================================*/
void LCD_DrawPicture( uint16_t coordiX, uint16_t coordiY, uint16_t width, uint16_t height, const uint8_t *pic )
{
  uint16_t *readPixel = (uint16_t*)pic;
  uint32_t i = 0, j = height * width;

  LCD_SetWindow(coordiX, coordiY, coordiX + width - 1, coordiY + height - 1);

  for(i = 0; i < j; i++)
    LCD_WriteColor(readPixel[i]);
}
Пример #13
0
//清屏
void LCD_Clear(u16 Color)
{
	u16 i,j;	
	LCD_SetWindow(0,0,LCD_WIDTH-1,LCD_HEIGHT-1);
	for(i=0;i<LCD_WIDTH;i++)
  {
		for (j=0;j<LCD_HEIGHT;j++)
		{
				 LCD_WR_DATA(Color);
		}
	}
}
Пример #14
0
void long_shadow(){ // WE LOVE IT! NO ANTIALIAS!!
	s16 x, y;
	LCD_SetWindow(30, 30, 210, 210);
	for (y=30;y<240;y++)for (x=30;x<240;x++){
		if (((x-120)*(x-120)+(y-120)*(y-120)<119*119)&&
			(x>y-138)&&(x<y+138)&&(x+y>240))
				LCD_MixPixel_x32(0x0, 12);
		else
			LCD_GetPixel();
	}

}
Пример #15
0
/**
 *  A simple cog for painting the screen
 */
void LCD_Run(void) {

    FILE *fp;
    uint8_t buffer[500];
    uint16_t x, y, i, j;
    int dataOffset;
    int size;
    int counter = 0;

    LCD_Init();

    // Initialize the interface to the SD card
    sd_mount(SD_DO, SD_SCK, SD_DI, SD_SS);

    while(1) {
//    paint(0xF800);
//    pause(100);
//    paint(0x07E0);
//    pause(100);
//    paint(0x001F);
//    pause(100);

        // Open the first image
        if(counter == 0) {
            fp = fopen("1.bmp", "r");
            counter++;
        }
        else {
            fp = fopen("2.bmp", "r");
            counter = 0;
        }

        // Read in the header
        fread(buffer, 1, 54, fp);
        // Get the size of the image
        // 16 bit numbers, do some bit shifting
        x = buffer[18] + (buffer[19] << 8);
        y = buffer[22] + (buffer[23] << 8);
        //size = buffer[2] | (buffer[3] << 8) | (buffer[4] << 16) | (buffer[5] << 24);
        dataOffset = buffer[10] | (buffer[11] << 8) | (buffer[12] << 16) | (buffer[13] << 24);

        // Seek the file pointer to the start of the pixel data
        fseek(fp, dataOffset, SEEK_SET);


        LCD_SetWindow(0,0,239,400);

        for(i = 0; i < y; i++) {

            // Read a line in
            fread(buffer, 1, x * 2, fp);

            for(j = 0; j < x * 2; j += 2) {
                // Write the pixel data out to the display
                // Note that the pixel data is the Red, Green, Blue data in the 565 format, ie:
                //
                // Bit 0  1  2  3  4  5  6  7    8  9  10 11 12 13 14 15
                // Use B1 B2 B3 B4 B5 G0 G1 G2   G3 G4 G5 R1 R2 R3 R4 R5
                //
                // Notice that we only have 5 bits of Blue and Red?  The human eye is more sensitive
                // to the color green, so to make the RGB fit into 16 bits it is given priority
                LCD_Write_Data((buffer[j]) + (buffer[j+1] << 8));
            }
        }

        // Close and prepare for the next file
        fclose(fp);

    }
}
Пример #16
0
int main(){
	SysTick_Config(SystemCoreClock / 2000);  // 0.5ms

	// NEED OF KEY AND LED
	RCC_ClockSecuritySystemCmd(ENABLE);
	RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE);
	GPIO_InitTypeDef GPIO_InitStructure;
	GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
	GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5;
	GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
	GPIO_Init(GPIOB, &GPIO_InitStructure);
	GPIO_InitStructure.GPIO_Pin = GPIO_Pin_15;
	GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;
	GPIO_Init(GPIOB, &GPIO_InitStructure);

	// Init LCD
	LCD_Cmd_InitFSMC();
	LCD_Cmd_Init();
	LCD_Cmd_InitBacklight();

	// Put some background
//	LCD_FillRectangle_RGB565(0, 0, 240, 320, C_RGB565(0x80, 0x80, 0x80));
	Painter_PutImage(res_img_res_lp_jpg,0,0,0xff);

//	Painter_SetupContextBitmask(240, 320, 0);
//	benchmark(2);

	// A circle to overlay long shadow
	LCD_FillCircle_RGB4444(120, 120, 100+18, 0x88fa);

	// now you can see it
	long_shadow();
	// an alternative shadow
//	LCD_FillCircle(120+1, 120+1, 100+2, 0x8886, 0);
//	LCD_FillCircle(120, 120, 100+2, 0x8886, 0);
//	LCD_FillCircle(120, 120, 100+1, 0x8886, 0);

	// Put my clock panel on screen
	LCD_FillCircle_RGB565(120, 120, 100, C_RGB565(0, 0, 0));
	LCD_FillCircle_RGB565(120, 120, 90, C_RGB565(0xff, 0xff, 0xff));

	// Clock frame need some shadow!
	Painter_SetupContextBitmask(210, 210, 0);
	u16 x, y, i;
	u32 t;
	for (x=0;x<200;x++) for (y=0;y<200;y++){
		t = (x-100)*(x-100)+(y-100)*(y-100);
		if ((t>=91*91)&&(t<100*100)) LCD_SetBitMask(_d_dl_ctx.bm, x, y, 210);
	}

	// Draw ticks and numbers
	const s8 TICK_XI[] = { 0,  42,  73,  85,  73,  42,   0, -42, -73, -85, -73, -42};
	const s8 TICK_YI[] = {-85, -73, -42,   0,  42,  73,  85,  73,  42,   0, -42, -73};
	const s8 TICK_XO[] = { 0,  44,  77,  90,  77,  45,   0, -44, -77, -90, -77, -45};
	const s8 TICK_YO[] = {-90, -77, -45,   0,  44,  77,  90,  77,  45,   0, -44, -77};
	const u16 *text[] = {res_string_0/*_FSTR_0*/,
			res_string_1/*_FSTR_1*/,
			res_string_2/*_FSTR_2*/,
			res_string_3/*_FSTR_3*/,
			res_string_4/*_FSTR_4*/,
			res_string_5/*_FSTR_5*/,
			res_string_6/*_FSTR_6*/,
			res_string_7/*_FSTR_7*/,
			res_string_8/*_FSTR_8*/,
			res_string_9/*_FSTR_9*/,
			res_string_11/*_FSTR_10*/,
			res_string_12/*_FSTR_11*/,
			res_string_13/*_FSTR_12*/
			};
	const u16 *col = res_string_14/*_FSTR_:*/;
	const u16 *space = res_string_15/*_FSTR_ */;
	u16 time[20];

	for (i=0;i<12;i++){
		Painter_LocateContextBitmask(100+TICK_XO[i], 100+TICK_YO[i]);
		Painter_DrawLine(120+TICK_XO[i], 120+TICK_YO[i], 120+TICK_XI[i], 120+TICK_YI[i], 0x000f, 5, PAINTER_DRAW_BM_HOLD);
		Painter_PutString(text[i?i:12], 14, 0x000f, 0
						 , 120+TICK_XI[i]-(TICK_XO[i]-TICK_XI[i])*2-5, 120+TICK_YI[i]-(TICK_YO[i]-TICK_YI[i])*2-8
						 , 20, 20, PAINTER_STR_SHADOW*2);
	}

	// Bravo!
	Painter_Fill_BitMaskShadow(30, 30, 230, 230, 0L, 10, 10, 210, 0x0008, 4, 4, 15);

	// LET IT RUN!
	u8 m, s; // so-called second and minute
	bitmask bm;
	_UNUSED(bm);
	s = 0; m = 0;
	Painter_SetupContextBitmask(200, 200, 0); // new context for new shadow
	Painter_LocateContextBitmask(100, 100); // start from center
	u8 shadow_on;
	u16 bg[200*60];
	// grab screen region, saving for later repaint
	LCD_SetWindow(20, 240, 200, 60);
	LCD_GetImage_RGB565(bg, 200*60);
	while (1){
		// PUSH BUTTON TO RUN REALLY FAST, WITHOUT SHADOW!
		shadow_on = GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_15)?PAINTER_STR_SHADOW*2:0;
		LCD_FillCircle_RGB565(120, 120, 65, 0xffff); // Clear clock hands, sucks aha~
		// Dont forget bitmasks
		for (x=30;x<170;x++) for (y=30;y<170;y++){
			LCD_ResetBitMask(_d_dl_ctx.bm, x, y, 200);
		}
		// second hand
		u16 sh_x[] = {120, 120+(TICK_XI[_mod(s+11,12)]+3)/5,
					  120+TICK_XI[s]-(TICK_XO[s]-TICK_XI[s])*6,
					  120+(TICK_XI[_mod(s+1,12)]+3)/5
					 };
		u16 sh_y[] = {120, 120+(TICK_YI[_mod(s+11,12)]+3)/5,
					  120+TICK_YI[s]-(TICK_YO[s]-TICK_YI[s])*6,
					  120+(TICK_YI[_mod(s+1,12)]+3)/5
					 };
		// Center circle makes it cute~
		Painter_DrawCircle(120, 120, 4, 0x6a2f, 12, PAINTER_DRAW_BM_HOLD);
		Painter_DrawPoly(sh_x, sh_y, 4, 0x6a2f, 3, PAINTER_DRAW_BM_HOLD | PAINTER_DRAW_POLY_CLOSE);
//		Painter_DrawLine(120, 120
//					, 120+TICK_XI[s]-(TICK_XO[s]-TICK_XI[s])*6
//					, 120+TICK_YI[s]-(TICK_YO[s]-TICK_YI[s])*6,
//					0x6a2f, 5, PAINTER_DRAW_BM_HOLD);
//		Painter_DrawLine(120, 120
//					 , 120-(TICK_XI[s]+4)/8
//					 , 120-(TICK_YI[s]+4)/8,
//				0x6a2f, 5, PAINTER_DRAW_BM_HOLD);
		// GET MY SHADOW!
		if (shadow_on) Painter_Fill_BitMaskShadow(50, 50, 190, 190, 0L, 30, 30, 200, 0x0008, 4, 4, 12);
		for (x=30;x<170;x++) for (y=30;y<170;y++){
			LCD_ResetBitMask(_d_dl_ctx.bm, x, y, 200);
		}
		u32 mm = m % 12;
		// minute hand
		Painter_DrawLine(120, 120
						 , 120+TICK_XI[mm]-(TICK_XO[mm]-TICK_XI[mm])*10
						 , 120+TICK_YI[mm]-(TICK_YO[mm]-TICK_YI[mm])*10,
						 0xa22f, 5, PAINTER_DRAW_BM_HOLD);
		Painter_DrawLine(120, 120
						 , 120-(TICK_XI[mm]+4)/8
						 , 120-(TICK_YI[mm]+4)/8,
						 0xa22f, 5, PAINTER_DRAW_BM_HOLD);
		// Center circle makes it cute~
		Painter_DrawCircle(120, 120, 3, 0xa22f, 5, PAINTER_DRAW_BM_HOLD);
		// GET MY SHADOW!
		if (shadow_on) Painter_Fill_BitMaskShadow(50, 50, 190, 190, 0L, 30, 30, 200, 0x0008, 4, 4, 12);

		// show time in text
		u16 *p = time, *q;
		// need some space
		*p++ = space[0];
		mm = m?m:1;
		while (mm<10000) {
			*p++ = space[0];
			mm *= 10;
		}
		//put minute digits
		p = itoa(m, p);
		*p++ = col[0];
		//put second text directly
		q = (u16 *)(text)[s];
		while (*q) *p++ = *q++;
		*p++ = 0;

		// repaint the background
		LCD_SetWindow(20, 240, 200, 60);
		LCD_PutImage_RGB565(bg, 200*60);
		// GET MY TIME!
		Painter_PutString((const u16*)time, 48, 0xffff, 0xf5b9
						 , 20, 240, 200, 60, shadow_on  | PAINTER_STR_SFLUSH);

		put_fps(1);
		// PUSH A TO DASH!
		if (GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_15)) DUMMY;
		// TICK TOCK~
		s++;
		if (s == 12) {
			m++;
			s = 0;
		}
	}
	return 0;
}