Atmel Software Framework

calculator.c File Reference

Graphic Widget Toolkit library example application.

Copyright (C) 2012-2015 Atmel Corporation. All rights reserved.

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

Macros

#define MAXTOUCH_TWI_ADDRESS   0x4a
 Address of the mXT143E on TWI bus. More...
 

Functions

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...
 

#define MAXTOUCH_TWI_ADDRESS   0x4a

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
static bool read_touch_event ( struct mxt_device device,
struct win_pointer_event win_touch_event 
)
static

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.

Returns
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  )
static

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  )
static

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().