コード例 #1
0
ファイル: et024006dhu_gui.c プロジェクト: AndreyMostovov/asf
void gui_init(uint32_t fcpu_hz, uint32_t fhsb_hz, uint32_t fpbb_hz, uint32_t fpba_hz)
{
  et024006_Init(fcpu_hz, fhsb_hz);
  et024006_DrawFilledRect(0, 0, ET024006_WIDTH, ET024006_HEIGHT, BLACK);
  gpio_set_gpio_pin(ET024006DHU_BL_PIN);
  load_sdram_data(fhsb_hz);
  draw_startup(0, 0);
}
コード例 #2
0
ファイル: et024006dhu_gui.c プロジェクト: Mazetti/asf
/*!
 * \brief function to configure LCD
 */
void gui_init(U32 fcpu_hz, U32 fhsb_hz, U32 fpbb_hz, U32 fpba_hz)
{

  delay_init(fcpu_hz);
  et024006_Init( fcpu_hz, fhsb_hz );
  gpio_set_gpio_pin(ET024006DHU_BL_PIN);
  et024006_DrawFilledRect(0 , 0, ET024006_WIDTH, ET024006_HEIGHT, BLACK );

  gui_print_default_message();
}
コード例 #3
0
ファイル: mmi_task.c プロジェクト: InSoonPark/asf
//!
//! @brief This function initializes the hardware/software resources
//! required for the MMI task.
//!
void mmi_task_init(uint32_t cpu_f, uint32_t pba_f)
{
  // Initialize the LCD.
  et024006_Init(  cpu_f, cpu_f /*HSB*/);

  // Clear the display i.e. make it black
  et024006_DrawFilledRect(0, 0, ET024006_WIDTH, ET024006_HEIGHT, BLACK );

  // Set the backlight.
  gpio_set_gpio_pin(ET024006DHU_BL_PIN);

  mmi_state = MMI_TOP_MENU_START;
}
コード例 #4
0
ファイル: rtouch_example.c プロジェクト: InSoonPark/asf
/* \brief Initialize board.
 *
 */
void init_board(void)
{

#ifdef MAX_SPEED
	init_sys_clocks();
#else
  pcl_switch_to_osc(PCL_OSC0, FOSC0, OSC0_STARTUP);
#endif
	INTC_init_interrupts();

	init_dbg_rs232(FPBA_HZ);
	// Activate LED0 & LED1 & LED2 & LED3 pins in GPIO output
	// mode and switch them off.
	gpio_set_gpio_pin(LED0_GPIO);
	gpio_set_gpio_pin(LED1_GPIO);
	gpio_set_gpio_pin(LED2_GPIO);
	gpio_set_gpio_pin(LED3_GPIO);

	et024006_Init(FCPU_HZ, FCPU_HZ);
	gpio_set_gpio_pin(ET024006DHU_BL_PIN);
	et024006_DrawFilledRect(0, 0, ET024006_WIDTH, ET024006_HEIGHT, WHITE);
}
コード例 #5
0
ファイル: audio_example.c プロジェクト: kerichsen/asf
/*! \brief Main function. Execution starts here.
 *
 * \retval 42 Fatal error.
 */
int main(void)
{
    init_hmatrix();

    // Configure standard I/O streams as unbuffered.
#if (defined __GNUC__) && (defined __AVR32__)
    setbuf(stdin, NULL);
#endif
    setbuf(stdout, NULL);

#if (defined USB_RESYNC_METHOD) && (USB_RESYNC_METHOD == USB_RESYNC_METHOD_EXT_CLOCK_SYNTHESIZER)
    // Initialize the TWI using the internal RCOSC
    init_twi_CS2200(AVR32_PM_RCOSC_FREQUENCY);

    // Initialize the CS2200 and produce a default 11.2896 MHz frequency
    cs2200_setup(11289600, FOSC0);
#endif

    // Initializes the MCU system clocks
    init_sys_clocks();

    // Initialize the TWI
    init_twi(FPBA_HZ);

    audio_mixer_enable_dacs(DEFAULT_DACS);
    audio_mixer_dacs_start(DEFAULT_DAC_SAMPLE_RATE_HZ,
                           DEFAULT_DAC_NUM_CHANNELS,
                           DEFAULT_DAC_BITS_PER_SAMPLE,
                           DEFAULT_DAC_SWAP_CHANNELS);

    // Initialize the display
    et024006_Init(  FCPU_HZ, FHSB_HZ);

    // Set Backlight
    gpio_set_gpio_pin(ET024006DHU_BL_PIN);

    // Clear the display
    et024006_DrawFilledRect(0, 0, ET024006_WIDTH, ET024006_HEIGHT, WHITE );

    // Display a logo.
    et024006_PutPixmap(avr32_logo, AVR32_LOGO_WIDTH, 0, 0
                       ,(ET024006_WIDTH - AVR32_LOGO_WIDTH)/2
                       ,(ET024006_HEIGHT - AVR32_LOGO_HEIGHT)/2, AVR32_LOGO_WIDTH, AVR32_LOGO_HEIGHT);

    et024006_PrintString(AUDIO_DEMO_STRING, (const unsigned char *)&FONT8x16, 30, 5, BLACK, -1);
    et024006_PrintString("Please plug the USB.", (const unsigned char *)&FONT8x8, 30, 30, BLACK, -1);

    // Initialize USB task
    usb_task_init();

    // Initialize Controller
    controller_init(FCPU_HZ, FHSB_HZ, FPBB_HZ, FPBA_HZ);

#if USB_DEVICE_FEATURE == true
    // Initialize device audio USB task
    device_audio_task_init();

    // Initialize the HID USB task
    device_hid_task_init();
#endif
#if USB_HOST_FEATURE == true
    // Initialize host audio USB task
    host_audio_task_init();
#endif

#ifdef FREERTOS_USED
    // Start OS scheduler
    vTaskStartScheduler();
    portDBG_TRACE("FreeRTOS returned.");
    return 42;
#else
    // No OS here. Need to call each task in round-robin mode.
    while (true)
    {
        usb_task();
#if USB_DEVICE_FEATURE == true
        device_audio_task();
        device_hid_task();
#endif
#if USB_HOST_FEATURE == true
        host_audio_task();
#endif
    }
#endif  // FREERTOS_USED
}
コード例 #6
0
ファイル: ui.c プロジェクト: AndreyMostovov/asf
/**
 * \name PWM functions
 * @{
 */
