Microchip® Advanced Software Framework

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
App_widget_group

Data Structures

struct  app_calculator_t
 Calculator context. More...
 
struct  widget_context
 Widget application context. More...
 

Macros

#define BT_H   40
 Height (in pixels) of a normal sized button. More...
 
#define BT_POS_X(col)   (W_SP + (BT_W * (col)))
 Calculate button X coordinate. More...
 
#define BT_POS_Y(row)   (W_SP + T_H + T_SP + (BT_H * (row)))
 Calculate button Y coordinate. More...
 
#define BT_W   40
 Width (in pixels) of a normal sized button. More...
 
#define BT_X   4
 Number of buttons in one column. More...
 
#define BT_Y   5
 Number of buttons in one row. More...
 
#define MAX_DIGITS   9
 Maximum number of digits on display. More...
 
#define MAX_VALUE   999999999L
 Maximum value we can show on display. More...
 
#define MIN_VALUE   -999999999L
 Minimum value we can show on display. More...
 
#define T_H   16
 Height of the static text field. More...
 
#define T_SP   16
 Spacing between static text and button pad. More...
 
#define T_W   (BT_W * BT_X)
 Width of the static text field. More...
 
#define TOTAL_NUM_ICONS   3
 
#define W_SP   16
 Spacing between widget frame and components. More...
 

Enumerations

enum  command_id {
  DUMMY_ID,
  ICON_BUTTON_1_ID,
  ICON_BUTTON_2_ID,
  ICON_BUTTON_3_ID,
  BUTTON_PREV_ID,
  BUTTON_NEXT_ID,
  BUTTON_SELECT_ID,
  DUMMY_ID,
  SLIDER_ID,
  CHECK_BOX_ID,
  RADIO_BUTTON_1_ID,
  RADIO_BUTTON_2_ID,
  BUTTON_ID,
  DUMMY_ID,
  SLIDER_ID,
  BUTTON_ID,
  ICON_DUMMY_ID = 0,
  ICON_AUDIO_RECORD_ID,
  ICON_AUDIO_MIC_ID,
  ICON_AUDIO_PLAY_PAUSE_ID,
  ICON_AUDIO_STOP_ID,
  ICON_AUDIO_VOLUME_ID,
  ICON_AUDIO_RET_ID,
  ICON_AUDIO_MAX_ID,
  ICON_DUMMY_ID = 0,
  ICON_LPM_WAIT_ID,
  ICON_LPM_SLEEP_ID,
  ICON_LPM_BACKUP_ID,
  ICON_LPM_RET_ID,
  ICON_LPM_MAX
}
 Command event IDs. More...
 
enum  command_id {
  DUMMY_ID,
  ICON_BUTTON_1_ID,
  ICON_BUTTON_2_ID,
  ICON_BUTTON_3_ID,
  BUTTON_PREV_ID,
  BUTTON_NEXT_ID,
  BUTTON_SELECT_ID,
  DUMMY_ID,
  SLIDER_ID,
  CHECK_BOX_ID,
  RADIO_BUTTON_1_ID,
  RADIO_BUTTON_2_ID,
  BUTTON_ID,
  DUMMY_ID,
  SLIDER_ID,
  BUTTON_ID,
  ICON_DUMMY_ID = 0,
  ICON_AUDIO_RECORD_ID,
  ICON_AUDIO_MIC_ID,
  ICON_AUDIO_PLAY_PAUSE_ID,
  ICON_AUDIO_STOP_ID,
  ICON_AUDIO_VOLUME_ID,
  ICON_AUDIO_RET_ID,
  ICON_AUDIO_MAX_ID,
  ICON_DUMMY_ID = 0,
  ICON_LPM_WAIT_ID,
  ICON_LPM_SLEEP_ID,
  ICON_LPM_BACKUP_ID,
  ICON_LPM_RET_ID,
  ICON_LPM_MAX
}
 Command event IDs. More...
 
