Slideshow application
[Applications]

The slideshow application is a timed, automatic image loader. It demonstrates use of the Window toolkit and Tiny Simple file system. More...

Collaboration diagram for Slideshow application:

Data Structures

struct  slide_context
 Context for the slideshow application. More...

Functions

static void slide_get_next_file (bool increment)
 Find index of next slideshow file to load.
static void slide_show_file (void)
 Start loading current file to screen.
static void slide_timer_callback (struct timer *timer)
 Timer alarm callback for automatic loading.
static bool slide_window_handler (struct win_window *win, enum win_event_type type, void const *data)
 Event handler for the application windows.
static void slide_worker (struct workqueue_task *task)
 Application task worker.
static void slide_launch_helper (struct workqueue_task *task, char *file_prefix)
 Common slideshow launcher.
void app_slideshow_pics_launch (struct workqueue_task *task)
 Launch picture slideshow.
void app_slideshow_avr_launch (struct workqueue_task *task)
 Launch 8-bit AVR presentation slideshow.
void app_slideshow_uc3_launch (struct workqueue_task *task)
 Launch UC3 presentation slideshow.
void app_slideshow_xmega_launch (struct workqueue_task *task)
 Launch AVR XMEGA presentation slideshow.
void app_slideshow_dx_launch (struct workqueue_task *task)
 Launch Display Xplain presentation slideshow.

Variables

struct tsfs myfs
 Filesystem control struct, needed when searching for files.
static struct slide_contextslide_context
 Pointer to slideshow application context.

Color scheme



#define COLOR_BACKGROUND   GFX_COLOR(0, 0, 0)
 Color to initally fill display with.

Slideshow timing configuration



#define SECONDS_PER_SLIDE   4
 Number of seconds to wait before loading the next slide.
#define SECONDS_PER_PAUSE   16
 Number of seconds to wait before loading the next slide, when the user previously selected the previous slide.
#define TIMER_CLOCK_RATE   (0xffff / 4)
 Minimum timer clock rate to use.

Slideshow image size



#define SLIDE_SIZE_X   320
 Width of slideshow images.
#define SLIDE_SIZE_Y   240
 Height of slideshow images.

Slideshow filename prefix



#define SLIDE_PREFIX_PICS   "s_"
 Filename prefix for picture slideshow.
#define SLIDE_PREFIX_AVR   "avr"
 Filename prefix for AVR presentation slideshow.
#define SLIDE_PREFIX_UC3   "uc3"
 Filename prefix for UC3 presentation slideshow.
#define SLIDE_PREFIX_XMEGA   "xmega"
 Filename prefix for AVR XMEGA presentation slideshow.
#define SLIDE_PREFIX_DX   "dispxpl"
 Filename prefix for Display Xplained presentation slideshow.

Detailed Description

The slideshow application is a timed, automatic image loader. It demonstrates use of the Window toolkit and Tiny Simple file system.

The user can manually control the loading of the slides by tapping the left or right sections of the display to select the previous or next slide, respectively. If the user selects the previous slide, there is a 16 second delay before the automatic loading continues. If the next slide is selected, the delay defaults to the same as during automatic loading: 4 seconds.

To exit the application, the user must tap the middle section of the display when the application is not loading a slide.

Five application launcher functions are supplied, and these will each start a slideshow with:

This application makes use of the Timer driver for timing of the automatic loading and the Fileloader utility for loading files directly from filesystem to screen.


Define Documentation

#define COLOR_BACKGROUND   GFX_COLOR(0, 0, 0)

Color to initally fill display with.

Definition at line 70 of file app_slideshow.c.

#define SECONDS_PER_PAUSE   16

Number of seconds to wait before loading the next slide, when the user previously selected the previous slide.

Definition at line 86 of file app_slideshow.c.

Referenced by slide_window_handler().

#define SECONDS_PER_SLIDE   4

Number of seconds to wait before loading the next slide.

Definition at line 81 of file app_slideshow.c.

Referenced by slide_launch_helper(), slide_timer_callback(), and slide_window_handler().

#define SLIDE_PREFIX_AVR   "avr"

Filename prefix for AVR presentation slideshow.

Definition at line 120 of file app_slideshow.c.

Referenced by app_slideshow_avr_launch().

#define SLIDE_PREFIX_DX   "dispxpl"

Filename prefix for Display Xplained presentation slideshow.

Definition at line 126 of file app_slideshow.c.

Referenced by app_slideshow_dx_launch().