void ui_pwm_led_init(uint8_t lednum)
{
	/* Timer waveform options */
	static tc_waveform_opt_t waveform_options = {
		/* Channel selection. */
		.channel  = 1,

		.bswtrg   = TC_EVT_EFFECT_NOOP,
		.beevt    = TC_EVT_EFFECT_NOOP,
		.bcpc     = TC_EVT_EFFECT_NOOP,
		.bcpb     = TC_EVT_EFFECT_NOOP,

		.aswtrg   = TC_EVT_EFFECT_NOOP,
		.aeevt    = TC_EVT_EFFECT_NOOP,
		.acpc     = TC_EVT_EFFECT_NOOP,
		.acpa     = TC_EVT_EFFECT_NOOP,

		/* Waveform selection */
		.wavsel   = TC_WAVEFORM_SEL_UP_MODE_RC_TRIGGER,
		/* External event trigger enable. */
		.enetrg   = false,
		/* External event selection (non-zero for Channel B to work) */
		.eevt     = !0,
		/* External event edge selection. */
		.eevtedg  = TC_SEL_NO_EDGE,

		.cpcdis   = false,
		.cpcstop  = false,

		.burst    = false,
		.clki     = false,
		/* Internal source clock 5, fPBA/128. */
		.tcclks   = TC_CLOCK_SOURCE_TC5,
	};
	switch (lednum) {
	case LED0:
		/* Assign output pin to timer/counter 0 channel A */

		/* Channel selection. */
		waveform_options.channel = 1;

		waveform_options.bcpc = TC_EVT_EFFECT_NOOP;

		waveform_options.bcpb = TC_EVT_EFFECT_NOOP;
		/* RC compare effect on TIOA. */
		waveform_options.acpc = TC_EVT_EFFECT_CLEAR;
		/* RA compare effect on TIOA. */
		waveform_options.acpa = TC_EVT_EFFECT_SET;

		/* Setup timer/counter waveform mode */
		sysclk_enable_peripheral_clock(&AVR32_TC0);
		tc_init_waveform(&AVR32_TC0, &waveform_options);

		/* Write the TOP (RC) and COMPARE (RA) values */
		tc_write_ra(&AVR32_TC0, 1, 1);   /* Set RA value. */
		tc_write_rc(&AVR32_TC0, 1, 255); /* Set RC value. */

		/* Start the timer PWM channel */
		tc_start(&AVR32_TC0, 1);
		break;

	case LED1:
		/* Assign output pin to timer/counter 1 channel B */

		/* Channel selection. */
		waveform_options.channel = 2;

		waveform_options.acpc = TC_EVT_EFFECT_NOOP;

		waveform_options.acpa = TC_EVT_EFFECT_NOOP;
		/* RC compare effect on TIOB. */
		waveform_options.bcpc = TC_EVT_EFFECT_CLEAR;
		/* RB compare effect on TIOB. */
		waveform_options.bcpb = TC_EVT_EFFECT_SET;

		/* Setup timer/counter waveform mode */
		sysclk_enable_peripheral_clock(&AVR32_TC1);
		tc_init_waveform(&AVR32_TC1, &waveform_options);

		/* Write the TOP (RC) and COMPARE (RB) values */
		tc_write_rb(&AVR32_TC1, 2, 1);   /* Set RB value. */
		tc_write_rc(&AVR32_TC1, 2, 255); /* Set RC value. */

		/* Start the timer PWM channel */
		tc_start(&AVR32_TC1, 2);
		break;

	default:
		break;
	}
}