enum  command_id {
  DUMMY_ID,
  ICON_BUTTON_1_ID,
  ICON_BUTTON_2_ID,
  ICON_BUTTON_3_ID,
  BUTTON_PREV_ID,
  BUTTON_NEXT_ID,
  BUTTON_SELECT_ID,
  DUMMY_ID,
  SLIDER_ID,
  CHECK_BOX_ID,
  RADIO_BUTTON_1_ID,
  RADIO_BUTTON_2_ID,
  BUTTON_ID,
  DUMMY_ID,
  SLIDER_ID,
  BUTTON_ID,
  ICON_DUMMY_ID = 0,
  ICON_AUDIO_RECORD_ID,
  ICON_AUDIO_MIC_ID,
  ICON_AUDIO_PLAY_PAUSE_ID,
  ICON_AUDIO_STOP_ID,
  ICON_AUDIO_VOLUME_ID,
  ICON_AUDIO_RET_ID,
  ICON_AUDIO_MAX_ID,
  ICON_DUMMY_ID = 0,
  ICON_LPM_WAIT_ID,
  ICON_LPM_SLEEP_ID,
  ICON_LPM_BACKUP_ID,
  ICON_LPM_RET_ID,
  ICON_LPM_MAX
}
 Command event IDs. More...
 

Functions

static bool app_calc_handler (struct wtk_basic_frame *frame, win_command_t command_data)
 Frame handler for the application. More...
 
static void app_calc_update_disp (struct app_calculator_t *calc)
 Update calculator display with new value. More...
 
bool app_widget_launch (void)
 Setup widget demo. More...
 
static void app_widget_update_colors (struct widget_context *widget)
 Update colors. More...
 
static void calc_perform_operation (struct app_calculator_t *calc)
 Perform calculation. More...
 
static bool widget_frame_command_handler (struct wtk_basic_frame *frame, win_command_t command_data)
 Frame handler for the application. More...
 

Variables

static const char btn_string [] = "Reset Slider"
 Description for the button. More...
 
static const char checkbox_string [] = "Invert colors"
 Description for the check box. More...
 
static const char rb1_string [] = "Color scheme 1"
 Description for the first radio button. More...
 
static const char rb2_string [] = "Color scheme 2"
 Description for the second radio button. More...
 
static struct widget_contextwidget_ctx
 Statically allocated context pointer. More...
 
static struct widget_contextwidget_ctx
 Statically allocated context pointer. More...
 
static struct widget_contextwidget_ctx
 Statically allocated context pointer. More...
 

Color scheme

#define COLOR_SCHEME_0_FG   GFX_COLOR(30, 30, 200)
 Color scheme 0 foreground color. More...
 
#define COLOR_SCHEME_0_BG   GFX_COLOR(255, 255, 255)
 Color scheme 0 background color. More...
 
#define COLOR_SCHEME_1_FG   GFX_COLOR(0, 255, 0)
 Color scheme 1 foreground color. More...
 
#define COLOR_SCHEME_1_BG   GFX_COLOR(0, 100, 100)
 Color scheme 1 background color. More...
 
#define APP_BACKGROUND_COLOR   GFX_COLOR(220, 220, 220)
 Background color of the application frame. More...
 

Widget positions and sizes

#define WIDGET_POS_X   14
 Leftmost X coordinate in frame for the widgets. More...
 
#define WIDGET_POS_Y   5
 Topmost Y coordinate in frame for the widgets. More...
 
#define SLIDER_POS_Y   10
 Slider X coordinate, inside frame. More...
 
#define SLIDER_SIZE_X   120
 Width of slider. More...
 
#define SLIDER_SIZE_Y   40
 Height of slider. More...
 
#define SLIDER_PB_SPACING_X   10
 Spacing between the slider and progress bars. More...
 
#define PB_SIZE_X   SLIDER_SIZE_X
 Width of progress bar. More...
 
#define PB_SIZE_Y   SLIDER_SIZE_Y
 Height of progress bar. More...
 
