File system contents application
[Applications]

The file system contents application demonstrates parts of the Tiny Simple File System. It also demonstrates how to do string formatting using the stream utilities. More...

Collaboration diagram for File system contents application:

Data Structures

struct  app_files
 The files application context. More...

Defines

#define FONT_HEADER_SIZE   16
 Number of bytes in the header for the font files loaded from the TSFS.
#define FILE_NAMES_PER_PAGE   8
 Number of files to present size information per page.

Enumerations

enum  app_files_page_numbers {
  PAGE_NUM_BLANK = 1, PAGE_NUM_FIRST = 2, PAGE_NUM_INTRO_SCREEN = PAGE_NUM_FIRST, PAGE_NUM_INFO_SCREEN,
  PAGE_NUM_LAST = PAGE_NUM_INFO_SCREEN
}
 

File demo application static page numbers.

More...
enum  app_files_button_ids { BUTTON_NEXT_ID = 1, BUTTON_PREV_ID, BUTTON_QUIT_ID }
 

Event command ID for the application widgets.

More...

Functions

static void string_file_size (char *file_size_str, uint32_t size, size_t str_size)
 Format a file size into a string.
static void screen_draw_introduction (void)
 Draw file system introduction page.
static void screen_draw_file_system_info (void)
 Draw file system information page.
static void screen_draw_file_list_from_index (uint_fast8_t index)
 Draw a list of files from file entry index.
static void app_files_frame_draw_handler (struct win_window *win, const struct win_clip_region *clip)
 Frame draw handler handling draw events.
static bool app_files_frame_command_handler (struct wtk_basic_frame *frame, win_command_t command_data)
 Frame command handler handling the button events.
static void app_files_load_worker (struct workqueue_task *task)
 Setup the font object after loading the font from the file system.
void app_files_launch (struct workqueue_task *task)
 Launch the files and string formatting application.

Variables

struct tsfs myfs
 TSFS control struct, needed for file listing.
static struct app_filesthe_app_files
 The files application context pointer.
static struct font font_fixedrus
 Fixed point russian font object.

Color scheme



#define COLOR_TEXT   GFX_COLOR(250, 250, 250)
 Color on text strings.
#define COLOR_TEXT_SHADED   GFX_COLOR(150, 150, 150)
 Color on shaded text strings.
#define COLOR_BACKGROUND   GFX_COLOR(0, 0, 0)
 Background color.
#define COLOR_LINE   GFX_COLOR(48, 120, 158)
 Color on horizontal lines.

Text appearance



#define TEXT_HEADER_HEIGHT   30
 Height of common screen header in pixels.
#define TEXT_INDENT   5
 Number of pixels to indent a string.
#define TEXT_PADDING   3
 Number of pixels to add in front of a string.
#define TEXT_PADDING_NEWLINE   2
 Number of pixels for space after newline.

Detailed Description

The file system contents application demonstrates parts of the Tiny Simple File System. It also demonstrates how to do string formatting using the stream utilities.

This application provides some basic information about the Tiny Simple File System on two pages. The following pages list all the files on the current file system along with the file size of each file.

There are two navigation buttons at the bottom right corner, along with an exit button. The navigation buttons navigates between the different demonstration pages, while the exit button restarts the desktop application.


Define Documentation

#define COLOR_BACKGROUND   GFX_COLOR(0, 0, 0)

Background color.

Definition at line 86 of file app_files.c.

#define COLOR_LINE   GFX_COLOR(48, 120, 158)

Color on horizontal lines.

Definition at line 88 of file app_files.c.

Referenced by screen_draw_file_list_from_index(), screen_draw_file_system_info(), and screen_draw_introduction().

#define COLOR_TEXT   GFX_COLOR(250, 250, 250)

Color on text strings.

Definition at line 82 of file app_files.c.

#define COLOR_TEXT_SHADED   GFX_COLOR(150, 150, 150)

Color on shaded text strings.

Definition at line 84 of file app_files.c.

#define FILE_NAMES_PER_PAGE   8

Number of files to present size information per page.

Definition at line 63 of file app_files.c.

Referenced by app_files_frame_command_handler(), app_files_frame_draw_handler(), and screen_draw_file_list_from_index().

#define FONT_HEADER_SIZE   16

Number of bytes in the header for the font files loaded from the TSFS.

Definition at line 60 of file app_files.c.

#define TEXT_HEADER_HEIGHT   30

Height of common screen header in pixels.

Definition at line 94 of file app_files.c.

Referenced by screen_draw_file_list_from_index(), screen_draw_file_system_info(), and screen_draw_introduction().

#define TEXT_INDENT   5

Number of pixels to indent a string.

Definition at line 96 of file app_files.c.

#define TEXT_PADDING   3

Number of pixels to add in front of a string.

Definition at line 98 of file app_files.c.

#define TEXT_PADDING_NEWLINE   2

Number of pixels for space after newline.

Definition at line 100 of file app_files.c.


Enumeration Type Documentation

Event command ID for the application widgets.

Enumerator:
BUTTON_NEXT_ID 

Event command ID for the next button.

BUTTON_PREV_ID 

Event command ID for the previous button.

BUTTON_QUIT_ID 

Event command ID for the exit button.

Definition at line 106 of file app_files.c.

