Index: apps/settings.c
===================================================================
RCS file: /cvsroot/rockbox/apps/settings.c,v
retrieving revision 1.432
diff -u -r1.432 settings.c
--- apps/settings.c	27 Oct 2006 20:41:32 -0000	1.432
+++ apps/settings.c	6 Nov 2006 09:50:46 -0000
@@ -2077,6 +2077,167 @@
 #endif
 }
 
+/* Useful for time and other multi integer settings */
+bool set_multi_int(const char* string, const struct opt_items * names,
+                           struct opt_settings * variable, int varcount)
+{
+    int i, j;
+    char buf[32];
+    long button;
+    int cursor = 0;
+    bool done = false;
+    int oldvalue[varcount];
+    int pos = 0;
+
+    for(j = 0; j < varcount; j++)
+        oldvalue[j] = *(int*)variable[j].setting;
+
+    FOR_NB_SCREENS(i)
+    {
+        screens[i].clear_display();
+#ifdef HAVE_LCD_BITMAP
+        screens[i].setmargins(0, 8);
+#endif
+    }
+
+    snprintf(buf, sizeof(buf), "%s", string);
+    FOR_NB_SCREENS(i)
+        screens[i].puts(0, 0, buf);
+
+    /* print variable names */
+    for(j = 0; j < varcount ; j++)
+    {
+        if (j > 0)
+        {
+            snprintf(buf, sizeof(buf), ":");
+            FOR_NB_SCREENS(i)
+                screens[i].puts(pos - 2, 1, buf);
+        }
+
+        snprintf(buf, sizeof(buf), "%s", P2STR(names[j].string));
+        FOR_NB_SCREENS(i)
+            screens[i].puts(pos, 1, buf);
+
+        pos += strlen(buf) + 3;
+    }
+
+    snprintf(buf, sizeof(buf), "%s", str(LANG_TIMER_CONFIRM));
+    FOR_NB_SCREENS(i)
+        screens[i].puts(0, 5, buf);
+
+    gui_syncstatusbar_draw(&statusbars, true);
+
+    while(!done)
+    {
+        pos = 0;
+
+        /* print variables */
+        for(j = 0; j < varcount; j++)
+        {
+            if (j > 0)
+            {
+                snprintf(buf, sizeof(buf), " :");
+                FOR_NB_SCREENS(i)
+                screens[i].puts(pos - 3, 3, buf);
+            }
+
+            snprintf(buf, sizeof(buf), "%d", *(int*)variable[j].setting);
+
+#ifdef HAVE_LCD_BITMAP
+            if (cursor == j)
+            {
+                FOR_NB_SCREENS(i)
+                     screens[i].puts_style_offset(pos, 3, buf, STYLE_INVERT, 0);
+            }
+            else
+#endif
+            {
+                FOR_NB_SCREENS(i)
+                     screens[i].puts(pos, 3, buf);
+            }
+
+            snprintf(buf, sizeof(buf), "%d", variable[j].setting_max);
+            pos += strlen(buf) + 3;
+        }
+
+        /* print empty char to terminate invert style */
+        snprintf(buf, sizeof(buf), " ");
+        FOR_NB_SCREENS(i)
+            screens[i].puts(pos - 3, 3, buf);
+
+#ifdef HAVE_LCD_BITMAP
+       FOR_NB_SCREENS(i)
+           screens[i].update();
+#endif
+
+        button = get_action(CONTEXT_SETTINGS, TIMEOUT_BLOCK);
+
+        switch (button)
+        {
+            case ACTION_STD_NEXT:
+                cursor ++;
+                if (cursor >= varcount)
+                    cursor = varcount - 1;
+                if (global_settings.talk_menu)
+                    talk_id(names[cursor].voice_id, false);
+                break;
+
+            case ACTION_STD_PREV:
+                if (cursor == 0)
+                {
+                    /* cancel if pressing left when cursor
+                       is already at the far left */
+                    for(j = 0; j < varcount; j++)
+                       *(int*)variable[j].setting = oldvalue[j];
+                    gui_syncsplash(HZ/2, true, str(LANG_MENU_SETTING_CANCEL));
+                    done = true;
+                }
+                else
+                    cursor --;
+                    if (cursor < 0)
+                        cursor = 0;
+                    if (global_settings.talk_menu)
+                        talk_id(names[cursor].voice_id, false);
+                break;
+
+            case ACTION_SETTINGS_INC:
+            case ACTION_SETTINGS_INCREPEAT:
+                *(int*)variable[cursor].setting += 1;
+                if (*(int*)variable[cursor].setting >
+                        variable[cursor].setting_max)
+                    *(int*)variable[cursor].setting = 0;
+                if (global_settings.talk_menu)
+                    talk_unit(INT, *(int*)variable[cursor].setting);
+                break;
+
+            case ACTION_SETTINGS_DEC:
+            case ACTION_SETTINGS_DECREPEAT:
+                *(int*)variable[cursor].setting -= 1;
+                if (*(int*)variable[cursor].setting < 0)
+                    *(int*)variable[cursor].setting =
+                        variable[cursor].setting_max;
+                if (global_settings.talk_menu)
+                    talk_unit(INT, *(int*)variable[cursor].setting);
+                break;
+
+            case ACTION_STD_OK:
+                done = true;
+                break;
+
+            case ACTION_STD_CANCEL:
+                for(j = 0; j < varcount; j++)
+                   *(int*)variable[j].setting = oldvalue[j];  
+                gui_syncsplash(HZ/2, true, str(LANG_MENU_SETTING_CANCEL));
+                return false;
+
+            default:
+                if (default_event_handler(button) == SYS_USB_CONNECTED)
+                    return true;
+        }
+    }
+    return false;
+}
+
 /* NOTE: the 'type' parameter specifies the actual type of the variable
    that 'variable' points to. not the value within. Only variables with
    type 'bool' should use parameter BOOL.
Index: apps/settings.h
===================================================================
RCS file: /cvsroot/rockbox/apps/settings.h,v
retrieving revision 1.250
diff -u -r1.250 settings.h
--- apps/settings.h	27 Oct 2006 20:41:32 -0000	1.250
+++ apps/settings.h	6 Nov 2006 09:50:47 -0000
@@ -170,7 +170,6 @@
                           13= 1GB, 14 = 1.5GB 15 = 1.75MB*/
     int rec_split_type; /* split/stop */
     int rec_split_method; /* time/filesize */
-
     int rec_prerecord_time; /* In seconds, 0-30, 0 means OFF */
     int rec_directory; /* 0=base dir, 1=current dir */
     bool rec_startup; /* true means start Rockbox in recording screen */
@@ -513,6 +512,11 @@
     long voice_id;
 };
 
+struct opt_settings {
+    int* setting;
+    int setting_max;
+};
+
 /* prototypes */
 
 void settings_calc_config_sector(void);
@@ -534,6 +538,8 @@
 bool set_bool(const char* string, bool* variable );
 bool set_option(const char* string, void* variable, enum optiontype type,
                 const struct opt_items* options, int numoptions, void (*function)(int));
+bool set_multi_int(const char* string, const struct opt_items * names,
+                           struct opt_settings * variable, int varcount);
 bool set_int(const unsigned char* string, const char* unit, int voice_unit,
              int* variable,
              void (*function)(int), int step, int min, int max, 
Index: apps/sound_menu.c
===================================================================
RCS file: /cvsroot/rockbox/apps/sound_menu.c,v
retrieving revision 1.119
diff -u -r1.119 sound_menu.c
--- apps/sound_menu.c	27 Oct 2006 20:41:32 -0000	1.119
+++ apps/sound_menu.c	6 Nov 2006 09:50:48 -0000
@@ -41,6 +41,7 @@
 #include "sound.h"
 #ifdef HAVE_RECORDING
 #include "audio.h"
+#include "recording.h"
 #ifdef CONFIG_TUNER
 #include "radio.h"
 #endif
@@ -601,6 +602,46 @@
                       INT, names, 5, NULL );
 }
 #endif /* HAVE_AGC */
+
+/* Displays a menu for changing the countdown timer settings */
+static bool countdown_timer(void)
+{
+    bool retval;
+    struct timer* timer = get_timerstat();
+    int old_timer_day = timer->days;
+    int old_timer_hr = timer->hrs;
+    int old_timer_min = timer->mins;
+
+    /* pause timer while in timer settings */
+    timer->countdown = false;
+
+    static const struct opt_items names[] = {
+        { STR(LANG_TIMER_DAYS) },
+        { STR(LANG_TIMER_HRS) },
+        { STR(LANG_TIMER_MINS) }
+    };
+
+    struct opt_settings settings[] = {
+        { &timer->days, 6 },
+        { &timer->hrs, 23 },
+        { &timer->mins, 59 }
+    };
+
+    retval = set_multi_int(str(LANG_TIMER_SET), names, settings, 3);
+
+    if ((old_timer_day != timer->days) ||
+            (old_timer_hr != timer->hrs) ||
+            (old_timer_min != timer->mins))
+    {
+        timer->secs = 0;
+        timer->timer_display = false;
+    }
+    else /* restart timer if no change */
+        timer->countdown = true;
+
+    return retval;
+}
+
 #endif /* HAVE_RECORDING */
 
 static bool chanconf(void)
