Beispiel #1
0
static void mmi_ms_display( void )
{
  uint32_t i;
  for( i=0 ; i<MS_N_PROGRESS_BAR ; i++ )
  {
    if( ms_progress_bar_level[i] != 0 )
    {
      if( ms_progress_bar_type[i] == BLUE )
        et024006_DrawFilledRect(80+3 + i*(17+2), 180+3, 17, 10, BLUE_LEV(ms_progress_bar_level[i]) );
      else
        et024006_DrawFilledRect(80+3 + i*(17+2), 180+3, 17, 10, RED_LEV(ms_progress_bar_level[i]) );
      ms_progress_bar_level[i] -= 1;
    }
  }
}
Beispiel #2
0
/*! \brief Draws the elements that need periodic update in the play view.
 *
 *  Updates the current play time.
 */
static bool draw_playtime_update(struct file_info *current_file_info)
{
  uint32_t hours, minutes, seconds, tmp, time_ms;
  char time_elapsed[32];

  // get the time and put it into a printable format
  time_ms = current_file_info->elapsed_time;
  tmp = time_ms;
  hours = tmp / (1000 * 60 * 60);
  tmp %= 1000 * 60 * 60;
  minutes = tmp / (1000 * 60);
  tmp %= 1000 * 60;
  seconds = tmp / 1000;
  sprintf(time_elapsed,"%02lu:%02lu:%02lu",hours, minutes, seconds);

  // draw background behind the play time
  if(ram_files[AUDIO_PLAYER_IMAGE].start_addr)
  {
    et024006_PutPixmap(ram_files[AUDIO_PLAYER_IMAGE].start_addr,
                       ET024006_WIDTH, ELAPSED_TIME_POS_X, ELAPSED_TIME_POS_Y, ELAPSED_TIME_POS_X, ELAPSED_TIME_POS_Y, ELAPSED_TIME_WIDTH, ELAPSED_TIME_HEIGHT);
  }
  else
  {
    et024006_DrawFilledRect( ELAPSED_TIME_POS_X, ELAPSED_TIME_POS_Y, ELAPSED_TIME_WIDTH, ELAPSED_TIME_HEIGHT, (et024006_color_t)APPLI_BG_COLOR);

  }
  // draw the playtime
  et024006_PrintString(time_elapsed, (unsigned char *) TIME_FONT, ELAPSED_TIME_POS_X, ELAPSED_TIME_POS_Y, APPLI_FG_COLOR, -1);

  draw_song_progress_bar(current_file_info);

  return true;
}
Beispiel #3
0
//!
//! @brief This function displays a box on the LCD.
//!
static void display_box( uint32_t x, uint32_t y, uint32_t size_x, uint32_t size_y, uint16_t color, uint16_t edge_color )
{
  et024006_DrawFilledRect(x, y, size_x, size_y, color);
  et024006_DrawHorizLine(x, y, size_x, edge_color);
  et024006_DrawVertLine(x+size_x-1, y, size_y, edge_color);
  et024006_DrawHorizLine(x, y+size_y-1, size_x, edge_color);
  et024006_DrawVertLine(x, y, size_y, edge_color);
}
Beispiel #4
0
/*!
 * \brief function to display default message
 */
static void gui_print_default_message(void)
{
  // Display default message.
  et024006_DrawFilledRect(0 , 0, ET024006_WIDTH, ET024006_HEIGHT, BLACK );
  et024006_PrintString("ATMEL AVR UC3", (const unsigned char *)&FONT6x8, 80, 50, WHITE, -1);
  et024006_PrintString("Cybercom Bluetooth", (const unsigned char *)&FONT6x8, 80, 60, WHITE, -1);
  et024006_PrintString("    SPP Lite Demo  ", (const unsigned char *)&FONT6x8, 80, 70, WHITE, -1);
}
Beispiel #5
0
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);
}
Beispiel #6
0
/*! \brief Draws the file list on the disk navigation view.
 */
