Microchip® Advanced Software Framework

calculator.c File Reference

Graphic Widget Toolkit library example application.

Copyright (c) 2012-2018 Microchip Technology Inc. and its subsidiaries.

#include <asf.h>
#include "widget_gui.h"
#include "atmel_logo_small.h"


 Address of the mXT143E on TWI bus. More...


int main (void)
 Main application function. More...
static void mxt_init (struct mxt_device *device)
 Set maXTouch configuration. More...
static bool read_touch_event (struct mxt_device *device, struct win_pointer_event *win_touch_event)
 Convert touch events from the touchscreen into window pointer events. More...
static void setup_gui_root_window (void)
 Configure the root GUI window. More...
static void show_out_of_memory_error (void)
 Show an out of memory error on the display. More...


Address of the mXT143E on TWI bus.

Referenced by mxt_init().

int main ( void  )

Main application function.

This function calls all the necessary initialization functions before launching the calculator widget and entering the main work loop.

The main work loop is responsible for handling the low level user input, so it reads touch data from the mXT143E Xplained, translates and passes it on to the window system's event queue.

All the processing for the calculator is done by the calculator widget's event handler function app_calc_handler(). This function is called by the window system when it maps a user input event to an interaction with the calculator, i.e., a button press.

References app_widget_launch(), board_init(), gfx_init, membag_init(), mxt_init(), read_touch_event(), setup_gui_root_window(), show_out_of_memory_error(), sysclk_init(), win_init(), win_process_events(), win_queue_pointer_event(), and win_reset_root_geometry().

static void mxt_init ( struct mxt_device device)
static bool read_touch_event ( struct mxt_device device,
struct win_pointer_event win_touch_event 

Convert touch events from the touchscreen into window pointer events.

Reads touch events in from the touchscreen and converts them into a Window Manager pointer event, for enqueuing into the window event queue.

Boolean true if a touch event was read, false if no touch event or a corrupt touch event was received

References win_pointer_event::buttons, gfx_get_height(), gfx_get_width(), win_pointer_event::is_relative, mxt_is_message_pending(), MXT_MOVE_EVENT, MXT_PRESS_EVENT, mxt_read_touch_event(), MXT_RELEASE_EVENT, win_pointer_event::pos, mxt_touch_event::status, STATUS_OK, win_pointer_event::type, WIN_POINTER_MOVE, WIN_POINTER_PRESS, WIN_POINTER_RELEASE, WIN_TOUCH_BUTTON, mxt_touch_event::x, win_point::x, mxt_touch_event::y, and win_point::y.

Referenced by main().

static void setup_gui_root_window ( void  )

Configure the root GUI window.

Configures the root window background to be a tiled version of the Atmel company logo, and sets it as being visible.

References atmel_logo_small, win_attributes::background, WIN_ATTR_BACKGROUND, win_get_attributes(), win_get_root(), win_root, win_set_attributes(), and win_show().

Referenced by main().

static void show_out_of_memory_error ( void  )

Show an out of memory error on the display.

Shows a full screen error when called, signaling that the system ran out of memory when initializing a WTK application.

References GFX_COLOR_BLACK, GFX_COLOR_RED, GFX_COLOR_TRANSPARENT, gfx_draw_filled_rect, gfx_draw_string_aligned(), gfx_get_height(), gfx_get_width(), gfx_set_clipping(), sysfont, TEXT_ALIGN_CENTER, and TEXT_POS_CENTER.

Referenced by main().