gui.h File Reference


Detailed Description

GUI.

Author:
Atmel Corporation: http://www.atmel.com
Support and FAQ: http://support.atmel.no/

Definition in file APPLICATIONS/EVK1104-EVK1105-DSPLIB-DEMO/gui.h.

#include "et024006dhu.h"
#include "dsp_sprintf.h"

Go to the source code of this file.

Defines

#define GUI_BOXES
#define GUI_COMMENT_BG_COLOR   GUI_NO_COLOR
#define GUI_COMMENT_FG_COLOR   GUI_TEXT_COLOR
#define GUI_COMMENT_HEIGHT   56
#define GUI_COMMENT_ID   5
#define GUI_COMMENT_WIDTH   190
#define GUI_COMMENT_X   126
#define GUI_COMMENT_Y   153
#define GUI_FILTER_BG_COLOR   GUI_NO_COLOR
#define GUI_FILTER_FG_COLOR   GUI_TEXT_COLOR
#define GUI_FILTER_HEIGHT   32
#define GUI_FILTER_ID   4
#define GUI_FILTER_WIDTH   171
#define GUI_FILTER_X   130
#define GUI_FILTER_Y   32
#define GUI_FONT   FONT8x8
#define GUI_FONT_HEIGHT   8
#define GUI_FONT_WIDTH   8
#define GUI_INPUT_BG_COLOR   GUI_MAIN_BG_COLOR
#define GUI_INPUT_FG_COLOR   GUI_MAIN_FG_COLOR
#define GUI_INPUT_HEIGHT   56
#define GUI_INPUT_ID   2
#define GUI_INPUT_WIDTH   92
#define GUI_INPUT_X   84
#define GUI_INPUT_Y   82
#define GUI_MAIN_BG_COLOR   0xF79E
#define GUI_MAIN_FG_COLOR   BLACK
#define GUI_NO_COLOR   ((uint16_t) -1)
#define GUI_NO_SEL   -1
#define GUI_OUTPUT_BG_COLOR   GUI_MAIN_BG_COLOR
#define GUI_OUTPUT_FG_COLOR   GUI_MAIN_FG_COLOR
#define GUI_OUTPUT_HEIGHT   56
#define GUI_OUTPUT_ID   3
#define GUI_OUTPUT_WIDTH   92
#define GUI_OUTPUT_X   210
#define GUI_OUTPUT_Y   82
#define GUI_SELECTION_COLOR   0xAA3F
#define GUI_SOURCE1_BG_COLOR   GUI_MAIN_BG_COLOR
#define GUI_SOURCE1_FG_COLOR   GUI_MAIN_FG_COLOR
#define GUI_SOURCE1_HEIGHT   56
#define GUI_SOURCE1_ID   0
#define GUI_SOURCE1_WIDTH   92
#define GUI_SOURCE1_X   13
#define GUI_SOURCE1_Y   10
#define GUI_SOURCE2_BG_COLOR   GUI_MAIN_BG_COLOR
#define GUI_SOURCE2_FG_COLOR   GUI_MAIN_FG_COLOR
#define GUI_SOURCE2_HEIGHT   56
#define GUI_SOURCE2_ID   1
#define GUI_SOURCE2_WIDTH   92
#define GUI_SOURCE2_X   13
#define GUI_SOURCE2_Y   153
#define GUI_TEXT_BUFFER_SIZE   256
 This does not takje care of the buffer overflow, so make sure this value is big enough.
#define GUI_TEXT_COLOR   0xAEAE
#define gui_text_printf(box_id, format,...)
 Print a text in the text area.
#define GUI_ZOOM_BOX_HEIGHT   218
#define GUI_ZOOM_BOX_WIDTH   320
#define GUI_ZOOM_BOX_X   0
#define GUI_ZOOM_BOX_Y   0

Functions

void gui_change_update_fs (uint32_t time_ms)
 This function change the frequency rate of the update of the display.
void gui_clear_view (void)
uint32_t gui_get_update_fs (void)
void gui_init (int cpu_hz, int hsb_hz, int pba_hz, int pbb_hz)
void gui_set_selection (int box_id)
 Select a new box (can select only one box a time).
void gui_task (void)
void gui_text_print (int box_id, const char *text)
 Print text in a text box.


Define Documentation

#define GUI_BOXES

#define GUI_COMMENT_BG_COLOR   GUI_NO_COLOR

#define GUI_COMMENT_FG_COLOR   GUI_TEXT_COLOR

#define GUI_COMMENT_HEIGHT   56

#define GUI_COMMENT_ID   5

#define GUI_COMMENT_WIDTH   190

