USB Related:

Consolidated some more of the USB code in the WPS.
    Have backlight turn offf when USB Connected.
menu.c:
    LINE_X was set wrong for player.
settings_menu.c / wps-display.c:
    Added 1 Line ID3+. Has progress bar & Kbps.
    Renamed some of the WPS options to be more readable.
wps.c / wps-display.c
    Fixed problem with FF/REW when 'Remaining Time' is on.
    Added %pb to the WPS mix. Player progress bar thingy.
    Thanks to whoever fixed my PLAYER_PROGRESS function :-)
    Changed how volume changes on player (works better now).
    General cleanup of Custom WPS code.


git-svn-id: svn://svn.rockbox.org/rockbox/trunk@2091 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Justin Heiner 2002-08-31 04:58:35 +00:00
parent ae17b526ff
commit b5025a8c40
8 changed files with 117 additions and 85 deletions

View file

@ -17,7 +17,9 @@
*
****************************************************************************/
#include <stdbool.h>
#include "lcd.h"
#include "backlight.h"
#include "menu.h"
#include "button.h"
#include "kernel.h"
@ -69,7 +71,7 @@ struct menu {
#else /* HAVE_LCD_BITMAP */
#define LINE_X 0 /* X position the entry-list starts at */
#define LINE_X 1 /* X position the entry-list starts at */
#define MENU_LINES 2
@ -331,8 +333,10 @@ Menu menu_run(int m)
#ifdef HAVE_LCD_BITMAP
laststate = statusbar(false);
#endif
backlight_time(4);
usb_acknowledge(SYS_USB_CONNECTED_ACK);
usb_wait_for_disconnect(&button_queue);
backlight_time(global_settings.backlight);
#ifdef HAVE_LCD_BITMAP
statusbar(laststate);
#else

View file

@ -26,6 +26,8 @@
#include "panic.h"
#include "debug.h"
#include "button.h"
#include "usb.h"
#include "backlight.h"
#include "lcd.h"
#include "mpeg.h"
#include "string.h"

View file

@ -21,13 +21,13 @@
#include <stdio.h>
#include <stdbool.h>
#include "lcd.h"
#include "menu.h"
#include "mpeg.h"
#include "button.h"
#include "kernel.h"
#include "sprintf.h"
#include "settings.h"
#include "settings_menu.h"
#include "backlight.h"
@ -97,12 +97,12 @@ static Menu scroll_speed(void)
static Menu wps_set(void)
{
#ifdef HAVE_LCD_BITMAP
char* names[] = { "ID3 Tags ", "File ", "Parse ", "Custom WPS " };
char* names[] = { "ID3 Tags ", "Filename ", "Dir Parse ", "Custom WPS " };
set_option("[WPS display]", &global_settings.wps_display, names, 4 );
#else
char* names[] = { "1 Line ID3", "2 Line ID3", "File ",
"Parse ", "Custom WPS " };
set_option("[WPS display]", &global_settings.wps_display, names, 5 );
char* names[] = { "1 Line ID3 ", "1 Line ID3+", "2 Line ID3 ", "Filename ",
"Dir Parse ", "Custom WPS " };
set_option("[WPS display]", &global_settings.wps_display, names, 6 );
#endif
return MENU_OK;
}

View file

@ -26,6 +26,7 @@
#include "dir.h"
#include "file.h"
#include "lcd.h"
#include "backlight.h"
#include "button.h"
#include "kernel.h"
#include "usb.h"
@ -731,12 +732,16 @@ bool dirbrowse(char *root)
#ifdef HAVE_LCD_BITMAP
bool laststate=statusbar(false);
#endif
backlight_time(4);
/* Tell the USB thread that we are safe */
DEBUGF("dirbrowse got SYS_USB_CONNECTED\n");
usb_acknowledge(SYS_USB_CONNECTED_ACK);
/* Wait until the USB cable is extracted again */
usb_wait_for_disconnect(&button_queue);
backlight_time(global_settings.backlight);
/* Force a re-read of the root directory */
restore = true;

View file

@ -47,10 +47,11 @@
#define PLAY_DISPLAY_CUSTOM_WPS 3
#else
#define PLAY_DISPLAY_1LINEID3 0
#define PLAY_DISPLAY_2LINEID3 1
#define PLAY_DISPLAY_FILENAME_SCROLL 2
#define PLAY_DISPLAY_TRACK_TITLE 3
#define PLAY_DISPLAY_CUSTOM_WPS 4
#define PLAY_DISPLAY_1LINEID3_PLUS 1
#define PLAY_DISPLAY_2LINEID3 2
#define PLAY_DISPLAY_FILENAME_SCROLL 3
#define PLAY_DISPLAY_TRACK_TITLE 4
#define PLAY_DISPLAY_CUSTOM_WPS 5
#endif
#define LINE_LEN 64
@ -60,6 +61,7 @@ static char custom_wps[5][LINE_LEN];
static char display[5][LINE_LEN];
static int scroll_line;
static int scroll_line_custom;
bool wps_time_countup = true;
static bool load_custom_wps(void)
{
@ -232,6 +234,12 @@ static bool display_custom_wps( struct mp3entry* id3,
switch(cchr3)
{
#ifdef HAVE_LCD_CHARCELLS
case 'b': /* Progress Bar (PLAYER ONLY)*/
draw_player_progress(id3, ff_rewind_count);
snprintf(buf, LINE_LEN, "\x01");
break;
#endif
case 'p': /* Playlist Position */
snprintf(buf, LINE_LEN, "%d", id3->index + 1);
break;
@ -245,6 +253,7 @@ static bool display_custom_wps( struct mp3entry* id3,
snprintf(buf, LINE_LEN, "%d:%02d",
i / 60000,
i % 60000 / 1000);
wps_time_countup = true;
break;
case 'r': /* Remaining Time in Song */
@ -252,6 +261,7 @@ static bool display_custom_wps( struct mp3entry* id3,
snprintf(buf, LINE_LEN, "%d:%02d",
i / 60000,
i % 60000 / 1000 );
wps_time_countup = false;
break;
case 't': /* Total Time */
@ -367,9 +377,8 @@ bool wps_refresh(struct mp3entry* id3, int ffwd_offset, bool refresh_scroll)
scroll_line = scroll_line_custom;
if (scroll_line != l)
display_custom_wps(id3, 0, l, false, custom_wps[l]);
else
if (refresh_scroll)
display_custom_wps(id3, 0, l, true, custom_wps[l]);
if (scroll_line == l && refresh_scroll)
display_custom_wps(id3, 0, l, true, custom_wps[l]);
}
else
{
@ -389,11 +398,6 @@ bool wps_refresh(struct mp3entry* id3, int ffwd_offset, bool refresh_scroll)
slidebar(0, LCD_HEIGHT-6, LCD_WIDTH, 6, id3->elapsed*100/id3->length, Grow_Right);
lcd_update();
#endif
#ifdef PLAYER_PROGRESS
#ifdef HAVE_LCD_CHARCELLS
draw_player_progress(10,1,id3);
#endif
#endif
return true;
}
@ -466,7 +470,6 @@ void wps_display(struct mp3entry* id3)
for (tmpcnt=2;tmpcnt<=5;tmpcnt++)
display[tmpcnt][0] = 0;
scroll_line = 0;
wps_refresh(id3,0,false);
break;
}
case PLAY_DISPLAY_FILENAME_SCROLL:
@ -476,7 +479,6 @@ void wps_display(struct mp3entry* id3)
snprintf(display[1], sizeof display[1], "%s", "%pc/%pt");
#endif
scroll_line = 0;
wps_refresh(id3,0,false);
break;
}
case PLAY_DISPLAY_2LINEID3:
@ -506,12 +508,10 @@ void wps_display(struct mp3entry* id3)
strncpy(display[l++], "%fb kbit %ffHz", LINE_LEN);
}
scroll_line = 0;
wps_refresh(id3,0,false);
#else
strncpy(display[0], "%ia", LINE_LEN);
strncpy(display[1], "%it", LINE_LEN);
scroll_line = 1;
wps_refresh(id3,0,false);
#endif
break;
}
@ -521,7 +521,13 @@ void wps_display(struct mp3entry* id3)
strncpy(display[0], "%pp/%pe: %fc", LINE_LEN);
strncpy(display[1], "%pc/%pt", LINE_LEN);
scroll_line = 0;
wps_refresh(id3,0,false);
break;
}
case PLAY_DISPLAY_1LINEID3_PLUS:
{
strncpy(display[0], "%pp/%pe: %fc", LINE_LEN);
strncpy(display[1], "%pr%pb%fbkps", LINE_LEN);
scroll_line = 0;
break;
}
#endif
@ -532,51 +538,41 @@ void wps_display(struct mp3entry* id3)
strncpy(display[0], "Couldn't Load Custom WPS", LINE_LEN);
strncpy(display[1], "%pc/%pt", LINE_LEN);
}
wps_refresh(id3,0,false);
break;
}
}
}
wps_refresh(id3,0,false);
status_draw();
lcd_update();
}
#ifdef PLAYER_PROGRESS
/*static int bin2int(char *input, int size)
{
int result=0;
while(size--) {
result <<= 1;
result += (*input++ - '0');
}
return result;
}
*/
#ifdef HAVE_LCD_CHARCELLS
void draw_player_progress(int x, int y, struct mp3entry* id3)
bool draw_player_progress(struct mp3entry* id3, int ff_rewwind_count)
{
if(!id3)
return(false);
char player_progressbar[7];
char binline[36];
int songpos = 0;
int i,j;
memset(binline, 0, sizeof binline);
memset(player_progressbar, 0, sizeof player_progressbar);
songpos = (id3->elapsed * 36) / id3->length;
memset(binline, 1, sizeof binline);
memset(player_progressbar, 1, sizeof player_progressbar);
if(wps_time_countup == false)
songpos = ((id3->elapsed - ff_rewwind_count) * 36) / id3->length;
else
songpos = ((id3->elapsed + ff_rewwind_count) * 36) / id3->length;
for (i=0; i < songpos; i++)
binline[i] = 1;
binline[i] = 0;
for (i=0; i<=6; i++) {
for (j=0;j<5;j++) {
player_progressbar[i] <<= 1;
player_progressbar[i] += binline[i*5+j];
}
/* player_progressbar[i] = bin2int(binline+(i*5),4); */
}
lcd_define_pattern(8,player_progressbar,7);
lcd_puts(x,y,"\x01");
return(true);
}
#endif
#endif