@@ -1096,6 +1137,8 @@
     items[i].desc = ID2P(LANG_RECORD_AGC_CLIPTIME);
     items[i++].function = agc_cliptime;
 #endif
+    items[i].desc = ID2P(LANG_TIMER_SET);
+    items[i++].function = countdown_timer;
 
     m=menu_init( items, i, NULL, NULL, NULL, NULL);
     result = menu_run(m);
Index: apps/gui/statusbar.c
===================================================================
RCS file: /cvsroot/rockbox/apps/gui/statusbar.c,v
retrieving revision 1.32
diff -u -r1.32 statusbar.c
--- apps/gui/statusbar.c	26 Sep 2006 11:56:58 -0000	1.32
+++ apps/gui/statusbar.c	6 Nov 2006 09:50:51 -0000
@@ -37,6 +37,7 @@
 #include "action.h" /* for keys_locked */
 #include "statusbar.h"
 #ifdef HAVE_RECORDING
+#include "recording.h"
 #include "audio.h"
 #endif
 
@@ -116,7 +117,11 @@
 #define STATUSBAR_LOCKR_WIDTH                   5
 
 #if (CONFIG_LED == LED_VIRTUAL) || defined(HAVE_REMOTE_LCD)
+#ifdef HAVE_MMC
 #define STATUSBAR_DISK_WIDTH                    12
+#else
+#define STATUSBAR_DISK_WIDTH                    7
+#endif
 #define STATUSBAR_DISK_X_POS(statusbar_width)   statusbar_width - \
                                                 STATUSBAR_DISK_WIDTH
 #else
@@ -125,6 +130,7 @@
 #define STATUSBAR_TIME_X_END(statusbar_width)   statusbar_width - 1 - \
                                                 STATUSBAR_DISK_WIDTH
 #if defined(HAVE_RECORDING)
+#define TIMER_ICON_WIDTH 7
 /* analogue frequency numbers taken from the order of frequencies in sample_rate */
 #define FREQ_44 7
 #define FREQ_48 8
@@ -231,6 +237,20 @@
         bar->info.minute = tm->tm_min;
     }
 #endif /* CONFIG_RTC */