#define GUI_COMMENT_X   126

#define GUI_COMMENT_Y   153

#define GUI_FILTER_BG_COLOR   GUI_NO_COLOR

#define GUI_FILTER_FG_COLOR   GUI_TEXT_COLOR

#define GUI_FILTER_HEIGHT   32

#define GUI_FILTER_ID   4

#define GUI_FILTER_WIDTH   171

#define GUI_FILTER_X   130

#define GUI_FILTER_Y   32

#define GUI_FONT   FONT8x8

Definition at line 115 of file APPLICATIONS/EVK1104-EVK1105-DSPLIB-DEMO/gui.h.

Referenced by gui_text_print().

#define GUI_FONT_HEIGHT   8

Definition at line 117 of file APPLICATIONS/EVK1104-EVK1105-DSPLIB-DEMO/gui.h.

Referenced by gui_text_print().

#define GUI_FONT_WIDTH   8

#define GUI_INPUT_BG_COLOR   GUI_MAIN_BG_COLOR

#define GUI_INPUT_FG_COLOR   GUI_MAIN_FG_COLOR

#define GUI_INPUT_HEIGHT   56

#define GUI_INPUT_ID   2

#define GUI_INPUT_WIDTH   92

#define GUI_INPUT_X   84

#define GUI_INPUT_Y   82

#define GUI_MAIN_BG_COLOR   0xF79E

#define GUI_MAIN_FG_COLOR   BLACK

#define GUI_NO_COLOR   ((uint16_t) -1)

#define GUI_NO_SEL   -1

#define GUI_OUTPUT_BG_COLOR   GUI_MAIN_BG_COLOR

#define GUI_OUTPUT_FG_COLOR   GUI_MAIN_FG_COLOR

#define GUI_OUTPUT_HEIGHT   56

#define GUI_OUTPUT_ID   3

#define GUI_OUTPUT_WIDTH   92

#define GUI_OUTPUT_X   210

#define GUI_OUTPUT_Y   82

#define GUI_SELECTION_COLOR   0xAA3F

Definition at line 59 of file APPLICATIONS/EVK1104-EVK1105-DSPLIB-DEMO/gui.h.

Referenced by gui_set_selection().

#define GUI_SOURCE1_BG_COLOR   GUI_MAIN_BG_COLOR

#define GUI_SOURCE1_FG_COLOR   GUI_MAIN_FG_COLOR

#define GUI_SOURCE1_HEIGHT   56

#define GUI_SOURCE1_ID   0

#define GUI_SOURCE1_WIDTH   92

#define GUI_SOURCE1_X   13

#define GUI_SOURCE1_Y   10

#define GUI_SOURCE2_BG_COLOR   GUI_MAIN_BG_COLOR

#define GUI_SOURCE2_FG_COLOR   GUI_MAIN_FG_COLOR

#define GUI_SOURCE2_HEIGHT   56

#define GUI_SOURCE2_ID   1

#define GUI_SOURCE2_WIDTH   92

#define GUI_SOURCE2_X   13

#define GUI_SOURCE2_Y   153

#define GUI_TEXT_BUFFER_SIZE   256

This does not takje care of the buffer overflow, so make sure this value is big enough.

Definition at line 120 of file APPLICATIONS/EVK1104-EVK1105-DSPLIB-DEMO/gui.h.

#define GUI_TEXT_COLOR   0xAEAE

#define gui_text_printf ( box_id,
format,
...   ) 

Value:

{                                                                              \
  extern char gui_text_buffer[];                                               \
  dsp16_sprintf(gui_text_buffer, format, __VA_ARGS__);                         \
  gui_text_print(box_id, (const char *) gui_text_buffer);                      \
}
Print a text in the text area.

Definition at line 184 of file APPLICATIONS/EVK1104-EVK1105-DSPLIB-DEMO/gui.h.

Referenced by state_machine_idle(), and state_machine_source().

#define GUI_ZOOM_BOX_HEIGHT   218

#define GUI_ZOOM_BOX_WIDTH   320

#define GUI_ZOOM_BOX_X   0

#define GUI_ZOOM_BOX_Y   0


Function Documentation

void gui_change_update_fs ( uint32_t  time_ms  ) 

This function change the frequency rate of the update of the display.

Definition at line 105 of file APPLICATIONS/EVK1104-EVK1105-DSPLIB-DEMO/gui.c.

References gui_cpu_hz, and gui_fs.

Referenced by gui_init(), and state_machine_idle().