void ui_pwm_update(uint8_t channum, uint8_t brightness)
{
	switch (channum) {
	case LED0:
		if (brightness != 0) {
			gpio_enable_module_pin(AVR32_TC0_A1_0_1_PIN,
					AVR32_TC0_A1_0_1_FUNCTION);
			tc_start(&AVR32_TC0, 1);
			tc_write_ra(&AVR32_TC0, 1, brightness);
		} else {
			tc_stop(&AVR32_TC0, 1);
			LED_Off(LED0);
		}

		break;

	case LED1:
		if (brightness != 0) {
			gpio_enable_module_pin(AVR32_TC1_B2_0_PIN,
					AVR32_TC1_B2_0_FUNCTION);
			tc_start(&AVR32_TC1, 2);
			tc_write_rb(&AVR32_TC1, 2, brightness);
		} else {
			tc_stop(&AVR32_TC1, 2);
			LED_Off(LED0);
		}

		break;

	default:
		break;
	}
}

/* End of PWM */
/** @} */

/**
 * \name Display functions
 * @{
 */

static void ui_display_enable(void)
{
	delay_init(sysclk_get_cpu_hz());

	et024006_Init( sysclk_get_cpu_hz(), sysclk_get_hsb_hz());

	/* Clear the display i.e. make it black */
	et024006_DrawFilledRect(0, 0, ET024006_WIDTH, ET024006_HEIGHT, BLACK );

	/* Set the backlight. */
	gpio_set_gpio_pin(ET024006DHU_BL_PIN);

	ui_display_init_rtc();

	ui_display_welcome_msg();
}
コード例 #7
0
ファイル: main.c プロジェクト: cryptx2/cryptx2-firmware
/*! \brief Main function. Execution starts here.
 */
int main(void)
{
	//uint8_t i = 0;
	uint16_t temp_crc;
	irq_initialize_vectors();
	cpu_irq_enable();

	// Initialize the sleep manager
	sleepmgr_init();

	sysclk_init();
	board_init();

	ui_init();
	ui_powerdown();

	memories_initialization();

	// Initialize LCD
	et024006_Init( FOSC0, FOSC0 );
	gpio_set_gpio_pin(ET024006DHU_BL_PIN);
	
	//et024006_PrintConsole("Welcome Eric", BLACK, -1);
	//clear_lcd
	et024006_DrawFilledRect(1, 1, ET024006_WIDTH, ET024006_HEIGHT, BLACK);
	
	// Initialize AES module
	aes_task();

	// Start TC
	tc_task();

	Init_System_Status();
	// Initialize crc for fast calculations
	crcInit();
		
	// Read the stored values from the flash
	Load_stored_values();
	//i = sizeof(stored_values_t) - sizeof(uint16_t);
	temp_crc = crcFast((const uint8_t *)&Stored_values_ram, 192);
	//temp_crc1 = crcFast("123456789", 9);
	if (temp_crc == Stored_values_ram.block_crc)
	{
		stSystemStatus.stored_value_crc_status = 1;
	}
	//Stored_values_ram.salt[5] = 0x4d68ab23;
	
	//Update_stored_values();
	// 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);
	}

	// The main loop manages only the power mode
	// because the USB management is done by interrupt
	while (true)
	{
		if (main_b_msc_enable)
		{
			if (!udi_msc_process_trans())
			{
				sleepmgr_enter_sleep();
			}
		}
		else
		{
			sleepmgr_enter_sleep();
		}
		//main_process_mode();
	}
}
コード例 #8
0
ファイル: gui.c プロジェクト: InSoonPark/asf
static void qt60168_resources_init(const pm_freq_param_t *pm_freq_param)
{
        static const gpio_map_t QT60168_SPI_GPIO_MAP =
                {
                        {QT60168_SPI_SCK_PIN,          QT60168_SPI_SCK_FUNCTION         },  // SPI Clock.
                        {QT60168_SPI_MISO_PIN,         QT60168_SPI_MISO_FUNCTION        },  // MISO.
                        {QT60168_SPI_MOSI_PIN,         QT60168_SPI_MOSI_FUNCTION        },  // MOSI.
                        {QT60168_SPI_NPCS0_PIN,        QT60168_SPI_NPCS0_FUNCTION}  // Chip Select NPCS.
                };

        // SPI options.
        spi_options_t spiOptions =
                {
                        .reg          = QT60168_SPI_NCPS,
                        .baudrate     = QT60168_SPI_MASTER_SPEED, // Defined in conf_qt60168.h.
                        .bits         = QT60168_SPI_BITS,         // Defined in conf_qt60168.h.
                        .spck_delay   = 0,
                        .trans_delay  = 0,
                        .stay_act     = 0,
                        .spi_mode     = 3,
                        .modfdis      = 1
                };

        // Assign I/Os to SPI.
        gpio_enable_module(QT60168_SPI_GPIO_MAP,
                           sizeof(QT60168_SPI_GPIO_MAP) / sizeof(QT60168_SPI_GPIO_MAP[0]));
#if EXT_BOARD != SPB105
        // Initialize as master.
        spi_initMaster(QT60168_SPI, &spiOptions);

        // Set selection mode: variable_ps, pcs_decode, delay.
        spi_selectionMode(QT60168_SPI, 0, 0, 0);

        // Enable SPI.
        spi_enable(QT60168_SPI);
#endif

        // Initialize QT60168 with SPI clock Osc0.
        spi_setupChipReg(QT60168_SPI, &spiOptions, pm_freq_param->cpu_f);
}
#endif