static bool draw_file_list(struct display_file_list *lst_str)
{
  size_t i;
  uint16_t pos_x, pos_y;

  // Find the 1rst line updated.
  for(i=0; i<lst_str->nb_elts; i++)
    if (lst_str->list[i].updated)
      break;
   // Compute the Y position the string to display.
   pos_x = FILE_LIST_POS_X + FILE_LIST_ITEM_X;
   pos_y = FILE_LIST_POS_Y + FILE_LIST_SPACING * i;
   // If it is the last line, then clear the rest of the list.
   if (i == lst_str->nb_elts)
   {
     if (ram_files[DISK_NAV_IMAGE].start_addr)
       et024006_PutPixmap(ram_files[DISK_NAV_IMAGE].start_addr,
                          ET024006_WIDTH, pos_x, pos_y,
                          pos_x, pos_y,
                          FILE_LIST_WIDTH - FILE_LIST_ITEM_X, FILE_LIST_SPACING * (MAX_DISPLAY_FILE - lst_str->nb_elts));
     else
        et024006_DrawFilledRect(pos_x, pos_y,
                                FILE_LIST_WIDTH - FILE_LIST_ITEM_X, FILE_LIST_SPACING * (MAX_DISPLAY_FILE - lst_str->nb_elts),
                                (et024006_color_t) APPLI_BG_COLOR);
     return true;
   }
   // Invalidate the item.
   lst_str->list[i].updated = false;
   // Draw only the 1rst line updated.
   // Print the background.
   if (ram_files[DISK_NAV_IMAGE].start_addr)
     et024006_PutPixmap(ram_files[DISK_NAV_IMAGE].start_addr,
                        ET024006_WIDTH, pos_x, pos_y,
                        pos_x, pos_y,
                        FILE_LIST_WIDTH - FILE_LIST_ITEM_X, FILE_LIST_ITEM_HEIGHT);
   else
     et024006_DrawFilledRect(pos_x, pos_y,
                             FILE_LIST_WIDTH - FILE_LIST_ITEM_X, FILE_LIST_ITEM_HEIGHT,
                             (et024006_color_t) APPLI_BG_COLOR);
   // Draw the string.
   et024006_PrintString((char*) lst_str->list[i].file_name,
                        (unsigned char *) FILE_LIST_FONT, pos_x, pos_y,
                        APPLI_FG_COLOR, APPLI_BG_COLOR);
   return false;
}
Beispiel #7
0
/*!
 * \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();
}
Beispiel #8
0
void gui_display_infobox(void)
{
        int i;

#if BOARD != EVK1100
        // Draw info box
        et024006_DrawFilledRect(SCROLL_X,
                                SCROLL_Y,
                                SCROLL_W,
                                SCROLL_H,
                                infobox_contents.bg_color);

        for (i = 0; i < INFO_MAX_LINES; i++)
        {
                if (strlen(infobox_contents.lines[i]))
                {
                        int x;
                        x = 160 - ((strlen(infobox_contents.lines[i]) / 2)*10);
                        if (x < 0) x = 10;
                        et024006_PrintString(infobox_contents.lines[i],
                                             (const unsigned char*)&FONT8x8,
                                             x,
                                             (i+1)*12+SCROLL_Y,
                                             INFO_FG_COLOR,
                                             infobox_contents.bg_color);
                }
        }
        if (info_bitmap.data && info_bitmap.data_len) {
                printk("Displaying pixmap (size %d)\n", info_bitmap.data_len);
                et024006_PutPixmap( (et024006_color_t *)info_bitmap.data,
                                    info_bitmap.width, // Map width
                                    0,  // map_x
                                    0,  // map_y
                                    40, // x
                                    40, // y
                                    info_bitmap.width, // width
                                    info_bitmap.height); // height
        }
        else {
                printk("Not displaying picture\n");
        }
#else
        dip204_clear_display();
        for (i = 0; i < INFO_MAX_LINES; i++)
        {
                int len = strlen(infobox_contents.lines[i]);
                int col = (MAX_LINE_LEN/2) - (len/2);
                if ( col <= 0) col = 1;
                dip204_set_cursor_position(col,i+1); /* col,line */
                dip204_write_string(infobox_contents.lines[i]);
                dip204_hide_cursor();
        }
#endif
}
Beispiel #9
0
static bool draw_pause_button(void)
{
  if(ram_files[AUDIO_PLAYER_IMAGE].start_addr)
  {
    et024006_PutPixmap(ram_files[AUDIO_PLAYER_IMAGE].start_addr,
                       ET024006_WIDTH, PLAY_BUTTON_POS_X, PLAY_BUTTON_POS_Y,
                       PLAY_BUTTON_POS_X, PLAY_BUTTON_POS_Y, PLAY_BUTTON_WIDTH, PLAY_BUTTON_HEIGHT);
  }
  else
  {
    et024006_DrawFilledRect(PLAY_BUTTON_POS_X, PLAY_BUTTON_POS_Y,
                            PLAY_BUTTON_WIDTH, PLAY_BUTTON_HEIGHT, (et024006_color_t)APPLI_BG_COLOR);
  }

  et024006_DrawFilledRect(PAUSE_BUTTON_POS_X, PAUSE_BUTTON_POS_Y,
                          PAUSE_BUTTON_PART_WIDTH, PAUSE_BUTTON_HEIGHT, PAUSE_BUTTON_COLOR);
  et024006_DrawFilledRect(PAUSE_BUTTON_POS_X + PAUSE_BUTTON_PART_WIDTH + PAUSE_BUTTON_SPACING, PAUSE_BUTTON_POS_Y,
                          PAUSE_BUTTON_PART_WIDTH, PAUSE_BUTTON_HEIGHT, PAUSE_BUTTON_COLOR);
  return true;
}
Beispiel #10
0
/*! \brief Draws the navigation on the screen.
 */
static bool draw_navigation(int offset_x, int offset_y)
{
  if(ram_files[DISK_NAV_IMAGE].start_addr)
  {
    draw_background(DISK_NAV_IMAGE, offset_x, offset_y);
  }
  else
  {
    et024006_DrawFilledRect(0, 0, ET024006_WIDTH, ET024006_HEIGHT, (et024006_color_t)APPLI_BG_COLOR);
  }
  return true;
}
Beispiel #11
0
//!
//! @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;
}
Beispiel #12
0
/*! \brief Draw the play view.
 * Draws all elements in the play view.
 *
 * \param offset_x X offset of the picture.
 * \param offset_y Y offset of the picture.
 */