+#ifdef HAVE_RECORDING
+    struct timer* timer = get_timerstat();
+    bar->info.timer_day = timer->days;
+    bar->info.timer_hour = timer->hrs;
+    bar->info.timer_min = timer->mins;
+    /* avoid an update every second unless less than one
+       minute remains on the timer */
+    if (!bar->info.timer_day && !bar->info.timer_hour && !bar->info.timer_min)
+        bar->info.timer_sec = timer->secs;
+    else
+        bar->info.timer_sec = 0;
+
+    bar->info.timer_display = timer->timer_display;
+#endif
 
     /* only redraw if forced to, or info has changed */
     if (force_redraw || bar->redraw_volume ||
@@ -308,8 +328,14 @@
         if (bar->info.keylockremote)
             gui_statusbar_icon_lock_remote(display);
 #endif
+#ifdef HAVE_RECORDING
+        if (bar->info.timer_display)
+            gui_statusbar_timer(display, bar->info.timer_day, bar->info.timer_hour,
+                                   bar->info.timer_min, bar->info.timer_sec);
+#endif
 #ifdef CONFIG_RTC
-        gui_statusbar_time(display, bar->info.hour, bar->info.minute);
+        gui_statusbar_time(display, bar->info.hour, bar->info.minute,
+                               bar->info.timer_display);
 #endif /* CONFIG_RTC */
 #if (CONFIG_LED == LED_VIRTUAL) || defined(HAVE_REMOTE_LCD)
         if(!display->has_disk_led && bar->info.led)
@@ -569,10 +595,11 @@
 /*
  * Print time to status bar
  */
-void gui_statusbar_time(struct screen * display, int hour, int minute)
+void gui_statusbar_time(struct screen * display, int hour, int minute,
+                           bool timer_display)
 {
     unsigned char buffer[6];
-    unsigned int width, height;
+    int width, height;
     if ( hour >= 0 &&
          hour <= 23 &&
          minute >= 0 &&
@@ -591,15 +618,68 @@
     display->setfont(FONT_SYSFIXED);
     display->getstringsize(buffer, &width, &height);
     if (height <= STATUSBAR_HEIGHT) {
+#ifdef HAVE_RECORDING
+        if (timer_display)
+            display->set_drawmode(DRMODE_INVERSEVID);
+#endif
         display->putsxy(STATUSBAR_TIME_X_END(display->width) - width,
                         STATUSBAR_Y_POS, buffer);
     }
+    display->set_drawmode(DRMODE_SOLID);
     display->setfont(FONT_UI);
 
 }
 #endif
 
 #ifdef HAVE_RECORDING
+void gui_statusbar_timer(struct screen * display, int dy, int hr, int mn, int sc)
+{
+    unsigned char buffer[8];
+    int width, height, offset;
+
+#ifdef CONFIG_RTC
+    strncpy(buffer, " --:--", sizeof buffer);
+    display->getstringsize(buffer, &width, &height);
+    offset = width;
+#else
+    offset = 0;
+#endif
+
+    /* vary the display depending on the remaining time to save space */
+    if (dy)
+        snprintf(buffer, sizeof(buffer), " %dd%02dh", hr > 58 ? dy + 1 : dy,
+                    hr > 58 ? 0 : hr + 1);
+    else if (!hr && !mn)
+        snprintf(buffer, sizeof(buffer), "%02ds", sc);
+    else
+        snprintf(buffer, sizeof(buffer), "%02dh%02dm", mn > 58 ? hr + 1: hr,
+                    mn > 58 ? 0 : mn + 1);
+
+    display->setfont(FONT_SYSFIXED);
+    display->getstringsize(buffer, &width, &height);
+
+    if (height <= STATUSBAR_HEIGHT)
+    {
+        if((display->width) >= (STATUSBAR_LOCKR_X_POS + STATUSBAR_LOCKR_WIDTH +
+                                  STATUSBAR_DISK_WIDTH + width + offset + 1))
+            display->putsxy(STATUSBAR_TIME_X_END(display->width) - width -
+                                offset, STATUSBAR_Y_POS, buffer);
+        /* display only an icon for small screens */
+        else if ((display->width) >= (STATUSBAR_LOCKR_X_POS +
+                                           STATUSBAR_LOCKR_WIDTH +
+                                           STATUSBAR_DISK_WIDTH +
+                                           TIMER_ICON_WIDTH + offset + 1))
+            display->mono_bitmap(bitmap_icons_7x7[Icon_Timer],
+                                       STATUSBAR_TIME_X_END(display->width) -
+                                       TIMER_ICON_WIDTH - offset,
+                                       STATUSBAR_Y_POS,
+                                       TIMER_ICON_WIDTH, STATUSBAR_HEIGHT);
+    }
+
+    display->setfont(FONT_UI);
+
+}
+
 void gui_statusbar_icon_recording_info(struct screen * display)
 {
 #if (CONFIG_CODEC != SWCODEC) || (defined(SIMULATOR) && defined(HAVE_SPDIF_IN))
Index: apps/gui/statusbar.h
===================================================================
RCS file: /cvsroot/rockbox/apps/gui/statusbar.h,v
retrieving revision 1.17
diff -u -r1.17 statusbar.h
--- apps/gui/statusbar.h	2 Sep 2006 17:30:30 -0000	1.17
+++ apps/gui/statusbar.h	6 Nov 2006 09:50:51 -0000
@@ -39,6 +39,13 @@
     int hour;
     int minute;
 #endif
+#ifdef HAVE_RECORDING
+    int timer_day;
+    int timer_hour;
+    int timer_min;
+    int timer_sec;
+    int timer_display;
+#endif
 
 #ifdef CONFIG_CHARGING
     bool inserted;
@@ -106,11 +113,13 @@
 void gui_statusbar_icon_lock_remote(struct screen * display);
 void gui_statusbar_led(struct screen * display);
 #ifdef HAVE_RECORDING
+void gui_statusbar_timer(struct screen * display, int dy, int hr, int mn, int sc);
 void gui_statusbar_icon_recording_info(struct screen * display);
 #endif
 
 #ifdef CONFIG_RTC
-void gui_statusbar_time(struct screen * display, int hour, int minute);
+void gui_statusbar_time(struct screen * display, int hour, int minute,
+                            bool timer_display);
 #endif
 
 
Index: apps/keymaps/keymap-h1x0_h3x0.c
===================================================================
RCS file: /cvsroot/rockbox/apps/keymaps/keymap-h1x0_h3x0.c,v
retrieving revision 1.36
diff -u -r1.36 keymap-h1x0_h3x0.c
--- apps/keymaps/keymap-h1x0_h3x0.c	6 Nov 2006 09:19:38 -0000	1.36
+++ apps/keymaps/keymap-h1x0_h3x0.c	6 Nov 2006 09:50:53 -0000
@@ -440,6 +440,10 @@
     { ACTION_SETTINGS_INCREPEAT,    BUTTON_RC_REW|BUTTON_REPEAT,    BUTTON_NONE },
     { ACTION_SETTINGS_DEC,          BUTTON_RC_FF,                   BUTTON_NONE },
     { ACTION_SETTINGS_DECREPEAT,    BUTTON_RC_FF|BUTTON_REPEAT,     BUTTON_NONE },
+    { ACTION_STD_PREV,              BUTTON_RC_SOURCE,                  BUTTON_NONE },
+    { ACTION_STD_PREVREPEAT,        BUTTON_RC_SOURCE|BUTTON_REPEAT,    BUTTON_NONE },
+    { ACTION_STD_NEXT,              BUTTON_RC_BITRATE,                   BUTTON_NONE },
+    { ACTION_STD_NEXTREPEAT,        BUTTON_RC_BITRATE|BUTTON_REPEAT,     BUTTON_NONE },
 /*    { ACTION_NONE,                  BUTTON_RC_ON,                   BUTTON_NONE },
     { ACTION_NONE,                  BUTTON_RC_STOP,                 BUTTON_NONE },
     { ACTION_NONE,                  BUTTON_RC_MENU|BUTTON_REL,      BUTTON_NONE },
@@ -452,8 +456,11 @@
     { ACTION_SETTINGS_INCREPEAT,    BUTTON_RC_VOL_UP|BUTTON_REPEAT, BUTTON_NONE },
     { ACTION_SETTINGS_DEC,          BUTTON_RC_VOL_DOWN,             BUTTON_NONE },
     { ACTION_SETTINGS_DECREPEAT,    BUTTON_RC_VOL_DOWN|BUTTON_REPEAT,   BUTTON_NONE },
-    { ACTION_NONE,                  BUTTON_RC_REW,                  BUTTON_NONE },
-    { ACTION_NONE,                  BUTTON_RC_FF,                   BUTTON_NONE },
+    { ACTION_STD_PREV,              BUTTON_RC_REW,                  BUTTON_NONE },
+    { ACTION_STD_PREVREPEAT,        BUTTON_RC_REW|BUTTON_REPEAT,    BUTTON_NONE },
+    { ACTION_STD_NEXT,              BUTTON_RC_FF,                   BUTTON_NONE },
+    { ACTION_STD_NEXTREPEAT,        BUTTON_RC_FF|BUTTON_REPEAT,     BUTTON_NONE },
+    { ACTION_SETTINGS_RESET,        BUTTON_RC_ON,                   BUTTON_NONE },
     
     LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
 }; /* button_context_settings */
Index: apps/keymaps/keymap-x5.c
===================================================================
RCS file: /cvsroot/rockbox/apps/keymaps/keymap-x5.c,v
retrieving revision 1.25
diff -u -r1.25 keymap-x5.c
--- apps/keymaps/keymap-x5.c	6 Nov 2006 09:19:39 -0000	1.25
+++ apps/keymaps/keymap-x5.c	6 Nov 2006 09:50:54 -0000
@@ -209,6 +209,9 @@
     { ACTION_SETTINGS_DEC,          BUTTON_DOWN,                BUTTON_NONE },
     { ACTION_SETTINGS_DECREPEAT,    BUTTON_DOWN|BUTTON_REPEAT,  BUTTON_NONE },
     { ACTION_STD_PREV,              BUTTON_LEFT,                BUTTON_NONE },
+    { ACTION_STD_PREVREPEAT,        BUTTON_LEFT|BUTTON_REPEAT,  BUTTON_NONE },
+    { ACTION_STD_NEXT,              BUTTON_RIGHT,               BUTTON_NONE },
+    { ACTION_STD_NEXTREPEAT,        BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_NONE },
     { ACTION_STD_CANCEL,            BUTTON_REC,                 BUTTON_NONE },
 
     LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
Index: apps/lang/english.lang
===================================================================
RCS file: /cvsroot/rockbox/apps/lang/english.lang,v
retrieving revision 1.294
diff -u -r1.294 english.lang
--- apps/lang/english.lang	6 Nov 2006 09:24:16 -0000	1.294
+++ apps/lang/english.lang	6 Nov 2006 09:51:01 -0000
@@ -9991,6 +9991,86 @@
   </voice>
 </phrase>
 <phrase>
+  id: LANG_TIMER_CONFIRM
+  desc: Confirm string for recording countdown timer settings
+  user:
+  <source>
+    *: "Press PLAY to confirm"
+  </source>
+  <dest>
+    *: "Press PLAY to confirm"
+    h100,h120,h300: "Press NAVI to confirm"
+  </dest>
+  <voice>
+    *: ""
+  </voice>
+</phrase>
+<phrase>
+  id: LANG_TIMER_SET
+  desc: Recording timer menu
+  <source>
+    *: "Set countdown timer"
+  </source>
+  <dest>
+    *: "Set countdown timer"
+  </dest>
+  <voice>
+    *: "Set countdown timer"
+  </voice>
+</phrase>
+<phrase>
+  id: LANG_TIMER_DAYS
+  desc: recording timer settings string
+  <source>
+    *: "Days"
+  </source>
+  <dest>
+    *: "Days"
+  </dest>
+  <voice>
+    *: "Days"
+  </voice>
+</phrase>
+<phrase>
+  id: LANG_TIMER_HRS
+  desc: recording timer settings string
+  <source>
+    *: "Hrs"
+  </source>
+  <dest>
+    *: "Hrs"
+  </dest>
+  <voice>
+    *: "Hrs"
+  </voice>
+</phrase>
+<phrase>
+  id: LANG_TIMER_MINS
+  desc: recording timer settings string
+  <source>
+    *: "Mins"
+  </source>
+  <dest>
+    *: "Mins"
+  </dest>
+  <voice>
+    *: "Mins"
+  </voice>
+</phrase>
+<phrase>
+  id: LANG_REC_TIMER
+  desc: recording screen timer string
+  <source>
+    *: "Timer"
+  </source>
+  <dest>
+    *: "Timer"
+  </dest>
+  <voice>
+    *: "Timer"
+  </voice>
+</phrase>
+<phrase>
   id: LANG_DITHERING
   desc: in the sound settings menu
   user:
Index: apps/recorder/icons.c
===================================================================
RCS file: /cvsroot/rockbox/apps/recorder/icons.c,v
retrieving revision 1.86
diff -u -r1.86 icons.c
--- apps/recorder/icons.c	13 Oct 2006 04:16:49 -0000	1.86
+++ apps/recorder/icons.c	6 Nov 2006 09:51:03 -0000
@@ -39,6 +39,11 @@
 #endif
 };
 
+const unsigned char bitmap_icons_7x7[][7] =
+{
+    [Icon_Timer]={0x1c, 0x22, 0x41, 0x4f, 0x49, 0x22, 0x1d},  /* Recording timer icon */
+};
+
 const unsigned char bitmap_icons_6x8[][6] =
 {
     { 0x60, 0x7f, 0x03, 0x33, 0x3f, 0x00 }, /* Musical note */
@@ -126,7 +131,7 @@
 #ifdef HAVE_MMC
     {0x15,0x3f,0x7d,0x7B,0x77,0x67,0x79,0x7b,0x57,0x4f,0x47,0x7f};
 #else
-    {0x00,0x00,0x00,0x1c,0x2e,0x4f,0x77,0x79,0x3a,0x1c,0x00,0x00};
+    {0x1c,0x2e,0x4f,0x77,0x79,0x3a,0x1c,0x00,0x00,0x00,0x00,0x00};
 #endif
 
 /*
Index: apps/recorder/icons.h
===================================================================
RCS file: /cvsroot/rockbox/apps/recorder/icons.h,v
retrieving revision 1.66
diff -u -r1.66 icons.h
--- apps/recorder/icons.h	13 Oct 2006 04:16:49 -0000	1.66
+++ apps/recorder/icons.h	6 Nov 2006 09:51:04 -0000
@@ -47,6 +47,11 @@
     Icon5x8Last
 };
 
+enum icons_7x7 {
+    Icon_Timer,
+    Icon7x7Last
+};
+
 enum icons_6x8 {
     Icon_Audio,
     Icon_Folder,
@@ -121,6 +126,7 @@
 #endif
 
 extern const unsigned char bitmap_icons_5x8[Icon5x8Last][5];
+extern const unsigned char bitmap_icons_7x7[Icon7x7Last][7];
 extern const unsigned char bitmap_icons_6x8[Icon6x8Last][6];
 extern const unsigned char bitmap_icons_7x8[Icon7x8Last][7];
 #if CONFIG_CODEC == SWCODEC
Index: apps/recorder/recording.c
===================================================================
RCS file: /cvsroot/rockbox/apps/recorder/recording.c,v
retrieving revision 1.143
diff -u -r1.143 recording.c
--- apps/recorder/recording.c	1 Oct 2006 10:04:40 -0000	1.143
+++ apps/recorder/recording.c	6 Nov 2006 09:51:07 -0000
@@ -71,6 +71,8 @@
 #include "radio.h"
 #ifdef HAVE_RECORDING
 
+static struct timer timer;
+
 #define PM_HEIGHT ((LCD_HEIGHT >= 72) ? 2 : 1)
 
 bool f2_rec_screen(void);
@@ -784,6 +786,38 @@
     }
 }
 
+/* countdown timer tick task */
+void timer_tick_task(void)
+{
+    static int mini_tick = 0;
+
+    mini_tick ++;
+    /* the countdown */
+    if ((mini_tick > HZ) && (timer.countdown))
+    {
+        timer.secs -= 1;
+        if (timer.secs < 0){
+            timer.mins -= 1;
+            timer.secs = 59;
+            if (timer.mins < 0){
+                timer.hrs -= 1;
+                timer.mins = 59;
+                if (timer.hrs < 0){
+                    timer.days -= 1;
+                    timer.hrs = 23;
+                    if (timer.days < 0)
+                    {
+                        timer.days = timer.hrs = timer.mins = timer.secs = 0;
+                        /* switch timer display on/off when countdown finished */
+                        timer.timer_display = !timer.timer_display; 
+                    }
+                }
+            }
+        }
+        mini_tick = 0;
+    }
+}
+
 bool recording_screen(bool no_source)
 {
     long button;
@@ -823,6 +857,7 @@
     int i;
     int filename_offset[NB_SCREENS];
     int pm_y[NB_SCREENS];
+    int countdown_offset = 0;
 
     static const unsigned char *byte_units[] = {
         ID2P(LANG_BYTE),
@@ -832,6 +867,11 @@
     };
 
     global_settings.recscreen_on = true;
+
+    /* Stop countdown if countdown settings changed */
+    if (!timer.countdown)
+        tick_remove_task(timer_tick_task);
+
     cursor = 0;
 #if (CONFIG_LED == LED_REAL) && !defined(SIMULATOR)
     ata_set_led_enabled(false);
@@ -973,6 +1013,15 @@
             last_audio_stat = audio_stat;
         }
 
+        /* When countdown timer reaches zero fake a new file button press */
+        if (timer.countdown && !timer.days && !timer.hrs && !timer.mins &&
+                !timer.secs)
+        {
+            tick_remove_task(timer_tick_task);
+            button = ACTION_REC_NEWFILE;
+            timer.countdown = false;
+        }
+
         switch(button)
         {
             case ACTION_REC_LCD:
@@ -1018,7 +1067,27 @@
             case ACTION_REC_NEWFILE:
                 /* Only act if the mpeg is stopped */
                 if(!(audio_stat & AUDIO_STATUS_RECORD))
-                {
+                {   /* if countdown timer is set, start countdown */
+                    if (timer.days || timer.hrs || timer.mins || timer.secs)
+                    {
+                        if (button == ACTION_REC_PAUSE)
+                        {
+                            timer.countdown = !timer.countdown;
+                            if (timer.countdown)
+                                tick_add_task(timer_tick_task);
+                            else
+                                 tick_remove_task(timer_tick_task);
+                            break;
+                        }
+                        else
+                        {
+                        /* if newfile button pressed and countdown timer is on,
+                           start new file and reset timer */
+                            tick_remove_task(timer_tick_task);
+                            timer.days = timer.hrs = timer.mins = timer.secs = 0;
+                            timer.countdown = false;
+                        }
+                    }
                     /* is this manual or triggered recording? */
                     if ((global_settings.rec_trigger_mode == TRIG_MODE_OFF) ||
                         (peak_meter_trigger_status() != TRIG_OFF))
@@ -1225,7 +1294,6 @@
 #ifdef HAVE_FMRADIO_IN
                     const int prev_rec_source = global_settings.rec_source;
 #endif
-
 #if CONFIG_LED == LED_REAL
                     /* led is restored at begin of loop / end of function */
                     led(false);
@@ -1249,6 +1317,10 @@
                             && prev_rec_source == AUDIO_SRC_FMRADIO)
                             radio_status = FMRADIO_OFF;
 #endif
+                        /* if countdown timer settings changed in menu, 
+                           stop counting and reset */
+                        if (!timer.countdown)
+                            tick_remove_task(timer_tick_task);
 
 #if CONFIG_CODEC == SWCODEC
                         /* reinit after submenu exit */
@@ -1353,6 +1425,9 @@
                 break;
         }
 
+        /* display timer status in status bar if countdown enabled */
+        timer.timer_display = timer.countdown;
+
 #ifdef HAVE_AGC
         peak_read = !peak_read;
         if (peak_read) { /* every 2nd run of loop */
@@ -1389,11 +1464,13 @@
 
             if ((global_settings.rec_sizesplit) && (global_settings.rec_split_method))
             {
+                countdown_offset = 1;
                 dmb = dsize/1024/1024;
                 snprintf(buf, sizeof(buf), "%s %dMB",
                              str(LANG_SYSFONT_SPLIT_SIZE), dmb);
             }
-            else
+            /* only display recording time if countdown timer is off */
+            else if (!timer.days && !timer.hrs && !timer.mins && !timer.secs)
             {
                 hours = seconds / 3600;
                 minutes = (seconds - (hours * 3600)) / 60;
@@ -1401,6 +1478,11 @@
                          str(LANG_SYSFONT_RECORDING_TIME),
                          hours, minutes, seconds%60);
             }
+            else
+            {
+                countdown_offset = 0;
+                snprintf(buf, 32, "");
+            }
             
             for(i = 0; i < screen_update; i++)
                 screens[i].puts(0, 0, buf); 
@@ -1424,7 +1506,8 @@
                              str(LANG_SYSFONT_RECORD_TIMESPLIT_REC),
                              dhours, dminutes);
                 }
-                else
+                /* only display recording size if countdown timer is off */    
+                else if (!timer.days && !timer.hrs && !timer.mins && !timer.secs)
                 {
                     output_dyn_value(buf2, sizeof buf2,
                                      num_recorded_bytes,
@@ -1436,6 +1519,16 @@
             for(i = 0; i < screen_update; i++)
                 screens[i].puts(0, 1, buf);
 
+            /* display countdown timer if set */
+            if (timer.days || timer.hrs || timer.mins || timer.secs)
+            {
+                 snprintf(buf, 32, "%s %d:%02d:%02d:%02d", str(LANG_REC_TIMER),
+                        timer.days, timer.hrs, timer.mins, timer.secs);
+
+                 for(i = 0; i < screen_update; i++)
+                     screens[i].puts(0, countdown_offset, buf);
+            }
+
             for(i = 0; i < screen_update; i++)
             {
                 if (filename_offset[i] > 0)
@@ -2037,6 +2130,12 @@
 }
 #endif /* CONFIG_KEYPAD == RECORDER_PAD */
 
+struct timer *get_timerstat(void)
+{
+    return &timer;
+}
+
+
 #if CONFIG_CODEC == SWCODEC
 void audio_beep(int duration)
 {
Index: apps/recorder/recording.h
===================================================================
RCS file: /cvsroot/rockbox/apps/recorder/recording.h,v
retrieving revision 1.5
diff -u -r1.5 recording.h
--- apps/recorder/recording.h	28 Aug 2006 22:38:40 -0000	1.5
+++ apps/recorder/recording.h	6 Nov 2006 09:51:07 -0000
@@ -23,6 +23,18 @@
 char *rec_create_filename(char *buf);
 int rec_create_directory(void);
 
+struct timer
+{
+    bool countdown;
+    bool timer_display;
+    int days;
+    int hrs;
+    int mins;
+    int secs;
+};
+
+struct timer *get_timerstat(void);
+
 #if CONFIG_CODEC == SWCODEC
 /* selects an audio source for recording or playback */
 #define SRCF_PLAYBACK         0x0000    /* default */