void gui_init(const pm_freq_param_t *pm_freq_param) {
#if BOARD == EVK1100
        static const gpio_map_t DIP204_SPI_GPIO_MAP =
                {
                        {DIP204_SPI_SCK_PIN,  DIP204_SPI_SCK_FUNCTION },  // SPI Clock.
                        {DIP204_SPI_MISO_PIN, DIP204_SPI_MISO_FUNCTION},  // MISO.
                        {DIP204_SPI_MOSI_PIN, DIP204_SPI_MOSI_FUNCTION},  // MOSI.
                        {DIP204_SPI_NPCS_PIN, DIP204_SPI_NPCS_FUNCTION}   // Chip Select NPCS.
                };
        spi_options_t spiOptions =
                {
                        .reg          = DIP204_SPI_NPCS,
                        .baudrate     = 1000000,
                        .bits         = 8,
                        .spck_delay   = 0,
                        .trans_delay  = 0,
                        .stay_act     = 1,
                        .spi_mode     = 3,
                        .modfdis      = 1
                };
#endif

        memset(&scroll_box_contents, 0, sizeof scroll_box_contents);
        memset(&title_contents, 0, sizeof title_contents);
        memset(&button_contents, 0, sizeof button_contents);
        memset(&infobox_contents, 0, sizeof infobox_contents);
        memset(&info_bitmap, 0, sizeof info_bitmap);
#if BOARD == EVK1104
        // Init touch sensor resources: GPIO, SPI and QT60168.
        qt60168_resources_init(pm_freq_param);
        // Initialize QT60168 component.
        qt60168_init(pm_freq_param->cpu_f);
#endif
#if BOARD == EVK1100
        // Assign I/Os to SPI
        gpio_enable_module(DIP204_SPI_GPIO_MAP,
                           sizeof(DIP204_SPI_GPIO_MAP) / sizeof(DIP204_SPI_GPIO_MAP[0]));
#if 0
        // Initialize as master
        spi_initMaster(DIP204_SPI, &spiOptions);

        // Set selection mode: variable_ps, pcs_decode, delay
        spi_selectionMode(DIP204_SPI, 0, 0, 0);

        // Enable SPI
        spi_enable(DIP204_SPI);
#endif
        // setup chip registers
        spi_setupChipReg(DIP204_SPI, &spiOptions, FOSC0);

        // initialize LCD
        dip204_init(backlight_PWM, true);
        dip204_set_cursor_position(1,1);
        dip204_write_string("http server demo!");
#else
        // Init display
        et024006_Init(  pm_freq_param->cpu_f, pm_freq_param->cpu_f /*HSB*/);
        // Turn on the display backlight
        gpio_set_gpio_pin(ET024006DHU_BL_PIN);
#endif
        mod = 1;
}


void gui_set_title(const char *str, unsigned char line)
{
        int len;

        Assert(line < 3);

        memset(&title_contents.title[line], 0, sizeof title_contents.title[0]);
        len = strlen(str);

        if (len >= sizeof title_contents.title[0]) {
                len = sizeof title_contents.title[0] - 1;
        }
        strncpy(title_contents.title[line], str, len);

        mod = 1;
}

int gui_set_button(short id, const char *label, size_t len, button_cb_t cb)
{

        if (id >= NUM_BUTTONS) {
                return 0;
        }
        if (len >= sizeof button_contents.labels[id]) {
                len = sizeof button_contents.labels[id] - 1;
        }
        button_contents.cbs[id] = cb;
        strncpy(button_contents.labels[id], label, len);
        mod = 1;

        return 1;
}

void gui_clear_scroll_box(void)
{

        memset(&scroll_box_contents, 0, sizeof scroll_box_contents);
        scroll_box_contents.dispstart = 0;
}
コード例 #9
0
ファイル: qt60168_example.c プロジェクト: avrxml/asf
/*! \brief Initializes QT60168 resources: GPIO and SPI
 */