#define CHECK_BOX_SPACING_Y   20
 Spacing above check box to slider and progress bars. More...
 
#define RADIO_BUTTON_SPACING_Y   10
 Spacing above each radio button. More...
 
#define BUTTON_SPACING_Y   20
 Spacing above the button. More...
 
#define BUTTON_SIZE_Y   30
 Height of the button. More...
 

#define APP_BACKGROUND_COLOR   GFX_COLOR(220, 220, 220)

Background color of the application frame.

#define BT_H   40

Height (in pixels) of a normal sized button.

#define BT_POS_X (   col)    (W_SP + (BT_W * (col)))

Calculate button X coordinate.

#define BT_POS_Y (   row)    (W_SP + T_H + T_SP + (BT_H * (row)))

Calculate button Y coordinate.

#define BT_W   40

Width (in pixels) of a normal sized button.

#define BT_X   4

Number of buttons in one column.

#define BT_Y   5

Number of buttons in one row.

#define BUTTON_SIZE_Y   30

Height of the button.

#define BUTTON_SPACING_Y   20

Spacing above the button.

#define CHECK_BOX_SPACING_Y   20

Spacing above check box to slider and progress bars.

#define COLOR_SCHEME_0_BG   GFX_COLOR(255, 255, 255)

Color scheme 0 background color.

Referenced by app_widget_update_colors().

#define COLOR_SCHEME_0_FG   GFX_COLOR(30, 30, 200)

Color scheme 0 foreground color.

Referenced by app_widget_update_colors().

#define COLOR_SCHEME_1_BG   GFX_COLOR(0, 100, 100)

Color scheme 1 background color.

Referenced by app_widget_update_colors().

#define COLOR_SCHEME_1_FG   GFX_COLOR(0, 255, 0)

Color scheme 1 foreground color.

Referenced by app_widget_update_colors().

#define MAX_DIGITS   9

Maximum number of digits on display.

Referenced by app_calc_update_disp().

#define MAX_VALUE   999999999L

Maximum value we can show on display.

Referenced by app_calc_update_disp(), and calc_perform_operation().

#define MIN_VALUE   -999999999L

Minimum value we can show on display.

Referenced by app_calc_update_disp(), and calc_perform_operation().

#define PB_SIZE_X   SLIDER_SIZE_X

Width of progress bar.

#define PB_SIZE_Y   SLIDER_SIZE_Y

Height of progress bar.

#define RADIO_BUTTON_SPACING_Y   10

Spacing above each radio button.

#define SLIDER_PB_SPACING_X   10

Spacing between the slider and progress bars.

#define SLIDER_POS_Y   10

Slider X coordinate, inside frame.

#define SLIDER_SIZE_X   120

Width of slider.

#define SLIDER_SIZE_Y   40

Height of slider.

#define T_H   16

Height of the static text field.

#define T_SP   16

Spacing between static text and button pad.

#define T_W   (BT_W * BT_X)

Width of the static text field.

#define TOTAL_NUM_ICONS   3
#define W_SP   16

Spacing between widget frame and components.

#define WIDGET_POS_X   14

Leftmost X coordinate in frame for the widgets.

#define WIDGET_POS_Y   5

Topmost Y coordinate in frame for the widgets.

enum command_id

Command event IDs.

Note
The first entry in this enum is zero-valued, and therefore reserved for widgets that should not issue command events.
See Also
Widget toolkit
Enumerator
DUMMY_ID 

Unused command event ID.

ICON_BUTTON_1_ID 

Command event ID for first icon button.

ICON_BUTTON_2_ID 

Command event ID for second icon button.

ICON_BUTTON_3_ID 

Command event ID for third icon button.

BUTTON_PREV_ID 

Command event ID for previous icon button.

BUTTON_NEXT_ID 

Command event ID for next icon button.

BUTTON_SELECT_ID 

Command event ID for select icon button.

DUMMY_ID 

Unused command event ID.

SLIDER_ID 

Command event ID for slider.

CHECK_BOX_ID 

Command event ID for check box.

RADIO_BUTTON_1_ID 

Command event ID for radio button 1.

RADIO_BUTTON_2_ID 

Command event ID for radio button 2.

BUTTON_ID 

Command event ID for button.

DUMMY_ID 

Unused command event ID.

SLIDER_ID 
BUTTON_ID 
ICON_DUMMY_ID 

Dummy icon.

ICON_AUDIO_RECORD_ID 

Command event ID for audio record icon button.

ICON_AUDIO_MIC_ID 

Command event ID for microphone icon button.

ICON_AUDIO_PLAY_PAUSE_ID 

Command event ID for pause icon button.

ICON_AUDIO_STOP_ID 

Command event ID for stop icon button.

ICON_AUDIO_VOLUME_ID 

Command event ID for volume icon button.

ICON_AUDIO_RET_ID 

Command event ID for return icon button.

ICON_AUDIO_MAX_ID 
ICON_DUMMY_ID 

Dummy icon.

ICON_LPM_WAIT_ID 

Command event ID for wait mode icon button.

ICON_LPM_SLEEP_ID 

Command event ID for sleep mode icon button.

ICON_LPM_BACKUP_ID 

Command event ID for backup mode icon button.

ICON_LPM_RET_ID 

Command event ID for second icon button.

ICON_LPM_MAX 

Max information icon number.

enum command_id

Command event IDs.

Note
The first entry in this enum is zero-valued, and therefore reserved for widgets that should not issue command events.
See Also
Widget toolkit
Enumerator
DUMMY_ID 

Unused command event ID.

ICON_BUTTON_1_ID 

Command event ID for first icon button.

ICON_BUTTON_2_ID 

Command event ID for second icon button.

ICON_BUTTON_3_ID 

Command event ID for third icon button.

BUTTON_PREV_ID 

Command event ID for previous icon button.

BUTTON_NEXT_ID 

Command event ID for next icon button.

BUTTON_SELECT_ID 

Command event ID for select icon button.

DUMMY_ID 

Unused command event ID.

SLIDER_ID 

Command event ID for slider.

CHECK_BOX_ID 

Command event ID for check box.

RADIO_BUTTON_1_ID 

Command event ID for radio button 1.

RADIO_BUTTON_2_ID 

Command event ID for radio button 2.

BUTTON_ID 

Command event ID for button.

DUMMY_ID 

Unused command event ID.

SLIDER_ID 
BUTTON_ID 
ICON_DUMMY_ID 

Dummy icon.

ICON_AUDIO_RECORD_ID 

Command event ID for audio record icon button.

ICON_AUDIO_MIC_ID 

Command event ID for microphone icon button.

ICON_AUDIO_PLAY_PAUSE_ID 

Command event ID for pause icon button.

ICON_AUDIO_STOP_ID 

Command event ID for stop icon button.

ICON_AUDIO_VOLUME_ID 

Command event ID for volume icon button.

ICON_AUDIO_RET_ID 

Command event ID for return icon button.

ICON_AUDIO_MAX_ID 
ICON_DUMMY_ID 

Dummy icon.

ICON_LPM_WAIT_ID 

Command event ID for wait mode icon button.

ICON_LPM_SLEEP_ID 

Command event ID for sleep mode icon button.

ICON_LPM_BACKUP_ID 

Command event ID for backup mode icon button.

ICON_LPM_RET_ID 

Command event ID for second icon button.

ICON_LPM_MAX 

Max information icon number.

enum command_id

Command event IDs.

Note
The first entry in this enum is zero-valued, and therefore reserved for widgets that should not issue command events.
See Also
Widget toolkit
Enumerator
DUMMY_ID 

Unused command event ID.

ICON_BUTTON_1_ID 

Command event ID for first icon button.

ICON_BUTTON_2_ID 

Command event ID for second icon button.

ICON_BUTTON_3_ID 

Command event ID for third icon button.

BUTTON_PREV_ID 