static bool draw_play_view(int offset_x, int offset_y)
{
  // draw background if available
  if(ram_files[AUDIO_PLAYER_IMAGE].start_addr)
  {
    draw_background(AUDIO_PLAYER_IMAGE, offset_x, offset_y);
  }
  else
  {
    et024006_DrawFilledRect(0, 0, ET024006_WIDTH, ET024006_HEIGHT, BLACK);
  }
  return true;
}
Beispiel #13
0
/*! \brief Draws the song progress bar on the screen.
 *
 * \param init If true the progress bar is initialized which should be done after a song change
 * or after a new draw of the play view. If the progress bar should just be updated call with false
 * \param ptime Current play time in milliseconds.
 * \param current_file_info contains the total play time length
 */
static bool draw_song_progress_bar(struct file_info *current_file_info)
{
  int song_bar_width;

  song_bar_width = (current_file_info->elapsed_time * SONG_BAR_WIDTH) / current_file_info->total_time;
  song_bar_width = Min(SONG_BAR_WIDTH, song_bar_width);

  et024006_DrawFilledRect(SONG_BAR_POS_X, SONG_BAR_POS_Y, song_bar_width, SONG_BAR_HEIGHT, SONG_BAR_FILL_COLOR);
  if (ram_files[AUDIO_PLAYER_IMAGE].start_addr)
    et024006_PutPixmap(ram_files[AUDIO_PLAYER_IMAGE].start_addr,
                       ET024006_WIDTH, SONG_BAR_POS_X + song_bar_width, SONG_BAR_POS_Y,
                       SONG_BAR_POS_X + song_bar_width, SONG_BAR_POS_Y,
                       SONG_BAR_WIDTH - song_bar_width, SONG_BAR_HEIGHT);
  return true;
}
Beispiel #14
0
/*! \brief Draw the startup image on the display.
 */