static void qt60168_resources_init(void)
{
  static const gpio_map_t QT60168_SPI_GPIO_MAP =
  {
    {QT60168_SPI_SCK_PIN,          QT60168_SPI_SCK_FUNCTION         },  // SPI Clock.
    {QT60168_SPI_MISO_PIN,         QT60168_SPI_MISO_FUNCTION        },  // MISO.
    {QT60168_SPI_MOSI_PIN,         QT60168_SPI_MOSI_FUNCTION        },  // MOSI.
    {QT60168_SPI_NPCS0_PIN,        QT60168_SPI_NPCS0_FUNCTION}  // Chip Select NPCS.
  };

  // SPI options.
  spi_options_t spiOptions =
  {
    .reg          = QT60168_SPI_NCPS,
    .baudrate     = QT60168_SPI_MASTER_SPEED, // Defined in conf_qt60168.h.
    .bits         = QT60168_SPI_BITS,         // Defined in conf_qt60168.h.
    .spck_delay   = 0,
    .trans_delay  = 0,
    .stay_act     = 0,
    .spi_mode     = 3,
    .modfdis      = 1
  };

  // Assign I/Os to SPI.
  gpio_enable_module(QT60168_SPI_GPIO_MAP,
                     sizeof(QT60168_SPI_GPIO_MAP) / sizeof(QT60168_SPI_GPIO_MAP[0]));

  // Initialize as master.
  spi_initMaster(QT60168_SPI, &spiOptions);

  // Set selection mode: variable_ps, pcs_decode, delay.
  spi_selectionMode(QT60168_SPI, 0, 0, 0);

  // Enable SPI.
  spi_enable(QT60168_SPI);

  // Initialize QT60168 with SPI clock Osc0.
  spi_setupChipReg(QT60168_SPI, &spiOptions, FOSC0);
}


typedef enum
{
  DEMO_COLOR_ALL=0
, DEMO_COLOR_BLUE
, DEMO_COLOR_RED
, DEMO_COLOR_GREEN
, DEMO_COLOR_MAX
} demo_color_t;

typedef enum
{
  DEMO_DISPLAY_BOXES=0
, DEMO_DISPLAY_WHEEL
, DEMO_DISPLAY_MAX
} demo_display_t;

/*! \brief Main function
 */
