Esempio n. 1
0
static void gui_print( TString textToDisplay )
{
  int	i = 0;
  boolean strError = false;

  while ( textToDisplay[i] != 0 )
  {
    // Maximum length for display, adjust in engine
    if ( i == 19 )
    {
      strError = true;
      break;
    }
    i++;
  }

  et024006_PrintString("                                          ", (const unsigned char *)&FONT6x8, 80, 80, WHITE, -1);
  if (!strError )
  {
    et024006_PrintString((char*)textToDisplay, (const unsigned char *)&FONT6x8, 80, 80, WHITE, -1);

  }
  else
  {
    et024006_PrintString("str err" , (const unsigned char *)&FONT6x8, 80, 80, WHITE, -1);

  }
}
Esempio n. 2
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);
}
Esempio n. 3
0
static void display_perf(uint32_t x, uint32_t y, bool b_clear, uint32_t perf_kBps, uint16_t string_color)
{
  display_box(x, y, 50, 18, WHITE, BLACK);
  if( !b_clear )
  {
    sprintf(string, "%5ld", perf_kBps);
    et024006_PrintString(string, (const unsigned char *)&FONT8x8, x+5, y+6, string_color, -1);
  }
  else
  {
    et024006_PrintString("KByte/s", (const unsigned char *)&FONT8x8, x+55, y+6, BLACK, -1);
  }
}
Esempio n. 4
0
static bool draw_cursor(struct display_file_list *lst_str)
{
  // Print the cursor
  et024006_PrintString(">", (unsigned char *) FILE_LIST_FONT,
                       FILE_LIST_POS_X, FILE_LIST_POS_Y, APPLI_FG_COLOR, APPLI_BG_COLOR);
  return true;
}
Esempio n. 5
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;
}
Esempio n. 6
0
static bool draw_no_file(struct display_file_list *lst_str)
{
  const char message[] = "Empty directory";
  et024006_PrintString((char *) message, (unsigned char *) FILE_LIST_FONT,
                       FILE_LIST_POS_X + FILE_LIST_ITEM_X, FILE_LIST_POS_Y,
                       0xFD60, APPLI_BG_COLOR);
  return true;
}
Esempio n. 7
0
static bool draw_config_view_print_repeat(struct player_info *player)
{
  int offset_y;

  // Clear the previous repeat message
  if (ram_files[CONFIG_IMAGE].start_addr)
    et024006_PutPixmap(ram_files[CONFIG_IMAGE].start_addr,
                       ET024006_WIDTH, REPEAT_POS_X + 10*REPEAT_FONT_WIDTH, REPEAT_POS_Y,
                       REPEAT_POS_X + 10*REPEAT_FONT_WIDTH, REPEAT_POS_Y,
                       REPEAT_FONT_WIDTH, REPEAT_MESSAGE_HEIGHT);

  // Print the message
  et024006_PrintString("Repeat:  [ ] Off", (unsigned char *) REPEAT_FONT,
                       REPEAT_POS_X, REPEAT_POS_Y, APPLI_FG_COLOR, APPLI_BG_COLOR);
  et024006_PrintString("         [ ] Track", (unsigned char *) REPEAT_FONT,
                       REPEAT_POS_X, REPEAT_POS_Y + REPEAT_FONT_HEIGHT, APPLI_FG_COLOR, APPLI_BG_COLOR);
  et024006_PrintString("         [ ] Folder", (unsigned char *) REPEAT_FONT,
                       REPEAT_POS_X, REPEAT_POS_Y + 2*REPEAT_FONT_HEIGHT, APPLI_FG_COLOR, APPLI_BG_COLOR);
  et024006_PrintString("         [ ] All", (unsigned char *) REPEAT_FONT,
                       REPEAT_POS_X, REPEAT_POS_Y + 3*REPEAT_FONT_HEIGHT, APPLI_FG_COLOR, APPLI_BG_COLOR);

  switch (player->repeat)
  {
  case AUDIO_REPEAT_TRACK:
    offset_y = 1*REPEAT_FONT_HEIGHT;
    break;
  case AUDIO_REPEAT_FOLDER:
    offset_y = 2*REPEAT_FONT_HEIGHT;
    break;
  case AUDIO_REPEAT_ALL:
    offset_y = 3*REPEAT_FONT_HEIGHT;
    break;
  case AUDIO_REPEAT_OFF:
  default:
    offset_y = 0;
  }

  // Draw cursor
  et024006_PrintString("X", (unsigned char *) REPEAT_FONT,
                       REPEAT_POS_X + 10*REPEAT_FONT_WIDTH, REPEAT_POS_Y + offset_y, APPLI_FG_COLOR, APPLI_BG_COLOR);

  return true;
}
Esempio n. 8
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);
}
Esempio n. 9
0
File: gui.c Progetto: InSoonPark/asf
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
}
Esempio n. 10
0
static void draw_device_type(void)
{
  char *type = "";

  if (ai_is_usb_ms())
    type = "USB MS";
  else if (ai_is_hid_class())
    type = "USB Audio";
  else if (ai_is_sd_mmc())
    type = "SD/MMC card";

  et024006_PrintString(type, (unsigned char *) FONT8x8, 16, 5, 0xFD60, APPLI_BG_COLOR);
}
Esempio n. 11
0
static bool draw_config_view_print_cursor(struct display_file_list *lst_str)
{
  // Clear the previous cursor position
  if (ram_files[CONFIG_IMAGE].start_addr)
    et024006_PutPixmap(ram_files[CONFIG_IMAGE].start_addr,
                       ET024006_WIDTH, CURSOR_POS_X, REPEAT_POS_Y,
                       CURSOR_POS_X, REPEAT_POS_Y,
                       CURSOR_FONT_WIDTH, CURSOR_RANGE_HEIGHT);

  switch (lst_str->mode_pos)
  {
  case MODE_POS_REPEAT:
    et024006_PrintString(">", (unsigned char *) CURSOR_FONT,
                         CURSOR_POS_X, REPEAT_POS_Y, APPLI_FG_COLOR, APPLI_BG_COLOR);
    break;
  case MODE_POS_SHUFFLE:
    et024006_PrintString(">", (unsigned char *) CURSOR_FONT,
                         CURSOR_POS_X, SHUFFLE_POS_Y, APPLI_FG_COLOR, APPLI_BG_COLOR);
    break;
  }
  return true;
}
Esempio n. 12
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);
}
Esempio n. 13
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;
}
Esempio n. 14
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;
}
Esempio n. 15
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();
}
Esempio n. 16
0
static bool draw_play_view_print_title(struct file_info *current_file_info)
{
  char string[TITLE_CHARS_MAX+2];

  strncpy(string, (const char *) current_file_info->title, TITLE_CHARS_MAX);
  string[TITLE_CHARS_MAX+1] = '\0';
  // draw background behind the text
  if(ram_files[AUDIO_PLAYER_IMAGE].start_addr)
    et024006_PutPixmap(ram_files[AUDIO_PLAYER_IMAGE].start_addr,
                       ET024006_WIDTH, TITLE_POS_X, TITLE_POS_Y,
                       TITLE_POS_X, TITLE_POS_Y, TITLE_WIDTH, TITLE_HEIGHT);
  if(string[0] != '\0')
  {
    et024006_PrintString(string, (unsigned char *) TITLE_FONT, TITLE_POS_X, TITLE_POS_Y,
                         APPLI_FG_COLOR, APPLI_BG_COLOR);
  }
  return true;
}
Esempio n. 17
0
static bool draw_play_view_print_file(struct file_info *current_file_info)
{
  char string[NAME_CHARS_MAX+2];

  strncpy(string, (const char *) current_file_info->name, NAME_CHARS_MAX);
  string[NAME_CHARS_MAX+1] = '\0';
  // draw background behind the text
  if(ram_files[AUDIO_PLAYER_IMAGE].start_addr)
    et024006_PutPixmap(ram_files[AUDIO_PLAYER_IMAGE].start_addr,
                       ET024006_WIDTH, FILE_NAME_POS_X, FILE_NAME_POS_Y,
                       FILE_NAME_POS_X, FILE_NAME_POS_Y, FILE_NAME_WIDTH, FILE_NAME_HEIGHT);
  // if no artist data is available we print the file name
  if(string[0] != '\0')
  {
    et024006_PrintString(string, (unsigned char *) FILE_NAME_FONT, FILE_NAME_POS_X, FILE_NAME_POS_Y,
                         APPLI_FG_COLOR, APPLI_BG_COLOR);
  }
  return true;
}
Esempio n. 18
0
static bool draw_play_view_print_total_time(struct file_info *current_file_info)
{
  uint32_t hours, minutes, seconds, tmp;
  char time_string[32];

  tmp = current_file_info->total_time;
  hours = tmp / (1000 * 60 * 60);
  tmp %= 1000 * 60 * 60;
  minutes = tmp / (1000 * 60);
  tmp %= 1000 * 60;
  seconds = tmp / 1000;
  sprintf(time_string, "%02u:%02u:%02u", (unsigned int) hours, (unsigned int) minutes, (unsigned int) seconds);
  // Draw background behind the text.
  if(ram_files[AUDIO_PLAYER_IMAGE].start_addr)
    et024006_PutPixmap(ram_files[AUDIO_PLAYER_IMAGE].start_addr,
                       ET024006_WIDTH, TOTAL_TIME_POS_X, TOTAL_TIME_POS_Y, TOTAL_TIME_POS_X, TOTAL_TIME_POS_Y, TOTAL_TIME_WIDTH, TOTAL_TIME_HEIGHT);
  et024006_PrintString(time_string, (unsigned char *) TIME_FONT, TOTAL_TIME_POS_X, TOTAL_TIME_POS_Y, APPLI_FG_COLOR, APPLI_BG_COLOR);

  return true;
}
Esempio n. 19
0
void gui_display_getstring(void)
{
        int j;
        int i;
#if BOARD != EVK1100
        int fg_color, bg_color;
#endif
        char str[22];

#if BOARD == EVK1100
        if (redisplay) {
                dip204_clear_display();
                for (j = 0; j <= SCROLL_DISP_LINES; j++) {
                        strncpy(str, &(char_array[get_string_data.rowstart+j][get_string_data.colstart]), MAX_LINE_LEN);
                        str[MAX_LINE_LEN] = '\0';
                        dip204_set_cursor_position(1,j+2); /* col,line */
                        dip204_write_string(str);
                }
        }
#else
        for (j = 0; j < GS_MAX_ROWS; j++) {
                for (i = 0; i < strlen(char_array[j]); i++) {
                        if (get_string_data.row == j && get_string_data.col == i) {
                                fg_color = CURSOR_FG_COLOR;
                                bg_color = CURSOR_BG_COLOR;
                        } else {
                                fg_color = SCROLL_FG_COLOR;
                                bg_color = SCROLL_BG_COLOR;
                        }
                        str[0] = char_array[j][i];
                        str[1] = 0;
                        et024006_PrintString(str,
                                             (const unsigned char*)&FONT8x8,
                                             (i+1)*10+SCROLL_X + 10,
                                             (j+1)*12+SCROLL_Y,
                                             fg_color,
                                             bg_color);
                }
        }
#endif

#if BOARD == EVK1100
        if (redisplay){
                if (get_string_data.rowstart == GS_MAX_ROWS - SCROLL_DISP_LINES) {
                        dip204_set_cursor_position(1,1); /* col,line */
                        dip204_write_string("                   ");
                        j = 1;
                        for (i = 0; i <  (sizeof func_row/sizeof func_row[0]); i++) {
                                dip204_set_cursor_position(j,get_string_data.rowstart + SCROLL_DISP_LINES); /* col,line */
                                dip204_write_string(func_row[i]);
                                j += strlen(func_row[i]);
                        }
                }
                redisplay = false;
        }

        dip204_set_cursor_position(1,1); /* col,line */
        dip204_write_string("                   ");
        dip204_set_cursor_position(1,1); /* col,line */
        dip204_write_string(getstring);
        if (get_string_data.row == GS_MAX_ROWS) {
                dip204_set_cursor_position(get_string_data.col * strlen(func_row[0]) + 2, GS_MAX_ROWS); /* col,line */
        } else {
                dip204_set_cursor_position(get_string_data.col + 1 - get_string_data.colstart,
                                           get_string_data.row + 2 - get_string_data.rowstart); /* col,line */
        }
        dip204_show_cursor();
#else
        j = 1;
        for (i = 0; i <  (sizeof func_row/sizeof func_row[0]); i++) {
                if (get_string_data.row == GS_MAX_ROWS && get_string_data.col == i) {
                        fg_color = CURSOR_FG_COLOR;
                        bg_color = CURSOR_BG_COLOR;
                } else {
                        fg_color = SCROLL_FG_COLOR;
                        bg_color = SCROLL_BG_COLOR;
                }
                et024006_PrintString(func_row[i],
                                     (const unsigned char*)&FONT8x8,
                                     j*10 + SCROLL_X + 10,
                                     5*12+SCROLL_Y,
                                     fg_color,
                                     bg_color);
                j += strlen(func_row[i])-1;
        }
#endif
}
Esempio n. 20
0
void ui_usb_message_reception(void)
{
	static uint8_t rowcounter = 0;
	uint8_t rows_in_message = 0;
	uint8_t i;

	switch (ui_msg[0]) {
	case MESSAGE_DTA_SIMPLE_LED:
		switch (ui_msg[1]) {
		case 0x00:
			ui_pwm_update(LED0, ui_msg[2]);
			break;

		case 0x01:
			ui_pwm_update(LED1, ui_msg[2]);
			break;

		case 0x02:
			if (ui_msg[2] > 0) {
				LED_On(LED2);
			} else {
				LED_Off(LED2);
			}

			break;

		default:
			break;
		}
		break;

	case MESSAGE_DTA_SIMPLE_DISPLAY_BACKLIGHT:
		switch (ui_msg[1]) {
		case 0x01:
		/* Not supported on this Board */

		default:
			break;
		}

	case MESSAGE_DTA_STRING_BASIC:
		if (ui_msg[2] > 37) {
			/* Truncate everything longer than 37 characters
			 * (command is 3 bytes long) */
			ui_msg[40] = '\0';
		} else {
			ui_msg[ui_msg[2] + 3] = '\0';
		}

		rows_in_message++;
		rowcounter++;
		for (i = 3; i < ui_msg[2] + 3; i++) {
			if (ui_msg[i] == '\n') {
				rows_in_message++;
				rowcounter++;
			}

			if (rowcounter >= DISPLAY_MAX_LINES) {
				i = 3;
				rowcounter = 1;
				rows_in_message = 1;
				ui_display_clr_screen();
			}
		}
		et024006_PrintString((char *)(&(ui_msg[3])),
				(const uint8_t*)&FONT8x16, DISPLAY_FIRST_LINE_X,
				DISPLAY_FIRST_LINE_Y+
				(rowcounter-rows_in_message)*17, BLUE, -1);

		break;

	default:
		break;
	}
}
Esempio n. 21
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);
}
Esempio n. 22
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;
}
//!
//! @brief Looks for HID events.
//!
bool is_usb_hid_event(void) {
  static bool b_on_off = false;
  static bool b_prev   = false;
  static bool b_next   = false;
  static bool b_vol_up = false;
  static bool b_vol_dn = false;

  // Management of Play/Pause
  //
  if(is_joystick_pressed() && b_on_off==false)
  {
    b_on_off = true;
    key = HID_PLAY_PAUSE;
    et024006_PrintString("PLAY", (const unsigned char *)&FONT8x8, 153, 70+4, BLUE, WHITE);
    return true;
  }
  if(!is_joystick_pressed() && b_on_off==true)
  {
    b_on_off = false;
    key = 0;
    et024006_PrintString("    ", (const unsigned char *)&FONT8x8, 153, 70+4, BLUE, WHITE);
    return true;
  }

  // Management of Prev
  //
  if (is_joystick_left() && b_prev == false)
  {
    b_prev = true;
    key = HID_PREV;

    et024006_PrintString("PREV", (const unsigned char *)&FONT8x8, 153, 70+4, BLUE, WHITE);
    return true;
  }
  if (!is_joystick_left() && b_prev == true)
  {
    b_prev = false;
    key = 0;

    et024006_PrintString("    ", (const unsigned char *)&FONT8x8, 153, 70+4, BLUE, WHITE);
    return true;
  }

  // Management of Next
  //
  if (is_joystick_right() && b_next == false)
  {
    b_next = true;
    key = HID_NEXT;

    et024006_PrintString("NEXT", (const unsigned char *)&FONT8x8, 153, 70+4, BLUE, WHITE);
    return true;
  }
  if (!is_joystick_right() && b_next == true)
  {
    b_next = false;
    key = 0;

    et024006_PrintString("    ", (const unsigned char *)&FONT8x8, 153, 70+4, BLUE, WHITE);
    return true;
  }


  // Management of Vol -
  //
  if (is_joystick_down() && b_vol_dn == false)
  {
    key = HID_VOL_DN;
    b_vol_dn = true;

    et024006_PrintString("VOL-", (const unsigned char *)&FONT8x8, 153, 70+4, BLUE, WHITE);
    return true;
  }
  if (!is_joystick_down() && b_vol_dn == true)
  {
    b_vol_dn = false;
    key = 0;

    et024006_PrintString("    ", (const unsigned char *)&FONT8x8, 153, 70+4, BLUE, WHITE);
    return true;
  }

  // Management of Vol +
  //
  if (is_joystick_up() && b_vol_up == false)
  {
    key = HID_VOL_UP;
    b_vol_up = true;

    et024006_PrintString("VOL+", (const unsigned char *)&FONT8x8, 153, 70+4, BLUE, WHITE);
    return true;
  }
  if (!is_joystick_up() && b_vol_up == true)
  {
    b_vol_up = false;
    key = 0;

    et024006_PrintString("    ", (const unsigned char *)&FONT8x8, 153, 70+4, BLUE, WHITE);
    return true;
  }

  return false;
}
Esempio n. 24
0
//!
//! @brief Entry point of the MMI task management
//!
void mmi_task(void)
{
  uint32_t i;
  switch( mmi_state )
  {
  case MMI_TOP_MENU_START:
    // Draw the background AVR32 logo.
    et024006_PutPixmap(avr32_logo, 320, 0, 0, 0, 0, 320, 240);

    // Display welcome string.
    et024006_PrintString("EVK1104 Demo", (const unsigned char *)&FONT8x8, 110, 220, BLACK, -1);

    mmi_state = MMI_TOP_MENU;
    break;

  case MMI_TOP_MENU:
    if( Is_usb_vbus_high() )
    {
      mmi_state = MMI_MASS_STORAGE_START;
    }
    break;

  case MMI_MASS_STORAGE_START:
    // Draw the background AVR32 logo.
    et024006_PutPixmap(avr32_logo, 320, 0, 0, 0, 0, 320, 240);

    // Display USB key logo.
    et024006_DrawFilledRect(220-1, 20-1, 80+2, 42+2, BLACK );
    et024006_PutPixmap(ms_key_logo, 80, 0, 0, 220, 20, 80, 42);

    // Display title.
    et024006_PrintString("U-Disk", (const unsigned char *)&FONT6x8, 240, 65, BLACK, -1);

    // Display Activity window.
    display_box(80, 180, 156, 16, WHITE, BLACK);

    // Display performances box.
    display_perf(120, 201, true, 0, 0);

    ms_old_cnt_read = ms_cnt_read =0;
    ms_old_cnt_write = ms_cnt_write =0;
    mmi_state = MMI_MASS_STORAGE;
    ms_cnt_screen = 0;
    for( i=0 ; i<MS_N_PROGRESS_BAR ; i++ )
    {
      ms_progress_bar_level[i] = 1;
      ms_progress_bar_type[i] = BLACK;
    }
    mmi_ms_display();

    cpu_set_timeout( cpu_ms_2_cy(TIMER_MS_PROGRESS_BAR_UPDATE, pm_freq_param.cpu_f), &ms_activity_timer);
    cpu_set_timeout( cpu_ms_2_cy(TIMER_MS_PROGRESS_BAR_CLEAR,  pm_freq_param.cpu_f), &ms_clear_timer);
    break;

  case MMI_MASS_STORAGE:
    // Manage progress-bar shading.
    //
    if( cpu_is_timeout(&ms_clear_timer) )
    {
      cpu_set_timeout( cpu_ms_2_cy(TIMER_MS_PROGRESS_BAR_CLEAR,  pm_freq_param.cpu_f), &ms_clear_timer);
      mmi_ms_display();
    }

    // Manage progress-bar box moving.
    //
    if( cpu_is_timeout(&ms_activity_timer) )
    {
      cpu_set_timeout( cpu_ms_2_cy(TIMER_MS_PROGRESS_BAR_UPDATE, pm_freq_param.cpu_f), &ms_activity_timer);
      if( ms_old_cnt_write != ms_cnt_write )
      {
        ms_cnt_screen = (unsigned char)(ms_cnt_screen-1)%MS_N_PROGRESS_BAR;
        ms_progress_bar_type[ms_cnt_screen] = RED;

        // Compute performances
        //
        perf_write = (U64)(ms_cnt_write - ms_old_cnt_write)*SD_MMC_SECTOR_SIZE/TIMER_MS_PROGRESS_BAR_UPDATE;
        display_perf(120, 201, false, perf_write, RED);
        ms_old_cnt_write = ms_cnt_write;
        ms_progress_bar_level[ms_cnt_screen] = (perf_write>10000) ? 31 :
                                               (perf_write> 7500) ? 29 :
                                               (perf_write> 5000) ? 27 : 25 ;
      }
      else if( ms_old_cnt_read != ms_cnt_read )
      {
        ms_cnt_screen = (unsigned char)(ms_cnt_screen+1)%MS_N_PROGRESS_BAR;
        ms_progress_bar_type[ms_cnt_screen] = BLUE;

        // Compute performances
        //
        perf_read = (U64)(ms_cnt_read - ms_old_cnt_read)*SD_MMC_SECTOR_SIZE/TIMER_MS_PROGRESS_BAR_UPDATE;
        display_perf(120, 201, false, perf_read, BLUE);
        ms_old_cnt_read = ms_cnt_read;
        ms_progress_bar_level[ms_cnt_screen] = (perf_read>10000) ? 31 :
                                               (perf_read> 7500) ? 29 :
                                               (perf_read> 5000) ? 27 : 25 ;
      }
      else
      {
        display_perf(120, 201, true, 0, 0);
      }
    }

    // Detect USB unplug.
    //
    if( Is_usb_vbus_low() )
    {
      mmi_state = MMI_TOP_MENU_START;
    }
    break;

  default:
    break;
  }

}
Esempio n. 25
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)...
}
Esempio n. 26
0
File: gui.c Progetto: InSoonPark/asf
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
}
Esempio n. 27
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
}
Esempio n. 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;
        }
     }
  }
}