static bool draw_startup(int offset_x, int offset_y)
{
  if(ram_files[STARTUP_IMAGE].start_addr)
  {
    draw_background(STARTUP_IMAGE, offset_x, offset_y);
  }
  else
  {
    et024006_DrawFilledRect(0, 0, ET024006_WIDTH, ET024006_HEIGHT, (et024006_color_t)APPLI_BG_COLOR);
  }

    et024006_PrintString(AUDIO_PLAYER_APPLICATION_VERSION,
            (unsigned char *) VERSION_FONT, VERSION_POS_X, VERSION_POS_Y,
	    VERSION_FONT_COLOR, APPLI_BG_COLOR);

  return true;
}
Beispiel #15
0
static void ui_display_draw_textbox(void)
{
	/* Clear the display i.e. make it black */
	et024006_DrawFilledRect(0, 0, ET024006_WIDTH, ET024006_HEIGHT, BLACK );
	/* Draw blue Rectangle */
	et024006_DrawHorizLine(DISPLAY_FIRST_LINE_X - 2,
			DISPLAY_FIRST_LINE_Y - 2, ET024006_WIDTH - 20, BLUE);
	et024006_DrawVertLine(DISPLAY_FIRST_LINE_X - 2,
			DISPLAY_FIRST_LINE_Y - 2, ET024006_HEIGHT - 30, BLUE);
	et024006_DrawHorizLine(DISPLAY_FIRST_LINE_X - 2, ET024006_HEIGHT - 10,
			ET024006_WIDTH - 20, BLUE);
	et024006_DrawVertLine(ET024006_WIDTH - 10, DISPLAY_FIRST_LINE_Y - 2,
			ET024006_HEIGHT - 30, BLUE);
	/* Draw Welcome String */
	et024006_PrintString((char *)"Atmel Android Accessory Demo",
			(const uint8_t *)&FONT8x16, 12, 2, BLUE, WHITE);
}
Beispiel #16
0
void ui_usb_enum_event(uhc_device_t *dev, uhc_enum_status_t status)
{
	(void)dev;
	ui_enum_status = status;

	et024006_DrawFilledRect(0, 0, ET024006_WIDTH, ET024006_HEIGHT, BLACK );

	if (ui_enum_status != UHC_ENUM_SUCCESS) {
		/* Draw Device incompatible */
		et024006_PrintString((char *)"This Device is not compatible!",
				(const uint8_t *)&FONT8x16, 30, 125, BLUE,
				WHITE);
	} else {
		ui_display_draw_textbox();
	}

	ui_display_disable_rtc();
}
Beispiel #17
0
static void ui_display_welcome_msg(void)
{
	/* Clear Display */
	et024006_DrawFilledRect(0, 0, ET024006_WIDTH, ET024006_HEIGHT, WHITE);
	/* Picture of Cellphone */
	et024006_PutPixmap(pic_cellphone, 80, 0, 0, 0, 0, 80, 99);
	/* Picture of USB Part */
	et024006_PutPixmap(pic_usb_connector, 160, 0, 0, 160, 120, 160, 120);
	/* Draw Welcome String */
	et024006_PrintString((char *)"Atmel Android",
			(const uint8_t *)&FONT8x16, 180, 30, BLUE, WHITE);
	et024006_PrintString((char *)"Accessory Demo",
			(const uint8_t *)&FONT8x16, 180, 50, BLUE, WHITE);
	/* Draw Plugin Android */
	et024006_PrintString((char *)"Please connect",
			(const uint8_t *)&FONT8x16, 20, 170, BLUE, WHITE);
	et024006_PrintString((char *)"an Android Device",
			(const uint8_t *)&FONT8x16, 20, 190, BLUE, WHITE);
}
Beispiel #18
0
/* \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);
}
Beispiel #19
0
static bool draw_play_button(void)
{
  if(ram_files[AUDIO_PLAYER_IMAGE].start_addr)
  {
    et024006_PutPixmap(ram_files[AUDIO_PLAYER_IMAGE].start_addr,
                       ET024006_WIDTH, PAUSE_BUTTON_POS_X, PAUSE_BUTTON_POS_Y,
                       PAUSE_BUTTON_POS_X, PAUSE_BUTTON_POS_Y, PAUSE_BUTTON_WIDTH, PAUSE_BUTTON_HEIGHT);
  }
  else
  {
    et024006_DrawFilledRect(PAUSE_BUTTON_POS_X, PAUSE_BUTTON_POS_Y,
                            PAUSE_BUTTON_WIDTH, PAUSE_BUTTON_HEIGHT, PAUSE_BUTTON_COLOR);
  }
  et024006_DrawVertLine( PLAY_BUTTON_POS_X+2, PLAY_BUTTON_POS_Y +1, 14, PAUSE_BUTTON_COLOR);
  et024006_DrawVertLine( PLAY_BUTTON_POS_X+3, PLAY_BUTTON_POS_Y+2, 12, PAUSE_BUTTON_COLOR);
  et024006_DrawVertLine( PLAY_BUTTON_POS_X+4, PLAY_BUTTON_POS_Y+3, 10, PAUSE_BUTTON_COLOR);
  et024006_DrawVertLine( PLAY_BUTTON_POS_X+5, PLAY_BUTTON_POS_Y+4, 9, PAUSE_BUTTON_COLOR);
  et024006_DrawVertLine( PLAY_BUTTON_POS_X+6, PLAY_BUTTON_POS_Y+5, 7, PAUSE_BUTTON_COLOR);
  et024006_DrawVertLine( PLAY_BUTTON_POS_X+7, PLAY_BUTTON_POS_Y+5, 6, PAUSE_BUTTON_COLOR);
  et024006_DrawVertLine( PLAY_BUTTON_POS_X+8, PLAY_BUTTON_POS_Y+6, 4, PAUSE_BUTTON_COLOR);
  et024006_DrawVertLine( PLAY_BUTTON_POS_X+9, PLAY_BUTTON_POS_Y+7, 3, PAUSE_BUTTON_COLOR);
  return true;
}
Beispiel #20
0
/*! \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
}
Beispiel #21
0
static void ui_display_clr_screen(void)
{
	et024006_DrawFilledRect(DISPLAY_FIRST_LINE_X - 1,
			DISPLAY_FIRST_LINE_Y - 1, ET024006_WIDTH - 22,
			ET024006_HEIGHT - 32, BLACK );
}
Beispiel #22
0
void ui_display_draw_dot(void)
{
	static uint8_t dotnumber;

	switch (dotnumber) {
	case 0x00:
		et024006_DrawFilledRect(40, 105, 10, 10, BLACK);
		dotnumber++;
		break;

	case 0x01:
		et024006_DrawFilledRect(40, 125, 10, 10, BLACK);
		dotnumber++;
		break;

	case 0x02:
		et024006_DrawFilledRect(50, 145, 10, 10, BLACK);
		dotnumber++;
		break;

	case 0x03:
		et024006_DrawFilledRect(70, 145, 10, 10, BLACK);
		dotnumber++;
		break;

	case 0x04:
		et024006_DrawFilledRect(90, 125, 10, 10, BLACK);
		dotnumber++;
		break;

	case 0x05:
		et024006_DrawFilledRect(110, 105, 10, 10, BLACK);
		dotnumber++;
		break;

	case 0x06:
		et024006_DrawFilledRect(130, 95, 10, 10, BLACK);
		dotnumber++;
		break;

	case 0x07:
		et024006_DrawFilledRect(150, 95, 10, 10, BLACK);
		dotnumber++;
		break;

	case 0x08:
		et024006_DrawFilledRect(170, 95, 10, 10, BLACK);
		dotnumber++;
		break;

	case 0x09:
		et024006_DrawFilledRect(190, 95, 10, 10, BLACK);
		dotnumber++;
		break;

	case 0x0A:
		et024006_DrawFilledRect(195, 110, 10, 10, BLACK);
		dotnumber++;
		break;

	case 0x0B:
		et024006_DrawFilledRect(40, 105, 10, 10, WHITE);
		et024006_DrawFilledRect(40, 125, 10, 10, WHITE);
		et024006_DrawFilledRect(50, 145, 10, 10, WHITE);
		et024006_DrawFilledRect(70, 145, 10, 10, WHITE);
		et024006_DrawFilledRect(90, 125, 10, 10, WHITE);
		et024006_DrawFilledRect(110, 105, 10, 10, WHITE);
		et024006_DrawFilledRect(130, 95, 10, 10, WHITE);
		et024006_DrawFilledRect(150, 95, 10, 10, WHITE);
		et024006_DrawFilledRect(170, 95, 10, 10, WHITE);
		et024006_DrawFilledRect(190, 95, 10, 10, WHITE);
		et024006_DrawFilledRect(195, 110, 10, 10, WHITE);
		dotnumber = 0x00;
		break;

	default:
		break;
	}
}
Beispiel #23
0
/**
 * \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();
}
Beispiel #24
0
/*! \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();
	}
}
Beispiel #25
0
/**
 * \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);
}
Beispiel #26
0
/*! \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)...
}
Beispiel #27
0
/*! \brief Draws the volume bar on the playing view.
 */