int main(void)
{
  int i;
  bool idle=false; // Detect key transition (PRESSED -> RELEASED)
  U32 x_start;
  U32 y_start;
  U32 x_size;
  U32 y_size;
  U16 color;
  const U16 icon[QT60168_TOUCH_NUMBER_OF_SENSORS] = {0, 1*16, 2*16, 3*16, 4*16, 5*16, -1, -1, 6*16, 7*16, 8*16, 9*16, 10*16, 11*16, -1, -1};
  demo_color_t    demo_color=DEMO_COLOR_ALL;
  demo_display_t  demo_display=DEMO_DISPLAY_WHEEL;
  bool touch_states[QT60168_TOUCH_NUMBER_OF_SENSORS];

  // Switch the main clock to the external oscillator 0
  pm_switch_to_osc0(&AVR32_PM, FOSC0, OSC0_STARTUP);

  // Initialize RS232 debug text output.
  init_dbg_rs232(FOSC0);

  // Initialize QT60168 resources: GPIO, SPI and QT60168.
  qt60168_resources_init();

  // Initialize QT60168 component.
  qt60168_init(FOSC0);

  // Initialize the LCD.
  et024006_Init(  FOSC0/*CPU*/, FOSC0/*HSB*/);

  // Clear the display i.e. make it black
  et024006_DrawFilledRect(0, 0, ET024006_WIDTH, ET024006_HEIGHT, BLACK );

  // Set the backlight.
  gpio_set_gpio_pin(ET024006DHU_BL_PIN);

  // Display welcome string.
  et024006_PrintString("QT60168 EXAMPLE", (const unsigned char *)&FONT8x8, 110,  5, WHITE, -1);
  et024006_PrintString("Press the QTouch sensors.", (const unsigned char *)&FONT6x8,  95, 20, WHITE, -1);
  et024006_PrintString("Color: All", (const unsigned char *)&FONT6x8,  10, 200, WHITE, -1);
  et024006_PrintString("Display sensors", (const unsigned char *)&FONT6x8,  120, 200, WHITE, -1);

  et024006_DrawLine(DEMO_START_X, DEMO_START_Y-1, DEMO_START_X+DEMO_SIZE_X, DEMO_START_Y-1, WHITE );
  et024006_DrawLine(DEMO_START_X, DEMO_START_Y+DEMO_SIZE_Y+1, DEMO_START_X+DEMO_SIZE_X, DEMO_START_Y+DEMO_SIZE_Y+1, WHITE );

  // Memorize the status for each key.
  for( i=0 ; i<QT60168_TOUCH_NUMBER_OF_SENSORS ; i++ )
    touch_states[i] = qt60168_is_key_pressed(i);

  // Set LED state in a known state.
  gpio_set_gpio_pin(LED0_GPIO);
  gpio_set_gpio_pin(LED1_GPIO);
  gpio_set_gpio_pin(LED2_GPIO);
  gpio_set_gpio_pin(LED3_GPIO);

  while(1)
  {
    for( i=0 ; i<QT60168_TOUCH_NUMBER_OF_SENSORS ; i++)
    {
      // Test Press event on sensors
      //
      if( !touch_states[i] && qt60168_is_key_pressed(i) )
      {
        touch_states[i] = true;

        if( i==QT60168_TOUCH_SENSOR_BUTTON_0 )
        {
          gpio_tgl_gpio_pin(LED0_GPIO);
          et024006_PrintString("B0", (const unsigned char *)&FONT6x8,  10, 215, WHITE, -1);
          demo_color=(demo_color+1) % DEMO_COLOR_MAX;

          // Erase previous line
          et024006_DrawFilledRect(10, 200, 80, 10, BLACK );
          switch( demo_color )
          {
          case DEMO_COLOR_BLUE:
            et024006_PrintString("Color: Blue", (const unsigned char *)&FONT6x8,  10, 200, WHITE, -1);
            break;
          case DEMO_COLOR_RED:
            et024006_PrintString("Color: Red", (const unsigned char *)&FONT6x8,  10, 200, WHITE, -1);
            break;
          case DEMO_COLOR_GREEN:
            et024006_PrintString("Color: Green", (const unsigned char *)&FONT6x8,  10, 200, WHITE, -1);
            break;
          default:
            et024006_PrintString("Color: All", (const unsigned char *)&FONT6x8,  10, 200, WHITE, -1);
            break;
          }
        }
        else if( i==QT60168_TOUCH_SENSOR_BUTTON_1 )
        {
          gpio_tgl_gpio_pin(LED1_GPIO);
          et024006_PrintString("B1", (const unsigned char *)&FONT6x8,  30, 215, WHITE, -1);
          demo_display=(demo_display+1) % DEMO_DISPLAY_MAX;

          // Erase previous line
          et024006_DrawFilledRect(120, 200, 160, 10, BLACK );
          switch( demo_display )
          {
          case DEMO_DISPLAY_WHEEL:
            et024006_PrintString("Display sensors", (const unsigned char *)&FONT6x8,  120, 200, WHITE, -1);
            break;
          case DEMO_DISPLAY_BOXES:
          default:
            et024006_PrintString("Display random boxes", (const unsigned char *)&FONT6x8,  120, 200, WHITE, -1);
            break;
          }
          // Erase display
          et024006_DrawFilledRect(DEMO_START_X, DEMO_START_Y, DEMO_SIZE_X, DEMO_SIZE_Y, BLACK );
        }
        else if( i==QT60168_TOUCH_SENSOR_BUTTON_2 )
        {
          gpio_tgl_gpio_pin(LED2_GPIO);
          et024006_PrintString("B2", (const unsigned char *)&FONT6x8,  50, 215, WHITE, -1);
        }

        else if( i==QT60168_TOUCH_SENSOR_BUTTON_3 )
        {
          gpio_tgl_gpio_pin(LED3_GPIO);
          et024006_PrintString("B3", (const unsigned char *)&FONT6x8,  70, 215, WHITE, -1);
        }
        else
        {
          // Press transition detected for the wheel
          idle = false;

          // Draw Wheel[i]
          et024006_DrawFilledRect(100 + icon[i], 215-2, 10, 10, WHITE );
        }
      }



      // Test Release event on sensors
      //
      if(touch_states[i] && !qt60168_is_key_pressed(i))
      {
        touch_states[i] = false;
        if( i==QT60168_TOUCH_SENSOR_BUTTON_0 )
        { // Erase "B0"
          et024006_DrawFilledRect(10, 215-2, 12, 12, BLACK );
        }
        else if( i==QT60168_TOUCH_SENSOR_BUTTON_1 )
        { // Erase "B1"
          et024006_DrawFilledRect(30, 215-2, 12, 12, BLACK );
        }
        else if( i==QT60168_TOUCH_SENSOR_BUTTON_2 )
        { // Erase "B2"
          et024006_DrawFilledRect(50, 215-2, 12, 12, BLACK );
        }
        else if( i==QT60168_TOUCH_SENSOR_BUTTON_3 )
        { // Erase "B3"
          et024006_DrawFilledRect(70, 215-2, 12, 12, BLACK );
        }
        else
        { // Erase Wheel[i]
          et024006_DrawFilledRect(100 + icon[i], 215-2, 10, 10, BLACK );
        }
      }
    } // for...



    if( demo_display==DEMO_DISPLAY_WHEEL )
    {
      if( touch_states[QT60168_TOUCH_SENSOR_BUTTON_0] ) color = WHITE;
      else                                              color = BLUE;
      et024006_DrawFilledRect(30, 50, DEMO_WHEEL_SIZE_X, DEMO_WHEEL_SIZE_Y, color );

      if( touch_states[QT60168_TOUCH_SENSOR_BUTTON_1] ) color = WHITE;
      else                                              color = BLUE;
      et024006_DrawFilledRect(30, 80, DEMO_WHEEL_SIZE_X, DEMO_WHEEL_SIZE_Y, color );

      if( touch_states[QT60168_TOUCH_SENSOR_BUTTON_2] ) color = WHITE;
      else                                              color = BLUE;
      et024006_DrawFilledRect(30, 110, DEMO_WHEEL_SIZE_X, DEMO_WHEEL_SIZE_Y, color );

      if( touch_states[QT60168_TOUCH_SENSOR_BUTTON_3] ) color = WHITE;
      else                                              color = BLUE;
      et024006_DrawFilledRect(30, 140, DEMO_WHEEL_SIZE_X, DEMO_WHEEL_SIZE_Y, color );

      if( touch_states[QT60168_TOUCH_SENSOR_WHEEL_0] ) color = WHITE;
      else                                             color = BLUE;
      et024006_DrawFilledRect(DEMO_WHEEL_START_X + DEMO_WHEEL_RADIUS*SIN0,
                              DEMO_WHEEL_START_Y - DEMO_WHEEL_RADIUS*COS0,
                              DEMO_WHEEL_SIZE_X, DEMO_WHEEL_SIZE_Y, color );

      if( touch_states[QT60168_TOUCH_SENSOR_WHEEL_1] ) color = WHITE;
      else                                             color = BLUE;
      et024006_DrawFilledRect(DEMO_WHEEL_START_X + DEMO_WHEEL_RADIUS*SIN30,
                              DEMO_WHEEL_START_Y - DEMO_WHEEL_RADIUS*COS30,
                              DEMO_WHEEL_SIZE_X, DEMO_WHEEL_SIZE_Y, color );

      if( touch_states[QT60168_TOUCH_SENSOR_WHEEL_2] ) color = WHITE;
      else                                             color = BLUE;
      et024006_DrawFilledRect(DEMO_WHEEL_START_X + DEMO_WHEEL_RADIUS*SIN60,
                              DEMO_WHEEL_START_Y - DEMO_WHEEL_RADIUS*COS60,
                              DEMO_WHEEL_SIZE_X, DEMO_WHEEL_SIZE_Y, color );

      if( touch_states[QT60168_TOUCH_SENSOR_WHEEL_3] ) color = WHITE;
      else                                             color = BLUE;
      et024006_DrawFilledRect(DEMO_WHEEL_START_X + DEMO_WHEEL_RADIUS*SIN90,
                              DEMO_WHEEL_START_Y - DEMO_WHEEL_RADIUS*COS90,
                              DEMO_WHEEL_SIZE_X, DEMO_WHEEL_SIZE_Y, color );

      if( touch_states[QT60168_TOUCH_SENSOR_WHEEL_4] ) color = WHITE;
      else                                             color = BLUE;
      et024006_DrawFilledRect(DEMO_WHEEL_START_X + DEMO_WHEEL_RADIUS*SIN60,
                              DEMO_WHEEL_START_Y + DEMO_WHEEL_RADIUS*COS60,
                              DEMO_WHEEL_SIZE_X, DEMO_WHEEL_SIZE_Y, color );

      if( touch_states[QT60168_TOUCH_SENSOR_WHEEL_5] ) color = WHITE;
      else                                             color = BLUE;
      et024006_DrawFilledRect(DEMO_WHEEL_START_X + DEMO_WHEEL_RADIUS*SIN30,
                              DEMO_WHEEL_START_Y + DEMO_WHEEL_RADIUS*COS30,
                              DEMO_WHEEL_SIZE_X, DEMO_WHEEL_SIZE_Y, color );

      if( touch_states[QT60168_TOUCH_SENSOR_WHEEL_6] ) color = WHITE;
      else                                             color = BLUE;
      et024006_DrawFilledRect(DEMO_WHEEL_START_X - DEMO_WHEEL_RADIUS*SIN0,
                              DEMO_WHEEL_START_Y + DEMO_WHEEL_RADIUS*COS0,
                              DEMO_WHEEL_SIZE_X, DEMO_WHEEL_SIZE_Y, color );

      if( touch_states[QT60168_TOUCH_SENSOR_WHEEL_7] ) color = WHITE;
      else                                             color = BLUE;
      et024006_DrawFilledRect(DEMO_WHEEL_START_X - DEMO_WHEEL_RADIUS*SIN30,
                              DEMO_WHEEL_START_Y + DEMO_WHEEL_RADIUS*COS30,
                              DEMO_WHEEL_SIZE_X, DEMO_WHEEL_SIZE_Y, color );

      if( touch_states[QT60168_TOUCH_SENSOR_WHEEL_8] ) color = WHITE;
      else                                             color = BLUE;
      et024006_DrawFilledRect(DEMO_WHEEL_START_X - DEMO_WHEEL_RADIUS*SIN60,
                              DEMO_WHEEL_START_Y + DEMO_WHEEL_RADIUS*COS60,
                              DEMO_WHEEL_SIZE_X, DEMO_WHEEL_SIZE_Y, color );

      if( touch_states[QT60168_TOUCH_SENSOR_WHEEL_9] ) color = WHITE;
      else                                             color = BLUE;
      et024006_DrawFilledRect(DEMO_WHEEL_START_X - DEMO_WHEEL_RADIUS*SIN90,
                              DEMO_WHEEL_START_Y + DEMO_WHEEL_RADIUS*COS90,
                              DEMO_WHEEL_SIZE_X, DEMO_WHEEL_SIZE_Y, color );

      if( touch_states[QT60168_TOUCH_SENSOR_WHEEL_10] ) color = WHITE;
      else                                              color = BLUE;
      et024006_DrawFilledRect(DEMO_WHEEL_START_X - DEMO_WHEEL_RADIUS*SIN60,
                              DEMO_WHEEL_START_Y - DEMO_WHEEL_RADIUS*COS60,
                              DEMO_WHEEL_SIZE_X, DEMO_WHEEL_SIZE_Y, color );

      if( touch_states[QT60168_TOUCH_SENSOR_WHEEL_11] ) color = WHITE;
      else                                              color = BLUE;
      et024006_DrawFilledRect(DEMO_WHEEL_START_X - DEMO_WHEEL_RADIUS*SIN30,
                              DEMO_WHEEL_START_Y - DEMO_WHEEL_RADIUS*COS30,
                              DEMO_WHEEL_SIZE_X, DEMO_WHEEL_SIZE_Y, color );
    }

    else if( !idle && ( demo_display==DEMO_DISPLAY_BOXES ) )
    { // Display a box randomly on the screen.
      idle = true;
      x_start = DEMO_START_X + rand()%DEMO_SIZE_X;
      y_start = DEMO_START_Y + rand()%DEMO_SIZE_Y;
      x_size  = rand()%(DEMO_START_X+DEMO_SIZE_X-x_start);
      y_size  = rand()%(DEMO_START_Y+DEMO_SIZE_Y-y_start);
      color   = rand()%0x10000;
      switch( demo_color )
      {
      case DEMO_COLOR_BLUE:
        color = color & BLUE;
        break;
      case DEMO_COLOR_RED:
        color = color & RED;
        break;
      case DEMO_COLOR_GREEN:
        color = color & GREEN;
        break;
      default:
        break;
      }

      et024006_DrawFilledRect(
        x_start
      , y_start
      , x_size
      , y_size
      , color );
    }
  } // while(1)...
}
コード例 #10
0
ファイル: main.c プロジェクト: InSoonPark/asf
/**
 * \brief Main function.
 */