View file

@ -25,10 +25,8 @@
bool wps_refresh(struct mp3entry* id3, int ffwd_offset, bool refresh_scroll);
void wps_display(struct mp3entry* id3);
#ifdef PLAYER_PROGRESS
#ifdef HAVE_LCD_CHARCELLS
void draw_player_progress(int x, int y, struct mp3entry* id3);
#endif
bool draw_player_progress(struct mp3entry* id3, int ff_rewind_count);
#endif
#endif

View file

@ -22,6 +22,7 @@
#include "file.h"
#include "lcd.h"
#include "backlight.h"
#include "button.h"
#include "kernel.h"
#include "tree.h"
@ -59,23 +60,56 @@ static bool paused = false;
static struct mp3entry* id3 = NULL;
static int old_release_mask;
void display_volume_level(int vol_level)
#ifdef HAVE_PLAYER_KEYPAD
void player_change_volume(void)
{
int button;
bool fun_done = false;
char buffer[32];
lcd_stop_scroll();
snprintf(buffer,sizeof(buffer),"Vol: %d %% ", vol_level * 2);
while(!fun_done)
{
snprintf(buffer,sizeof(buffer),"Vol: %d %% ", global_settings.volume * 2);
#ifdef HAVE_LCD_CHARCELLS
lcd_puts(0, 0, buffer);
lcd_puts(0, 0, buffer);
#else
lcd_puts(2, 3, buffer);
lcd_update();
lcd_puts(2, 3, buffer);
lcd_update();
#endif
sleep(HZ/6);
button = button_get(false);
switch(button)
{
case BUTTON_MENU | BUTTON_RIGHT:
case BUTTON_MENU | BUTTON_RIGHT | BUTTON_REPEAT:
global_settings.volume++;
if(global_settings.volume > mpeg_sound_max(SOUND_VOLUME))
global_settings.volume = mpeg_sound_max(SOUND_VOLUME);
mpeg_sound_set(SOUND_VOLUME, global_settings.volume);
wps_refresh(id3,0,false);
settings_save();
break;
case BUTTON_MENU | BUTTON_LEFT:
case BUTTON_MENU | BUTTON_LEFT | BUTTON_REPEAT:
global_settings.volume--;
if(global_settings.volume < mpeg_sound_min(SOUND_VOLUME))
global_settings.volume = mpeg_sound_min(SOUND_VOLUME);
mpeg_sound_set(SOUND_VOLUME, global_settings.volume);
wps_refresh(id3,0,false);
settings_save();
break;
case BUTTON_MENU | BUTTON_REL:
fun_done = true;
break;
}
yield();
}
status_draw();
wps_refresh(id3,0,true);
}
#endif
void display_keylock_text(bool locked)
{
@ -133,6 +167,9 @@ static void handle_usb(void)
#ifdef HAVE_LCD_BITMAP
bool laststate=statusbar(false);
#endif
backlight_time(4);
/* Tell the USB thread that we are safe */
DEBUGF("wps got SYS_USB_CONNECTED\n");
usb_acknowledge(SYS_USB_CONNECTED_ACK);
@ -140,6 +177,8 @@ static void handle_usb(void)
/* Wait until the USB cable is extracted again */
usb_wait_for_disconnect(&button_queue);
backlight_time(global_settings.backlight);
#ifdef HAVE_LCD_BITMAP
statusbar(laststate);
#endif
@ -195,14 +234,7 @@ int player_id3_show(void)
#ifndef SIMULATOR
case SYS_USB_CONNECTED:
/* Tell the USB thread that we are safe */
DEBUGF("wps got SYS_USB_CONNECTED\n");
usb_acknowledge(SYS_USB_CONNECTED_ACK);
/* Wait until the USB cable is extracted again */
usb_wait_for_disconnect(&button_queue);
/* Signal to our caller that we have been in USB mode */
handle_usb();
return SYS_USB_CONNECTED;
break;
#endif
@ -316,7 +348,10 @@ static bool ffwd_rew(int button)
if ((int)(id3->elapsed + ff_rewind_count) < 0)
ff_rewind_count = -id3->elapsed;
wps_refresh(id3, ff_rewind_count, false);
if(wps_time_countup == false)
wps_refresh(id3, -ff_rewind_count, false);
else
wps_refresh(id3, ff_rewind_count, false);
break;
case BUTTON_RIGHT | BUTTON_REPEAT:
@ -360,7 +395,10 @@ static bool ffwd_rew(int button)
if ((id3->elapsed + ff_rewind_count) > id3->length)
ff_rewind_count = id3->length - id3->elapsed;
wps_refresh(id3, ff_rewind_count, false);
if(wps_time_countup == false)
wps_refresh(id3, -ff_rewind_count, false);
else
wps_refresh(id3, ff_rewind_count, false);
break;
case BUTTON_LEFT | BUTTON_REL:
@ -524,10 +562,10 @@ static bool menu(void)
button_set_release(old_release_mask);
main_menu();
#ifdef HAVE_LCD_BITMAP
if(global_settings.statusbar)
lcd_setmargins(0, STATUSBAR_HEIGHT);
else
lcd_setmargins(0, 0);
if(global_settings.statusbar)
lcd_setmargins(0, STATUSBAR_HEIGHT);
else
lcd_setmargins(0, 0);
#endif
old_release_mask = button_set_release(RELEASE_MASK);
}
@ -565,27 +603,15 @@ static bool menu(void)
/* change volume */
case BUTTON_MENU | BUTTON_LEFT:
case BUTTON_MENU | BUTTON_LEFT | BUTTON_REPEAT:
global_settings.volume--;
if(global_settings.volume < mpeg_sound_min(SOUND_VOLUME))
global_settings.volume = mpeg_sound_min(SOUND_VOLUME);
mpeg_sound_set(SOUND_VOLUME, global_settings.volume);
display_volume_level(global_settings.volume);
wps_display(id3);
status_draw();
settings_save();
player_change_volume();
exit = true;
break;
/* change volume */
case BUTTON_MENU | BUTTON_RIGHT:
case BUTTON_MENU | BUTTON_RIGHT | BUTTON_REPEAT:
global_settings.volume++;
if(global_settings.volume > mpeg_sound_max(SOUND_VOLUME))
global_settings.volume = mpeg_sound_max(SOUND_VOLUME);
mpeg_sound_set(SOUND_VOLUME, global_settings.volume);
display_volume_level(global_settings.volume);
wps_display(id3);
status_draw();
settings_save();
player_change_volume();
exit = true;
break;
/* show id3 tags */

View file

@ -22,6 +22,7 @@
#include "playlist.h"
extern bool keys_locked;
extern bool wps_time_countup;
int wps_show(void);