Exemple #1
0
void lcd_draw_rect(uint16 x1, uint16 x2, uint16 y1, uint16 y2, uint16 color, uint8 fill)
{
    uint16 i;

    if(fill) {                          // if the rectangle has to be filled
        lcd_set_address(x1,x2,y1,y2);
        for(i=0; i<(((x2-x1+1)*(y2-y1+1)+1))-1; i++) {
            writedata16_cont(color);
        }
        writedata16_last(color);
    }
    else {                              // if not to be filled
        lcd_draw_rect(x1,x1,y1,y2,color,1); // draw left line
        lcd_draw_rect(x2,x2,y1,y2,color,1); // draw right line
        lcd_draw_rect(x1,x2,y1,y1,color,1); // draw bottom line
        lcd_draw_rect(x1,x2,y2,y2,color,1); // draw top line
    }
}
Exemple #2
0
/*------------------------------------------------------------
 * Function Name  : PidCalibrationDrawSeleteGUI
 * Description    : PID标定表界面选择GUI
 * Input          : None
 * Output         : None
 * Return         : None
 *------------------------------------------------------------*/
void PidCalibrationDrawSeleteGUI( uint8_t Index, FunctionalState NewFunc )
{
	RECORD_POS_TypeDef pos;
	uint8_t WIDTH = 24;
	uint16_t LENTH = GetPidCalLenth();

	pos = GetPidCalPos(Index);
	
	switch ( NewFunc )
	{
		case ENABLE:
			lcd_draw_rect(pos.x-1,pos.y-1,LENTH+2,WIDTH+2,COLOR_SELECT_BACK);
			lcd_draw_rect(pos.x-2,pos.y-2,LENTH+4,WIDTH+4,COLOR_SELECT_BACK);
			break;
		
		case DISABLE:
			GUI_AddRectangleOutsideLine(pos.x,pos.y,LENTH,WIDTH);
			break;
	}
}
/*------------------------------------------------------------
 * Function Name  : MoreParameterDrawSeleteGUI
 * Description    : 更多参数界面选择GUI
 * Input          : None
 * Output         : None
 * Return         : None
 *------------------------------------------------------------*/
void MoreParameterDrawSeleteGUI( uint8_t Index, FunctionalState NewFunc )
{
	RECORD_POS_TypeDef pos;
	uint8_t WIDTH = 34;
	const uint16_t LENTH = RECTANGLE_LENTH;

	pos = GetMoreParameterPos(Index);
	
	switch ( NewFunc )
	{
		case ENABLE:
			lcd_draw_rect(pos.x-3,pos.y-3,LENTH+6,WIDTH+6,COLOR_SELECT_BACK);
			lcd_draw_rect(pos.x-4,pos.y-4,LENTH+8,WIDTH+8,COLOR_SELECT_BACK);
			break;
		
		case DISABLE:
			lcd_draw_rect(pos.x-3,pos.y-3,LENTH+6,WIDTH+6,COLOR_BACK);
			lcd_draw_rect(pos.x-4,pos.y-4,LENTH+8,WIDTH+8,COLOR_BACK);
			break;
	}
}
/*------------------------------------------------------------
 * Function Name  : SoftActiveDrawSeleteGUI
 * Description    : 画选择GUI
 * Input          : None
 * Output         : None
 * Return         : None
 *------------------------------------------------------------*/
void SoftActiveDrawSeleteGUI( uint8_t index, FunctionalState NewFunc )
{
	RECORD_POS_TypeDef pos = {0};
	uint8_t WIDTH = 24;
	uint16_t LENTH = 96;

	pos.x = SoftActive.pos[index].x;
	pos.y = SoftActive.pos[index].y;
	
	switch ( NewFunc )
	{
		case ENABLE:
			lcd_draw_rect(pos.x-1,pos.y-1,LENTH+2,WIDTH+2,COLOR_SELECT_BACK);
			lcd_draw_rect(pos.x-2,pos.y-2,LENTH+4,WIDTH+4,COLOR_SELECT_BACK);
			break;
		
		case DISABLE:
			GUI_AddRectangleOutsideLine(pos.x,pos.y,LENTH,WIDTH);
			break;
	}
}
/*------------------------------------------------------------
 * Function Name  : ManageModeDrawSeleteGUI
 * Description    : 画选择GUI
 * Input          : None
 * Output         : None
 * Return         : None
 *------------------------------------------------------------*/
