summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/recorder/peakmeter.c50
-rw-r--r--apps/recorder/peakmeter.h2
-rw-r--r--apps/wps-display.c30
-rw-r--r--apps/wps.c2
-rw-r--r--firmware/drivers/lcd-recorder.c9
5 files changed, 46 insertions, 47 deletions
diff --git a/apps/recorder/peakmeter.c b/apps/recorder/peakmeter.c
index e1850a4bb0..2e787ba982 100644
--- a/apps/recorder/peakmeter.c
+++ b/apps/recorder/peakmeter.c
@@ -51,11 +51,15 @@ static int peak_meter_clip_hold;
51/* specifies the value range in peak volume values */ 51/* specifies the value range in peak volume values */
52unsigned short peak_meter_range_min; 52unsigned short peak_meter_range_min;
53unsigned short peak_meter_range_max; 53unsigned short peak_meter_range_max;
54unsigned short peak_meter_range;
54 55
55/* if set to true clip timeout is disabled */ 56/* if set to true clip timeout is disabled */
56static bool peak_meter_clip_eternal = false; 57static bool peak_meter_clip_eternal = false;
57 58
58static bool peak_meter_use_dbfs = true; 59static bool peak_meter_use_dbfs = true;
60static unsigned short db_min = 0;
61static unsigned short db_max = 9000;
62static unsigned short db_range = 9000;
59 63
60 64
61#ifndef SIMULATOR 65#ifndef SIMULATOR
@@ -110,8 +114,9 @@ static long clip_time_out[] = {
110 114
111/* precalculated peak values that represent magical 115/* precalculated peak values that represent magical
112 dBfs values. Used to draw the scale */ 116 dBfs values. Used to draw the scale */
117#define DB_SCALE_SRC_VALUES_SIZE 11
113#if 0 118#if 0
114static int db_scale_src_values[] = { 119const static int db_scale_src_values[DB_SCALE_SRC_VALUES_SIZE] = {
115 32767, /* 0 db */ 120 32767, /* 0 db */
116 23197, /* - 3 db */ 121 23197, /* - 3 db */
117 16422, /* - 6 db */ 122 16422, /* - 6 db */
@@ -125,7 +130,7 @@ static int db_scale_src_values[] = {
125 33, /* -60 db */ 130 33, /* -60 db */
126}; 131};
127#else 132#else
128static int db_scale_src_values[] = { 133static const int db_scale_src_values[DB_SCALE_SRC_VALUES_SIZE] = {
129 32752, /* 0 db */ 134 32752, /* 0 db */
130 22784, /* - 3 db */ 135 22784, /* - 3 db */
131 14256, /* - 6 db */ 136 14256, /* - 6 db */
@@ -140,7 +145,7 @@ static int db_scale_src_values[] = {
140}; 145};
141#endif 146#endif
142 147
143int db_scale_count = sizeof db_scale_src_values / sizeof (int); 148static int db_scale_count = DB_SCALE_SRC_VALUES_SIZE;
144 149
145/* if db_scale_valid is false the content of 150/* if db_scale_valid is false the content of
146 db_scale_lcd_coord needs recalculation */ 151 db_scale_lcd_coord needs recalculation */
@@ -343,6 +348,11 @@ void peak_meter_set_min(int newmin) {
343 peak_meter_range_min = newmin * MAX_PEAK / 100; 348 peak_meter_range_min = newmin * MAX_PEAK / 100;
344 } 349 }
345 } 350 }
351
352 peak_meter_range = peak_meter_range_max - peak_meter_range_min;
353
354 db_min = calc_db(peak_meter_range_min);
355 db_range = db_max - db_min;
346 db_scale_valid = false; 356 db_scale_valid = false;
347} 357}
348 358
@@ -378,6 +388,11 @@ void peak_meter_set_max(int newmax) {
378 peak_meter_range_max = newmax * MAX_PEAK / 100; 388 peak_meter_range_max = newmax * MAX_PEAK / 100;
379 } 389 }
380 } 390 }
391
392 peak_meter_range = peak_meter_range_max - peak_meter_range_min;
393
394 db_max = calc_db(peak_meter_range_max);
395 db_range = db_max - db_min;
381 db_scale_valid = false; 396 db_scale_valid = false;
382} 397}
383 398
@@ -482,7 +497,7 @@ void peak_meter_playback(bool playback) {
482 * that ocurred. This function could be used by a thread for 497 * that ocurred. This function could be used by a thread for
483 * busy reading the MAS. 498 * busy reading the MAS.
484 */ 499 */
485void peak_meter_peek(void) { 500inline void peak_meter_peek(void) {
486#ifdef SIMULATOR 501#ifdef SIMULATOR
487 int left = 8000; 502 int left = 8000;
488 int right = 9000; 503 int right = 9000;
@@ -632,7 +647,6 @@ void peak_meter_set_clip_hold(int time) {
632 * @return unsigned short - A value 0 <= return value <= meterwidth 647 * @return unsigned short - A value 0 <= return value <= meterwidth
633 */ 648 */
634unsigned short peak_meter_scale_value(unsigned short val, int meterwidth){ 649unsigned short peak_meter_scale_value(unsigned short val, int meterwidth){
635 int range;
636 int retval; 650 int retval;
637 651
638 if (val <= peak_meter_range_min) { 652 if (val <= peak_meter_range_min) {
@@ -648,22 +662,16 @@ unsigned short peak_meter_scale_value(unsigned short val, int meterwidth){
648 /* different scaling is used for dBfs and linear percent */ 662 /* different scaling is used for dBfs and linear percent */
649 if (peak_meter_use_dbfs) { 663 if (peak_meter_use_dbfs) {
650 664
651 /* needed the offset in 'zoomed' meters */
652 int dbmin = calc_db(peak_meter_range_min);
653
654 range = calc_db(peak_meter_range_max) - dbmin;
655
656 /* scale the samples dBfs */ 665 /* scale the samples dBfs */
657 retval = (calc_db(retval) - dbmin) * meterwidth / range; 666 retval = (calc_db(retval) - db_min) * meterwidth / db_range;
658 } 667 }
659 668
660 /* Scale for linear percent display */ 669 /* Scale for linear percent display */
661 else 670 else
662 { 671 {
663 range =(peak_meter_range_max - peak_meter_range_min);
664
665 /* scale the samples */ 672 /* scale the samples */
666 retval = ((retval - peak_meter_range_min) * meterwidth) / range; 673 retval = ((retval - peak_meter_range_min) * meterwidth)
674 / peak_meter_range;
667 } 675 }
668 return retval; 676 return retval;
669} 677}
@@ -697,14 +705,7 @@ void peak_meter_draw(int x, int y, int width, int height) {
697 /* read the volume info from MAS */ 705 /* read the volume info from MAS */
698 left = peak_meter_read_l(); 706 left = peak_meter_read_l();
699 right = peak_meter_read_r(); 707 right = peak_meter_read_r();
700 peak_meter_peek(); 708 /*peak_meter_peek();*/
701
702 /* restrict the range to avoid drawing outside the lcd */
703 left = MAX(peak_meter_range_min, left);
704 left = MIN(peak_meter_range_max, left);
705
706 right = MAX(peak_meter_range_min, right);
707 right = MIN(peak_meter_range_max, right);
708 709
709 /* scale the samples dBfs */ 710 /* scale the samples dBfs */
710 left = peak_meter_scale_value(left, meterwidth); 711 left = peak_meter_scale_value(left, meterwidth);
@@ -715,7 +716,7 @@ void peak_meter_draw(int x, int y, int width, int height) {
715 if (!db_scale_valid){ 716 if (!db_scale_valid){
716 717
717 if (peak_meter_use_dbfs) { 718 if (peak_meter_use_dbfs) {
718 db_scale_count = sizeof db_scale_src_values / sizeof (int); 719 db_scale_count = DB_SCALE_SRC_VALUES_SIZE;
719 for (i = 0; i < db_scale_count; i++){ 720 for (i = 0; i < db_scale_count; i++){
720 /* find the real x-coords for predefined interesting 721 /* find the real x-coords for predefined interesting
721 dBfs values. These only are recalculated when the 722 dBfs values. These only are recalculated when the
@@ -729,12 +730,11 @@ void peak_meter_draw(int x, int y, int width, int height) {
729 730
730 /* when scaling linear we simly make 10% steps */ 731 /* when scaling linear we simly make 10% steps */
731 else { 732 else {
732 int range = peak_meter_range_max - peak_meter_range_min;
733 db_scale_count = 10; 733 db_scale_count = 10;
734 for (i = 0; i < db_scale_count; i++) { 734 for (i = 0; i < db_scale_count; i++) {
735 db_scale_lcd_coord[i] = 735 db_scale_lcd_coord[i] =
736 (i * (MAX_PEAK / 10) - peak_meter_range_min) * 736 (i * (MAX_PEAK / 10) - peak_meter_range_min) *
737 meterwidth / range; 737 meterwidth / peak_meter_range;
738 } 738 }
739 } 739 }
740 740
diff --git a/apps/recorder/peakmeter.h b/apps/recorder/peakmeter.h
index 356926f9de..db419a0afa 100644
--- a/apps/recorder/peakmeter.h
+++ b/apps/recorder/peakmeter.h
@@ -21,7 +21,7 @@
21 21
22/*#define PM_DEBUG */ 22/*#define PM_DEBUG */
23#ifdef PM_DEBUG 23#ifdef PM_DEBUG
24extern bool peak_meter_histogramm(void); 24extern bool peak_meter_histogram(void);
25#endif 25#endif
26 26
27 27
diff --git a/apps/wps-display.c b/apps/wps-display.c
index f8dbcde420..cfc968a3ec 100644
--- a/apps/wps-display.c
+++ b/apps/wps-display.c
@@ -524,6 +524,8 @@ bool wps_refresh(struct mp3entry* id3, int ffwd_offset, unsigned char refresh_mo
524 char buf[MAX_PATH]; 524 char buf[MAX_PATH];
525 unsigned char flags; 525 unsigned char flags;
526 int i; 526 int i;
527 int h = font_get(FONT_UI)->height;
528 bool update_line;
527#ifdef HAVE_LCD_BITMAP 529#ifdef HAVE_LCD_BITMAP
528 /* to find out wether the peak meter is enabled we 530 /* to find out wether the peak meter is enabled we
529 assume it wasn't until we find a line that contains 531 assume it wasn't until we find a line that contains
@@ -544,6 +546,7 @@ bool wps_refresh(struct mp3entry* id3, int ffwd_offset, unsigned char refresh_mo
544 546
545 for (i = 0; i < MAX_LINES; i++) 547 for (i = 0; i < MAX_LINES; i++)
546 { 548 {
549 update_line = false;
547 if ( !format_lines[i] ) 550 if ( !format_lines[i] )
548 break; 551 break;
549 552
@@ -559,24 +562,21 @@ bool wps_refresh(struct mp3entry* id3, int ffwd_offset, unsigned char refresh_mo
559#ifdef HAVE_LCD_CHARCELLS 562#ifdef HAVE_LCD_CHARCELLS
560 draw_player_progress(id3, ff_rewind_count); 563 draw_player_progress(id3, ff_rewind_count);
561#else 564#else
562 int w,h;
563 int offset = global_settings.statusbar ? STATUSBAR_HEIGHT : 0; 565 int offset = global_settings.statusbar ? STATUSBAR_HEIGHT : 0;
564 lcd_getstringsize("M",&w,&h);
565 slidebar(0, i*h + offset + 1, LCD_WIDTH, 6, 566 slidebar(0, i*h + offset + 1, LCD_WIDTH, 6,
566 (id3->elapsed + ff_rewind_count) * 100 / id3->length, 567 (id3->elapsed + ff_rewind_count) * 100 / id3->length,
567 Grow_Right); 568 Grow_Right);
568 continue;
569#endif 569#endif
570 } 570 update_line = true;
571 } else
571 572
572#ifdef HAVE_LCD_BITMAP 573#ifdef HAVE_LCD_BITMAP
573 /* peak meter */ 574 /* peak meter */
574 if (flags & refresh_mode & WPS_REFRESH_PEAK_METER) { 575 if (flags & refresh_mode & WPS_REFRESH_PEAK_METER) {
575 int peak_meter_y; 576 int peak_meter_y;
576 struct font *fnt = font_get(FONT_UI);
577 int h = fnt->height;
578 int offset = global_settings.statusbar ? STATUSBAR_HEIGHT : 0; 577 int offset = global_settings.statusbar ? STATUSBAR_HEIGHT : 0;
579 578
579 update_line = true;
580 peak_meter_y = i * h + offset; 580 peak_meter_y = i * h + offset;
581 581
582 /* The user might decide to have the peak meter in the last 582 /* The user might decide to have the peak meter in the last
@@ -590,29 +590,35 @@ bool wps_refresh(struct mp3entry* id3, int ffwd_offset, unsigned char refresh_mo
590 peak_meter_draw(0, peak_meter_y, LCD_WIDTH, 590 peak_meter_draw(0, peak_meter_y, LCD_WIDTH,
591 MIN(h, LCD_HEIGHT - peak_meter_y)); 591 MIN(h, LCD_HEIGHT - peak_meter_y));
592 } 592 }
593 continue; 593 } else
594 }
595#endif 594#endif
596 595
597 /* static line */ 596 /* scroll line */
598 if (flags & WPS_REFRESH_SCROLL) 597 if (flags & WPS_REFRESH_SCROLL)
599 { 598 {
600 if (refresh_mode & WPS_REFRESH_SCROLL) { 599 if (refresh_mode & WPS_REFRESH_SCROLL)
600 {
601 lcd_puts_scroll(0, i, buf); 601 lcd_puts_scroll(0, i, buf);
602 } 602 }
603 } 603 }
604 else 604
605 /* dynamic / static line */
606 if ((flags & refresh_mode & WPS_REFRESH_DYNAMIC) ||
607 (flags & refresh_mode & WPS_REFRESH_STATIC))
605 { 608 {
609 update_line = true;
606 lcd_puts(0, i, buf); 610 lcd_puts(0, i, buf);
607 } 611 }
608 } 612 }
613 if (update_line) {
614 lcd_update_rect(0, i * h, LCD_WIDTH, h);
615 }
609 } 616 }
610#ifdef HAVE_LCD_BITMAP 617#ifdef HAVE_LCD_BITMAP
611 /* Now we know wether the peak meter is used. 618 /* Now we know wether the peak meter is used.
612 So we can enable / disable the peak meter thread */ 619 So we can enable / disable the peak meter thread */
613 peak_meter_enabled = enable_pm; 620 peak_meter_enabled = enable_pm;
614#endif 621#endif
615 lcd_update();
616 622
617 return true; 623 return true;
618} 624}
diff --git a/apps/wps.c b/apps/wps.c
index 8f9295a293..68d158e18e 100644
--- a/apps/wps.c
+++ b/apps/wps.c
@@ -687,7 +687,7 @@ int wps_show(void)
687 break; 687 break;
688 } 688 }
689 peak_meter_peek(); 689 peak_meter_peek();
690 yield(); 690 sleep(1);
691 691
692 if (TIME_AFTER(current_tick, next_refresh)) { 692 if (TIME_AFTER(current_tick, next_refresh)) {
693 wps_refresh(id3, 0, WPS_REFRESH_PEAK_METER); 693 wps_refresh(id3, 0, WPS_REFRESH_PEAK_METER);
diff --git a/firmware/drivers/lcd-recorder.c b/firmware/drivers/lcd-recorder.c
index 10071dc3d7..16729464fc 100644
--- a/firmware/drivers/lcd-recorder.c
+++ b/firmware/drivers/lcd-recorder.c
@@ -823,7 +823,6 @@ static void scroll_thread(void)
823 int index; 823 int index;
824 int w, h; 824 int w, h;
825 int xpos, ypos; 825 int xpos, ypos;
826 bool update;
827 826
828 /* initialize scroll struct array */ 827 /* initialize scroll struct array */
829 for (index = 0; index < SCROLLABLE_LINES; index++) { 828 for (index = 0; index < SCROLLABLE_LINES; index++) {
@@ -834,15 +833,12 @@ static void scroll_thread(void)
834 833
835 while ( 1 ) { 834 while ( 1 ) {
836 835
837 update = false;
838
839 /* wait 0.5s before starting scroll */ 836 /* wait 0.5s before starting scroll */
840 if ( TIME_AFTER(current_tick, scroll_start_tick) ) { 837 if ( TIME_AFTER(current_tick, scroll_start_tick) ) {
841 838
842 for ( index = 0; index < SCROLLABLE_LINES; index++ ) { 839 for ( index = 0; index < SCROLLABLE_LINES; index++ ) {
843 s = &scroll[index]; 840 s = &scroll[index];
844 if ( s->mode == SCROLL_MODE_RUN ) { 841 if ( s->mode == SCROLL_MODE_RUN ) {
845 update = true;
846 842
847 s->offset += scroll_step; 843 s->offset += scroll_step;
848 844
@@ -855,12 +851,9 @@ static void scroll_thread(void)
855 851
856 lcd_clearrect(xpos, ypos, LCD_WIDTH - xmargin, h); 852 lcd_clearrect(xpos, ypos, LCD_WIDTH - xmargin, h);
857 lcd_putsxyofs(xpos, ypos, s->offset, s->line); 853 lcd_putsxyofs(xpos, ypos, s->offset, s->line);
854 lcd_update_rect(xpos, ypos, LCD_WIDTH - xmargin, h);
858 } 855 }
859 } 856 }
860
861 if (update) {
862 lcd_update();
863 }
864 } 857 }
865 858
866 sleep(HZ/scroll_speed); 859 sleep(HZ/scroll_speed);