示例#1
0
/**
 * \brief Application entry point for ili9225_spi_lcd example.
 *
 * \return Unused (ANSI-C compatibility).
 */
int main(void)
{
	sysclk_init();
	board_init();

	/* Initialize debug console */
	configure_console();

	/* Initialize display parameter */
	g_ili9225_display_opt.ul_width = ILI9225_LCD_WIDTH;
	g_ili9225_display_opt.ul_height = ILI9225_LCD_HEIGHT;
	g_ili9225_display_opt.foreground_color = COLOR_BLACK;
	g_ili9225_display_opt.background_color = COLOR_WHITE;

	/* Switch off backlight */
	aat31xx_disable_backlight();

	/* Initialize LCD */
	ili9225_init(&g_ili9225_display_opt);

	/* Set backlight level */
	aat31xx_set_backlight(AAT31XX_AVG_BACKLIGHT_LEVEL);

	/* Turn on LCD */
	ili9225_display_on();

	/* Draw filled rectangle with white color */
	ili9225_set_foreground_color(COLOR_WHITE);
	ili9225_draw_filled_rectangle(0, 0, ILI9225_LCD_WIDTH, ILI9225_LCD_HEIGHT);

	/* Draw text and basic shapes on the LCD */
	ili9225_set_foreground_color(COLOR_BLACK);
	ili9225_draw_string(10, 20, (uint8_t *)"ili9225_lcd");

	/* Draw three circle with red, green and blue color */
	ili9225_set_foreground_color(COLOR_RED);
	ili9225_draw_circle(60, 80, 30);
	ili9225_set_foreground_color(COLOR_GREEN);
	ili9225_draw_circle(60, 120, 30);
	ili9225_set_foreground_color(COLOR_BLUE);
	ili9225_draw_circle(60, 160, 30);

	/* Draw one line */
	ili9225_draw_line(0, 0, 176, 220);

	while (1) {
	}
}
示例#2
0
int main (void)
{
	/* Insert system clock initialization code here (sysclk_init()). */

	sysclk_init();
	board_init();

	/* Insert application code here, after the board has been initialized. */
	
	if (SysTick_Config(sysclk_get_cpu_hz() / 1000)) {
		puts("-E- Systick configuration error\r");
		while (1) {
			/* Capture error */
			gpio_set_pin_low(LED2_GPIO);
		}
	}
	
	config_lcd();
	
	pmc_enable_periph_clk(ID_ENC);
	
	//Interrupt for A:
	pio_set_input(PIOA, GPIO_A, PIO_DEFAULT);
	pio_pull_down(PIOA, GPIO_A, ENABLE);
	pio_handler_set(PIOA, ID_ENC, GPIO_A, PIO_IT_RISE_EDGE, pin_handler);
	pio_enable_interrupt(PIOA, GPIO_A);
	
	//Interrupt for B:
	pio_set_input(PIOA, GPIO_B, PIO_DEFAULT);
	pio_pull_down(PIOA, GPIO_B, ENABLE);
	pio_handler_set(PIOA, ID_ENC, GPIO_B, PIO_IT_RISE_EDGE, pin_handler);
	pio_enable_interrupt(PIOA, GPIO_B);
	
	//Interrupt for C:
	pio_set_input(PIOA, GPIO_C, PIO_DEFAULT);
	pio_pull_down(PIOA, GPIO_C, ENABLE);
	//pio_handler_set(PIOA, ID_ENC, GPIO_C, PIO_IT_RISE_EDGE, pin_handler);
	pio_handler_set(PIOA, ID_ENC, GPIO_C, PIO_IT_FALL_EDGE, pin_handler);
	pio_enable_interrupt(PIOA, GPIO_C);
	
	//Enable Interrupt GPIO:
	NVIC_DisableIRQ(PIOA_IRQn);
	NVIC_ClearPendingIRQ(PIOA_IRQn);
	NVIC_SetPriority(PIOA_IRQn, 0);
	NVIC_EnableIRQ(PIOA_IRQn);
	
	ili9225_set_foreground_color(COLOR_BLACK);
	ili9225_draw_string(10,10, (uint8_t *)"Encoder Test");
	
	while (1){
		ili9225_set_foreground_color(COLOR_WHITE);
		ili9225_draw_filled_rectangle(0,30,ILI9225_LCD_WIDTH,ILI9225_LCD_HEIGHT);
		ili9225_set_foreground_color(COLOR_BLACK);
		graus = ((float)round/ENC_RES)*VOLTA_COMP;
		snprintf(buf, sizeof(buf), "Graus:%.3f", graus );
		ili9225_draw_string(10,50, buf);
		snprintf(buf, sizeof(buf), "Round:%d", round );
		ili9225_draw_string(10,80, buf);
		mdelay(500);
	}
}