summaryrefslogtreecommitdiff
path: root/apps/recorder/recording.c
diff options
context:
space:
mode:
authorMartin Scarratt <mmmm@rockbox.org>2006-09-18 10:06:03 +0000
committerMartin Scarratt <mmmm@rockbox.org>2006-09-18 10:06:03 +0000
commit7ef47ed87614d6100b491b2c0eb9f75d1fdc1f01 (patch)
tree6367eca3de5fcb0bbe165026b5658ef391b62fb7 /apps/recorder/recording.c
parent28546a6530f97a9f58937731ad477246a6baaa32 (diff)
downloadrockbox-7ef47ed87614d6100b491b2c0eb9f75d1fdc1f01.tar.gz
rockbox-7ef47ed87614d6100b491b2c0eb9f75d1fdc1f01.zip
Recording countdown timer: set timer in recording settings screen (max 1 week countdown), start/pause timer in recording screen by pressing the pause button. If you have a separate record button then this will override the timer and start to record. Icon at bottom right of screen indicates timer is ticking. If you are in the recording screen when the countdown is over, recording will start automatically, if not then the icon will flash to indicate you should return to the recording screen to begin recording.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@10990 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/recorder/recording.c')
-rw-r--r--apps/recorder/recording.c173
1 files changed, 168 insertions, 5 deletions
diff --git a/apps/recorder/recording.c b/apps/recorder/recording.c
index 6ee71d2eee..4d0e226254 100644
--- a/apps/recorder/recording.c
+++ b/apps/recorder/recording.c
@@ -69,8 +69,18 @@
69#include "screen_access.h" 69#include "screen_access.h"
70#include "action.h" 70#include "action.h"
71#include "radio.h" 71#include "radio.h"
72#include "timer.h"
72#ifdef HAVE_RECORDING 73#ifdef HAVE_RECORDING
73 74
75#ifdef SIMULATOR
76bool timer_register(int reg_prio, void (*unregister_callback)(void),
77 long cycles, int int_prio, void (*timer_callback)(void));
78void timer_unregister(void);
79#define TIMER_FREQ 0
80#endif
81#define TIMER_ICON_WIDTH 7
82#define TIMER_ICON_HEIGHT 7
83
74#define PM_HEIGHT ((LCD_HEIGHT >= 72) ? 2 : 1) 84#define PM_HEIGHT ((LCD_HEIGHT >= 72) ? 2 : 1)
75 85
76bool f2_rec_screen(void); 86bool f2_rec_screen(void);
@@ -78,6 +88,9 @@ bool f3_rec_screen(void);
78 88
79#define MAX_FILE_SIZE 0x7F800000 /* 2 GB - 4 MB */ 89#define MAX_FILE_SIZE 0x7F800000 /* 2 GB - 4 MB */
80 90
91int days, hrs, mins, secs;
92bool timer_icon; /* timer icon displayed? */
93
81int screen_update = NB_SCREENS; 94int screen_update = NB_SCREENS;
82bool remote_display_on = true; 95bool remote_display_on = true;
83const char* const freq_str[6] = 96const char* const freq_str[6] =
@@ -779,6 +792,52 @@ static void trigger_listener(int trigger_status)
779 } 792 }
780} 793}
781 794
795/* countdown timer callback function */
796void timer_callback(void)
797{
798 static int mini_tick = 0;
799 /* print icon at bottom right of main screen */
800 if (timer_icon)
801 screens[0].mono_bitmap(bitmap_icons_7x7[Icon_Timer],
802 screens[0].width - TIMER_ICON_WIDTH,
803 screens[0].height - TIMER_ICON_HEIGHT,
804 TIMER_ICON_WIDTH, TIMER_ICON_HEIGHT);
805 else
806 screens[0].mono_bitmap(bitmap_icons_7x7[Icon_Blank],
807 screens[0].width - TIMER_ICON_WIDTH,
808 screens[0].height - TIMER_ICON_HEIGHT,
809 TIMER_ICON_WIDTH, TIMER_ICON_HEIGHT);
810
811 screens[0].update_rect(screens[0].width - TIMER_ICON_WIDTH,
812 screens[0].height - TIMER_ICON_HEIGHT,
813 TIMER_ICON_WIDTH, TIMER_ICON_HEIGHT);
814
815 mini_tick ++;
816 /* the countdown */
817 if (mini_tick > 10)
818 {
819 secs -= 1;
820 if (secs < 0){
821 mins -= 1;
822 secs = 59;
823 if (mins < 0){
824 hrs -= 1;
825 mins = 59;
826 if (hrs < 0){
827 days -= 1;
828 hrs = 23;
829 if (days < 0)
830 {
831 days = hrs = mins = secs = 0;
832 timer_icon = !timer_icon; /* flash icon when */
833 } /* countdown finished */
834 }
835 }
836 }
837 mini_tick = 0;
838 }
839}
840
782bool recording_screen(bool no_source) 841bool recording_screen(bool no_source)
783{ 842{
784 long button; 843 long button;
@@ -818,6 +877,8 @@ bool recording_screen(bool no_source)
818 int i; 877 int i;
819 int filename_offset[NB_SCREENS]; 878 int filename_offset[NB_SCREENS];
820 int pm_y[NB_SCREENS]; 879 int pm_y[NB_SCREENS];
880 static bool countdown; /* countdown in progress indicator */
881 int countdown_offset = 0;
821 882
822 static const unsigned char *byte_units[] = { 883 static const unsigned char *byte_units[] = {
823 ID2P(LANG_BYTE), 884 ID2P(LANG_BYTE),
@@ -827,6 +888,20 @@ bool recording_screen(bool no_source)
827 }; 888 };
828 889
829 global_settings.recscreen_on = true; 890 global_settings.recscreen_on = true;
891
892 /* Stop countdown if countdown settings changed */
893 if ((mins != global_settings.ctdn_mins)||
894 (hrs != global_settings.ctdn_hrs) ||
895 (days != global_settings.ctdn_days))
896 {
897 mins = global_settings.ctdn_mins;
898 hrs = global_settings.ctdn_hrs;
899 days = global_settings.ctdn_days;
900 secs = global_settings.ctdn_secs;
901 countdown = false;
902 timer_unregister();
903 }
904
830 cursor = 0; 905 cursor = 0;
831#if (CONFIG_LED == LED_REAL) && !defined(SIMULATOR) 906#if (CONFIG_LED == LED_REAL) && !defined(SIMULATOR)
832 ata_set_led_enabled(false); 907 ata_set_led_enabled(false);
@@ -969,6 +1044,17 @@ bool recording_screen(bool no_source)
969 last_audio_stat = audio_stat; 1044 last_audio_stat = audio_stat;
970 } 1045 }
971 1046
1047 /* When countdown timer reaches zero fake a new file button press */
1048 if (countdown && !days && !hrs && !mins && !secs)
1049 {
1050 timer_unregister();
1051 button = ACTION_REC_NEWFILE;
1052 countdown = false;
1053 global_settings.ctdn_days = days;
1054 global_settings.ctdn_hrs = hrs;
1055 global_settings.ctdn_mins = mins;
1056 }
1057
972 switch(button) 1058 switch(button)
973 { 1059 {
974 case ACTION_REC_LCD: 1060 case ACTION_REC_LCD:
@@ -1004,7 +1090,12 @@ bool recording_screen(bool no_source)
1004#if CONFIG_CODEC != SWCODEC 1090#if CONFIG_CODEC != SWCODEC
1005 peak_meter_playback(true); 1091 peak_meter_playback(true);
1006 peak_meter_enabled = false; 1092 peak_meter_enabled = false;
1007#endif 1093#endif
1094 /* keeps settings the same as the countdown values */
1095 global_settings.ctdn_days = days;
1096 global_settings.ctdn_hrs = hrs;
1097 global_settings.ctdn_mins = mins;
1098 global_settings.ctdn_secs = secs;
1008 done = true; 1099 done = true;
1009 } 1100 }
1010 update_countdown = 1; /* Update immediately */ 1101 update_countdown = 1; /* Update immediately */
@@ -1014,7 +1105,27 @@ bool recording_screen(bool no_source)
1014 case ACTION_REC_NEWFILE: 1105 case ACTION_REC_NEWFILE:
1015 /* Only act if the mpeg is stopped */ 1106 /* Only act if the mpeg is stopped */
1016 if(!(audio_stat & AUDIO_STATUS_RECORD)) 1107 if(!(audio_stat & AUDIO_STATUS_RECORD))
1017 { 1108 { /* if countdown timer is set, start countdown */
1109 if (days || hrs || mins || secs)
1110 {
1111 if (button == ACTION_REC_PAUSE)
1112 {
1113 countdown = !countdown;
1114 if (countdown)
1115 timer_register(1, NULL, TIMER_FREQ/10, 1, timer_callback);
1116 else
1117 timer_unregister();
1118 break;
1119 }
1120 else
1121 {
1122 /* if newfile button pressed and countdown timer is on,
1123 start new file and reset timer */
1124 timer_unregister();
1125 days = hrs = mins = secs = 0;
1126 countdown = false;
1127 }
1128 }
1018 /* is this manual or triggered recording? */ 1129 /* is this manual or triggered recording? */
1019 if ((global_settings.rec_trigger_mode == TRIG_MODE_OFF) || 1130 if ((global_settings.rec_trigger_mode == TRIG_MODE_OFF) ||
1020 (peak_meter_trigger_status() != TRIG_OFF)) 1131 (peak_meter_trigger_status() != TRIG_OFF))
@@ -1221,7 +1332,11 @@ bool recording_screen(bool no_source)
1221#ifdef HAVE_FMRADIO_IN 1332#ifdef HAVE_FMRADIO_IN
1222 const int prev_rec_source = global_settings.rec_source; 1333 const int prev_rec_source = global_settings.rec_source;
1223#endif 1334#endif
1224 1335 /* maintain countdown values when entering menu */
1336 global_settings.ctdn_days = days;
1337 global_settings.ctdn_hrs = hrs;
1338 global_settings.ctdn_mins = mins;
1339 global_settings.ctdn_secs = secs;
1225#if CONFIG_LED == LED_REAL 1340#if CONFIG_LED == LED_REAL
1226 /* led is restored at begin of loop / end of function */ 1341 /* led is restored at begin of loop / end of function */
1227 led(false); 1342 led(false);
@@ -1245,6 +1360,19 @@ bool recording_screen(bool no_source)
1245 && prev_rec_source == AUDIO_SRC_FMRADIO) 1360 && prev_rec_source == AUDIO_SRC_FMRADIO)
1246 radio_status = FMRADIO_OFF; 1361 radio_status = FMRADIO_OFF;
1247#endif 1362#endif
1363 /* if countdown timer settings changed in menu,
1364 stop counting and reset */
1365 if ((hrs != global_settings.ctdn_hrs) ||
1366 (mins != global_settings.ctdn_mins) ||
1367 (days != global_settings.ctdn_days))
1368 {
1369 days = global_settings.ctdn_days;
1370 hrs = global_settings.ctdn_hrs;
1371 mins = global_settings.ctdn_mins;
1372 secs = global_settings.ctdn_secs;
1373 countdown = false;
1374 timer_unregister();
1375 }
1248 1376
1249#if CONFIG_CODEC == SWCODEC 1377#if CONFIG_CODEC == SWCODEC
1250 /* reinit after submenu exit */ 1378 /* reinit after submenu exit */
@@ -1347,6 +1475,8 @@ bool recording_screen(bool no_source)
1347 break; 1475 break;
1348 } 1476 }
1349 1477
1478 timer_icon = countdown; /* display timer icon if countdown enabled */
1479
1350#ifdef HAVE_AGC 1480#ifdef HAVE_AGC
1351 peak_read = !peak_read; 1481 peak_read = !peak_read;
1352 if (peak_read) { /* every 2nd run of loop */ 1482 if (peak_read) { /* every 2nd run of loop */
@@ -1383,11 +1513,13 @@ bool recording_screen(bool no_source)
1383 1513
1384 if ((global_settings.rec_sizesplit) && (global_settings.rec_split_method)) 1514 if ((global_settings.rec_sizesplit) && (global_settings.rec_split_method))
1385 { 1515 {
1516 countdown_offset = 1;
1386 dmb = dsize/1024/1024; 1517 dmb = dsize/1024/1024;
1387 snprintf(buf, sizeof(buf), "%s %dMB", 1518 snprintf(buf, sizeof(buf), "%s %dMB",
1388 str(LANG_SYSFONT_SPLIT_SIZE), dmb); 1519 str(LANG_SYSFONT_SPLIT_SIZE), dmb);
1389 } 1520 }
1390 else 1521 /* only display recording time if countdown timer is off */
1522 else if (!days && !hrs && !mins && !secs)
1391 { 1523 {
1392 hours = seconds / 3600; 1524 hours = seconds / 3600;
1393 minutes = (seconds - (hours * 3600)) / 60; 1525 minutes = (seconds - (hours * 3600)) / 60;
@@ -1395,6 +1527,11 @@ bool recording_screen(bool no_source)
1395 str(LANG_SYSFONT_RECORDING_TIME), 1527 str(LANG_SYSFONT_RECORDING_TIME),
1396 hours, minutes, seconds%60); 1528 hours, minutes, seconds%60);
1397 } 1529 }
1530 else
1531 {
1532 countdown_offset = 0;
1533 snprintf(buf, 32, "");
1534 }
1398 1535
1399 for(i = 0; i < screen_update; i++) 1536 for(i = 0; i < screen_update; i++)
1400 screens[i].puts(0, 0, buf); 1537 screens[i].puts(0, 0, buf);
@@ -1418,7 +1555,8 @@ bool recording_screen(bool no_source)
1418 str(LANG_SYSFONT_RECORD_TIMESPLIT_REC), 1555 str(LANG_SYSFONT_RECORD_TIMESPLIT_REC),
1419 dhours, dminutes); 1556 dhours, dminutes);
1420 } 1557 }
1421 else 1558 /* only display recording size if countdown timer is off */
1559 else if (!days && !hrs && !mins && !secs)
1422 { 1560 {
1423 output_dyn_value(buf2, sizeof buf2, 1561 output_dyn_value(buf2, sizeof buf2,
1424 num_recorded_bytes, 1562 num_recorded_bytes,
@@ -1430,6 +1568,16 @@ bool recording_screen(bool no_source)
1430 for(i = 0; i < screen_update; i++) 1568 for(i = 0; i < screen_update; i++)
1431 screens[i].puts(0, 1, buf); 1569 screens[i].puts(0, 1, buf);
1432 1570
1571 /* display countdown timer if set */
1572 if (days || hrs || mins || secs)
1573 {
1574 snprintf(buf, 32, "%s %d:%02d:%02d:%02d", str(LANG_REC_TIMER),
1575 days, hrs, mins, secs);
1576
1577 for(i = 0; i < screen_update; i++)
1578 screens[i].puts(0, countdown_offset, buf);
1579 }
1580
1433 for(i = 0; i < screen_update; i++) 1581 for(i = 0; i < screen_update; i++)
1434 { 1582 {
1435 if (filename_offset[i] > 0) 1583 if (filename_offset[i] > 0)
@@ -2123,6 +2271,21 @@ unsigned long pcm_rec_status(void)
2123 2271
2124#endif /* #ifdef SIMULATOR */ 2272#endif /* #ifdef SIMULATOR */
2125#endif /* #ifdef CONFIG_CODEC == SWCODEC */ 2273#endif /* #ifdef CONFIG_CODEC == SWCODEC */
2274#ifdef SIMULATOR
2275bool timer_register(int reg_prio, void (*unregister_callback)(void),
2276 long cycles, int int_prio, void (*timer_callback)(void))
2277{
2278 reg_prio = reg_prio;
2279 unregister_callback = unregister_callback;
2280 cycles = cycles;
2281 int_prio = int_prio;
2282 timer_callback = timer_callback;
2283 return false;
2284}
2126 2285
2286void timer_unregister(void)
2287{
2288}
2289#endif
2127 2290
2128#endif /* HAVE_RECORDING */ 2291#endif /* HAVE_RECORDING */