void ManageModeDrawSeleteGUI( uint8_t index, FunctionalState NewFunc )
{
	RECORD_POS_TypeDef pos = {0};
	uint8_t WIDTH = 34;
	const uint16_t LENTH = RECTANGLE_LENTH;

	pos.x =  ManageMode.pos[index].x;
	pos.y =  ManageMode.pos[index].y;
	
	switch ( NewFunc )
	{
		case ENABLE:
			lcd_draw_rect(pos.x-1,pos.y-1,LENTH+2,WIDTH+2,COLOR_SELECT_BACK);
			lcd_draw_rect(pos.x-2,pos.y-2,LENTH+4,WIDTH+4,COLOR_SELECT_BACK);
			break;
		
		case DISABLE:
			lcd_draw_rect(pos.x-1,pos.y-1,LENTH+2,WIDTH+2,COLOR_BACK);
			lcd_draw_rect(pos.x-2,pos.y-2,LENTH+4,WIDTH+4,COLOR_BACK);
			break;
	}
}
Exemple #6
0
void lcd_draw_line(uint16 x1, uint16 x2, uint16 y1, uint16 y2, uint16 color)
{
    if((x1 == x2) || (y1 == y2)){
        lcd_draw_rect(x1,x2,y1,y2,color,1);
    }else{
        uint16 t;
        int xerr=0,yerr=0,delta_x,delta_y,distance;
        int incx,incy,uRow,uCol;

        delta_x=x2-x1;
        delta_y=y2-y1;
        uRow=x1;
        uCol=y1;
        if(delta_x>0)incx=1;
        else if(delta_x==0)incx=0;
        else {incx=-1;delta_x=-delta_x;}
        if(delta_y>0)incy=1;
        else if(delta_y==0)incy=0;
        else{incy=-1;delta_y=-delta_y;}
        if( delta_x>delta_y)distance=delta_x;
        else distance=delta_y;
        for(t=0;t<=distance+1;t++ )
        {
            lcd_set_pixel(uRow,uCol, color);
            xerr+=delta_x ;
            yerr+=delta_y ;
            if(xerr>distance)
            {
                xerr-=distance;
                uRow+=incx;
            }
            if(yerr>distance)
            {
                yerr-=distance;
                uCol+=incy;
            }
        }
    }
}
Exemple #7
0
/*------------------------------------------------------------
 * Function Name  : GUI_CalibrationTable
 * Description    : 标定表GUI界面
 * Input          : None
 * Output         : None
 * Return         : None
 *------------------------------------------------------------*/
void GUI_CalibrationTable( SMPL_NAME_TypeDef2 ch, uint16_t x, uint16_t y, uint8_t segs )
{
	uint16_t x_serial,y_serial,x_force,y_force,x_code,y_code;
	const uint8_t FONT_DISTANCE = 34;
	uint8_t i = 0;
	uint16_t CUR_COLOR = WHITE;
	uint16_t lenth,width;
	
	x_serial = x;
	y_serial = y;
	x_force = x_serial + SERIAL_LEN + COLUMN_DISTANCE;
	y_force = y;
	x_code = x_force + FORCE_LEN + COLUMN_DISTANCE;
	y_code = y;
	
	lenth = SERIAL_LEN + FORCE_LEN + CODE_LEN + 4 * COLUMN_DISTANCE;
	width = segs * FONT_DISTANCE + 37;
	lcd_draw_rect(x-COLUMN_DISTANCE,y-37,lenth,width,LIGHT_GRAY3);
	lcd_draw_rect(x-COLUMN_DISTANCE-1,y-38,lenth+2,width+2,LIGHT_GRAY3);
	lcd_fill(x-COLUMN_DISTANCE,y-7,lenth,2,LIGHT_GRAY3);
	
	GUI_DispStr24At(x_serial,y_serial-FONT_DISTANCE,COLOR_POINT,COLOR_BACK,"No.");
	if (ch == SMPL_KY_NUM)
	{
		GUI_DispStr24At(x_force,y_force-FONT_DISTANCE,COLOR_POINT,COLOR_BACK,"力值(kN)");
	}
	else
	{
		GUI_DispStr24At(x_force,y_force-FONT_DISTANCE,COLOR_POINT,COLOR_BACK,"力值(N)");
	}
		
	GUI_DispStr24At(x_code+12,y_code-FONT_DISTANCE,COLOR_POINT,COLOR_BACK,"码值");
	
	if ((segs < 1) || (segs > CALIBRATION_MAX_SEGS))
	{
		return;
	}
	
	for (i=0; i<segs; ++i)
	{
		//分配颜色
		if ( (i-1) % 2 )
		{
			CUR_COLOR = WHITE;
		}
		else
		{
			CUR_COLOR = WHITE;
		}
		PidCalibration.color_cal[i] = CUR_COLOR;
		
		//画编号
		lcd_fill(x_serial,y_serial,SERIAL_LEN,RECTANGLE_WIDTH,CUR_COLOR);
		GUI_AddRectangleOutsideLine(x_serial,y_serial,SERIAL_LEN,RECTANGLE_WIDTH);
		
		PidCalibration.pos_cal[i].Serial.x = x_serial;
		PidCalibration.pos_cal[i].Serial.y = y_serial;
		y_serial += RECTANGLE_WIDTH + ROW_DISTANCE;
		
		//画力值
		lcd_fill(x_force,y_force,FORCE_LEN,RECTANGLE_WIDTH,CUR_COLOR);
		GUI_AddRectangleOutsideLine(x_force,y_force,FORCE_LEN,RECTANGLE_WIDTH);
		
		PidCalibration.pos_cal[i].Force.x = x_force;
		PidCalibration.pos_cal[i].Force.y = y_force;
		y_force += RECTANGLE_WIDTH + ROW_DISTANCE;
		
		//画码值
		lcd_fill(x_code,y_code,CODE_LEN,RECTANGLE_WIDTH,CUR_COLOR);
		GUI_AddRectangleOutsideLine(x_code,y_code,CODE_LEN,RECTANGLE_WIDTH);
		
		PidCalibration.pos_cal[i].Code.x = x_code;
		PidCalibration.pos_cal[i].Code.y = y_code;
		y_code += RECTANGLE_WIDTH + ROW_DISTANCE;
	}
}
Exemple #8
0
/*------------------------------------------------------------
 * Function Name  : GUI_PIDTable
 * Description    : PID表格GUI界面
 * Input          : None
 * Output         : None
 * Return         : None
 *------------------------------------------------------------*/
