diff options
Diffstat (limited to 'apps/gui/gwps.c')
-rw-r--r-- | apps/gui/gwps.c | 141 |
1 files changed, 88 insertions, 53 deletions
diff --git a/apps/gui/gwps.c b/apps/gui/gwps.c index 4fc9acbece..f06ea5baf1 100644 --- a/apps/gui/gwps.c +++ b/apps/gui/gwps.c | |||
@@ -1,3 +1,21 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2002 Jerome Kuptz | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
1 | #include <stdio.h> | 19 | #include <stdio.h> |
2 | #include <string.h> | 20 | #include <string.h> |
3 | #include <stdlib.h> | 21 | #include <stdlib.h> |
@@ -42,12 +60,15 @@ | |||
42 | #define RWPS_DEFAULTCFG WPS_DIR "/rockbox_default.rwps" | 60 | #define RWPS_DEFAULTCFG WPS_DIR "/rockbox_default.rwps" |
43 | /* currently only on wps_state is needed */ | 61 | /* currently only on wps_state is needed */ |
44 | struct wps_state wps_state; | 62 | struct wps_state wps_state; |
45 | struct gui_syncwps gui_syncwps; | 63 | struct gui_wps gui_wps[NB_SCREENS]; |
46 | struct wps_data wps_datas[NB_SCREENS]; | 64 | static struct wps_data wps_datas[NB_SCREENS]; |
47 | 65 | ||
48 | bool keys_locked = false; | 66 | static bool keys_locked = false; |
49 | 67 | ||
50 | long gui_wps_show() | 68 | /* change the path to the current played track */ |
69 | static void wps_state_update_ctp(const char *path); | ||
70 | |||
71 | long gui_wps_show(void) | ||
51 | { | 72 | { |
52 | long button = 0, lastbutton = 0; | 73 | long button = 0, lastbutton = 0; |
53 | bool ignore_keyup = true; | 74 | bool ignore_keyup = true; |
@@ -67,10 +88,8 @@ long gui_wps_show() | |||
67 | #else | 88 | #else |
68 | FOR_NB_SCREENS(i) | 89 | FOR_NB_SCREENS(i) |
69 | { | 90 | { |
70 | if(global_settings.statusbar) | 91 | gui_wps[i].display->setmargins(0, global_settings.statusbar? |
71 | gui_syncwps.gui_wps[i].display->setmargins(0, STATUSBAR_HEIGHT); | 92 | STATUSBAR_HEIGHT:0); |
72 | else | ||
73 | gui_syncwps.gui_wps[i].display->setmargins(0, 0); | ||
74 | } | 93 | } |
75 | #endif | 94 | #endif |
76 | 95 | ||
@@ -87,7 +106,7 @@ long gui_wps_show() | |||
87 | if (gui_wps_display()) | 106 | if (gui_wps_display()) |
88 | return 0; | 107 | return 0; |
89 | FOR_NB_SCREENS(i) | 108 | FOR_NB_SCREENS(i) |
90 | gui_wps_refresh(&gui_syncwps.gui_wps[i], 0, WPS_REFRESH_ALL); | 109 | gui_wps_refresh(&gui_wps[i], 0, WPS_REFRESH_ALL); |
91 | wps_state_update_ctp(wps_state.id3->path); | 110 | wps_state_update_ctp(wps_state.id3->path); |
92 | } | 111 | } |
93 | 112 | ||
@@ -119,7 +138,7 @@ long gui_wps_show() | |||
119 | bool pm=false; | 138 | bool pm=false; |
120 | FOR_NB_SCREENS(i) | 139 | FOR_NB_SCREENS(i) |
121 | { | 140 | { |
122 | if(gui_syncwps.gui_wps[i].data->peak_meter_enabled) | 141 | if(gui_wps[i].data->peak_meter_enabled) |
123 | pm = true; | 142 | pm = true; |
124 | } | 143 | } |
125 | 144 | ||
@@ -137,8 +156,12 @@ long gui_wps_show() | |||
137 | 156 | ||
138 | if (TIME_AFTER(current_tick, next_refresh)) { | 157 | if (TIME_AFTER(current_tick, next_refresh)) { |
139 | FOR_NB_SCREENS(i) | 158 | FOR_NB_SCREENS(i) |
140 | gui_wps_refresh(&gui_syncwps.gui_wps[i], 0, WPS_REFRESH_PEAK_METER); | 159 | { |
141 | next_refresh += HZ / PEAK_METER_FPS; | 160 | if(gui_wps[i].data->peak_meter_enabled) |
161 | gui_wps_refresh(&gui_wps[i], 0, | ||
162 | WPS_REFRESH_PEAK_METER); | ||
163 | next_refresh += HZ / PEAK_METER_FPS; | ||
164 | } | ||
142 | } | 165 | } |
143 | } | 166 | } |
144 | 167 | ||
@@ -213,7 +236,7 @@ long gui_wps_show() | |||
213 | status_set_audio(false); | 236 | status_set_audio(false); |
214 | #endif | 237 | #endif |
215 | FOR_NB_SCREENS(i) | 238 | FOR_NB_SCREENS(i) |
216 | gui_syncwps.gui_wps[i].display->stop_scroll(); | 239 | gui_wps[i].display->stop_scroll(); |
217 | 240 | ||
218 | /* set dir browser to current playing song */ | 241 | /* set dir browser to current playing song */ |
219 | if (global_settings.browse_current && | 242 | if (global_settings.browse_current && |
@@ -232,7 +255,8 @@ long gui_wps_show() | |||
232 | #ifdef WPS_RC_PAUSE | 255 | #ifdef WPS_RC_PAUSE |
233 | case WPS_RC_PAUSE: | 256 | case WPS_RC_PAUSE: |
234 | #ifdef WPS_RC_PAUSE_PRE | 257 | #ifdef WPS_RC_PAUSE_PRE |
235 | if ((button == WPS_RC_PAUSE) && (lastbutton != WPS_RC_PAUSE_PRE)) | 258 | if ((button == WPS_RC_PAUSE) && |
259 | (lastbutton != WPS_RC_PAUSE_PRE)) | ||
236 | break; | 260 | break; |
237 | #endif | 261 | #endif |
238 | #endif | 262 | #endif |
@@ -333,7 +357,8 @@ long gui_wps_show() | |||
333 | #ifdef AB_REPEAT_ENABLE | 357 | #ifdef AB_REPEAT_ENABLE |
334 | /* if we're in A/B repeat mode and the current position | 358 | /* if we're in A/B repeat mode and the current position |
335 | is past the A marker, jump back to the A marker... */ | 359 | is past the A marker, jump back to the A marker... */ |
336 | if ( ab_repeat_mode_enabled() && ab_after_A_marker(wps_state.id3->elapsed) ) | 360 | if ( ab_repeat_mode_enabled() |
361 | && ab_after_A_marker(wps_state.id3->elapsed) ) | ||
337 | { | 362 | { |
338 | ab_jump_to_A_marker(); | 363 | ab_jump_to_A_marker(); |
339 | break; | 364 | break; |
@@ -391,7 +416,8 @@ long gui_wps_show() | |||
391 | #ifdef AB_REPEAT_ENABLE | 416 | #ifdef AB_REPEAT_ENABLE |
392 | /* if we're in A/B repeat mode and the current position is | 417 | /* if we're in A/B repeat mode and the current position is |
393 | before the A marker, jump to the A marker... */ | 418 | before the A marker, jump to the A marker... */ |
394 | if ( ab_repeat_mode_enabled() && ab_before_A_marker(wps_state.id3->elapsed) ) | 419 | if ( ab_repeat_mode_enabled() |
420 | && ab_before_A_marker(wps_state.id3->elapsed) ) | ||
395 | { | 421 | { |
396 | ab_jump_to_A_marker(); | 422 | ab_jump_to_A_marker(); |
397 | break; | 423 | break; |
@@ -417,17 +443,16 @@ long gui_wps_show() | |||
417 | #endif | 443 | #endif |
418 | #endif | 444 | #endif |
419 | FOR_NB_SCREENS(i) | 445 | FOR_NB_SCREENS(i) |
420 | gui_syncwps.gui_wps[i].display->stop_scroll(); | 446 | gui_wps[i].display->stop_scroll(); |
421 | 447 | ||
422 | if (main_menu()) | 448 | if (main_menu()) |
423 | return true; | 449 | return true; |
424 | #ifdef HAVE_LCD_BITMAP | 450 | #ifdef HAVE_LCD_BITMAP |
425 | FOR_NB_SCREENS(i) | 451 | FOR_NB_SCREENS(i) |
426 | { | 452 | { |
427 | if(global_settings.statusbar) | 453 | gui_wps[i].display->setmargins(0, |
428 | gui_syncwps.gui_wps[i].display->setmargins(0, STATUSBAR_HEIGHT); | 454 | global_settings.statusbar? |
429 | else | 455 | STATUSBAR_HEIGHT:0); |
430 | gui_syncwps.gui_wps[i].display->setmargins(0, 0); | ||
431 | } | 456 | } |
432 | #endif | 457 | #endif |
433 | restore = true; | 458 | restore = true; |
@@ -552,8 +577,9 @@ long gui_wps_show() | |||
552 | if (update_track) | 577 | if (update_track) |
553 | { | 578 | { |
554 | bool upt = false; | 579 | bool upt = false; |
555 | FOR_NB_SCREENS(i){ | 580 | FOR_NB_SCREENS(i) |
556 | if(update(&gui_syncwps.gui_wps[i])) | 581 | { |
582 | if(update(&gui_wps[i])) | ||
557 | upt = true; | 583 | upt = true; |
558 | } | 584 | } |
559 | if (upt) | 585 | if (upt) |
@@ -577,7 +603,7 @@ long gui_wps_show() | |||
577 | fade(0); | 603 | fade(0); |
578 | 604 | ||
579 | FOR_NB_SCREENS(i) | 605 | FOR_NB_SCREENS(i) |
580 | gui_syncwps.gui_wps[i].display->stop_scroll(); | 606 | gui_wps[i].display->stop_scroll(); |
581 | bookmark_autobookmark(); | 607 | bookmark_autobookmark(); |
582 | audio_stop(); | 608 | audio_stop(); |
583 | #ifdef AB_REPEAT_ENABLE | 609 | #ifdef AB_REPEAT_ENABLE |
@@ -617,7 +643,7 @@ long gui_wps_show() | |||
617 | 643 | ||
618 | if (wps_state.id3){ | 644 | if (wps_state.id3){ |
619 | FOR_NB_SCREENS(i) | 645 | FOR_NB_SCREENS(i) |
620 | gui_wps_refresh(&gui_syncwps.gui_wps[i], 0, WPS_REFRESH_NON_STATIC); | 646 | gui_wps_refresh(&gui_wps[i], 0, WPS_REFRESH_NON_STATIC); |
621 | } | 647 | } |
622 | } | 648 | } |
623 | if (button != BUTTON_NONE) | 649 | if (button != BUTTON_NONE) |
@@ -674,11 +700,17 @@ static void wps_reset(struct wps_data *data) | |||
674 | 700 | ||
675 | /* to setup up the wps-data from a format-buffer (isfile = false) | 701 | /* to setup up the wps-data from a format-buffer (isfile = false) |
676 | from a (wps-)file (isfile = true)*/ | 702 | from a (wps-)file (isfile = true)*/ |
677 | bool wps_data_load(struct wps_data *wps_data, const char *buf, bool isfile, bool display) | 703 | bool wps_data_load(struct wps_data *wps_data, |
704 | const char *buf, | ||
705 | bool isfile, | ||
706 | bool display) | ||
678 | { | 707 | { |
679 | int i, s; | 708 | int i, s; |
680 | int fd; | 709 | int fd; |
681 | if(!wps_data || !buf) return false; | 710 | |
711 | if(!wps_data || !buf) | ||
712 | return false; | ||
713 | |||
682 | if(!isfile) | 714 | if(!isfile) |
683 | { | 715 | { |
684 | wps_clear(wps_data); | 716 | wps_clear(wps_data); |
@@ -694,9 +726,10 @@ bool wps_data_load(struct wps_data *wps_data, const char *buf, bool isfile, bool | |||
694 | * wants to be a virtual file. Feel free to modify dirbrowse() | 726 | * wants to be a virtual file. Feel free to modify dirbrowse() |
695 | * if you're feeling brave. | 727 | * if you're feeling brave. |
696 | */ | 728 | */ |
697 | if (! strcmp(buf, WPS_DEFAULTCFG) || !strcmp(buf, RWPS_DEFAULTCFG) ) { | 729 | if (! strcmp(buf, WPS_DEFAULTCFG) || !strcmp(buf, RWPS_DEFAULTCFG) ) |
698 | wps_reset(wps_data); | 730 | { |
699 | return false; | 731 | wps_reset(wps_data); |
732 | return false; | ||
700 | } | 733 | } |
701 | size_t bmpdirlen; | 734 | size_t bmpdirlen; |
702 | char *bmpdir = strrchr(buf, '.'); | 735 | char *bmpdir = strrchr(buf, '.'); |
@@ -706,7 +739,8 @@ bool wps_data_load(struct wps_data *wps_data, const char *buf, bool isfile, bool | |||
706 | 739 | ||
707 | if (fd >= 0) | 740 | if (fd >= 0) |
708 | { | 741 | { |
709 | int numread = read(fd, wps_data->format_buffer, sizeof(wps_data->format_buffer) - 1); | 742 | int numread = read(fd, wps_data->format_buffer, |
743 | sizeof(wps_data->format_buffer) - 1); | ||
710 | 744 | ||
711 | if (numread > 0) | 745 | if (numread > 0) |
712 | { | 746 | { |
@@ -733,24 +767,19 @@ bool wps_data_load(struct wps_data *wps_data, const char *buf, bool isfile, bool | |||
733 | any_defined_line = false; | 767 | any_defined_line = false; |
734 | for (i=0; i<WPS_MAX_LINES; i++) | 768 | for (i=0; i<WPS_MAX_LINES; i++) |
735 | { | 769 | { |
736 | if (wps_data->format_lines[i][s]) | 770 | if (wps_data->format_lines[i][s] && |
771 | wps_data->format_lines[i][s][0]) | ||
737 | { | 772 | { |
738 | if (*(wps_data->format_lines[i][s]) == 0) | 773 | FOR_NB_SCREENS(z) |
739 | { | 774 | screens[z].puts(0, i, |
740 | FOR_NB_SCREENS(z) | 775 | wps_data-> |
741 | screens[z].puts(0,i," "); | 776 | format_lines[i][s]); |
742 | } | ||
743 | else | ||
744 | { | ||
745 | FOR_NB_SCREENS(z) | ||
746 | screens[z].puts(0,i,wps_data->format_lines[i][s]); | ||
747 | } | ||
748 | any_defined_line = true; | 777 | any_defined_line = true; |
749 | } | 778 | } |
750 | else | 779 | else |
751 | { | 780 | { |
752 | FOR_NB_SCREENS(z) | 781 | FOR_NB_SCREENS(z) |
753 | screens[z].puts(0,i," "); | 782 | screens[z].puts(0, i, " "); |
754 | } | 783 | } |
755 | } | 784 | } |
756 | if (any_defined_line) | 785 | if (any_defined_line) |
@@ -759,7 +788,7 @@ bool wps_data_load(struct wps_data *wps_data, const char *buf, bool isfile, bool | |||
759 | FOR_NB_SCREENS(z) | 788 | FOR_NB_SCREENS(z) |
760 | screens[z].update(); | 789 | screens[z].update(); |
761 | #endif | 790 | #endif |
762 | sleep(HZ/2); | 791 | sleep(HZ/2); |
763 | } | 792 | } |
764 | } | 793 | } |
765 | } | 794 | } |
@@ -775,7 +804,6 @@ bool wps_data_load(struct wps_data *wps_data, const char *buf, bool isfile, bool | |||
775 | /* wps_data end */ | 804 | /* wps_data end */ |
776 | 805 | ||
777 | /* wps_state */ | 806 | /* wps_state */ |
778 | struct wps_state wps_state; | ||
779 | 807 | ||
780 | void wps_state_init(void) | 808 | void wps_state_init(void) |
781 | { | 809 | { |
@@ -785,23 +813,31 @@ void wps_state_init(void) | |||
785 | wps_state.nid3 = NULL; | 813 | wps_state.nid3 = NULL; |
786 | wps_state.current_track_path[0] = '\0'; | 814 | wps_state.current_track_path[0] = '\0'; |
787 | } | 815 | } |
816 | |||
817 | #if 0 | ||
818 | /* these are obviously not used? */ | ||
819 | |||
788 | void wps_state_update_ff_rew(bool ff_rew) | 820 | void wps_state_update_ff_rew(bool ff_rew) |
789 | { | 821 | { |
790 | wps_state.ff_rewind = ff_rew; | 822 | wps_state.ff_rewind = ff_rew; |
791 | } | 823 | } |
824 | |||
792 | void wps_state_update_paused(bool paused) | 825 | void wps_state_update_paused(bool paused) |
793 | { | 826 | { |
794 | wps_state.paused = paused; | 827 | wps_state.paused = paused; |
795 | } | 828 | } |
796 | void wps_state_update_ctp(const char *path) | ||
797 | { | ||
798 | memcpy(wps_state.current_track_path, path, sizeof(wps_state.current_track_path)); | ||
799 | } | ||
800 | void wps_state_update_id3_nid3(struct mp3entry *id3, struct mp3entry *nid3) | 829 | void wps_state_update_id3_nid3(struct mp3entry *id3, struct mp3entry *nid3) |
801 | { | 830 | { |
802 | wps_state.id3 = id3; | 831 | wps_state.id3 = id3; |
803 | wps_state.nid3 = nid3; | 832 | wps_state.nid3 = nid3; |
804 | } | 833 | } |
834 | #endif | ||
835 | |||
836 | static void wps_state_update_ctp(const char *path) | ||
837 | { | ||
838 | memcpy(wps_state.current_track_path, path, | ||
839 | sizeof(wps_state.current_track_path)); | ||
840 | } | ||
805 | /* wps_state end*/ | 841 | /* wps_state end*/ |
806 | 842 | ||
807 | /* initial setup of a wps */ | 843 | /* initial setup of a wps */ |
@@ -838,7 +874,7 @@ void gui_sync_wps_screen_init(void) | |||
838 | { | 874 | { |
839 | int i; | 875 | int i; |
840 | FOR_NB_SCREENS(i) | 876 | FOR_NB_SCREENS(i) |
841 | gui_wps_set_disp(&gui_syncwps.gui_wps[i], &screens[i]); | 877 | gui_wps_set_disp(&gui_wps[i], &screens[i]); |
842 | } | 878 | } |
843 | 879 | ||
844 | void gui_sync_wps_init(void) | 880 | void gui_sync_wps_init(void) |
@@ -846,8 +882,7 @@ void gui_sync_wps_init(void) | |||
846 | int i; | 882 | int i; |
847 | FOR_NB_SCREENS(i) | 883 | FOR_NB_SCREENS(i) |
848 | { | 884 | { |
849 | gui_wps_init(&gui_syncwps.gui_wps[i]); | 885 | gui_wps_init(&gui_wps[i]); |
850 | gui_wps_set_data(&gui_syncwps.gui_wps[i], &wps_datas[i]); | 886 | gui_wps_set_data(&gui_wps[i], &wps_datas[i]); |
851 | } | 887 | } |
852 | } | 888 | } |
853 | |||