Esempio n. 1
0
void LCD_drawBar(uint8_t x_start, uint8_t y_start, int8_t width, int8_t height, int8_t perc, uint8_t bar_type)
{
	//perc=-perc;
	LCD_drawRectangle(x_start,y_start,width,height,OVERWRITE);//outer rectangle
	//for filler, -1px from app sides
	x_start++;
	y_start++;
	width-=2;
	height-=2;
	if(bar_type==BAR_VERTICAL)
	{
		if(perc<0)
		{
			perc=-perc;
			LCD_drawRectangle(x_start,y_start+height,width, -(int8_t)((uint16_t)(height)*perc/100) ,FILL);
		}
		else if(perc>0)
		{
			LCD_drawRectangle(x_start,y_start,width,(uint16_t)(height)*perc/100,FILL);
		}
	}
	else if(bar_type==BAR_HORIZONTAL)
	{
		if(perc<0)
		{
			perc=-perc;
			LCD_drawRectangle(x_start+width,y_start, -(int8_t)((uint16_t)(width)*perc/100) ,height,FILL);
		}
		else if(perc>0)
		{
			LCD_drawRectangle(x_start,y_start, (uint16_t)(width)*perc/100 ,height,FILL);
		}
	}
}
Esempio n. 2
0
int main(void)
{
	char cmd, subcmd, x, y, v, w, r;	//variables used for loops, buffering of command bytes, counters etc.
	uint16_t color;		//counters for long stuff that may go over 256
	uint8_t pressureThreshhold = 10;

	TouchScreen_init();

	USART_set_baud(6);
	LCD_init();

	//flush any received chars
	USART_flush();

	LCD_drawString("Ready For Command", 0, 10, 1, WHITE, USART_recv);

    /* Replace with your application code */
    while (1)  {
		if(!RX_available()) {

			TSPoint p = TouchScreen_getPoint();

			if(p.z > pressureThreshhold) {
				USART_printf("X = %d\r\n", p.x);
				USART_printf("Y = %d\r\n", p.y);
				USART_printf("Pressure = %d\r\n", p.z);
			}

		} else {
			cmd = USART_recv();
			switch(cmd) {

				case 124:
					subcmd = USART_recv();

					switch(subcmd) {

						case 1:	//clear screen
							LCD_paint_screen_black();
						break;
						//************************************************************************************************************
						case 3:	//draw circle
							x = USART_recv();
							y = USART_recv();
							r = USART_recv();

								// get integer color
							color = USART_recv();
							color = color << 8;
							color |= USART_recv();  

							LCD_drawCircle(x, y, r, color);
						break;
						case 4:
							x = USART_recv();
							y = USART_recv();
							r = USART_recv();

							// get integer color
							color = USART_recv();	//store it and increment RX_read
							color = color << 8;
							color |= USART_recv();

							LCD_fillCircle(x, y, r, color);
						break;
						case 12:	//line
							x = USART_recv();
							y = USART_recv();
							v = USART_recv();
							w = USART_recv();

							// get integer color
							color = USART_recv();
							color = color << 8;
							color |= USART_recv();

							LCD_drawLine(x, y, v, w, color);
						break;
						//************************************************************************************************************
 						case 15:
							x = USART_recv();
							y = USART_recv();
							v = USART_recv();
							w = USART_recv();

							// get integer color
							color = USART_recv();
							color = color << 8;
							color |= USART_recv();

							LCD_drawRectangle(x, y, v, w, color);
						break;
						//************************************************************************************************************
						case 16:		//set pixel
							x = USART_recv();
							y = USART_recv();

							color = USART_recv();
							color = color << 8;
							color |= USART_recv();
 					
					
							LCD_setPixel(x, y, color);
						break;
						case 18:
							x = USART_recv();
							y = USART_recv();
							v = USART_recv();
							w = USART_recv();

							// get integer color
							color = USART_recv();
							color = color << 8;
							color |= USART_recv();

							LCD_fillRectangle(x, y, v, w, color);
						break;
						case 20: // draw text
							x = USART_recv();

							y = USART_recv();

							// size
							r = USART_recv();

							// get integer color
							color = USART_recv();	//store it and increment RX_read
							color = color << 8;
							color |= USART_recv();

							// send string end with 0
							LCD_drawString(NULL, x, y, r, color, USART_recv);
						break;
					}
				break;
			}
		}
    }
}