static bool draw_volume_bar(struct file_info *current_file_info)
{
  uint8_t volume;

  // the volume is in dB and ranges from +6 to -72 and has an extra value for muted which is the
  // smallest int8_t value
  volume = current_file_info->volume;
  if(ram_files[AUDIO_PLAYER_IMAGE].start_addr)
  {
    et024006_PutPixmap(ram_files[AUDIO_PLAYER_IMAGE].start_addr,
                       ET024006_WIDTH, VOLUME_BAR_POS_X, VOLUME_BAR_POS_Y, VOLUME_BAR_POS_X, VOLUME_BAR_POS_Y, VOLUME_BAR_WIDTH, VOLUME_BAR_HEIGHT);
  }
  if(volume == VOLUME_MUTED)
  {

  }
  if(volume > VOLUME_LEVEL_1)
  {
    et024006_DrawFilledRect( VOLUME_BAR_POS_X, VOLUME_BAR_POS_Y + VOLUME_BAR_LEVEL10_HEIGHT - VOLUME_BAR_LEVEL1_HEIGHT,
                            VOLUME_BAR_PART_WIDTH, VOLUME_BAR_LEVEL1_HEIGHT, VOLUME_BAR_COLOR);
  }
  if(volume > VOLUME_LEVEL_2)
  {
    et024006_DrawFilledRect( VOLUME_BAR_POS_X + VOLUME_BAR_PART_WIDTH + VOLUME_BAR_SPACING,
                            VOLUME_BAR_POS_Y + VOLUME_BAR_LEVEL10_HEIGHT - VOLUME_BAR_LEVEL2_HEIGHT,
                            VOLUME_BAR_PART_WIDTH, VOLUME_BAR_LEVEL2_HEIGHT, VOLUME_BAR_COLOR);
  }
  if(volume > VOLUME_LEVEL_3)
  {
    et024006_DrawFilledRect( VOLUME_BAR_POS_X + 2* (VOLUME_BAR_PART_WIDTH + VOLUME_BAR_SPACING)+ 1,
                            VOLUME_BAR_POS_Y + VOLUME_BAR_LEVEL10_HEIGHT - VOLUME_BAR_LEVEL3_HEIGHT,
                            VOLUME_BAR_PART_WIDTH, VOLUME_BAR_LEVEL3_HEIGHT, VOLUME_BAR_COLOR);
  }
  if(volume > VOLUME_LEVEL_4)
  {
    et024006_DrawFilledRect( VOLUME_BAR_POS_X + 3 * (VOLUME_BAR_PART_WIDTH + VOLUME_BAR_SPACING) +1,
                            VOLUME_BAR_POS_Y + VOLUME_BAR_LEVEL10_HEIGHT - VOLUME_BAR_LEVEL4_HEIGHT,
                            VOLUME_BAR_PART_WIDTH, VOLUME_BAR_LEVEL4_HEIGHT, VOLUME_BAR_COLOR);
  }
  if(volume > VOLUME_LEVEL_5)
  {
    et024006_DrawFilledRect( VOLUME_BAR_POS_X + 4 * (VOLUME_BAR_PART_WIDTH + VOLUME_BAR_SPACING) +1,
                            VOLUME_BAR_POS_Y +VOLUME_BAR_LEVEL10_HEIGHT - VOLUME_BAR_LEVEL5_HEIGHT,
                            VOLUME_BAR_PART_WIDTH, VOLUME_BAR_LEVEL5_HEIGHT, VOLUME_BAR_COLOR);
  }
  if(volume > VOLUME_LEVEL_6)
  {
    et024006_DrawFilledRect( VOLUME_BAR_POS_X + 5 * (VOLUME_BAR_PART_WIDTH + VOLUME_BAR_SPACING) +1,
                            VOLUME_BAR_POS_Y + VOLUME_BAR_LEVEL10_HEIGHT - VOLUME_BAR_LEVEL6_HEIGHT,
                            VOLUME_BAR_PART_WIDTH, VOLUME_BAR_LEVEL6_HEIGHT, VOLUME_BAR_COLOR);
  }
  if(volume > VOLUME_LEVEL_7)
  {
    et024006_DrawFilledRect( VOLUME_BAR_POS_X + 6 * (VOLUME_BAR_PART_WIDTH + VOLUME_BAR_SPACING) +1,
                            VOLUME_BAR_POS_Y + VOLUME_BAR_LEVEL10_HEIGHT - VOLUME_BAR_LEVEL7_HEIGHT,
                            VOLUME_BAR_PART_WIDTH, VOLUME_BAR_LEVEL7_HEIGHT, VOLUME_BAR_COLOR);
  }
  if(volume > VOLUME_LEVEL_8)
  {
    et024006_DrawFilledRect( VOLUME_BAR_POS_X + 7 * (VOLUME_BAR_PART_WIDTH + VOLUME_BAR_SPACING) +2,
                            VOLUME_BAR_POS_Y + VOLUME_BAR_LEVEL10_HEIGHT - VOLUME_BAR_LEVEL8_HEIGHT,
                            VOLUME_BAR_PART_WIDTH, VOLUME_BAR_LEVEL8_HEIGHT, VOLUME_BAR_COLOR);
  }
  if(volume > VOLUME_LEVEL_9)
  {
    et024006_DrawFilledRect( VOLUME_BAR_POS_X + 8 * (VOLUME_BAR_PART_WIDTH + VOLUME_BAR_SPACING) +2,
                            VOLUME_BAR_POS_Y + VOLUME_BAR_LEVEL10_HEIGHT - VOLUME_BAR_LEVEL9_HEIGHT,
                            VOLUME_BAR_PART_WIDTH, VOLUME_BAR_LEVEL9_HEIGHT, VOLUME_BAR_COLOR);
  }
  if(volume >= VOLUME_LEVEL_10)
  {
    et024006_DrawFilledRect( VOLUME_BAR_POS_X + 9 * (VOLUME_BAR_PART_WIDTH + VOLUME_BAR_SPACING)+2, VOLUME_BAR_POS_Y,
                            VOLUME_BAR_PART_WIDTH, VOLUME_BAR_LEVEL10_HEIGHT, VOLUME_BAR_COLOR);
  }

  return true;
}
Beispiel #28
0
//!
//! @brief This function displays the MMI interface and some static informations.
//!
static void mmi_display( void )
{
  #if (defined __GNUC__) || ((defined USB_RESYNC_METHOD) && (USB_RESYNC_METHOD == USB_RESYNC_METHOD_SOFT_ADD_DEL_SAMPLES))
    char tmp[64];
  #endif
  if( mmi_state!=11 )
  {
     if( mmi_state==0 )
     {
        cpu_set_timeout( cpu_ms_2_cy(TIMER_STARTUP, FCPU_HZ), &timer );
        mmi_state++;
     }
     else if( cpu_is_timeout(&timer) )
     {
        switch( mmi_state++ )
        {
        case 1:
           LED_On( LED0 );
           cpu_set_timeout( cpu_ms_2_cy(TIMER_STARTUP, FCPU_HZ), &timer );

           // 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);
           #if(defined USB_RESYNC_METHOD)
              #if (defined USB_RESYNC_METHOD) && (USB_RESYNC_METHOD == USB_RESYNC_METHOD_EXT_CLOCK_SYNTHESIZER)
                 et024006_PrintString("32/44.1/48 KHz, HID, CS2200"     , (const unsigned char *)&FONT8x8, 50, START_Y_DEMO_TEXT+0*FONT_HEIGHT, BLUE, -1);
              #elif (defined USB_RESYNC_METHOD) && (USB_RESYNC_METHOD == USB_RESYNC_METHOD_SOFT_ADAPTIF_SRC)
                 et024006_PrintString("%32/44.1/48 KHz, HID, adaptive SRC", (const unsigned char *)&FONT8x8, 50, START_Y_DEMO_TEXT+0*FONT_HEIGHT, BLUE, -1);
              #elif (defined USB_RESYNC_METHOD) && (USB_RESYNC_METHOD == USB_RESYNC_METHOD_SOFT_ADD_DEL_SAMPLES)
                 sprintf( tmp, "%d.%d KHz, HID, Add/remove sample", SPEAKER_FREQUENCY/1000, SPEAKER_FREQUENCY%1000);
                 et024006_PrintString(tmp, (const unsigned char *)&FONT8x8, 50, START_Y_DEMO_TEXT+0*FONT_HEIGHT, BLUE, -1);
              #else
                 #error Unknown synchronization method.
              #endif
           #endif

           // Display bargraph window.
           mmi_activity_display(true, (uint32_t)NULL);

           #if (defined __GNUC__)
              sprintf( tmp, "RAM (DATA): %ld bytes", (uint32_t)&_edata-(uint32_t)&_data);
              et024006_PrintString(tmp, (const unsigned char *)&FONT8x8, 50, START_Y_DEMO_TEXT+10*FONT_HEIGHT, BLUE, -1);

              sprintf( tmp, "RAM (BSS): %ld bytes", (uint32_t)&end-(uint32_t)&__bss_start);
              et024006_PrintString(tmp, (const unsigned char *)&FONT8x8, 50, START_Y_DEMO_TEXT+11*FONT_HEIGHT, BLUE, -1);

              sprintf( tmp, "RAM (STACK): %ld bytes", (uint32_t)&_estack-(uint32_t)&_stack);
              et024006_PrintString(tmp, (const unsigned char *)&FONT8x8, 50, START_Y_DEMO_TEXT+12*FONT_HEIGHT, BLUE, -1);
           #endif
           #if (defined __GNUC__)
              et024006_PrintString("RAM (total used HEAP):       bytes", (const unsigned char *)&FONT8x8, 50, START_Y_DEMO_TEXT+13*FONT_HEIGHT, BLUE, WHITE);
              et024006_PrintString("RAM (curr used HEAP):        bytes", (const unsigned char *)&FONT8x8, 50, START_Y_DEMO_TEXT+14*FONT_HEIGHT, BLUE, WHITE);
           #elif (defined __ICCAVR32__)
              et024006_PrintString("RAM (free HEAP):             bytes", (const unsigned char *)&FONT8x8, 50, START_Y_DEMO_TEXT+14*FONT_HEIGHT, BLUE, WHITE);
           #endif
           break;

        case 2: cpu_set_timeout( cpu_ms_2_cy(TIMER_STARTUP, FCPU_HZ), &timer ); LED_On( LED1 ); break;
        case 3: cpu_set_timeout( cpu_ms_2_cy(TIMER_STARTUP, FCPU_HZ), &timer ); LED_On( LED2 ); break;
        case 4: cpu_set_timeout( cpu_ms_2_cy(TIMER_STARTUP, FCPU_HZ), &timer ); LED_On( LED3 ); break;
        case 5: cpu_set_timeout( cpu_ms_2_cy(TIMER_STARTUP, FCPU_HZ), &timer ); LED_Off( LED0 ); break;
        case 6: cpu_set_timeout( cpu_ms_2_cy(TIMER_STARTUP, FCPU_HZ), &timer ); LED_Off( LED1 ); break;
        case 7: cpu_set_timeout( cpu_ms_2_cy(TIMER_STARTUP, FCPU_HZ), &timer ); LED_Off( LED2 ); break;
        case 8:
           LED_Off( LED3 );
           cpu_stop_timeout(&timer);
           break;

        default:
           break;
        }
     }
  }
}
Beispiel #29
0
//!
//! @brief This function displays the a bargraph indicating the state of the audio buffers and
//! the PPM deviation between the incoming USB audio sampling frequency and the output DAC sampling frequency.
//!
static void mmi_activity_display( bool init, uint32_t fifo_cnt )
{
  static char tmp[20];
  static int32_t  ppm;
  #define TIMER_MMI            1000   // Unit is in ms.
  static t_cpu_time mmi_timer;
  static uint32_t old_fcpu_hz = 0;
  static uint32_t mmi_activity_state=0;
  static uint32_t i;

  if( init )
  {
     // Display PPM window
     et024006_PrintString("PPM", (const unsigned char *)&FONT8x8, 22, 70+4, BLUE, -1);
     display_box(50, 70, 40, 16, WHITE, BLACK);

     et024006_PrintString("HID", (const unsigned char *)&FONT8x8, 122, 70+4, BLUE, -1);
     display_box(150, 70, 40, 16, WHITE, BLACK);

     et024006_PrintString("CPU", (const unsigned char *)&FONT8x8, 222, 70+4, BLUE, -1);
     display_box(250, 70, 40, 16, WHITE, BLACK);

     et024006_PrintString("Buffers", (const unsigned char *)&FONT8x8, 0, 50+4, BLUE, -1);
     display_box(50, 50, 195, 16, WHITE, BLACK);
     cpu_set_timeout( cpu_ms_2_cy(TIMER_MMI, FCPU_HZ), &mmi_timer );
     goto mmi_end;
  }

  if( !cpu_is_timeout(&mmi_timer) )
     goto mmi_end;

  switch( mmi_activity_state )
  {
  case 0:
     i = 0;
     mmi_activity_state = 1;
     // no break here

  case 1:
     if( i>=USB_STREAM_BUFFER_NUMBER )
     {
        mmi_activity_state = 10;
        break;
     }
     if( i<fifo_cnt )
        et024006_DrawFilledRect(50+3 + i*(10+2), 50+3, 10, 10, BLUE_LEV(15) );
     else
        et024006_DrawFilledRect(50+3 + i*(10+2), 50+3, 10, 10, WHITE );
     i++;
     break;

  case 10:
     ppm = usb_stream_ppm_get();
     sprintf( tmp, "%4ld", ppm );
     et024006_PrintString(tmp, (const unsigned char *)&FONT8x8, 50+4, 70+4, BLUE, WHITE);
     mmi_activity_state = 20;
     break;

  case 20:
     if( old_fcpu_hz==FCPU_HZ )
     {
        mmi_activity_state = 30;
        break;
     }
     else
        mmi_activity_state = 21;
     // No break here

  case 21:
     old_fcpu_hz=FCPU_HZ;
     sprintf( tmp, "%ld", (uint32_t)FCPU_HZ/1000000);
     et024006_PrintString(tmp, (const unsigned char *)&FONT8x8, 250+4, 70+4, BLUE, WHITE);
     mmi_activity_state = 30;
     break;

#if (defined __GNUC__)
  case 30:
     sprintf( tmp, "%ld", get_heap_total_used_size() );
     et024006_PrintString(tmp, (const unsigned char *)&FONT8x8, 230, START_Y_DEMO_TEXT+13*FONT_HEIGHT, BLUE, WHITE);
     mmi_activity_state = 31;
     break;

  case 31:
     sprintf( tmp, "%ld", get_heap_curr_used_size() );
     et024006_PrintString(tmp, (const unsigned char *)&FONT8x8, 230, START_Y_DEMO_TEXT+14*FONT_HEIGHT, BLUE, WHITE);
     // No break here
#elif (defined __ICCAVR32__)
  case 30:
     sprintf( tmp, "%ld", get_heap_free_size() );
     et024006_PrintString(tmp, (const unsigned char *)&FONT8x8, 230, START_Y_DEMO_TEXT+14*FONT_HEIGHT, BLUE, WHITE);
     // No break here

#endif

  default:
     // Rearm timer
     cpu_set_timeout( cpu_ms_2_cy(TIMER_MMI, FCPU_HZ), &mmi_timer );
     mmi_activity_state = 0;
     break;
  }

mmi_end:
  return;
}
Beispiel #30
0
void gui_draw(int force_draw) {
        int i;

        if (! mod) {
                return;
        }
        mod = 0;
#if BOARD != EVK1100
        // Draw title box
        et024006_DrawFilledRect(TITLE_X,
                                TITLE_Y,
                                TITLE_W,
                                TITLE_H,
                                TITLE_BG_COLOR);
        if (title_contents.title[0][0]) {
                et024006_PrintString(title_contents.title[0],
                                     (const unsigned char*)&FONT8x8,
                                     TITLE_X + 10,
                                     TITLE_Y + 5,
                                     TITLE_FG_COLOR,
                                     TITLE_BG_COLOR);
                et024006_PrintString(title_contents.title[1],
                                     (const unsigned char*)&FONT8x8,
                                     TITLE_X + 10,
                                     TITLE_Y + 5 + 12,
                                     TITLE_FG_COLOR,
                                     TITLE_BG_COLOR);
                et024006_PrintString(title_contents.title[2],
                                     (const unsigned char*)&FONT8x8,
                                     TITLE_X + 10,
                                     TITLE_Y + 5 + 12 + 12,
                                     TITLE_FG_COLOR,
                                     TITLE_BG_COLOR);

        }


        // Draw scroll box
        et024006_DrawFilledRect(SCROLL_X,
                                SCROLL_Y,
                                SCROLL_W,
                                SCROLL_H,
                                scroll_box_contents.bg_color);

#endif
        switch (display_mode)
        {
        case GUI_INFOBOX:
                gui_display_infobox();
                break;

        case GUI_GETSTRING:
                gui_display_getstring();
                break;

        case GUI_LIST:
        {
#if BOARD == EVK1100
                dip204_clear_display();
#endif
                for (i = 0; i <= SCROLL_DISP_LINES; i++)
                {

#if BOARD == EVK1100

                        dip204_set_cursor_position(1,i+1); /* col,line */

                        dip204_write_string(scroll_box_contents.lines[i+scroll_box_contents.dispstart]);

#else

                        if ((scroll_box_contents.cursor == i + scroll_box_contents.dispstart) &&
                            scroll_box_contents.cursor != 0)
                        {
                                /* Print cursor line. */
                                et024006_PrintString(scroll_box_contents.lines[i+scroll_box_contents.dispstart],
                                                     (const unsigned char*)&FONT8x8,
                                                     SCROLL_X + 10,
                                                     (i+1)*12+SCROLL_Y,
                                                     scroll_box_contents.bg_color,
                                                     CURSOR_BG_COLOR);
                        }
                        else
                        {
                                et024006_PrintString(scroll_box_contents.lines[i+scroll_box_contents.dispstart],
                                                     (const unsigned char*)&FONT8x8,
                                                     SCROLL_X + 10,
                                                     (i+1)*12+SCROLL_Y,
                                                     SCROLL_FG_COLOR,
                                                     scroll_box_contents.bg_color);
                        }
#endif
                }
#if BOARD == EVK1100
                dip204_set_cursor_position(1, scroll_box_contents.cursor - scroll_box_contents.dispstart+1);
                dip204_show_cursor();
#endif
        }
        } /* switch */
        // Draw buttons
#if BOARD != EVK1100
        et024006_DrawFilledRect(BUTTON_X,
                                BUTTON_Y,
                                BUTTON_W,
                                BUTTON_H,
                                BUTTON_BG_COLOR);
        for (i = 0; i < NUM_BUTTONS-1; i++) {
                et024006_DrawVertLine(i*BUTTON_W/NUM_BUTTONS,
                                      BUTTON_Y,
                                      BUTTON_H,
                                      BUTTON_FG_COLOR);
                // Display button labels
                if (button_contents.labels[i]) {
                        et024006_PrintString(button_contents.labels[i],
                                             (const unsigned char*)&FONT8x8,
                                             i*BUTTON_W/NUM_BUTTONS + 5,
                                             BUTTON_Y + 10,
                                             BUTTON_FG_COLOR,
                                             BUTTON_BG_COLOR);
                }
        }
#endif
}