forked from len0rd/rockbox
Recording countdown timer and repeat timer - see FS #6297 for more details
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13165 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
3c6e46ce64
commit
49952325c9
13 changed files with 670 additions and 19 deletions
|
|
@ -44,6 +44,14 @@ const unsigned char bitmap_icons_5x8[][5] =
|
|||
#endif
|
||||
};
|
||||
|
||||
const unsigned char bitmap_icons_7x7[][7] =
|
||||
{
|
||||
[Icon_Timer] =
|
||||
{0x1c, 0x22, 0x41, 0x4f, 0x49, 0x22, 0x1d}, /* Recording timer icon */
|
||||
[Icon_Timer_rep]=
|
||||
{0x17, 0x26, 0x45, 0x41, 0x51, 0x32, 0x74}, /* Recording repeat timer icon */
|
||||
};
|
||||
|
||||
const unsigned char bitmap_icons_6x8[][6] =
|
||||
{
|
||||
{ 0x60, 0x7f, 0x03, 0x33, 0x3f, 0x00 }, /* Musical note */
|
||||
|
|
@ -159,7 +167,7 @@ const unsigned char bitmap_icon_disk[12] =
|
|||
#ifdef HAVE_MMC
|
||||
{0x15,0x3f,0x7d,0x7B,0x77,0x67,0x79,0x7b,0x57,0x4f,0x47,0x7f};
|
||||
#else
|
||||
{0x00,0x00,0x00,0x1c,0x2e,0x4f,0x77,0x79,0x3a,0x1c,0x00,0x00};
|
||||
{0x1c,0x2e,0x4f,0x77,0x79,0x3a,0x1c,0x00,0x00,0x00,0x00,0x00};
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -49,6 +49,12 @@ enum icons_5x8 {
|
|||
Icon5x8Last
|
||||
};
|
||||
|
||||
enum icons_7x7 {
|
||||
Icon_Timer,
|
||||
Icon_Timer_rep,
|
||||
Icon7x7Last
|
||||
};
|
||||
|
||||
/* If any icons are added to this enum, they must be
|
||||
added to the unused_but_needed enum in ../player/icons.h */
|
||||
enum icons_6x8 {
|
||||
|
|
@ -144,6 +150,7 @@ extern const unsigned char bitmap_formats_18x8[Format_18x8Last][18];
|
|||
#endif /* CONFIG_CODEC == SWCODEC && defined (HAVE_RECORDING) */
|
||||
|
||||
extern const unsigned char bitmap_icons_5x8[Icon5x8Last][5];
|
||||
extern const unsigned char bitmap_icons_7x7[Icon7x7Last][7];
|
||||
extern const unsigned char bitmap_icons_6x8[Icon6x8Last][6];
|
||||
extern const unsigned char bitmap_icons_7x8[Icon7x8Last][7];
|
||||
extern const unsigned char bitmap_icon_disk[];
|
||||
|
|
|
|||
|
|
@ -70,6 +70,8 @@
|
|||
#include "radio.h"
|
||||
#ifdef HAVE_RECORDING
|
||||
|
||||
static struct timer timer;
|
||||
|
||||
static bool in_screen = false;
|
||||
|
||||
bool in_recording_screen(void)
|
||||
|
|
@ -745,6 +747,37 @@ static void trigger_listener(int trigger_status)
|
|||
}
|
||||
}
|
||||
|
||||
/* countdown timer tick task */
|
||||
void timer_tick_task(void)
|
||||
{
|
||||
static int mini_tick = 0;
|
||||
|
||||
mini_tick ++;
|
||||
/* the countdown */
|
||||
if ((mini_tick >= HZ) && (timer.countdown))
|
||||
{
|
||||
mini_tick = 0;
|
||||
if (timer.secs) timer.secs -= 1;
|
||||
else{
|
||||
timer.secs = 59;
|
||||
if (timer.mins) timer.mins -= 1;
|
||||
else{
|
||||
timer.mins = 59;
|
||||
if (timer.hrs) timer.hrs -= 1;
|
||||
else{
|
||||
timer.hrs = 23;
|
||||
if (timer.days) timer.days -= 1;
|
||||
else{
|
||||
timer.days = timer.hrs = timer.mins = timer.secs = 0;
|
||||
/* switch timer display on/off when countdown finished */
|
||||
timer.timer_display = !timer.timer_display;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool recording_start_automatic = false;
|
||||
|
||||
bool recording_screen(bool no_source)
|
||||
|
|
@ -756,7 +789,7 @@ bool recording_screen(bool no_source)
|
|||
int w, h;
|
||||
int update_countdown = 1;
|
||||
bool have_recorded = false;
|
||||
unsigned int seconds;
|
||||
unsigned int seconds, prerec = 0;
|
||||
int hours, minutes;
|
||||
char filename[13];
|
||||
bool been_in_usb_mode = false;
|
||||
|
|
@ -793,6 +826,9 @@ bool recording_screen(bool no_source)
|
|||
int trig_xpos[NB_SCREENS];
|
||||
int trig_ypos[NB_SCREENS];
|
||||
int trig_width[NB_SCREENS];
|
||||
int countdown_offset = 0;
|
||||
bool repeat_timer_start = false;
|
||||
unsigned int repeat_timer;
|
||||
|
||||
static const unsigned char *byte_units[] = {
|
||||
ID2P(LANG_BYTE),
|
||||
|
|
@ -804,6 +840,11 @@ bool recording_screen(bool no_source)
|
|||
struct audio_recording_options rec_options;
|
||||
|
||||
in_screen = true;
|
||||
|
||||
/* Stop countdown if countdown settings changed */
|
||||
if (!timer.countdown)
|
||||
tick_remove_task(timer_tick_task);
|
||||
|
||||
cursor = 0;
|
||||
#if (CONFIG_LED == LED_REAL) && !defined(SIMULATOR)
|
||||
ata_set_led_enabled(false);
|
||||
|
|
@ -937,6 +978,25 @@ bool recording_screen(bool no_source)
|
|||
last_audio_stat = audio_stat;
|
||||
}
|
||||
|
||||
/* repeat_timer is the repeat time in seconds */
|
||||
repeat_timer = (timer.mins_rpt * 60 + timer.hrs_rpt *
|
||||
3600 + timer.days_rpt * 3600 * 24);
|
||||
|
||||
/* decide on repeat timer status */
|
||||
if ((repeat_timer > rec_timesplit_seconds()) &&
|
||||
global_settings.rec_timesplit)
|
||||
timer.repeater = true;
|
||||
else
|
||||
timer.repeater = false;
|
||||
|
||||
/* When countdown timer reaches zero fake a new file button press */
|
||||
if (timer.countdown && !timer.days && !timer.hrs && !timer.mins &&
|
||||
!timer.secs)
|
||||
{
|
||||
tick_remove_task(timer_tick_task);
|
||||
button = ACTION_REC_NEWFILE;
|
||||
timer.countdown = false;
|
||||
}
|
||||
|
||||
if (recording_start_automatic)
|
||||
{
|
||||
|
|
@ -991,7 +1051,27 @@ bool recording_screen(bool no_source)
|
|||
case ACTION_REC_NEWFILE:
|
||||
/* Only act if the mpeg is stopped */
|
||||
if(!(audio_stat & AUDIO_STATUS_RECORD))
|
||||
{
|
||||
{ /* if countdown timer is set, start countdown */
|
||||
if (timer.days || timer.hrs || timer.mins || timer.secs)
|
||||
{
|
||||
if (button == ACTION_REC_PAUSE)
|
||||
{
|
||||
timer.countdown = !timer.countdown;
|
||||
if (timer.countdown)
|
||||
tick_add_task(timer_tick_task);
|
||||
else
|
||||
tick_remove_task(timer_tick_task);
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* if newfile button pressed and countdown timer is on,
|
||||
start new file and reset timer */
|
||||
tick_remove_task(timer_tick_task);
|
||||
timer.days = timer.hrs = timer.mins = timer.secs = 0;
|
||||
timer.countdown = false;
|
||||
}
|
||||
}
|
||||
/* is this manual or triggered recording? */
|
||||
if ((global_settings.rec_trigger_mode == TRIG_MODE_OFF) ||
|
||||
(peak_meter_trigger_status() != TRIG_OFF))
|
||||
|
|
@ -999,6 +1079,11 @@ bool recording_screen(bool no_source)
|
|||
/* manual recording */
|
||||
have_recorded = true;
|
||||
rec_record();
|
||||
repeat_timer_start = true; /* allow access to repeat timer
|
||||
code */
|
||||
/* amount of file that has been prerecorded - needed for
|
||||
syncing repeat timer */
|
||||
prerec = audio_recorded_time() / HZ;
|
||||
last_seconds = 0;
|
||||
if (talk_menu)
|
||||
{ /* no voice possible here, but a beep */
|
||||
|
|
@ -1197,7 +1282,6 @@ bool recording_screen(bool no_source)
|
|||
#ifdef HAVE_FMRADIO_IN
|
||||
const int prev_rec_source = global_settings.rec_source;
|
||||
#endif
|
||||
|
||||
#if (CONFIG_LED == LED_REAL)
|
||||
/* led is restored at begin of loop / end of function */
|
||||
led(false);
|
||||
|
|
@ -1221,6 +1305,10 @@ bool recording_screen(bool no_source)
|
|||
&& prev_rec_source == AUDIO_SRC_FMRADIO)
|
||||
radio_status = FMRADIO_OFF;
|
||||
#endif
|
||||
/* if countdown timer settings changed in menu,
|
||||
stop counting and reset */
|
||||
if (!timer.countdown)
|
||||
tick_remove_task(timer_tick_task);
|
||||
|
||||
#if CONFIG_CODEC == SWCODEC
|
||||
/* reinit after submenu exit */
|
||||
|
|
@ -1319,6 +1407,9 @@ bool recording_screen(bool no_source)
|
|||
break;
|
||||
} /* end switch */
|
||||
|
||||
/* display timer status in status bar if countdown enabled */
|
||||
timer.timer_display = timer.countdown;
|
||||
|
||||
#ifdef HAVE_AGC
|
||||
peak_read = !peak_read;
|
||||
if (peak_read) { /* every 2nd run of loop */
|
||||
|
|
@ -1369,11 +1460,13 @@ bool recording_screen(bool no_source)
|
|||
#endif /* CONFIG_CODEC == SWCODEC */
|
||||
if ((global_settings.rec_sizesplit) && (global_settings.rec_split_method))
|
||||
{
|
||||
countdown_offset = 1;
|
||||
dmb = dsize/1024/1024;
|
||||
snprintf(buf, sizeof(buf), "%s %dMB",
|
||||
str(LANG_SYSFONT_SPLIT_SIZE), dmb);
|
||||
}
|
||||
else
|
||||
/* only display recording time if countdown timer is off */
|
||||
else if (!timer.days && !timer.hrs && !timer.mins && !timer.secs)
|
||||
{
|
||||
hours = seconds / 3600;
|
||||
minutes = (seconds - (hours * 3600)) / 60;
|
||||
|
|
@ -1381,6 +1474,11 @@ bool recording_screen(bool no_source)
|
|||
str(LANG_SYSFONT_RECORDING_TIME),
|
||||
hours, minutes, seconds%60);
|
||||
}
|
||||
else
|
||||
{
|
||||
countdown_offset = 0;
|
||||
snprintf(buf, 32, "");
|
||||
}
|
||||
|
||||
for(i = 0; i < screen_update; i++)
|
||||
screens[i].puts(0, 0, buf);
|
||||
|
|
@ -1404,7 +1502,8 @@ bool recording_screen(bool no_source)
|
|||
str(LANG_SYSFONT_RECORD_TIMESPLIT_REC),
|
||||
dhours, dminutes);
|
||||
}
|
||||
else
|
||||
/* only display recording size if countdown timer is off */
|
||||
else if (!timer.days && !timer.hrs && !timer.mins && !timer.secs)
|
||||
{
|
||||
output_dyn_value(buf2, sizeof buf2,
|
||||
num_recorded_bytes,
|
||||
|
|
@ -1416,6 +1515,16 @@ bool recording_screen(bool no_source)
|
|||
for(i = 0; i < screen_update; i++)
|
||||
screens[i].puts(0, 1, buf);
|
||||
|
||||
/* display countdown timer if set */
|
||||
if (timer.days || timer.hrs || timer.mins || timer.secs)
|
||||
{
|
||||
snprintf(buf, 32, "%s %d:%02d:%02d:%02d", str(LANG_REC_TIMER),
|
||||
timer.days, timer.hrs, timer.mins, timer.secs);
|
||||
|
||||
for(i = 0; i < screen_update; i++)
|
||||
screens[i].puts(0, countdown_offset, buf);
|
||||
}
|
||||
|
||||
for(i = 0; i < screen_update; i++)
|
||||
{
|
||||
if (filename_offset[i] > 0)
|
||||
|
|
@ -1449,11 +1558,36 @@ bool recording_screen(bool no_source)
|
|||
rec_new_file();
|
||||
last_seconds = 0;
|
||||
}
|
||||
else
|
||||
else if (repeat_timer_start)
|
||||
{
|
||||
peak_meter_trigger(false);
|
||||
peak_meter_set_trigger_listener(NULL);
|
||||
audio_stop_recording();
|
||||
|
||||
/* stop any more attempts to access this code until a new
|
||||
recording is started */
|
||||
repeat_timer_start = false;
|
||||
|
||||
/* start repeat countdown if set and only if
|
||||
stop time < repeat time */
|
||||
if (timer.repeater)
|
||||
{
|
||||
repeat_timer -= dseconds;
|
||||
timer.days = repeat_timer / (3600 * 24);
|
||||
timer.hrs = (repeat_timer - (timer.days * 3600 * 24)) /
|
||||
3600;
|
||||
timer.mins = (repeat_timer - (timer.hrs * 3600)) / 60;
|
||||
timer.secs = prerec; /* add prerecorded time to timer */
|
||||
|
||||
/* This is not really a toggle so much as a safety feature
|
||||
so that it is impossible to start the timer more than
|
||||
once */
|
||||
timer.countdown = !timer.countdown;
|
||||
if (timer.countdown)
|
||||
tick_add_task(timer_tick_task);
|
||||
else
|
||||
tick_remove_task(timer_tick_task);
|
||||
}
|
||||
}
|
||||
update_countdown = 1;
|
||||
}
|
||||
|
|
@ -2035,6 +2169,12 @@ static bool f3_rec_screen(void)
|
|||
}
|
||||
#endif /* CONFIG_KEYPAD == RECORDER_PAD */
|
||||
|
||||
struct timer *get_timerstat(void)
|
||||
{
|
||||
return &timer;
|
||||
}
|
||||
|
||||
|
||||
#if CONFIG_CODEC == SWCODEC
|
||||
void audio_beep(int duration)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -25,6 +25,22 @@ bool recording_screen(bool no_source);
|
|||
char *rec_create_filename(char *buf);
|
||||
int rec_create_directory(void);
|
||||
|
||||
struct timer
|
||||
{
|
||||
bool countdown;
|
||||
bool timer_display;
|
||||
unsigned int days;
|
||||
unsigned int hrs;
|
||||
unsigned int mins;
|
||||
unsigned int secs;
|
||||
unsigned int days_rpt;
|
||||
unsigned int hrs_rpt;
|
||||
unsigned int mins_rpt;
|
||||
bool repeater;
|
||||
};
|
||||
|
||||
struct timer *get_timerstat(void);
|
||||
|
||||
/* If true, start recording automatically when recording_sreen() is entered */
|
||||
extern bool recording_start_automatic;
|
||||
|
||||
|
|
@ -33,6 +49,7 @@ extern bool recording_start_automatic;
|
|||
void rec_set_source(int source, unsigned flags);
|
||||
#endif /* CONFIG_CODEC == SW_CODEC */
|
||||
|
||||
struct audio_recording_options;
|
||||
/* Initializes a recording_options structure with global settings.
|
||||
pass returned data to audio_set_recording_options or
|
||||
rec_set_recording_options */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue