/* \brief Main loop. * * Do calibration and then wait for touch events. * Upon a touch or move event we will draw a pixel on that position. */ int main(void) { init_board(); print_dbg("Resistive Touch Example\r\n"); rtouch_init(); rtouch_enable(); rtouch_set_event_handler(event_handler); gpio_clr_gpio_pin(LED0_GPIO); /* Do the calibration */ while(rtouch_calibrate()) ; /* Signal end of calibration */ gpio_set_gpio_pin(LED0_GPIO); while(true) { } }
/** * \brief Application entry point for spi_touchscreen example. * * \return Unused (ANSI-C compatibility). */ int main(void) { uint8_t uc_result; sysclk_init(); board_init(); configure_console(); /* Enable clocks for push buttons management */ pmc_enable_periph_clk(ID_PIOA); pmc_enable_periph_clk(ID_PIOB); pmc_enable_periph_clk(ID_PIOC); /* Output example information */ puts(STRING_HEADER); /* Configure systick for 1 ms. */ puts("Configure system tick to get 1ms tick period.\r"); if (SysTick_Config(sysclk_get_cpu_hz() / 1000)) { puts("Systick configuration error\r"); while (1); } /* Switch off backlight */ aat31xx_disable_backlight(); lcd_init(); lcd_set_foreground_color(UNI_COLOR_WHITE); lcd_draw_filled_rectangle(0, 0, LCD_WIDTH, LCD_HEIGHT); /* Turn on LCD */ lcd_display_on(); /* Switch on backlight */ aat31xx_set_backlight(AAT31XX_MAX_BACKLIGHT_LEVEL); /* Initializes the PIO interrupt management for touchscreen driver */ pio_handler_set_priority(PIOA, PIOA_IRQn, IRQ_PRIOR_PIO); pio_handler_set_priority(PIOB, PIOB_IRQn, IRQ_PRIOR_PIO); pio_handler_set_priority(PIOC, PIOC_IRQn, IRQ_PRIOR_PIO); /* Initialize touchscreen without calibration */ rtouch_init(LCD_WIDTH, LCD_HEIGHT); rtouch_enable(); rtouch_set_event_handler(event_handler); while (1) { uc_result = rtouch_calibrate(); if (uc_result == 0) { puts("Calibration successful !\r"); break; } else { puts("Calibration failed; error delta is too big ! Please retry calibration procedure...\r"); } } while (1) { } }
/** \brief Main function. Execution starts here. */ int main(void) { uint8_t uc_result; /* Initialize the sleep manager */ sleepmgr_init(); membag_init(); sysclk_init(); init_specific_board(); /* Initialize the console uart */ configure_console(); /* Output demo infomation. */ printf("-- SAM Toolkit Demo Example --\n\r"); printf("-- %s\n\r", BOARD_NAME); printf("-- Compiled: %s %s --\n\r", __DATE__, __TIME__); /* Configure systick for 1 ms. */ puts("Configure system tick to get 1ms tick period.\r"); if (SysTick_Config(sysclk_get_cpu_hz() / 1000)) { puts("Systick configuration error\r"); while (1) { } } /* Initialize gfx module */ gfx_init(); win_init(); /* Initialize FatFS and bitmap draw interface */ demo_draw_bmpfile_init(); /* Initialize touchscreen without calibration */ rtouch_init(LCD_WIDTH, LCD_HEIGHT); rtouch_enable(); rtouch_set_event_handler(event_handler); /* Initialize demo parameters */ demo_parameters_initialize(); while (g_demo_parameters.calib_points[0].raw.x == 0) { uc_result = rtouch_calibrate(); if (uc_result == 0) { demo_set_special_mode_status(DEMO_LCD_CALIBRATE_MODE, 0); puts("Calibration successful !\r"); break; } else { puts("Calibration failed; error delta is too big ! Please retry calibration procedure...\r"); } } /* Re-caculate the calibration data */ rtouch_compute_calibration( (rtouch_calibration_point_t *)&g_demo_parameters.calib_points[0]); /* Setup root window */ setup_gui_root_window(); gfx_draw_bitmap(&win_startup_bmp, 0, 40); /* Set backlight by the data read from demo parameters */ aat31xx_set_backlight(g_demo_parameters.backlight); /* Default RTC configuration, 24-hour mode */ rtc_set_hour_mode(RTC, 0); rtc_set_time(RTC, g_demo_parameters.hour, g_demo_parameters.minute, g_demo_parameters.second); rtc_set_date( RTC, g_demo_parameters.year, g_demo_parameters.month, g_demo_parameters.day, 1 ); /* Create a semaphore to manage the memories data transfer */ vSemaphoreCreateBinary(main_trans_semphr); /* Turn on main widget */ app_widget_main_on(true); /* Initialize QTouch */ demo_qt_init(); /* Start USB stack to authorize VBus monitoring */ udc_start(); if (!udc_include_vbus_monitoring()) { /* VBUS monitoring is not available on this product * thereby VBUS has to be considered as present */ main_vbus_action(true); } /* Create task to window task */ if (xTaskCreate(task_win, "WIN", TASK_WIN_STACK_SIZE, NULL, TASK_WIN_STACK_PRIORITY, NULL) != pdPASS) { printf("Failed to create test led task\r\n"); } /* Create task to usb mass storage task */ if (xTaskCreate(task_usb, "USB", TASK_USB_STACK_SIZE, NULL, TASK_USB_STACK_PRIORITY, NULL) != pdPASS) { printf("Failed to create test led task\r\n"); } /* Start the scheduler. */ vTaskStartScheduler(); /* Will only get here if there was insufficient memory to create the * idle task. */ return 0; }