void GUI_PIDTable( SMPL_NAME_TypeDef2 ch, uint16_t x, uint16_t y, uint8_t segs )
{
	uint16_t x_serial,y_serial,x_force,y_force,x_kp,y_kp,x_ki,y_ki;
	const uint8_t FONT_DISTANCE = 34;
	uint8_t i = 0;
	uint16_t CUR_COLOR = WHITE;
	uint16_t lenth,width;
	
	x_serial = x;
	y_serial = y;
	x_force = x_serial + SERIAL_LEN + COLUMN_DISTANCE;
	y_force = y;
	x_kp = x_force + FORCE_LEN + COLUMN_DISTANCE;
	y_kp = y;
	x_ki = x_kp + KP_LEN + COLUMN_DISTANCE;
	y_ki = y;
	
	lenth = SERIAL_LEN + FORCE_LEN + KP_LEN + KI_LEN + 5 * COLUMN_DISTANCE;
	width = segs * FONT_DISTANCE + 37;
	lcd_draw_rect(x-COLUMN_DISTANCE,y-37,lenth,width,LIGHT_GRAY3);
	lcd_draw_rect(x-COLUMN_DISTANCE-1,y-38,lenth+2,width+2,LIGHT_GRAY3);
	lcd_fill(x-COLUMN_DISTANCE,y-7,lenth,2,LIGHT_GRAY3);
	
	GUI_DispStr24At(x_serial,y_serial-FONT_DISTANCE,COLOR_POINT,COLOR_BACK,"No.");
	if (ch == SMPL_KY_NUM)
	{
		GUI_DispStr24At(x_force,y_force-FONT_DISTANCE,COLOR_POINT,COLOR_BACK,"截至(kN)");
	}
	else
	{
		GUI_DispStr24At(x_force,y_force-FONT_DISTANCE,COLOR_POINT,COLOR_BACK,"截至(N)");
	}
		
	GUI_DispStr24At(x_kp+24,y_kp-FONT_DISTANCE,COLOR_POINT,COLOR_BACK,"KP");
	GUI_DispStr24At(x_ki+24,y_ki-FONT_DISTANCE,COLOR_POINT,COLOR_BACK,"KI");
	
	if ((segs < 1) || (segs > PID_MAX_SEGS))
	{
		return;
	}
	
	for (i=0; i<segs; ++i)
	{
		//分配颜色
		if ( (i-1) % 2 )
		{
			CUR_COLOR = WHITE;
		}
		else
		{
			CUR_COLOR = WHITE;
		}
		PidCalibration.color_pid[i] = CUR_COLOR;
		
		//画编号
		lcd_fill(x_serial,y_serial,SERIAL_LEN,RECTANGLE_WIDTH,CUR_COLOR);
		GUI_AddRectangleOutsideLine(x_serial,y_serial,SERIAL_LEN,RECTANGLE_WIDTH);
		
		PidCalibration.pos_pid[i].Serial.x = x_serial;
		PidCalibration.pos_pid[i].Serial.y = y_serial;
		y_serial += RECTANGLE_WIDTH + ROW_DISTANCE;
		
		//画力值
		lcd_fill(x_force,y_force,FORCE_LEN,RECTANGLE_WIDTH,CUR_COLOR);
		GUI_AddRectangleOutsideLine(x_force,y_force,FORCE_LEN,RECTANGLE_WIDTH);
		
		PidCalibration.pos_pid[i].Force.x = x_force;
		PidCalibration.pos_pid[i].Force.y = y_force;
		y_force += RECTANGLE_WIDTH + ROW_DISTANCE;
		
		//画KP
		lcd_fill(x_kp,y_kp,KP_LEN,RECTANGLE_WIDTH,CUR_COLOR);
		GUI_AddRectangleOutsideLine(x_kp,y_kp,KP_LEN,RECTANGLE_WIDTH);
		
		PidCalibration.pos_pid[i].KP.x = x_kp;
		PidCalibration.pos_pid[i].KP.y = y_kp;
		y_kp += RECTANGLE_WIDTH + ROW_DISTANCE;
		
		//画KI
		lcd_fill(x_ki,y_ki,KI_LEN,RECTANGLE_WIDTH,CUR_COLOR);
		GUI_AddRectangleOutsideLine(x_ki,y_ki,KI_LEN,RECTANGLE_WIDTH);
		
		PidCalibration.pos_pid[i].KI.x = x_ki;
		PidCalibration.pos_pid[i].KI.y = y_ki;
		y_ki += RECTANGLE_WIDTH + ROW_DISTANCE;
	}
}
Exemple #9
0
int main(void)
{
    uint16 i =0;
//    char ch = 0x01;
    gpio_init();    //Init GPIO's


    //spi_init();   //Init SPI0

    lcd_init();

    lcd_clear(ILI9341_White);
    //lcd_set_Orientation(rot270);

    lcd_set_font(&Font13x16, true);
    //lcd_write_center_string(10,"Test");
    lcd_draw_rect(0,240,120,160,ILI9341_Navy,true);
    lcd_set_font_color(ILI9341_White);
    lcd_set_background_color(ILI9341_Navy);
    lcd_set_font(&Font8x11, true);
    lcd_write_center_string(145,"G A S S M A N N");

    lcd_set_font(&Font13x16, true);

    lcd_write_center_string(125,"PCS - 2020");

    lcd_draw_rect(0,240,0,20,ILI9341_GRAY1,true);
    lcd_draw_line(0,240,20,20,ILI9341_Black);

    lcd_draw_circle(120, 60,20,ILI9341_Red);
    lcd_set_font_color(ILI9341_Black);
    //lcd_set_background_color(ILI9341_White);
    lcd_set_background_color(ILI9341_GRAY1);
    lcd_draw_bitmap(60,5,&IPOD_SYMBOL);

    lcd_draw_bitmap(70,5,&FM_SYMBOL);
    lcd_draw_bitmap(80,5,&IR_SYMBOL);

    lcd_set_background_color(ILI9341_GRAY1);
    lcd_draw_battery(200, 5, 50);




    lcd_write_digit(5,200, 3, 9);
    lcd_send_cmd(ILI9341_DISPON);    //Display on

    while (1) {
        OUTPUT_TOGGLE(GREEN_LED);
        delay();
        lcd_set_background_color(ILI9341_GRAY1);
        lcd_draw_battery(200, 5, i%100);

        //lcd_set_background_color(i);
        lcd_set_background_color(ILI9341_White);
        //lcd_set_font_color(i);
        lcd_write_digit(5,200, i++%10, 9);
        //OUTPUT_TOGGLE(RED_LED);
        //delay();
        //OUTPUT_TOGGLE(BLUE_LED);
        //delay();
        //delay();
        //spi_send(ch);    //Send char over SPI
    }
}
Exemple #10
0
void lcd_draw_rect_full_width(uint16 y, uint16 height, uint16 color, uint8 fill)
{
    lcd_draw_rect(0,d_width_x,y,y+height-1,color,fill);
}
Exemple #11
0
void lcd_draw_rect_full_height(uint16 x, uint16 width, uint16 color, uint8 fill)
{
    lcd_draw_rect(x,x+width-1,0,d_width_y,color,fill);
}