#define SLIDE_PREFIX_PICS   "s_"

Filename prefix for picture slideshow.

Definition at line 118 of file app_slideshow.c.

Referenced by app_slideshow_pics_launch().

#define SLIDE_PREFIX_UC3   "uc3"

Filename prefix for UC3 presentation slideshow.

Definition at line 122 of file app_slideshow.c.

Referenced by app_slideshow_uc3_launch().

#define SLIDE_PREFIX_XMEGA   "xmega"

Filename prefix for AVR XMEGA presentation slideshow.

Definition at line 124 of file app_slideshow.c.

Referenced by app_slideshow_xmega_launch().

#define SLIDE_SIZE_X   320

Width of slideshow images.

Definition at line 106 of file app_slideshow.c.

Referenced by slide_show_file().

#define SLIDE_SIZE_Y   240

Height of slideshow images.

Definition at line 108 of file app_slideshow.c.

Referenced by slide_show_file().

#define TIMER_CLOCK_RATE   (0xffff / 4)

Minimum timer clock rate to use.

Note:
Assuming a 16-bit timer, a clock rate below 2^16 will allow for detection of whole seconds with the Timer driver. The clock rate is divided by a factor of four to ensure that a low enough clock rate is selected by the driver during initialization.

Definition at line 95 of file app_slideshow.c.

Referenced by app_memgame_launch(), and slide_launch_helper().


Function Documentation

void app_slideshow_avr_launch ( struct workqueue_task task  ) 

Launch 8-bit AVR presentation slideshow.

This launches the application with the filename prefix for the AVR presentation slideshow.

Parameters:
task Workqueue task to use for this application.

Definition at line 501 of file app_slideshow.c.

References slide_launch_helper(), and SLIDE_PREFIX_AVR.

void app_slideshow_dx_launch ( struct workqueue_task task  ) 

Launch Display Xplain presentation slideshow.

This launches the application with the filename prefix for the Display Xplained presentation slideshow.

Parameters:
task Workqueue task to use for this application.

Definition at line 540 of file app_slideshow.c.

References slide_launch_helper(), and SLIDE_PREFIX_DX.

void app_slideshow_pics_launch ( struct workqueue_task task  ) 

Launch picture slideshow.

This launches the application with the filename prefix for the picture slideshow.

Parameters:
task Workqueue task to use for this application.

Definition at line 488 of file app_slideshow.c.

References slide_launch_helper(), and SLIDE_PREFIX_PICS.

void app_slideshow_uc3_launch ( struct workqueue_task task  ) 

Launch UC3 presentation slideshow.

This launches the application with the filename prefix for the AVR UC3 presentation slideshow.

Parameters:
task Workqueue task to use for this application.

Definition at line 514 of file app_slideshow.c.

References slide_launch_helper(), and SLIDE_PREFIX_UC3.

void app_slideshow_xmega_launch ( struct workqueue_task task  ) 

Launch AVR XMEGA presentation slideshow.

This launches the application with the filename prefix for the AVR XMEGA presentation slideshow.

Parameters:
task Workqueue task to use for this application.

Definition at line 527 of file app_slideshow.c.

References slide_launch_helper(), and SLIDE_PREFIX_XMEGA.

static void slide_get_next_file ( bool  increment  )  [static]

Find index of next slideshow file to load.

This function searches through the TSFS file indexes until a file with the currently set filename prefix is found. The order in which the function searches through the slideshow files is selected with the parameter increment.

Parameters:
increment Indicate whether to increment (true) or decrement (false) the file index.

Definition at line 176 of file app_slideshow.c.

References slide_context::file_index, slide_context::file_prefix, myfs, strlen(), strncmp(), TSFS_FILENAME_LEN, tsfs_get_filename(), and tsfs_nr_files().

Referenced by slide_launch_helper(), slide_timer_callback(), and slide_window_handler().

static void slide_launch_helper ( struct workqueue_task task,
char *  file_prefix 
) [static]

Common slideshow launcher.

This function handles all the memory allocation, window creation and initialization of the slideshow application.

Three invisible windows that span the entire display are created, two of which cover the left and right quarter width of the screen, respectively. Loading of the first file in the slideshow indicated by file_prefix is then started.

If memory for the application context cannot be allocated or any window cannot be created, the application will exit immediately.

Parameters:
task Workqueue task to use for this application.
file_prefix Pointer to string with the filename prefix for the desired slideshow.

Definition at line 384 of file app_slideshow.c.