int main(void)
{

	/*
	 * Initialize basic features for the AVR UC3 family.
	 *  - Sysclk init for configuring clock speed.
	 *  - Configure and enable LCD Display.
	 */
	pcl_configure_clocks(&pcl_freq_param);
	et024006_Init( pcl_freq_param.cpu_f, pcl_freq_param.cpu_f );
	gpio_set_gpio_pin(ET024006DHU_BL_PIN);
	et024006_DrawFilledRect(0 , 0, ET024006_WIDTH, ET024006_HEIGHT, BLACK );
        et024006_PrintString("With FPU ", (const unsigned char *)&FONT8x16, 40, 0, WHITE, BLACK);
        et024006_PrintString("Without FPU ", (const unsigned char *)&FONT8x16, 200, 0, WHITE, BLACK);

	/*
	 * Initialize local variables for fractal algorithm with FPU optimization.
	 */
	xstep_wfpu = (xend_wfpu-xstart_wfpu)/WIDTH;
	ystep_wfpu = (yend_wfpu-ystart_wfpu)/HEIGHT;
	x_wfpu = xstart_wfpu;
	y_wfpu = ystart_wfpu;


	/*
	 * Initialize local variables for fractal algorithm without FPU optimization.
	 */
	xstep_wofpu = (xend_wofpu-xstart_wofpu)/WIDTH;
	ystep_wofpu = (yend_wofpu-ystart_wofpu)/HEIGHT;
	x_wofpu = xstart_wofpu;
	y_wofpu = ystart_wofpu;

	/*the main loop */
	do
	{
	draw_mandel_with_fpu();
	draw_mandel_without_fpu();
        if (i_wofpu == 121){
          et024006_DrawFilledRect(0 , 0, ET024006_WIDTH, ET024006_HEIGHT, BLACK );
          /*
           * Initialize local variables for fractal algorithm with FPU optimization.
           */
          xstep_wfpu = (xend_wfpu-xstart_wfpu)/WIDTH;
          ystep_wfpu = (yend_wfpu-ystart_wfpu)/HEIGHT;
          x_wfpu = xstart_wfpu;
          y_wfpu = ystart_wfpu;


          /*
           * Initialize local variables for fractal algorithm without FPU optimization.
           */
          xstep_wofpu = (xend_wofpu-xstart_wofpu)/WIDTH;
          ystep_wofpu = (yend_wofpu-ystart_wofpu)/HEIGHT;
          x_wofpu = xstart_wofpu;
          y_wofpu = ystart_wofpu;
          iter_wfpu =40;
          xstart_wfpu = -2.0;
          xend_wfpu    = 1.0;
          ystart_wfpu = -1.35;
          yend_wfpu   = 1.35;
          i_wfpu=0,j_wfpu=0,k_wfpu=0;
          iter_wofpu =40;
          xstart_wofpu = -2.0;
          xend_wofpu    = 1.0;
          ystart_wofpu = -1.35;
          yend_wofpu   = 1.35;
          i_wofpu=0,j_wofpu=0,k_wofpu=0;
          et024006_PrintString("With FPU ", (const unsigned char *)&FONT8x16, 40, 0, WHITE, BLACK);
          et024006_PrintString("Without FPU ", (const unsigned char *)&FONT8x16, 200, 0, WHITE, BLACK);
        }

	}while(true);
}