? .deps
? ajbrec.ajz
? apps.diff
? demo_menu.c.diff
? diff game_menu tetris.txt
? settings.diff
? status.diff
? recorder/Debug
? recorder/oscillosgraph.c
? recorder/oscillosgraph.h
? recorder/peakmeter.c_
? recorder/peakmeter.h_
? recorder/wormlet.c_
? recorder/wormlet.diff
? recorder/wormlet.h_
Index: settings.c
===================================================================
RCS file: /cvsroot/rockbox/apps/settings.c,v
retrieving revision 1.56
diff -u -b -r1.56 settings.c
--- settings.c	17 Sep 2002 12:48:56 -0000	1.56
+++ settings.c	17 Sep 2002 17:16:29 -0000
@@ -391,6 +391,8 @@
         if (config_block[0x24] != 0xFF)
             memcpy(&global_settings.total_uptime, &config_block[0x24], 4);
 
+        global_settings.peak_meter_release = 200;
+
         strncpy(global_settings.resume_file, &config_block[0xFC], MAX_PATH);
         global_settings.resume_file[MAX_PATH]=0;
     }
@@ -595,6 +597,7 @@
     global_settings.resume_offset = -1;
     global_settings.disk_spindown = 5;
     global_settings.browse_current = false;
+    global_settings.peak_meter_release = 200;
 }
 
 
Index: settings.h
===================================================================
RCS file: /cvsroot/rockbox/apps/settings.h,v
retrieving revision 1.41
diff -u -b -r1.41 settings.h
--- settings.h	10 Sep 2002 05:31:12 -0000	1.41
+++ settings.h	17 Sep 2002 17:16:29 -0000
@@ -84,6 +84,7 @@
     int ff_rewind_min_step; /* FF/Rewind minimum step size */
     int ff_rewind_accel; /* FF/Rewind acceleration (in seconds per doubling) */
     int disk_spindown; /* time until disk spindown, in seconds (0=off) */
+    int peak_meter_release; /* release time for peak meter: 20 - */
 
     /* show status bar */
     bool statusbar;    /* 0=hide, 1=show */
Index: settings_menu.c
===================================================================
RCS file: /cvsroot/rockbox/apps/settings_menu.c,v
retrieving revision 1.54
diff -u -b -r1.54 settings_menu.c
--- settings_menu.c	12 Sep 2002 06:45:47 -0000	1.54
+++ settings_menu.c	17 Sep 2002 17:16:31 -0000
@@ -51,6 +51,15 @@
     return MENU_OK;
 }
 
+#ifdef HAVE_LCD_BITMAP
+static Menu peak_meter_menu(void) 
+{
+    set_int( "Release time", "x 10 ms", &global_settings.peak_meter_release,
+             NULL, 1, 20, 10000);
+    return MENU_OK;
+}
+#endif
+
 #ifndef HAVE_RECORDER_KEYPAD
 static Menu shuffle(void)
 {
@@ -289,6 +298,9 @@
         { "Scroll Speed",    scroll_speed    },  
         { "Backlight",       backlight_timer },
         { "Contrast",        contrast        },  
+#ifdef HAVE_LCD_BITMAP
+        { "Peak meter",      peak_meter_menu },  
+#endif
     };
     
     m=menu_init( items, sizeof items / sizeof(struct menu_items) );
Index: wps-display.c
===================================================================
RCS file: /cvsroot/rockbox/apps/wps-display.c,v
retrieving revision 1.19
diff -u -b -r1.19 wps-display.c
--- wps-display.c	12 Sep 2002 13:33:58 -0000	1.19
+++ wps-display.c	17 Sep 2002 17:16:38 -0000
@@ -37,6 +37,7 @@
 #include "status.h"
 #include "wps-display.h"
 #include "debug.h"
+#include "mas.h"
 
 #ifdef HAVE_LCD_BITMAP
 #include "icons.h"
@@ -52,12 +53,12 @@
 #endif
 
 #define FORMAT_BUFFER_SIZE 300
-
 struct format_flags
 {
     bool dynamic;
     bool scroll;
     bool player_progress;
+    bool peak_meter;
 };
 
 static char format_buffer[FORMAT_BUFFER_SIZE];
@@ -66,6 +67,13 @@
 static int ff_rewind_count;
 bool wps_time_countup = true;
 
