示例#1
0
文件: main.c 项目: Tjalling7/asf
/**
 * \brief Shows on display an explanation of how to use the demonstration
 * SW1 pressed skips this explanation.
 */
static void main_introduction(void)
{
    LED_On(LED3_GPIO);  /* Keep power LED on */

    /* Display Atmel logo */
    if (!main_introduction_is_exist()) {
        gfx_mono_generic_put_bitmap(&bitmap_atmel, 10, 0);
        gfx_mono_draw_string(DISPLAY_INTRO_MSG_EXIT,
                             0, 25, &sysfont);
    }

    main_introduction_delay(DISPLAY_INTRO_ATMEL_DELAY);
    /* Display message */
    if (!main_introduction_is_exist()) {
        gfx_mono_init();
        gfx_mono_draw_string(DISPLAY_INTRO_MSG_A,
                             0, 10 * 0, &sysfont);
        gfx_mono_draw_string(DISPLAY_INTRO_MSG_B,
                             0, 10 * 1, &sysfont);
        gfx_mono_draw_string(DISPLAY_INTRO_MSG_C,
                             0, 10 * 2, &sysfont);
    }

    main_introduction_delay(DISPLAY_INTRO_HELP_DELAY);
    /* Display help */
    if (!main_introduction_is_exist()) {
        gfx_mono_init();
        gfx_mono_draw_string(DISPLAY_INTRO_HELP_A,
                             0, 10 * 0, &sysfont);
        gfx_mono_draw_string(DISPLAY_INTRO_HELP_B,
                             0, 10 * 1, &sysfont);
        gfx_mono_draw_string(DISPLAY_INTRO_HELP_C,
                             0, 10 * 2, &sysfont);
    }

    main_introduction_delay(DISPLAY_INTRO_HELP_DELAY);
    /* Display help */
    if (!main_introduction_is_exist()) {
        gfx_mono_init();
        gfx_mono_draw_string(DISPLAY_INTRO_INF_A,
                             0, 10 * 0, &sysfont);
        gfx_mono_draw_string(DISPLAY_INTRO_INF_B,
                             0, 10 * 1, &sysfont);
        gfx_mono_draw_string(DISPLAY_INTRO_INF_C,
                             0, 10 * 2, &sysfont);
    }

    main_introduction_delay(DISPLAY_INTRO_HELP_DELAY);

    /* Clean display */
    gfx_mono_init();
}
示例#2
0
void app_usb_task(void)
{
	static bool sw0_released = true;
	static bool usb_running = false;
	static bool cdc_running = false;
	static bool toggle = true;

	if (sw0_released && ioport_pin_is_low(GPIO_PUSH_BUTTON_0)) {
		/* A new press has been done */
		sw0_released = false;
		/* Switch USB state */
		if (usb_running) {
			udc_stop();
			gfx_mono_draw_filled_rect(DISPLAY_USB_STA_POS_X,
					DISPLAY_USB_STA_POS_Y,
					DISPLAY_USB_STA_SIZE_X,
					DISPLAY_USB_STA_SIZE_Y,
					GFX_PIXEL_CLR);
			app_microsd_start();
		} else {
			/* Stop FatFS on uSD card if enabled */
			app_microsd_stop();
			stdio_usb_init(); /* Start USB */
			gfx_mono_generic_put_bitmap(&bitmap_usb,
					DISPLAY_USB_STA_POS_X,
					DISPLAY_USB_STA_POS_Y);
		}

		usb_running = !usb_running;
		cdc_running = true;
	} else {
		/* Wait switch release */
		sw0_released = ioport_pin_is_high(GPIO_PUSH_BUTTON_0);
	}

	if (!usb_running) {
		return;
	}

	/* USB MSC task */
	while (udi_msc_process_trans()) {
	}

	if (app_usb_cdc_open && !cdc_running) {
		printf("\x0CSensor data logs:\r\n");
		cdc_running = true;
	}

	if (!app_usb_cdc_open && cdc_running) {
		cdc_running = false;
	}

	/* Toggle USB icon */
	if ((app_usb_cdc_open && app_usb_rec_toggle) ||
			(toggle && app_usb_rec_toggle)) {
		app_usb_rec_toggle = false;
		toggle = !toggle;
		gfx_mono_draw_rect(DISPLAY_USB_STACDC_POS_X,
				DISPLAY_USB_STACDC_POS_Y,
				DISPLAY_USB_STACDC_SIZE_X,
				DISPLAY_USB_STACDC_SIZE_Y,
				toggle ? GFX_PIXEL_SET : GFX_PIXEL_CLR);
	}
}