00106 {
00107   gui_fs.time_ms = time_ms;
00108   cpu_set_timeout(cpu_ms_2_cy(gui_fs.time_ms, gui_cpu_hz), &gui_fs.cpu_time);
00109 }

void gui_clear_view ( void   ) 

Definition at line 130 of file APPLICATIONS/EVK1104-EVK1105-DSPLIB-DEMO/gui.c.

References gui_draw_background().

Referenced by gui_init(), and state_machine_task().

00131 {
00132   gui_draw_background(0, 0, ET024006_WIDTH, ET024006_HEIGHT);
00133 }

uint32_t gui_get_update_fs ( void   ) 

Definition at line 111 of file APPLICATIONS/EVK1104-EVK1105-DSPLIB-DEMO/gui.c.

References gui_fs.

Referenced by state_machine_idle().

00112 {
00113   return gui_fs.time_ms;
00114 }

void gui_init ( int  cpu_hz,
int  hsb_hz,
int  pba_hz,
int  pbb_hz 
)

Definition at line 116 of file APPLICATIONS/EVK1104-EVK1105-DSPLIB-DEMO/gui.c.

References DEFAULT_SCREEN_UPDATE_FS_MS, gui_change_update_fs(), gui_clear_view(), and gui_cpu_hz.

Referenced by main().

00117 {
00118   gui_cpu_hz = cpu_hz;
00119   // Init the delay function
00120   delay_init(cpu_hz);
00121   // Init the display
00122   et024006_Init(cpu_hz, hsb_hz);
00123   gpio_set_gpio_pin(ET024006DHU_BL_PIN);
00124   // Draw the background
00125   gui_clear_view();
00126   // Set the frequency rate of the update of the display
00127   gui_change_update_fs(DEFAULT_SCREEN_UPDATE_FS_MS);
00128 }

void gui_set_selection ( int  box_id  ) 

Select a new box (can select only one box a time).

Definition at line 157 of file APPLICATIONS/EVK1104-EVK1105-DSPLIB-DEMO/gui.c.

References gui_box::bg_color, gui_draw_background(), GUI_NO_COLOR, GUI_NO_SEL, GUI_SELECTION_COLOR, gui_box::height, gui_box::width, gui_box::x, and gui_box::y.

Referenced by state_machine_filter(), state_machine_idle(), state_machine_signal(), and state_machine_source().

00158 {
00159   static int prev_selection = GUI_NO_SEL;
00160   struct gui_box *sb;
00161   int i;
00162 
00163   // Clear previous selections
00164   if (prev_selection != GUI_NO_SEL && prev_selection != box_id)
00165   {
00166     i = prev_selection;
00167     sb = (struct gui_box *) &box[i];
00168     // Don't do anything if the color is transparent
00169     if (sb->bg_color == GUI_NO_COLOR)
00170     {
00171       gui_draw_background(sb->x - 2, sb->y - 2, sb->width + 4, 2);
00172       gui_draw_background(sb->x - 2, sb->y + sb->height, sb->width + 4, 2);
00173       gui_draw_background(sb->x - 2, sb->y - 2, 2, sb->height + 4);
00174       gui_draw_background(sb->x + sb->width, sb->y - 2, 2, sb->height + 4);
00175     }
00176     else
00177     {
00178       et024006_DrawFilledRect(sb->x - 2, sb->y - 2, sb->width + 4, 2, sb->bg_color);
00179       et024006_DrawFilledRect(sb->x - 2, sb->y + sb->height, sb->width + 4, 2, sb->bg_color);
00180       et024006_DrawFilledRect(sb->x - 2, sb->y - 2, 2, sb->height + 4, sb->bg_color);
00181       et024006_DrawFilledRect(sb->x + sb->width, sb->y - 2, 2, sb->height + 4, sb->bg_color);
00182     }
00183   }
00184 
00185   prev_selection = box_id;
00186 
00187   if (box_id == GUI_NO_SEL)
00188     return;
00189   // Draw the selection
00190   sb = (struct gui_box *) &box[box_id];
00191   et024006_DrawFilledRect(sb->x - 2, sb->y - 2, sb->width + 4, 2, GUI_SELECTION_COLOR);
00192   et024006_DrawFilledRect(sb->x - 2, sb->y + sb->height, sb->width + 4, 2, GUI_SELECTION_COLOR);
00193   et024006_DrawFilledRect(sb->x - 2, sb->y - 2, 2, sb->height + 4, GUI_SELECTION_COLOR);
00194   et024006_DrawFilledRect(sb->x + sb->width, sb->y - 2, 2, sb->height + 4, GUI_SELECTION_COLOR);
00195 }

void gui_task ( void   ) 