+#ifdef HAVE_LCD_BITMAP
+static int peak_meter_max_l;
+static int peak_meter_max_r;
+static long peak_meter_timeout_l;
+static long peak_meter_timeout_r;
+#endif
+
 /* Set format string to use for WPS, splitting it into lines */
 static void wps_format(char* fmt)
 {
@@ -331,6 +339,13 @@
                 case 't':  /* Total Time */
                     format_time(buf, buf_size, id3->length);
                     return buf;
+
+#ifdef HAVE_LCD_BITMAP
+                case 'm': /* Peak Meter */
+                    flags->peak_meter = true;
+                    flags->dynamic = true;
+                    return "\x01";
+#endif
             }
             break;
     
@@ -511,6 +526,50 @@
     *buf = 0;
 }
 
+#ifdef HAVE_LCD_BITMAP
+static void wps_peak_meter(int line) {
+    int w,h;
+    int offset = global_settings.statusbar ? STATUSBAR_HEIGHT : 0;
+    lcd_getstringsize("M",FONT_UI,&w,&h);
+
+    int peak_meter_y = line * h + offset + 1;
+    int peak_meter_h = h;
+    int left, right;
+
+    /* read the volume info from MAS */
+    left = mas_codec_readreg(0xC) / (MAX_PEAK / LCD_WIDTH);
+    right = mas_codec_readreg(0xD) / (MAX_PEAK / LCD_WIDTH);
+
+    /* reset max values after timeout */
+    if (TIME_AFTER(current_tick, peak_meter_timeout_l)){
+        peak_meter_max_l = 0;
+    }
+
+    if (TIME_AFTER(current_tick, peak_meter_timeout_r)){
+        peak_meter_max_r = 0;
+    }
+
+    /* check for new max values */
+    if (left > peak_meter_max_l) {
+        peak_meter_max_l = left;
+        peak_meter_timeout_l = current_tick + global_settings.peak_meter_release;
+    }
+
+    if (right > peak_meter_max_r) {
+        peak_meter_max_r = right;
+        peak_meter_timeout_r = current_tick + global_settings.peak_meter_release;
+    }
+
+    /* draw the peak meter */
+    lcd_clearrect(0, peak_meter_y, LCD_WIDTH, peak_meter_h);
+    lcd_fillrect(0, peak_meter_y, left, peak_meter_h / 2 -1 );
+    lcd_fillrect(peak_meter_max_l, peak_meter_y, 1, peak_meter_h / 2 -1 );
+
+    lcd_fillrect(0, peak_meter_y + peak_meter_h / 2, right, peak_meter_h / 2- 1);
+    lcd_fillrect(peak_meter_max_r, peak_meter_y + peak_meter_h / 2, 1, peak_meter_h / 2- 1);
+}
+#endif
+
 bool wps_refresh(struct mp3entry* id3, int ffwd_offset, bool refresh_all)
 {
     char buf[MAX_PATH];
@@ -537,6 +596,7 @@
             flags.dynamic = false;
             flags.scroll = false;
             flags.player_progress = false;
+            flags.peak_meter = false;
             format_display(buf, sizeof(buf), id3, format_lines[i], &flags);
             dynamic_lines[i] = flags.dynamic;
             
@@ -555,6 +615,13 @@
                 continue;
 #endif
             }
+
+#ifdef HAVE_LCD_BITMAP
+            if (flags.peak_meter) {
+                wps_peak_meter(i);
+                continue;
+            }
+#endif
 
             if (!scroll_active && flags.scroll && !flags.dynamic)
             {
Index: wps.c
===================================================================
RCS file: /cvsroot/rockbox/apps/wps.c,v
retrieving revision 1.146
diff -u -b -r1.146 wps.c
--- wps.c	13 Sep 2002 15:54:23 -0000	1.146
+++ wps.c	17 Sep 2002 17:16:44 -0000
@@ -878,7 +878,7 @@
 /* demonstrates showing different formats from playtune */
 int wps_show(void)
 {
-    int button, lastbutton = 0;
+    int button = 0, lastbutton = 0;
     int old_repeat_mask;
     bool ignore_keyup = true;
     bool restore = false;
@@ -912,7 +912,22 @@
 
     while ( 1 )
     {
+
+        /* Only a device with lcd bitmap has 
+           a peak meter yet that needs extra updates.
+           Thus a few extra updates are introduced here */
+#ifdef HAVE_LCD_BITMAP
+        int i;
+        for (i = 0; i < HZ / 20; i++) {
+            button = button_get_w_tmo(1);
+            if (button != 0) {
+                break;
+            }
+            wps_refresh(id3, 0, false);
+        }
+#else
         button = button_get_w_tmo(HZ/5);
+#endif
 
         /* discard first event if it's a button release */
         if (button && ignore_keyup)