References app_desktop_restart(), win_attributes::area, assert, win_attributes::background, COLOR_BACKGROUND, win_attributes::event_handler, slide_context::file_index, slide_context::file_prefix, gfx_draw_filled_rect, gfx_get_height(), gfx_get_width(), gfx_height, gfx_set_clipping(), gfx_width, slide_context::left, membag_alloc(), membag_free(), slide_context::middle, win_area::pos, slide_context::right, SECONDS_PER_SLIDE, slide_context::secs_to_go, win_area::size, slide_get_next_file(), slide_show_file(), slide_timer_callback(), slide_window_handler(), slide_worker(), slide_context::task, slide_context::timer, TIMER_CLOCK_RATE, slide_context::timer_delay, timer_get_resolution, timer_init, timer_set_resolution, timer_write_resolution, win_create(), win_destroy(), win_get_root(), win_show(), and workqueue_task_set_work_func().

Referenced by app_slideshow_avr_launch(), app_slideshow_dx_launch(), app_slideshow_pics_launch(), app_slideshow_uc3_launch(), and app_slideshow_xmega_launch().

static void slide_show_file ( void   )  [static]

Start loading current file to screen.

Starts the loading to screen of the slideshow file indicated by the current file index. If the file cannot be loaded, the timer for autoloading of the next slide is started with a one second timeout.

Definition at line 225 of file app_slideshow.c.

References slide_context::busy, slide_context::file_index, load_file_to_screen(), myfs, slide_context::secs_to_go, SLIDE_SIZE_X, SLIDE_SIZE_Y, STATUS_OK, slide_context::task, slide_context::timer, slide_context::timer_delay, timer_set_alarm, timer_start, TSFS_FILENAME_LEN, and tsfs_get_filename().

Referenced by slide_launch_helper(), slide_timer_callback(), and slide_window_handler().

static void slide_timer_callback ( struct timer timer  )  [static]

Timer alarm callback for automatic loading.

This callback function is used with the Timer driver for autoloading of the slides. It keeps track of the number of elapsed seconds since the currently shown slide was loaded, and will start loading of the next slide once a timeout is detected.

Note:
The timeout is set either by the application window event handler, or by this function after a timeout.
Parameters:
timer Pointer to timer struct associated with the callback.

Definition at line 258 of file app_slideshow.c.

References SECONDS_PER_SLIDE, slide_context::secs_to_go, slide_get_next_file(), slide_show_file(), slide_context::timer_delay, and timer_set_alarm.

Referenced by slide_launch_helper().

static bool slide_window_handler ( struct win_window win,
enum win_event_type  type,
void const *  data 
) [static]

Event handler for the application windows.

This function handles the relevant events for the three application windows. In this application, only pointer releases require handling.

A pointer release in the left window triggers loading of the previous slide, the middle window triggers application exit, while the right window triggers loading of the next slide.

Depending on whether the previous or next slide was selected, different timeouts for the slide autoloading are set, i.e., to grant the user more time to read the previous slide.

Parameters:
win Pointer to application window.
type The type of the event.
data Pointer to data for the event.

Definition at line 294 of file app_slideshow.c.

References app_desktop_restart(), slide_context::busy, cpu_irq_restore(), cpu_irq_save(), slide_context::left, membag_free(), slide_context::middle, slide_context::right, SECONDS_PER_PAUSE, SECONDS_PER_SLIDE, slide_context::secs_to_go, slide_get_next_file(), slide_show_file(), slide_context::timer, timer_stop, win_destroy(), WIN_EVENT_POINTER, and WIN_POINTER_RELEASE.

Referenced by slide_launch_helper().

static void slide_worker ( struct workqueue_task task  )  [static]

Application task worker.

This task worker is called by the Fileloader utility" when loading of a slide has finished, and will start the timer for slide autoloading.

Parameters:
task Workqueue task for this worker function.

Definition at line 357 of file app_slideshow.c.

References slide_context::busy, slide_context::timer, slide_context::timer_delay, timer_set_alarm, and timer_start.

Referenced by slide_launch_helper().


Variable Documentation

struct tsfs myfs

Filesystem control struct, needed when searching for files.

struct slide_context* slide_context [static]

Pointer to slideshow application context.

Note:
This pointer is statically allocated, but the context itself is only allocated when the application is launched, and then destroyed upon exit to conserve memory.

Definition at line 163 of file app_slideshow.c.

Generated on Thu Apr 29 14:09:59 2010 for display-demo by  doxygen 1.6.3