File demo application static page numbers.

Enumerator:
PAGE_NUM_BLANK 

Initial black screen while loading font.

PAGE_NUM_FIRST 

First info page.

PAGE_NUM_INTRO_SCREEN 

Introduction screen page number.

PAGE_NUM_INFO_SCREEN 

Info screen page number.

PAGE_NUM_LAST 

Last info page, not counting file info pages.

Definition at line 66 of file app_files.c.


Function Documentation

static bool app_files_frame_command_handler ( struct wtk_basic_frame frame,
win_command_t  command_data 
) [static]

Frame command handler handling the button events.

See also:
wtk_basic_frame_command_handler_t
Parameters:
frame Pointer to the basic frame object
command_data Command data provided with the event, holds button ID
Returns:
true when application is exiting, false otherwise

Definition at line 391 of file app_files.c.

References app_desktop_restart(), BUTTON_NEXT_ID, BUTTON_PREV_ID, BUTTON_QUIT_ID, FILE_NAMES_PER_PAGE, app_files::frame, tsfs::header, membag_free(), memcpy(), myfs, tsfs_header::nr_files, app_files::old_sysfont, PAGE_NUM_FIRST, PAGE_NUM_LAST, app_files::page_number, sysfont, win_redraw(), and wtk_basic_frame_as_child().

static void app_files_frame_draw_handler ( struct win_window win,
const struct win_clip_region clip 
) [static]
void app_files_launch ( struct workqueue_task task  ) 

Launch the files and string formatting application.

Parameters:
task Workqueue task to use for the application's worker functions.
static void app_files_load_worker ( struct workqueue_task task  )  [static]

Setup the font object after loading the font from the file system.

This function is called when the font has been loaded from the file system. It will setup the font object with the data read. Afterwards it will show the initial page on the screen.

Parameters:
task Pointer to work queue task

Definition at line 440 of file app_files.c.

References assert, font::first_char, FONT_HEADER_SIZE, app_files::frame, font::height, font::hugemem, hugemem_read_block(), font::last_char, PAGE_NUM_INTRO_SCREEN, app_files::page_number, font::width, win_show(), and wtk_basic_frame_as_child().

static void screen_draw_file_list_from_index ( uint_fast8_t  index  )  [static]

Draw a list of files from file entry index.

This function will fill the screen with information about files in the file system starting at file entry index.

Parameters:
index Index to entry in the file table

Definition at line 305 of file app_files.c.

References COLOR_LINE, COLOR_TEXT, FILE_NAMES_PER_PAGE, GFX_COLOR_TRANSPARENT, gfx_draw_horizontal_line, gfx_draw_string(), gfx_font_get_height(), gfx_get_width(), tsfs::header, memset(), min_u, myfs, tsfs_header::nr_files, snprintf(), string_file_size(), TEXT_HEADER_HEIGHT, TEXT_INDENT, TEXT_PADDING, TSFS_FILENAME_LEN, tsfs_get_file_size(), tsfs_get_filename(), and tsfs_open().

Referenced by app_files_frame_draw_handler().

static void screen_draw_file_system_info ( void   )  [static]

Draw file system information page.

This function will print information about the currently loaded file system to the screen. Strings are formatted using streams.

Definition at line 240 of file app_files.c.

References COLOR_LINE, COLOR_TEXT, GFX_COLOR_TRANSPARENT, gfx_draw_horizontal_line, gfx_draw_string(), gfx_font_get_height(), gfx_get_width(), tsfs::header, myfs, tsfs_header::nr_files, snprintf(), string_file_size(), TEXT_HEADER_HEIGHT, TEXT_INDENT, TEXT_PADDING, TEXT_PADDING_NEWLINE, tsfs_header::version, and tsfs_header::volume_size.

Referenced by app_files_frame_draw_handler().

static void screen_draw_introduction ( void   )  [static]

Draw file system introduction page.

This function will print an introduction page about the Tiny Simple File System to the screen.

Definition at line 192 of file app_files.c.

References COLOR_LINE, COLOR_TEXT, GFX_COLOR_TRANSPARENT, gfx_draw_horizontal_line, gfx_draw_string(), gfx_font_get_height(), gfx_get_width(), TEXT_HEADER_HEIGHT, TEXT_INDENT, TEXT_PADDING, and TEXT_PADDING_NEWLINE.

Referenced by app_files_frame_draw_handler().

static void string_file_size ( char *  file_size_str,
uint32_t  size,
size_t  str_size 
) [static]

Format a file size into a string.

This function will take a file size size and format it into the string file_size_str. The function will format the size into B, kB, MB or GB depending on which unit size best suits the input size.

Parameters:
file_size_str Pointer to a string able to contain the size
size Size of file in bytes
str_size Size of file_size_str

Definition at line 152 of file app_files.c.

References snprintf(), and unhandled_case.

Referenced by screen_draw_file_list_from_index(), and screen_draw_file_system_info().


Variable Documentation

struct font font_fixedrus [static]
Initial value:
 {
        .type   = FONT_LOC_HUGEMEM,
        .scale  = 1,
}

Fixed point russian font object.

Definition at line 136 of file app_files.c.

struct tsfs myfs
struct app_files* the_app_files [static]

The files application context pointer.

Definition at line 133 of file app_files.c.

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