Definition at line 135 of file APPLICATIONS/EVK1104-EVK1105-DSPLIB-DEMO/gui.c.

References BUFFER_LENGTH, FFT_LENGTH, gui_cpu_hz, gui_fs, GUI_INPUT_ID, GUI_OUTPUT_ID, gui_print_fft_box(), gui_print_signal_box(), GUI_SOURCE1_ID, GUI_SOURCE2_ID, input_fft_view, output_fft_view, signal1_buf, signal2_buf, signal_in_buf, signal_in_fft, signal_out_buf, and signal_out_fft.

Referenced by main().

00136 {
00137   extern volatile Bool input_fft_view;
00138   extern volatile Bool output_fft_view;
00139 
00140   // Check the last time the printing has been done
00141   if (cpu_is_timeout(&gui_fs.cpu_time))
00142   {
00143     gui_print_signal_box(GUI_SOURCE1_ID, signal1_buf, sizeof(signal1_buf)/sizeof(signal1_buf[0]));
00144     gui_print_signal_box(GUI_SOURCE2_ID, signal2_buf, sizeof(signal2_buf)/sizeof(signal2_buf[0]));
00145     if (input_fft_view)
00146       gui_print_fft_box(GUI_INPUT_ID, signal_in_fft, FFT_LENGTH);
00147     else
00148       gui_print_signal_box(GUI_INPUT_ID, signal_in_buf, BUFFER_LENGTH);
00149     if (output_fft_view)
00150       gui_print_fft_box(GUI_OUTPUT_ID, signal_out_fft, FFT_LENGTH);
00151     else
00152       gui_print_signal_box(GUI_OUTPUT_ID, signal_out_buf, sizeof(signal2_buf)/sizeof(signal2_buf[0]));
00153     cpu_set_timeout(cpu_ms_2_cy(gui_fs.time_ms, gui_cpu_hz), &gui_fs.cpu_time);
00154   }
00155 }

void gui_text_print ( int  box_id,
const char *  text 
)

Print text in a text box.

Definition at line 246 of file APPLICATIONS/EVK1104-EVK1105-DSPLIB-DEMO/gui.c.

References gui_box::bg_color, gui_box::fg_color, gui_draw_background(), GUI_FONT, GUI_FONT_HEIGHT, GUI_NO_COLOR, gui_text_buffer, gui_box::height, gui_box::width, gui_box::x, gui_box::y, and zoom_view.

Referenced by main(), state_machine_filter(), state_machine_idle(), state_machine_signal(), state_machine_source(), and state_machine_task().

00247 {
00248   extern volatile Bool zoom_view;
00249   const struct gui_box *sb = (struct gui_box *) &box[box_id];
00250   int i, len;
00251   int y = sb->y;
00252 
00253   if (zoom_view)
00254     return;
00255 
00256   // Clear the background
00257   if (sb->bg_color == GUI_NO_COLOR)
00258     gui_draw_background(sb->x, sb->y, sb->width, sb->height);
00259   else
00260     et024006_DrawFilledRect(sb->x, sb->y, sb->width, sb->height, sb->bg_color);
00261 
00262   // Calculte the number of line to be displayed
00263   len = 0;
00264   i = 0;
00265   do
00266   {
00267     if (text[i] == '\n' || text[i] == '\0')
00268       len++;
00269   } while (text[i++]);
00270   // Set the y coordinate so that it will align the text in the middle of the text box (vertical axis)
00271   y += (sb->height - len*GUI_FONT_HEIGHT)/2;
00272 
00273   // Print the text line per line
00274   len = 0;
00275   i = 0;
00276   do
00277   {
00278     if (text[i] == '\n' || text[i] == '\0')
00279     {
00280       if (i - len >= 0)
00281       {
00282         memmove(gui_text_buffer, &text[i - len], len);
00283         gui_text_buffer[len] = '\0';
00284         if (sb->bg_color == GUI_NO_COLOR)
00285           et024006_PrintString(gui_text_buffer, (const unsigned char *) &GUI_FONT, sb->x, y, sb->fg_color, -1);
00286         else
00287           et024006_PrintString(gui_text_buffer, (const unsigned char *) &GUI_FONT, sb->x, y, sb->fg_color, sb->bg_color);
00288         gui_text_buffer[len] = ' ';
00289       }
00290       y += GUI_FONT_HEIGHT;
00291       len = 0;
00292     }
00293     else
00294       len++;
00295   } while (text[i++]);
00296 }


Generated on Fri Feb 19 02:23:19 2010 for AVR32 UC3 - EVK1104 DSPLib Demo Documentation by  doxygen 1.5.5