Support the recording screen on the LCD remote. Also adds support for the peakmeter in the rremote WPS. Patch from Martin Scarratt (task 4818).


git-svn-id: svn://svn.rockbox.org/rockbox/trunk@9246 a1c6a512-1295-4272-9138-f99709370657
diff --git a/apps/gui/gwps-common.c b/apps/gui/gwps-common.c
index b250674..37306fb 100644
--- a/apps/gui/gwps-common.c
+++ b/apps/gui/gwps-common.c
@@ -1750,7 +1750,7 @@
 #endif
                 update_line = true;
             }
-            if (flags & refresh_mode & WPS_REFRESH_PEAK_METER && display->height >= LCD_HEIGHT) {
+            if (flags & refresh_mode & WPS_REFRESH_PEAK_METER) {
                 /* peak meter */
                 int peak_meter_y;
 
@@ -1761,12 +1761,12 @@
                    line so that it is only displayed if no status bar is
                    visible. If so we neither want do draw nor enable the
                    peak meter. */
-                if (peak_meter_y + h <= LCD_HEIGHT) {
+                if (peak_meter_y + h <= display->height) {
                     /* found a line with a peak meter -> remember that we must
                        enable it later */
                     enable_pm = true;
-                    peak_meter_draw(0, peak_meter_y, LCD_WIDTH,
-                                    MIN(h, LCD_HEIGHT - peak_meter_y));
+                    peak_meter_screen(gwps->display, 0, peak_meter_y,
+                                    MIN(h, display->height - peak_meter_y));
                 }
             }
 #else
diff --git a/apps/gui/icon.c b/apps/gui/icon.c
index 0cdee11..ef6f61f 100644
--- a/apps/gui/icon.c
+++ b/apps/gui/icon.c
@@ -26,12 +26,14 @@
 void screen_put_iconxy(struct screen * display, int x, int y, ICON icon)
 {
 #ifdef HAVE_LCD_BITMAP
+    int width, height;
     int xpos, ypos;
+    display->getstringsize((unsigned char *)"M", &width, &height);
     xpos = x*CURSOR_WIDTH;
-    ypos = y*display->char_height + display->getymargin();
+    ypos = y*height + display->getymargin();
 
-    if ( display->char_height > CURSOR_HEIGHT )/* center the cursor */
-        ypos += (display->char_height - CURSOR_HEIGHT) / 2;
+    if ( height > CURSOR_HEIGHT )/* center the cursor */
+        ypos += (height - CURSOR_HEIGHT) / 2;
     if(icon==0)/* Don't display invalid icons */
         screen_clear_area(display, xpos, ypos, CURSOR_WIDTH, CURSOR_HEIGHT);
     else
diff --git a/apps/lang/english.lang b/apps/lang/english.lang
index 65e45cf..868b206 100644
--- a/apps/lang/english.lang
+++ b/apps/lang/english.lang
@@ -939,13 +939,13 @@
 
 id: LANG_RECORDING_LEFT
 desc: in the recording screen
-eng: "Gain Left"
+eng: "Gain L"
 voice: ""
 new:
 
 id: LANG_RECORDING_RIGHT
 desc: in the recording screen
-eng: "Gain Right"
+eng: "Gain R"
 voice: ""
 new:
 
diff --git a/apps/recorder/peakmeter.c b/apps/recorder/peakmeter.c
index 8bcc068..ec80622 100644
--- a/apps/recorder/peakmeter.c
+++ b/apps/recorder/peakmeter.c
@@ -33,6 +33,7 @@
 #include "lang.h"
 #include "peakmeter.h"
 #include "audio.h"
+#include "screen_access.h"
 #ifdef CONFIG_BACKLIGHT
 #include "backlight.h"
 #endif
@@ -48,6 +49,8 @@
 
 #endif
 
+struct meter_scales scales[NB_SCREENS];
+
 #if !defined(SIMULATOR) && CONFIG_CODEC != SWCODEC
 /* Data source */
 static int pm_src_left = MAS_REG_DQPEAK_L;
@@ -60,12 +63,6 @@
 static int pm_max_left;        /* maximum values between peak meter draws */
 static int pm_max_right;
 
-/* Peak hold */
-static int pm_peak_left;       /* buffered peak values */
-static int pm_peak_right;
-static long pm_peak_timeout_l; /* peak hold timeouts */
-static long pm_peak_timeout_r;
-
 /* Clip hold */
 static bool pm_clip_left = false;  /* when true a clip has occurred */
 static bool pm_clip_right = false;
@@ -82,6 +79,7 @@
 unsigned short peak_meter_range_max;  /* maximum of range in samples */
 static unsigned short pm_range;       /* range width in samples */
 static bool pm_use_dbfs = true;       /* true if peakmeter displays dBfs */
+bool level_check;                     /* true if peeked at peakmeter before drawing */
 static unsigned short pm_db_min = 0;      /* minimum of range in 1/100 dB */
 static unsigned short pm_db_max = 9000;   /* maximum of range in 1/100 dB */
 static unsigned short pm_db_range = 9000; /* range width in 1/100 dB */
@@ -140,7 +138,6 @@
 
 /* precalculated peak values that represent magical
    dBfs values. Used to draw the scale */
-#define DB_SCALE_SRC_VALUES_SIZE 12
 static const int db_scale_src_values[DB_SCALE_SRC_VALUES_SIZE] = {
     32752, /*   0 db */
     22784, /* - 3 db */
@@ -158,15 +155,6 @@
 
 static int db_scale_count = DB_SCALE_SRC_VALUES_SIZE;
 
-/* if db_scale_valid is false the content of
-   db_scale_lcd_coord needs recalculation */
-static bool db_scale_valid = false;
-
-/* contains the lcd x coordinates of the magical
-   scale values in db_scale_src_values */
-static int db_scale_lcd_coord[sizeof db_scale_src_values / sizeof (int)];
-
-
 /**
  * Calculates dB Value for the peak meter, uses peak value as input
  * @param int sample - The input value 
@@ -368,7 +356,9 @@
 
     pm_db_min = calc_db(peak_meter_range_min);
     pm_db_range = pm_db_max - pm_db_min;
-    db_scale_valid = false;
+    int i;
+    FOR_NB_SCREENS(i)
+        scales[i].db_scale_valid = false;
 }
 
 /**
@@ -410,7 +400,9 @@
 
     pm_db_max = calc_db(peak_meter_range_max);
     pm_db_range = pm_db_max - pm_db_min;
-    db_scale_valid = false;
+    int i;
+    FOR_NB_SCREENS(i)
+        scales[i].db_scale_valid = false;
 }
 
 /**
@@ -449,8 +441,10 @@
  */
 void peak_meter_set_use_dbfs(bool use)
 {
+    int i;
     pm_use_dbfs = use;
-    db_scale_valid = false;
+    FOR_NB_SCREENS(i)
+        scales[i].db_scale_valid = false;
 }
 
 /**
@@ -713,7 +707,8 @@
             break;
     }
 #endif
-
+    /* check levels next time peakmeter drawn */
+    level_check = true;
 #ifdef PM_DEBUG
     peek_calls++;
 #endif
@@ -816,23 +811,27 @@
     }
     return retval;
 }
-
-
+void peak_meter_screen(struct screen *display, int x, int y, int height)
+{
+    peak_meter_draw(display, &scales[display->screen_type], x, y,
+                        display->width, height);
+}           
 /**
  * Draws a peak meter in the specified size at the specified position.
  * @param int x - The x coordinate. 
- *                Make sure that 0 <= x and x + width < LCD_WIDTH
+ *                Make sure that 0 <= x and x + width < display->width
  * @param int y - The y coordinate. 
- *                Make sure that 0 <= y and y + height < LCD_HEIGHT
+ *                Make sure that 0 <= y and y + height < display->height
  * @param int width - The width of the peak meter. Note that for display
  *                    of clips a 3 pixel wide area is used ->
  *                    width > 3
  * @param int height - The height of the peak meter. height > 3
  */
-void peak_meter_draw(int x, int y, int width, int height) 
+void peak_meter_draw(struct screen *display, struct meter_scales *scales,
+                         int x, int y, int width, int height) 
 {
+    static int left_level = 0, right_level = 0;
     int left = 0, right = 0;
-    static int last_left = 0, last_right = 0;
     int meterwidth = width - 3;
     int i;
 
@@ -844,17 +843,21 @@
     /* if disabled only draw the peak meter */
     if (peak_meter_enabled) {
 
-        /* read the volume info from MAS */
-        left  = peak_meter_read_l(); 
-        right = peak_meter_read_r();
 
-        /* scale the samples dBfs */
-        left  = peak_meter_scale_value(left, meterwidth);
-        right = peak_meter_scale_value(right, meterwidth);
-    
-        /* if the scale has changed -> recalculate the scale 
+        if (level_check){
+            /* only read the volume info from MAS if peek since last read*/      
+            left_level  = peak_meter_read_l(); 
+            right_level = peak_meter_read_r();
+            level_check = false;
+        }
+
+        /* scale the samples dBfs */    
+        left  = peak_meter_scale_value(left_level, meterwidth);
+        right = peak_meter_scale_value(right_level, meterwidth);        
+
+         /*if the scale has changed -> recalculate the scale 
            (The scale becomes invalid when the range changed.) */
-        if (!db_scale_valid){
+        if (!scales->db_scale_valid){
 
             if (pm_use_dbfs) {
                 db_scale_count = DB_SCALE_SRC_VALUES_SIZE;
@@ -862,7 +865,7 @@
                     /* find the real x-coords for predefined interesting
                        dBfs values. These only are recalculated when the
                        scaling of the meter changed. */
-                        db_scale_lcd_coord[i] = 
+                        scales->db_scale_lcd_coord[i] = 
                             peak_meter_scale_value(
                                 db_scale_src_values[i], 
                                 meterwidth - 1);
@@ -873,7 +876,7 @@
             else {
                 db_scale_count = 10;
                 for (i = 0; i < db_scale_count; i++) {
-                    db_scale_lcd_coord[i] = 
+                    scales->db_scale_lcd_coord[i] = 
                         (i * (MAX_PEAK / 10) - peak_meter_range_min) *
                         meterwidth / pm_range;
                 }
@@ -881,20 +884,20 @@
 
             /* mark scale valid to avoid recalculating dBfs values
                of the scale. */
-            db_scale_valid = true;
+            scales->db_scale_valid = true;
         }
 
         /* apply release */
-        left  = MAX(left , last_left  - pm_peak_release);
-        right = MAX(right, last_right - pm_peak_release);
+        left  = MAX(left , scales->last_left  - pm_peak_release);
+        right = MAX(right, scales->last_right - pm_peak_release);
 
         /* reset max values after timeout */
-        if (TIME_AFTER(current_tick, pm_peak_timeout_l)){
-            pm_peak_left = 0;
+        if (TIME_AFTER(current_tick, scales->pm_peak_timeout_l)){
+            scales->pm_peak_left = 0;
         }
 
-        if (TIME_AFTER(current_tick, pm_peak_timeout_r)){
-            pm_peak_right = 0;
+        if (TIME_AFTER(current_tick, scales->pm_peak_timeout_r)){
+            scales->pm_peak_right = 0;
         }
 
         if (!pm_clip_eternal) {
@@ -910,51 +913,51 @@
         }
 
         /* check for new max values */
-        if (left > pm_peak_left) {
-            pm_peak_left = left - 1;
-            pm_peak_timeout_l =
+        if (left > scales->pm_peak_left) {
+            scales->pm_peak_left = left - 1;
+            scales->pm_peak_timeout_l =
                 current_tick + peak_time_out[pm_peak_hold];
         }
 
-        if (right > pm_peak_right) {
-            pm_peak_right = right - 1;
-            pm_peak_timeout_r = 
+        if (right > scales->pm_peak_right) {
+            scales->pm_peak_right = right - 1;
+            scales->pm_peak_timeout_r = 
                 current_tick + peak_time_out[pm_peak_hold];
         }
     }
 
     /* draw the peak meter */
-    lcd_set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID);
-    lcd_fillrect(x, y, width, height);
-    lcd_set_drawmode(DRMODE_SOLID);
+    display->set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID);
+    display->fillrect(x, y, width, height);
+    display->set_drawmode(DRMODE_SOLID);
 
     /* draw left */
-    lcd_fillrect (x, y, left, height / 2 - 2 );
-    if (pm_peak_left > 0) {
-        lcd_vline(x + pm_peak_left, y, y + height / 2 - 2 );
+    display->fillrect (x, y, left, height / 2 - 2 );
+    if (scales->pm_peak_left > 0) {
+        display->vline(x + scales->pm_peak_left, y, y + height / 2 - 2 );
     }
     if (pm_clip_left) {
-        lcd_fillrect(x + meterwidth, y, 3, height / 2 - 1);
+        display->fillrect(x + meterwidth, y, 3, height / 2 - 1);
     }
 
     /* draw right */
-    lcd_fillrect(x, y + height / 2 + 1, right, height / 2 - 2);
-    if (pm_peak_right > 0) {
-        lcd_vline( x + pm_peak_right, y + height / 2, y + height - 2);
+    display->fillrect(x, y + height / 2 + 1, right, height / 2 - 2);
+    if (scales->pm_peak_right > 0) {
+        display->vline( x + scales->pm_peak_right, y + height / 2, y + height - 2);
     }
     if (pm_clip_right) {
-        lcd_fillrect(x + meterwidth, y + height / 2, 3, height / 2 - 1);
+        display->fillrect(x + meterwidth, y + height / 2, 3, height / 2 - 1);
     }
 
     /* draw scale end */
-    lcd_vline(x + meterwidth, y, y + height - 2);
+    display->vline(x + meterwidth, y, y + height - 2);
 
-    lcd_set_drawmode(DRMODE_COMPLEMENT);
+    display->set_drawmode(DRMODE_COMPLEMENT);
     /* draw dots for scale marks */
     for (i = 0; i < db_scale_count; i++) {
         /* The x-coordinates of interesting scale mark points 
            have been calculated before */
-        lcd_drawpixel(db_scale_lcd_coord[i], y + height / 2 - 1);
+        display->drawpixel(scales->db_scale_lcd_coord[i], y + height / 2 - 1);
     }
     
 #ifdef HAVE_RECORDING
@@ -988,25 +991,25 @@
     if (trig_status != TRIG_OFF) {
         int start_trigx, stop_trigx, ycenter;
 
-        lcd_set_drawmode(DRMODE_SOLID);
+        display->set_drawmode(DRMODE_SOLID);
         ycenter = y + height / 2;
         /* display threshold value */
         start_trigx = x+peak_meter_scale_value(trig_strt_threshold,meterwidth);
-        lcd_vline(start_trigx, ycenter - 2, ycenter);
+        display->vline(start_trigx, ycenter - 2, ycenter);
         start_trigx ++;
-        if (start_trigx < LCD_WIDTH) lcd_drawpixel(start_trigx, ycenter - 1);
+        if (start_trigx < display->width ) display->drawpixel(start_trigx, ycenter - 1);
 
         stop_trigx = x + peak_meter_scale_value(trig_stp_threshold,meterwidth);
-        lcd_vline(stop_trigx, ycenter - 2, ycenter);
-        if (stop_trigx > 0) lcd_drawpixel(stop_trigx - 1, ycenter - 1);
+        display->vline(stop_trigx, ycenter - 2, ycenter);
+        if (stop_trigx > 0) display->drawpixel(stop_trigx - 1, ycenter - 1);
     }
 #endif /*HAVE_RECORDING*/
 
 #ifdef PM_DEBUG
     /* display a bar to show how many calls to peak_meter_peek 
        have ocurred since the last display */
-    lcd_set_drawmode(DRMODE_COMPLEMENT);
-    lcd_fillrect(x, y, tmp, 3);
+    display->set_drawmode(DRMODE_COMPLEMENT);
+    display->fillrect(x, y, tmp, 3);
 
     if (tmp < PEEKS_PER_DRAW_SIZE) {
         peeks_per_redraw[tmp]++;
@@ -1019,14 +1022,14 @@
 
     /* display a bar to show how many ticks have passed since 
        the last redraw */
-    lcd_fillrect(x, y + height / 2, current_tick - pm_tick, 2);
+    display->fillrect(x, y + height / 2, current_tick - pm_tick, 2);
     pm_tick = current_tick;
 #endif
 
-    last_left = left;
-    last_right = right;
+    scales->last_left = left;
+    scales->last_right = right;
 
-    lcd_set_drawmode(DRMODE_SOLID);
+    display->set_drawmode(DRMODE_SOLID);
 }
 
 #ifdef HAVE_RECORDING
@@ -1171,11 +1174,12 @@
 }
 #endif
 
-int peak_meter_draw_get_btn(int x, int y, int width, int height)
+int peak_meter_draw_get_btn(int x, int y, int height)
 {
     int button = BUTTON_NONE;
     long next_refresh = current_tick;
     long next_big_refresh = current_tick + HZ / 10;
+    int i;
 #ifndef SIMULATOR
     bool highperf = !ata_disk_is_active();
 #else
@@ -1196,8 +1200,11 @@
             sleep(0);          /* Sleep until end of current tick. */
         }
         if (TIME_AFTER(current_tick, next_refresh)) {
-            peak_meter_draw(x, y, width, height);
-            lcd_update_rect(x, y, width, height);
+            FOR_NB_SCREENS(i)
+            {
+                peak_meter_screen(&screens[i], x, y, height);
+                screens[i].update_rect(x, y, screens[i].width, height);
+            }
             next_refresh += HZ / PEAK_METER_FPS;
             dopeek = true;
         }
diff --git a/apps/recorder/peakmeter.h b/apps/recorder/peakmeter.h
index 5513dfa..759b454 100644
--- a/apps/recorder/peakmeter.h
+++ b/apps/recorder/peakmeter.h
@@ -29,8 +29,7 @@
 extern bool peak_meter_enabled;
 
 extern void peak_meter_playback(bool playback);
-extern void peak_meter_draw(int x, int y, int width, int height);
-extern int  peak_meter_draw_get_btn(int x, int y, int width, int height);
+extern int  peak_meter_draw_get_btn(int x, int y, int height);
 extern void peak_meter_set_clip_hold(int time);
 extern void peak_meter_peek(void);
 extern void peak_meter_init_range( bool dbfs, int range_min, int range_max);
@@ -80,4 +79,24 @@
 extern unsigned short peak_meter_range_min;
 extern unsigned short peak_meter_range_max;
 
+#define DB_SCALE_SRC_VALUES_SIZE 12
+struct meter_scales{
+    /* buffered peak values */
+    int pm_peak_left;
+    int pm_peak_right;
+    /* if db_scale_valid is false the content of
+       db_scale_lcd_coord needs recalculation */
+    bool db_scale_valid;
+    /* contains the lcd x coordinates of the magical
+       scale values in db_scale_src_values */
+    int db_scale_lcd_coord[DB_SCALE_SRC_VALUES_SIZE];
+    int last_left;
+    int last_right;
+    /* peak hold timeouts */
+    long pm_peak_timeout_l;
+    long pm_peak_timeout_r;
+};
+extern void peak_meter_draw(struct screen *display, struct meter_scales *meter_scales,
+                                int x, int y, int width, int height);
+extern void peak_meter_screen(struct screen *display, int x, int y, int height);
 #endif /* __PEAKMETER_H__ */
diff --git a/apps/recorder/radio.c b/apps/recorder/radio.c
index 5258b5b..7cdfd51 100644
--- a/apps/recorder/radio.c
+++ b/apps/recorder/radio.c
@@ -768,11 +768,17 @@
             /* Only display the peak meter when not recording */
             if(!audio_status())
             {
-                /* just main screen for the time being */
+
 #if CONFIG_CODEC != SWCODEC
-                peak_meter_draw(0, STATUSBAR_HEIGHT + fh*(top_of_screen + 4), LCD_WIDTH, fh);
+                FOR_NB_SCREENS(i)
+                {
+                    peak_meter_screen(&screens[i],0,
+                                          STATUSBAR_HEIGHT + fh*(top_of_screen + 4), fh);
+                    screens[i].update_rect(0, STATUSBAR_HEIGHT + fh*(top_of_screen + 4),
+                                               screens[i].width, fh);
+                }
 #endif
-                screens[SCREEN_MAIN].update_rect(0, STATUSBAR_HEIGHT + fh*(top_of_screen + 4), screens[SCREEN_MAIN].width, fh);
+
             }
 
             if(TIME_AFTER(current_tick, timeout))
diff --git a/apps/recorder/recording.c b/apps/recorder/recording.c
index 92275a5..84fef9f 100644
--- a/apps/recorder/recording.c
+++ b/apps/recorder/recording.c
@@ -43,6 +43,7 @@
 #include "lang.h"
 #include "font.h"
 #include "icons.h"
+#include "icon.h"
 #include "screens.h"
 #include "peakmeter.h"
 #include "statusbar.h"
@@ -60,6 +61,7 @@
 #include "sound.h"
 #include "ata.h"
 #include "splash.h"
+#include "screen_access.h"
 #ifdef HAVE_RECORDING
 
 
@@ -104,6 +106,17 @@
 #define REC_DEC BUTTON_LEFT
 #endif
 
+#if (CONFIG_REMOTE_KEYPAD == H100_REMOTE) || (CONFIG_KEYPAD == IRIVER_H300_PAD)
+#define REC_RC_SHUTDOWN (BUTTON_RC_STOP | BUTTON_REPEAT)
+#define REC_RC_STOPEXIT BUTTON_RC_STOP
+#define REC_RC_RECPAUSE BUTTON_RC_ON
+#define REC_RC_INC BUTTON_RC_BITRATE
+#define REC_RC_DEC BUTTON_RC_SOURCE
+#define REC_RC_NEXT BUTTON_RC_FF
+#define REC_RC_PREV BUTTON_RC_REW
+#define REC_RC_SETTINGS BUTTON_RC_MODE
+#endif
+
 bool f2_rec_screen(void);
 bool f3_rec_screen(void);
 
@@ -508,6 +521,7 @@
     bool led_state = false;
     int led_countdown = 2;
 #endif
+    int i;
 
 #ifdef HAVE_UDA1380
 /*calculate no. of digital steps to each analogue step. Assuming 
@@ -565,10 +579,13 @@
 
     settings_apply_trigger();
 
-    lcd_setfont(FONT_SYSFIXED);
-    lcd_getstringsize("M", &w, &h);
-    lcd_setmargins(global_settings.invert_cursor ? 0 : w, 8);
-
+    FOR_NB_SCREENS(i)
+    {
+        screens[i].setfont(FONT_SYSFIXED);
+        screens[i].getstringsize("M", &w, &h);
+        screens[i].setmargins(global_settings.invert_cursor ? 0 : w, 8);
+    }
+    
     if(rec_create_directory() > 0)
         have_recorded = true;
 
@@ -628,7 +645,7 @@
 #endif /* CONFIG_LED */
 
         /* Wait for a button a while (HZ/10) drawing the peak meter */
-        button = peak_meter_draw_get_btn(0, 8 + h*2, LCD_WIDTH, h);
+        button = peak_meter_draw_get_btn(0, 8 + h*2, h*2);
 
         if (last_audio_stat != audio_stat)
         {
@@ -643,6 +660,12 @@
         {
             case REC_STOPEXIT:
             case REC_SHUTDOWN:
+#ifdef REC_RC_STOPEXIT
+            case REC_RC_STOPEXIT:
+#endif
+#ifdef REC_RC_SHUTDOWN
+            case REC_RC_SHUTDOWN:
+#endif          
                 /* turn off the trigger */
                 peak_meter_trigger(false);
                 peak_meter_set_trigger_listener(NULL);
@@ -663,6 +686,9 @@
                 break;
 
             case REC_RECPAUSE:
+#ifdef REC_RC_RECPAUSE
+            case REC_RC_RECPAUSE:
+#endif
 #ifdef REC_RECPAUSE_PRE
                 if (lastbutton != REC_RECPAUSE_PRE)
                     break;
@@ -715,6 +741,9 @@
 
 #ifdef REC_PREV
             case REC_PREV:
+#ifdef REC_RC_PREV
+            case REC_RC_PREV:
+#endif
                 cursor--;
                 adjust_cursor();
                 update_countdown = 1; /* Update immediately */
@@ -723,6 +752,9 @@
 
 #ifdef REC_NEXT
             case REC_NEXT:
+#ifdef REC_RC_NEXT
+            case REC_RC_NEXT:
+#endif
                 cursor++;
                 adjust_cursor();
                 update_countdown = 1; /* Update immediately */
@@ -731,6 +763,10 @@
        
             case REC_INC:
             case REC_INC | BUTTON_REPEAT:
+#ifdef REC_RC_INC
+            case REC_RC_INC:
+            case REC_RC_INC | BUTTON_REPEAT:
+#endif
                 switch(cursor)
                 {
                     case 0:
@@ -788,6 +824,10 @@
                 
             case REC_DEC:
             case REC_DEC | BUTTON_REPEAT:
+#ifdef REC_RC_INC
+            case REC_RC_DEC:
+            case REC_RC_DEC | BUTTON_REPEAT:
+#endif
                 switch(cursor)
                 {
                     case 0:
@@ -848,6 +888,9 @@
                 
 #ifdef REC_SETTINGS
             case REC_SETTINGS:
+#ifdef REC_RC_SETTINGS
+            case REC_RC_SETTINGS:
+#endif
                 if(audio_stat != AUDIO_STATUS_RECORD)
                 {
 #if CONFIG_LED == LED_REAL
@@ -874,8 +917,11 @@
                     set_gain();
                     update_countdown = 1; /* Update immediately */
 
-                    lcd_setfont(FONT_SYSFIXED);
-                    lcd_setmargins(global_settings.invert_cursor ? 0 : w, 8);
+                    FOR_NB_SCREENS(i)
+                    {
+                        screens[i].setfont(FONT_SYSFIXED);
+                        screens[i].setmargins(global_settings.invert_cursor ? 0 : w, 8);
+                    }
                 }
                 break;
 #endif
@@ -943,7 +989,8 @@
         if (button != BUTTON_NONE)
             lastbutton = button;
 
-        lcd_setfont(FONT_SYSFIXED);
+            FOR_NB_SCREENS(i)       
+                screens[i].setfont(FONT_SYSFIXED);
 
         seconds = audio_recorded_time() / HZ;
         
@@ -957,14 +1004,16 @@
             update_countdown = 5;
             last_seconds = seconds;
 
-            lcd_clear_display();
+            FOR_NB_SCREENS(i)
+                screens[i].clear_display(); 
 
             hours = seconds / 3600;
             minutes = (seconds - (hours * 3600)) / 60;
             snprintf(buf, 32, "%s %02d:%02d:%02d",
                      str(LANG_RECORDING_TIME),
                      hours, minutes, seconds%60);
-            lcd_puts(0, 0, buf);
+            FOR_NB_SCREENS(i)
+                screens[i].puts(0, 0, buf); 
 
             dseconds = rec_timesplit_seconds();
             num_recorded_bytes = audio_num_recorded_bytes();
@@ -997,7 +1046,8 @@
                              str(LANG_RECORDING_SIZE), buf2);
                 }
             }
-            lcd_puts(0, 1, buf);
+            FOR_NB_SCREENS(i)
+                screens[i].puts(0, 1, buf);
 
             /* We will do file splitting regardless, either at the end of
                a split interval, or when the filesize approaches the 2GB
@@ -1017,10 +1067,15 @@
                               buf2, sizeof(buf2)));
             
             if (global_settings.invert_cursor && (pos++ == cursor))
-                lcd_puts_style(0, 3, buf, STYLE_INVERT);
+            {
+                FOR_NB_SCREENS(i)
+                    screens[i].puts_style_offset(0, 4, buf, STYLE_INVERT,0);
+            }
             else
-                lcd_puts(0, 3, buf);
-                
+            {
+                FOR_NB_SCREENS(i)
+                    screens[i].puts(0, 4, buf);
+            }                
 
             if(global_settings.rec_source == SOURCE_MIC)
             { 
@@ -1059,9 +1114,15 @@
                                   buf2, sizeof(buf2)));
 #endif
                 if(global_settings.invert_cursor && ((1==cursor)||(2==cursor)))
-                    lcd_puts_style(0, 4, buf, STYLE_INVERT);
+                {
+                    FOR_NB_SCREENS(i)
+                        screens[i].puts_style_offset(0, 5, buf, STYLE_INVERT,0);
+                }
                 else
-                    lcd_puts(0, 4, buf);
+                {
+                    FOR_NB_SCREENS(i)
+                        screens[i].puts(0, 5, buf);
+                }
             }
             else if(global_settings.rec_source == SOURCE_LINE)
             {
@@ -1104,9 +1165,16 @@
                                   buf2, sizeof(buf2)));
 #endif /* HAVE_UDA1380 */
                 if(global_settings.invert_cursor && ((1==cursor)||(2==cursor)))
-                    lcd_puts_style(0, 4, buf, STYLE_INVERT);
+                {
+                    FOR_NB_SCREENS(i)
+                        screens[i].puts_style_offset(0, 5, buf, STYLE_INVERT,0);
+                }
                 else
-                    lcd_puts(0, 4, buf);
+                {
+                     FOR_NB_SCREENS(i)
+                         screens[i].puts(0, 5, buf);
+                }                
+
 #ifdef HAVE_UDA1380
                 snprintf(buf, 32, "%s:%s (%s)",
                          str(LANG_RECORDING_RIGHT),
@@ -1134,39 +1202,59 @@
                                   buf2, sizeof(buf2)));
 #endif /* HAVE_UDA1380 */
                 if(global_settings.invert_cursor && ((1==cursor)||(3==cursor)))
-                    lcd_puts_style(0, 5, buf, STYLE_INVERT);
+                {
+                    FOR_NB_SCREENS(i)
+                        screens[i].puts_style_offset(0, 6, buf, STYLE_INVERT,0);
+                }
                 else
-                    lcd_puts(0, 5, buf);
-            }
-            switch(cursor)
-            {
-            case 1:
-                put_cursorxy(0, 4, true);
-                
-                if(global_settings.rec_source != SOURCE_MIC)
-                    put_cursorxy(0, 5, true);
-                
-                break;
-            case 2:
-                put_cursorxy(0, 4, true);
-                break;
-            case 3:
-                put_cursorxy(0, 5, true);
-                break;
-            default:
-                put_cursorxy(0, 0, true);
+                {
+                    FOR_NB_SCREENS(i)
+                        screens[i].puts(0, 6, buf);
+                }                
             }
 
+            if(!global_settings.invert_cursor){
+                switch(cursor)
+                {
+                    case 1:
+                        FOR_NB_SCREENS(i)
+                            screen_put_cursorxy(&screens[i], 0, 5, true);
+
+                        if(global_settings.rec_source != SOURCE_MIC)
+                        {
+                            FOR_NB_SCREENS(i)
+                                screen_put_cursorxy(&screens[i], 0, 6, true);
+                        }               
+                    break;
+                    case 2:
+                        FOR_NB_SCREENS(i)
+                            screen_put_cursorxy(&screens[i], 0, 5, true);
+                    break;
+                    case 3:
+                        FOR_NB_SCREENS(i)
+                            screen_put_cursorxy(&screens[i], 0, 6, true);
+                    break;
+                    default:
+                        FOR_NB_SCREENS(i)
+                            screen_put_cursorxy(&screens[i], 0, 4, true);
+                }
+            }
+            
             snprintf(buf, 32, "%s %s",
                      freq_str[global_settings.rec_frequency],
                      global_settings.rec_channels?
                      str(LANG_CHANNEL_MONO):str(LANG_CHANNEL_STEREO));
-            lcd_puts(0, 7, buf);
+
+            /* Main screen only for this info */
+            lcd_puts(0, 8, buf);
 
             gui_syncstatusbar_draw(&statusbars, true);
-            peak_meter_draw(0, 8 + h*2, LCD_WIDTH, h);
 
-            lcd_update();
+            FOR_NB_SCREENS(i)
+            {
+                peak_meter_screen(&screens[i], 0, 8 + h*2, h*2);
+                screens[i].update();                
+            }
 
             /* draw the trigger status */
             if (peak_meter_trigger_status() != TRIG_OFF)
@@ -1227,9 +1315,6 @@
     ata_set_led_enabled(true);
 #endif
     return been_in_usb_mode;
-/*
-#endif
-*/
 }
 
 #ifdef REC_F2
diff --git a/apps/sound_menu.c b/apps/sound_menu.c
index 1c61c66..5944c46 100644
--- a/apps/sound_menu.c
+++ b/apps/sound_menu.c
@@ -666,7 +666,7 @@
 
         peak_meter_draw_trig(0, LCD_HEIGHT - 8 - TRIG_HEIGHT);
 
-        button = peak_meter_draw_get_btn(0, LCD_HEIGHT - 8, LCD_WIDTH, 8);
+        button = peak_meter_draw_get_btn(0, LCD_HEIGHT - 8, 8);
 
         lcd_update();