Command event ID for previous icon button.

BUTTON_NEXT_ID 

Command event ID for next icon button.

BUTTON_SELECT_ID 

Command event ID for select icon button.

DUMMY_ID 

Unused command event ID.

SLIDER_ID 

Command event ID for slider.

CHECK_BOX_ID 

Command event ID for check box.

RADIO_BUTTON_1_ID 

Command event ID for radio button 1.

RADIO_BUTTON_2_ID 

Command event ID for radio button 2.

BUTTON_ID 

Command event ID for button.

DUMMY_ID 

Unused command event ID.

SLIDER_ID 
BUTTON_ID 
ICON_DUMMY_ID 

Dummy icon.

ICON_AUDIO_RECORD_ID 

Command event ID for audio record icon button.

ICON_AUDIO_MIC_ID 

Command event ID for microphone icon button.

ICON_AUDIO_PLAY_PAUSE_ID 

Command event ID for pause icon button.

ICON_AUDIO_STOP_ID 

Command event ID for stop icon button.

ICON_AUDIO_VOLUME_ID 

Command event ID for volume icon button.

ICON_AUDIO_RET_ID 

Command event ID for return icon button.

ICON_AUDIO_MAX_ID 
ICON_DUMMY_ID 

Dummy icon.

ICON_LPM_WAIT_ID 

Command event ID for wait mode icon button.

ICON_LPM_SLEEP_ID 

Command event ID for sleep mode icon button.

ICON_LPM_BACKUP_ID 

Command event ID for backup mode icon button.

ICON_LPM_RET_ID 

Command event ID for second icon button.

ICON_LPM_MAX 

Max information icon number.

static bool app_calc_handler ( struct wtk_basic_frame frame,
win_command_t  command_data 
)
static
static void app_calc_update_disp ( struct app_calculator_t calc)
static

Update calculator display with new value.

Parameters
calcPointer to calculator struct

References app_calculator_t::calc_regs, app_calculator_t::display, MAX_DIGITS, MAX_VALUE, MIN_VALUE, app_calculator_t::state, app_calculator_t::text, and wtk_label_change().

Referenced by app_calc_handler().

bool app_widget_launch ( void  )

Setup widget demo.

Allocates memory for the application context, and creates all widgets that make up its interface. If memory allocation or widget creation fails, the application exits immediately.

Returns
Boolean true if the application was launched successfully, false if a memory allocation occurred.

Referenced by main().

static void app_widget_update_colors ( struct widget_context widget)
static

Update colors.

Updates the colors for the progress bar and issues redrawing of the widgets.

Parameters
widgetContext for widget application

References widget_context::color_invert, widget_context::color_scheme, COLOR_SCHEME_0_BG, COLOR_SCHEME_0_FG, COLOR_SCHEME_1_BG, COLOR_SCHEME_1_FG, widget_context::pb, win_redraw(), wtk_progress_bar_as_child(), and wtk_progress_bar_set_colors().

Referenced by widget_frame_command_handler().

static void calc_perform_operation ( struct app_calculator_t calc)
static

Perform calculation.

Parameters
calcPointer to calculator struct

References app_calculator_t::calc_regs, MAX_VALUE, MIN_VALUE, app_calculator_t::operand, app_calculator_t::operation, app_calculator_t::result, and app_calculator_t::state.

Referenced by app_calc_handler().

static bool widget_frame_command_handler ( struct wtk_basic_frame frame,
win_command_t  command_data 
)
static

const char btn_string[] = "Reset Slider"
static

Description for the button.

const char checkbox_string[] = "Invert colors"
static

Description for the check box.

const char rb1_string[] = "Color scheme 1"
static

Description for the first radio button.

const char rb2_string[] = "Color scheme 2"
static

Description for the second radio button.

struct widget_context* widget_ctx
static

Statically allocated context pointer.

struct widget_context* widget_ctx
static

Statically allocated context pointer.

struct widget_context* widget_ctx
static

Statically allocated context pointer.