diff options
author | Martin Scarratt <mmmm@rockbox.org> | 2006-11-09 12:27:56 +0000 |
---|---|---|
committer | Martin Scarratt <mmmm@rockbox.org> | 2006-11-09 12:27:56 +0000 |
commit | d8103f3ba691adaeb83f8844e32b827c2c564d24 (patch) | |
tree | 06144354862a2ca70287b4a70738a30a53381684 | |
parent | ad70a9b2e602f41d7608d3c3ca58fc897c8c39b8 (diff) | |
download | rockbox-d8103f3ba691adaeb83f8844e32b827c2c564d24.tar.gz rockbox-d8103f3ba691adaeb83f8844e32b827c2c564d24.zip |
Recording trigger for software codec targets
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@11479 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | apps/lang/english.lang | 52 | ||||
-rw-r--r-- | apps/recorder/peakmeter.c | 104 | ||||
-rw-r--r-- | apps/recorder/peakmeter.h | 8 | ||||
-rw-r--r-- | apps/recorder/recording.c | 64 | ||||
-rw-r--r-- | apps/settings.c | 3 | ||||
-rw-r--r-- | apps/settings.h | 1 | ||||
-rw-r--r-- | apps/sound_menu.c | 188 |
7 files changed, 310 insertions, 110 deletions
diff --git a/apps/lang/english.lang b/apps/lang/english.lang index 8f7deb78a9..0fce21ec08 100644 --- a/apps/lang/english.lang +++ b/apps/lang/english.lang | |||
@@ -10144,3 +10144,55 @@ | |||
10144 | *: "Bitrate" | 10144 | *: "Bitrate" |
10145 | </voice> | 10145 | </voice> |
10146 | </phrase> | 10146 | </phrase> |
10147 | <phrase> | ||
10148 | id: LANG_RECORD_TRIGGER_TYPE | ||
10149 | desc: in recording trigger menu | ||
10150 | <source> | ||
10151 | *: "Trigtype" | ||
10152 | </source> | ||
10153 | <dest> | ||
10154 | *: "Trigtype" | ||
10155 | </dest> | ||
10156 | <voice> | ||
10157 | *: "Trigtype" | ||
10158 | </voice> | ||
10159 | </phrase> | ||
10160 | <phrase> | ||
10161 | id: LANG_RECORD_TRIGGER_STOP | ||
10162 | desc: trigger types | ||
10163 | <source> | ||
10164 | *: "Stop" | ||
10165 | </source> | ||
10166 | <dest> | ||
10167 | *: "Stop" | ||
10168 | </dest> | ||
10169 | <voice> | ||
10170 | *: "Stop" | ||
10171 | </voice> | ||
10172 | </phrase> | ||
10173 | <phrase> | ||
10174 | id: LANG_RECORD_TRIGGER_PAUSE | ||
10175 | desc: trigger types | ||
10176 | <source> | ||
10177 | *: "Pause" | ||
10178 | </source> | ||
10179 | <dest> | ||
10180 | *: "Pause" | ||
10181 | </dest> | ||
10182 | <voice> | ||
10183 | *: "Pause" | ||
10184 | </voice> | ||
10185 | </phrase> | ||
10186 | <phrase> | ||
10187 | id: LANG_RECORD_TRIGGER_NEWFILESTP | ||
10188 | desc: trigger types | ||
10189 | <source> | ||
10190 | *: "New file" | ||
10191 | </source> | ||
10192 | <dest> | ||
10193 | *: "New file" | ||
10194 | </dest> | ||
10195 | <voice> | ||
10196 | *: "New file" | ||
10197 | </voice> | ||
10198 | </phrase> | ||
diff --git a/apps/recorder/peakmeter.c b/apps/recorder/peakmeter.c index 44be43124a..1033ffee67 100644 --- a/apps/recorder/peakmeter.c +++ b/apps/recorder/peakmeter.c | |||
@@ -23,7 +23,7 @@ | |||
23 | #include "settings.h" | 23 | #include "settings.h" |
24 | #include "ata.h" | 24 | #include "ata.h" |
25 | #include "lcd.h" | 25 | #include "lcd.h" |
26 | #include "widgets.h" | 26 | #include "scrollbar.h" |
27 | #include "gwps.h" | 27 | #include "gwps.h" |
28 | #include "sprintf.h" | 28 | #include "sprintf.h" |
29 | #include "button.h" | 29 | #include "button.h" |
@@ -593,25 +593,33 @@ void peak_meter_peek(void) | |||
593 | pm_max_right = MAX(pm_max_right, right); | 593 | pm_max_right = MAX(pm_max_right, right); |
594 | 594 | ||
595 | #ifdef HAVE_RECORDING | 595 | #ifdef HAVE_RECORDING |
596 | #if CONFIG_CODEC == SWCODEC | ||
597 | /* Ignore any unread peakmeter data */ | ||
598 | #define MAX_DROP_TIME HZ/7 /* this value may need tweaking. Increase if you are | ||
599 | getting trig events when you shouldn't with | ||
600 | trig_stp_hold = 0 */ | ||
601 | if (!trig_stp_hold) | ||
602 | trig_stp_hold = MAX_DROP_TIME; | ||
603 | #endif | ||
604 | |||
596 | switch (trig_status) { | 605 | switch (trig_status) { |
597 | case TRIG_READY: | 606 | case TRIG_READY: |
598 | /* no more changes, if trigger was activated as release trigger */ | 607 | /* no more changes, if trigger was activated as release trigger */ |
599 | /* threshold exceeded? */ | 608 | /* threshold exceeded? */ |
600 | if ((left > trig_strt_threshold) | 609 | if ((left > trig_strt_threshold) |
601 | || (right > trig_strt_threshold)) { | 610 | || (right > trig_strt_threshold)) { |
602 | if (trig_strt_duration) { | ||
603 | /* reset trigger duration */ | 611 | /* reset trigger duration */ |
604 | trig_hightime = current_tick; | 612 | trig_hightime = current_tick; |
605 | 613 | ||
606 | /* reset dropout duration */ | 614 | /* reset dropout duration */ |
607 | trig_lowtime = current_tick; | 615 | trig_lowtime = current_tick; |
608 | 616 | ||
617 | if (trig_strt_duration) | ||
618 | set_trig_status(TRIG_STEADY); | ||
619 | else | ||
609 | /* if trig_duration is set to 0 the user wants to start | 620 | /* if trig_duration is set to 0 the user wants to start |
610 | recording immediately */ | 621 | recording immediately */ |
611 | set_trig_status(TRIG_STEADY); | ||
612 | } else { | ||
613 | set_trig_status(TRIG_GO); | 622 | set_trig_status(TRIG_GO); |
614 | } | ||
615 | } | 623 | } |
616 | break; | 624 | break; |
617 | 625 | ||
@@ -652,7 +660,11 @@ void peak_meter_peek(void) | |||
652 | || (right > trig_stp_threshold)) { | 660 | || (right > trig_stp_threshold)) { |
653 | /* restart hold time countdown */ | 661 | /* restart hold time countdown */ |
654 | trig_lowtime = current_tick; | 662 | trig_lowtime = current_tick; |
663 | #if CONFIG_CODEC == SWCODEC | ||
664 | } else if (current_tick - trig_lowtime > MAX_DROP_TIME){ | ||
665 | #else | ||
655 | } else { | 666 | } else { |
667 | #endif | ||
656 | set_trig_status(TRIG_POSTREC); | 668 | set_trig_status(TRIG_POSTREC); |
657 | trig_hightime = current_tick; | 669 | trig_hightime = current_tick; |
658 | } | 670 | } |
@@ -667,6 +679,7 @@ void peak_meter_peek(void) | |||
667 | 679 | ||
668 | set_trig_status(TRIG_RETRIG); | 680 | set_trig_status(TRIG_RETRIG); |
669 | trig_hightime = current_tick; | 681 | trig_hightime = current_tick; |
682 | trig_lowtime = current_tick; | ||
670 | } | 683 | } |
671 | else | 684 | else |
672 | 685 | ||
@@ -709,6 +722,11 @@ void peak_meter_peek(void) | |||
709 | } | 722 | } |
710 | break; | 723 | break; |
711 | } | 724 | } |
725 | #if CONFIG_CODEC == SWCODEC | ||
726 | /* restore stop hold value */ | ||
727 | if (trig_stp_hold == MAX_DROP_TIME) | ||
728 | trig_stp_hold = 0; | ||
729 | #endif | ||
712 | #endif | 730 | #endif |
713 | /* check levels next time peakmeter drawn */ | 731 | /* check levels next time peakmeter drawn */ |
714 | level_check = true; | 732 | level_check = true; |
@@ -1153,55 +1171,81 @@ int peak_meter_trigger_status(void) | |||
1153 | return trig_status; /* & TRIG_PIT_MASK;*/ | 1171 | return trig_status; /* & TRIG_PIT_MASK;*/ |
1154 | } | 1172 | } |
1155 | 1173 | ||
1156 | void peak_meter_draw_trig(int xpos, int ypos) | 1174 | void peak_meter_draw_trig(int xpos[], int ypos[], int trig_width[], int nb_screens) |
1157 | { | 1175 | { |
1158 | int barstart, barend; | 1176 | int barstart[NB_SCREENS]; |
1159 | int icon, ixpos; | 1177 | int barend[NB_SCREENS]; |
1178 | int icon; | ||
1179 | int ixpos[NB_SCREENS]; | ||
1160 | int i; | 1180 | int i; |
1181 | int trigbar_width[NB_SCREENS]; | ||
1182 | |||
1183 | FOR_NB_SCREENS(i) | ||
1184 | trigbar_width[i] = (trig_width[i] - (2 * (ICON_PLAY_STATE_WIDTH + 1))); | ||
1185 | |||
1161 | switch (trig_status) { | 1186 | switch (trig_status) { |
1162 | 1187 | ||
1163 | case TRIG_READY: | 1188 | case TRIG_READY: |
1164 | barstart = 0; | 1189 | FOR_NB_SCREENS(i){ |
1165 | barend = 0; | 1190 | barstart[i] = 0; |
1191 | barend[i] = 0; | ||
1192 | } | ||
1166 | icon = Icon_Stop; | 1193 | icon = Icon_Stop; |
1167 | ixpos = xpos; | 1194 | FOR_NB_SCREENS(i) |
1195 | ixpos[i] = xpos[i]; | ||
1168 | break; | 1196 | break; |
1169 | 1197 | ||
1170 | case TRIG_STEADY: | 1198 | case TRIG_STEADY: |
1171 | case TRIG_RETRIG: | 1199 | case TRIG_RETRIG: |
1172 | barstart = 0; | 1200 | FOR_NB_SCREENS(i) |
1173 | barend = TRIGBAR_WIDTH * (current_tick - trig_hightime) | 1201 | { |
1174 | / trig_strt_duration; | 1202 | barstart[i] = 0; |
1203 | barend[i] = (trig_strt_duration == 0) ? trigbar_width[i] : | ||
1204 | trigbar_width[i] * | ||
1205 | (current_tick - trig_hightime) / trig_strt_duration; | ||
1206 | } | ||
1175 | icon = Icon_Stop; | 1207 | icon = Icon_Stop; |
1176 | ixpos = xpos; | 1208 | FOR_NB_SCREENS(i) |
1209 | ixpos[i] = xpos[i]; | ||
1177 | break; | 1210 | break; |
1178 | 1211 | ||
1179 | case TRIG_GO: | 1212 | case TRIG_GO: |
1180 | case TRIG_CONTINUE: | 1213 | case TRIG_CONTINUE: |
1181 | barstart = TRIGBAR_WIDTH; | 1214 | FOR_NB_SCREENS(i) |
1182 | barend = TRIGBAR_WIDTH; | 1215 | { |
1216 | barstart[i] = trigbar_width[i]; | ||
1217 | barend[i] = trigbar_width[i]; | ||
1218 | } | ||
1183 | icon = Icon_Record; | 1219 | icon = Icon_Record; |
1184 | ixpos = TRIG_WIDTH - ICON_PLAY_STATE_WIDTH; | 1220 | FOR_NB_SCREENS(i) |
1221 | ixpos[i] = xpos[i]+ trig_width[i] - ICON_PLAY_STATE_WIDTH; | ||
1185 | break; | 1222 | break; |
1186 | 1223 | ||
1187 | case TRIG_POSTREC: | 1224 | case TRIG_POSTREC: |
1188 | barstart = TRIGBAR_WIDTH | 1225 | FOR_NB_SCREENS(i) |
1189 | - TRIGBAR_WIDTH * (current_tick - trig_lowtime) | 1226 | { |
1190 | / trig_stp_hold; | 1227 | barstart[i] = (trig_stp_hold == 0) ? 0 : |
1191 | barend = TRIGBAR_WIDTH; | 1228 | trigbar_width[i] - trigbar_width[i] * |
1229 | (current_tick - trig_lowtime) / trig_stp_hold; | ||
1230 | barend[i] = trigbar_width[i]; | ||
1231 | } | ||
1192 | icon = Icon_Record; | 1232 | icon = Icon_Record; |
1193 | ixpos = TRIG_WIDTH - ICON_PLAY_STATE_WIDTH; | 1233 | FOR_NB_SCREENS(i) |
1234 | ixpos[i] = xpos[i] + trig_width[i] - ICON_PLAY_STATE_WIDTH; | ||
1194 | break; | 1235 | break; |
1195 | 1236 | ||
1196 | default: | 1237 | default: |
1197 | return; | 1238 | return; |
1198 | } | 1239 | } |
1199 | scrollbar(xpos + ICON_PLAY_STATE_WIDTH + 1, ypos + 1, | 1240 | |
1200 | TRIGBAR_WIDTH, TRIG_HEIGHT - 2, | 1241 | for(i = 0; i < nb_screens; i++) |
1201 | TRIGBAR_WIDTH, barstart, barend, HORIZONTAL); | ||
1202 | FOR_NB_SCREENS(i) | ||
1203 | { | 1242 | { |
1204 | screens[i].mono_bitmap(bitmap_icons_7x8[icon], ixpos, ypos, | 1243 | gui_scrollbar_draw(&screens[i], xpos[i] + ICON_PLAY_STATE_WIDTH + 1, |
1244 | ypos[i] + 1, trigbar_width[i], TRIG_HEIGHT - 2, | ||
1245 | trigbar_width[i], barstart[i], barend[i], | ||
1246 | HORIZONTAL); | ||
1247 | |||
1248 | screens[i].mono_bitmap(bitmap_icons_7x8[icon], ixpos[i], ypos[i], | ||
1205 | ICON_PLAY_STATE_WIDTH, STATUSBAR_HEIGHT); | 1249 | ICON_PLAY_STATE_WIDTH, STATUSBAR_HEIGHT); |
1206 | } | 1250 | } |
1207 | } | 1251 | } |
diff --git a/apps/recorder/peakmeter.h b/apps/recorder/peakmeter.h index 548b95b7da..a521f975fa 100644 --- a/apps/recorder/peakmeter.h +++ b/apps/recorder/peakmeter.h | |||
@@ -69,14 +69,10 @@ extern void peak_meter_trigger(bool on); | |||
69 | extern int peak_meter_trigger_status(void); | 69 | extern int peak_meter_trigger_status(void); |
70 | extern void peak_meter_set_trigger_listener(void (*listener)(int status)); | 70 | extern void peak_meter_set_trigger_listener(void (*listener)(int status)); |
71 | 71 | ||
72 | //#define TRIG_WIDTH 12 | ||
73 | //#define TRIG_HEIGHT 14 | ||
74 | |||
75 | #define TRIG_WIDTH 112 | ||
76 | #define TRIG_HEIGHT 8 | 72 | #define TRIG_HEIGHT 8 |
77 | #define TRIGBAR_WIDTH (TRIG_WIDTH - (2 * (ICON_PLAY_STATE_WIDTH + 1))) | ||
78 | 73 | ||
79 | extern void peak_meter_draw_trig(int x, int y); | 74 | extern void peak_meter_draw_trig(int x[], int y[], int trig_width[], |
75 | int nb_screens); | ||
80 | 76 | ||
81 | extern unsigned short peak_meter_range_min; | 77 | extern unsigned short peak_meter_range_min; |
82 | extern unsigned short peak_meter_range_max; | 78 | extern unsigned short peak_meter_range_max; |
diff --git a/apps/recorder/recording.c b/apps/recorder/recording.c index 6a053cd12e..d38856db23 100644 --- a/apps/recorder/recording.c +++ b/apps/recorder/recording.c | |||
@@ -801,9 +801,16 @@ static void trigger_listener(int trigger_status) | |||
801 | /* if we're already recording this is a retrigger */ | 801 | /* if we're already recording this is a retrigger */ |
802 | else | 802 | else |
803 | { | 803 | { |
804 | rec_new_file(); | 804 | if((audio_status() & AUDIO_STATUS_PAUSE) && |
805 | /* tell recording_screen to reset the time */ | 805 | (global_settings.rec_trigger_type == 1)) |
806 | last_seconds = 0; | 806 | audio_resume_recording(); |
807 | /* New file on trig start*/ | ||
808 | else if (global_settings.rec_trigger_type != 2) | ||
809 | { | ||
810 | rec_new_file(); | ||
811 | /* tell recording_screen to reset the time */ | ||
812 | last_seconds = 0; | ||
813 | } | ||
807 | } | 814 | } |
808 | break; | 815 | break; |
809 | 816 | ||
@@ -811,7 +818,27 @@ static void trigger_listener(int trigger_status) | |||
811 | case TRIG_READY: | 818 | case TRIG_READY: |
812 | if(audio_status() & AUDIO_STATUS_RECORD) | 819 | if(audio_status() & AUDIO_STATUS_RECORD) |
813 | { | 820 | { |
814 | audio_stop(); | 821 | switch(global_settings.rec_trigger_type) |
822 | { | ||
823 | case 0: /* Stop */ | ||
824 | #if CONFIG_CODEC == SWCODEC | ||
825 | audio_stop_recording(); | ||
826 | #else | ||
827 | audio_stop(); | ||
828 | #endif | ||
829 | break; | ||
830 | |||
831 | case 1: /* Pause */ | ||
832 | audio_pause_recording(); | ||
833 | break; | ||
834 | |||
835 | case 2: /* New file on trig stop*/ | ||
836 | rec_new_file(); | ||
837 | /* tell recording_screen to reset the time */ | ||
838 | last_seconds = 0; | ||
839 | break; | ||
840 | } | ||
841 | |||
815 | if (global_settings.rec_trigger_mode != TRIG_MODE_REARM) | 842 | if (global_settings.rec_trigger_mode != TRIG_MODE_REARM) |
816 | { | 843 | { |
817 | peak_meter_set_trigger_listener(NULL); | 844 | peak_meter_set_trigger_listener(NULL); |
@@ -861,6 +888,9 @@ bool recording_screen(bool no_source) | |||
861 | int i; | 888 | int i; |
862 | int filename_offset[NB_SCREENS]; | 889 | int filename_offset[NB_SCREENS]; |
863 | int pm_y[NB_SCREENS]; | 890 | int pm_y[NB_SCREENS]; |
891 | int trig_xpos[NB_SCREENS]; | ||
892 | int trig_ypos[NB_SCREENS]; | ||
893 | int trig_width[NB_SCREENS]; | ||
864 | 894 | ||
865 | static const unsigned char *byte_units[] = { | 895 | static const unsigned char *byte_units[] = { |
866 | ID2P(LANG_BYTE), | 896 | ID2P(LANG_BYTE), |
@@ -1602,6 +1632,10 @@ bool recording_screen(bool no_source) | |||
1602 | line[i] = 3; | 1632 | line[i] = 3; |
1603 | break; | 1633 | break; |
1604 | #endif | 1634 | #endif |
1635 | default: | ||
1636 | line[i] = 5; /* to prevent uninitialisation | ||
1637 | warnings for line[0] */ | ||
1638 | break; | ||
1605 | } /* end switch */ | 1639 | } /* end switch */ |
1606 | #ifdef HAVE_AGC | 1640 | #ifdef HAVE_AGC |
1607 | if (screens[i].height < h * (2 + filename_offset[i] + PM_HEIGHT + line[i])) | 1641 | if (screens[i].height < h * (2 + filename_offset[i] + PM_HEIGHT + line[i])) |
@@ -1747,12 +1781,28 @@ bool recording_screen(bool no_source) | |||
1747 | } | 1781 | } |
1748 | 1782 | ||
1749 | /* draw the trigger status */ | 1783 | /* draw the trigger status */ |
1784 | FOR_NB_SCREENS(i) | ||
1785 | { | ||
1786 | trig_width[i] = ((screens[i].height < 64) || | ||
1787 | ((screens[i].height < 72) && (PM_HEIGHT > 1))) ? | ||
1788 | screens[i].width - 14 * w : screens[i].width; | ||
1789 | trig_xpos[i] = screens[i].width - trig_width[i]; | ||
1790 | trig_ypos[i] = ((screens[i].height < 72) && (PM_HEIGHT > 1)) ? | ||
1791 | h*2 : | ||
1792 | h*(1 + filename_offset[i] + PM_HEIGHT + line[i] | ||
1793 | #ifdef HAVE_AGC | ||
1794 | + 1 | ||
1795 | #endif | ||
1796 | ); | ||
1797 | } | ||
1798 | |||
1750 | if (peak_meter_trigger_status() != TRIG_OFF) | 1799 | if (peak_meter_trigger_status() != TRIG_OFF) |
1751 | { | 1800 | { |
1752 | peak_meter_draw_trig(LCD_WIDTH - TRIG_WIDTH, 4 * h); | 1801 | peak_meter_draw_trig(trig_xpos, trig_ypos, trig_width, |
1802 | screen_update); | ||
1753 | for(i = 0; i < screen_update; i++){ | 1803 | for(i = 0; i < screen_update; i++){ |
1754 | screens[i].update_rect(LCD_WIDTH - (TRIG_WIDTH + 2), 4 * h, | 1804 | screens[i].update_rect(trig_xpos[i], trig_ypos[i], |
1755 | TRIG_WIDTH + 2, TRIG_HEIGHT); | 1805 | trig_width[i] + 2, TRIG_HEIGHT); |
1756 | } | 1806 | } |
1757 | } | 1807 | } |
1758 | } | 1808 | } |
diff --git a/apps/settings.c b/apps/settings.c index 08e6376694..ea7e303d1d 100644 --- a/apps/settings.c +++ b/apps/settings.c | |||
@@ -687,6 +687,9 @@ static const struct bit_entry hd_bits[] = | |||
687 | 687 | ||
688 | /* If values are just added to the end, no need to bump the version. */ | 688 | /* If values are just added to the end, no need to bump the version. */ |
689 | /* new stuff to be added at the end */ | 689 | /* new stuff to be added at the end */ |
690 | #ifdef HAVE_RECORDING | ||
691 | {2, S_O(rec_trigger_type), 0, "trigger type", "stop,pause,nf stp"}, | ||
692 | #endif | ||
690 | 693 | ||
691 | /* Sum of all bit sizes must not grow beyond 0xB8*8 = 1472 */ | 694 | /* Sum of all bit sizes must not grow beyond 0xB8*8 = 1472 */ |
692 | }; | 695 | }; |
diff --git a/apps/settings.h b/apps/settings.h index 09d4974eee..079fd29649 100644 --- a/apps/settings.h +++ b/apps/settings.h | |||
@@ -193,6 +193,7 @@ struct user_settings | |||
193 | int rec_stop_postrec; /* negative: db, positive: % range -87 .. 100 */ | 193 | int rec_stop_postrec; /* negative: db, positive: % range -87 .. 100 */ |
194 | int rec_stop_gap; /* index of trig_durations */ | 194 | int rec_stop_gap; /* index of trig_durations */ |
195 | int rec_trigger_mode; /* see TRIG_MODE_XXX constants */ | 195 | int rec_trigger_mode; /* see TRIG_MODE_XXX constants */ |
196 | int rec_trigger_type; /* what to do when trigger released */ | ||
196 | 197 | ||
197 | #ifdef HAVE_AGC | 198 | #ifdef HAVE_AGC |
198 | int rec_agc_preset_mic; /* AGC mic preset modes: | 199 | int rec_agc_preset_mic; /* AGC mic preset modes: |
diff --git a/apps/sound_menu.c b/apps/sound_menu.c index fb766d604c..bcc9163893 100644 --- a/apps/sound_menu.c +++ b/apps/sound_menu.c | |||
@@ -32,7 +32,7 @@ | |||
32 | #ifdef HAVE_LCD_BITMAP | 32 | #ifdef HAVE_LCD_BITMAP |
33 | #include "icons.h" | 33 | #include "icons.h" |
34 | #include "font.h" | 34 | #include "font.h" |
35 | #include "widgets.h" | 35 | #include "scrollbar.h" |
36 | #endif | 36 | #endif |
37 | #include "lang.h" | 37 | #include "lang.h" |
38 | #include "sprintf.h" | 38 | #include "sprintf.h" |
@@ -45,7 +45,7 @@ | |||
45 | #include "radio.h" | 45 | #include "radio.h" |
46 | #endif | 46 | #endif |
47 | #endif | 47 | #endif |
48 | #if CONFIG_CODEC == MAS3587F | 48 | #ifdef HAVE_RECORDING |
49 | #include "peakmeter.h" | 49 | #include "peakmeter.h" |
50 | #include "mas.h" | 50 | #include "mas.h" |
51 | #endif | 51 | #endif |
@@ -812,6 +812,7 @@ bool sound_menu(void) | |||
812 | enum trigger_menu_option | 812 | enum trigger_menu_option |
813 | { | 813 | { |
814 | TRIGGER_MODE, | 814 | TRIGGER_MODE, |
815 | TRIGGER_TYPE, | ||
815 | PRERECORD_TIME, | 816 | PRERECORD_TIME, |
816 | START_THRESHOLD, | 817 | START_THRESHOLD, |
817 | START_DURATION, | 818 | START_DURATION, |
@@ -821,7 +822,7 @@ enum trigger_menu_option | |||
821 | TRIG_OPTION_COUNT, | 822 | TRIG_OPTION_COUNT, |
822 | }; | 823 | }; |
823 | 824 | ||
824 | #if !defined(SIMULATOR) && CONFIG_CODEC == MAS3587F | 825 | #ifdef HAVE_RECORDING |
825 | static char* create_thres_str(int threshold) | 826 | static char* create_thres_str(int threshold) |
826 | { | 827 | { |
827 | static char retval[6]; | 828 | static char retval[6]; |
@@ -864,17 +865,6 @@ static void change_threshold(int *threshold, int change) | |||
864 | } | 865 | } |
865 | } | 866 | } |
866 | 867 | ||
867 | /* Variable button definitions */ | ||
868 | #if CONFIG_KEYPAD == RECORDER_PAD | ||
869 | #define TRIG_CANCEL BUTTON_OFF | ||
870 | #define TRIG_ACCEPT BUTTON_PLAY | ||
871 | #define TRIG_RESET_SIM BUTTON_F2 | ||
872 | |||
873 | #elif CONFIG_KEYPAD == ONDIO_PAD | ||
874 | #define TRIG_CANCEL BUTTON_OFF | ||
875 | #define TRIG_ACCEPT BUTTON_MENU | ||
876 | #endif | ||
877 | |||
878 | /** | 868 | /** |
879 | * Displays a menu for editing the trigger settings. | 869 | * Displays a menu for editing the trigger settings. |
880 | */ | 870 | */ |
@@ -883,7 +873,8 @@ bool rectrigger(void) | |||
883 | int exit_request = false; | 873 | int exit_request = false; |
884 | enum trigger_menu_option selected = TRIGGER_MODE; | 874 | enum trigger_menu_option selected = TRIGGER_MODE; |
885 | bool retval = false; | 875 | bool retval = false; |
886 | int old_x_margin, old_y_margin; | 876 | int old_x_margin[NB_SCREENS]; |
877 | int old_y_margin[NB_SCREENS]; | ||
887 | 878 | ||
888 | #define TRIGGER_MODE_COUNT 3 | 879 | #define TRIGGER_MODE_COUNT 3 |
889 | static const unsigned char *trigger_modes[] = { | 880 | static const unsigned char *trigger_modes[] = { |
@@ -900,8 +891,16 @@ bool rectrigger(void) | |||
900 | "30s" | 891 | "30s" |
901 | }; | 892 | }; |
902 | 893 | ||
894 | #define TRIGGER_TYPE_COUNT 3 | ||
895 | static const unsigned char *trigger_types[] = { | ||
896 | ID2P(LANG_RECORD_TRIGGER_STOP), | ||
897 | ID2P(LANG_RECORD_TRIGGER_PAUSE), | ||
898 | ID2P(LANG_RECORD_TRIGGER_NEWFILESTP), | ||
899 | }; | ||
900 | |||
903 | static const unsigned char *option_name[] = { | 901 | static const unsigned char *option_name[] = { |
904 | [TRIGGER_MODE] = ID2P(LANG_RECORD_TRIGGER_MODE), | 902 | [TRIGGER_MODE] = ID2P(LANG_RECORD_TRIGGER_MODE), |
903 | [TRIGGER_TYPE] = ID2P(LANG_RECORD_TRIGGER_TYPE), | ||
905 | [PRERECORD_TIME] = ID2P(LANG_RECORD_PRERECORD_TIME), | 904 | [PRERECORD_TIME] = ID2P(LANG_RECORD_PRERECORD_TIME), |
906 | [START_THRESHOLD] = ID2P(LANG_RECORD_START_THRESHOLD), | 905 | [START_THRESHOLD] = ID2P(LANG_RECORD_START_THRESHOLD), |
907 | [START_DURATION] = ID2P(LANG_RECORD_MIN_DURATION), | 906 | [START_DURATION] = ID2P(LANG_RECORD_MIN_DURATION), |
@@ -917,37 +916,54 @@ bool rectrigger(void) | |||
917 | int old_stop_postrec = global_settings.rec_stop_postrec; | 916 | int old_stop_postrec = global_settings.rec_stop_postrec; |
918 | int old_stop_gap = global_settings.rec_stop_gap; | 917 | int old_stop_gap = global_settings.rec_stop_gap; |
919 | int old_trigger_mode = global_settings.rec_trigger_mode; | 918 | int old_trigger_mode = global_settings.rec_trigger_mode; |
919 | int old_trigger_type = global_settings.rec_trigger_type; | ||
920 | 920 | ||
921 | int offset = 0; | 921 | int offset[NB_SCREENS]; |
922 | int option_lines; | 922 | int option_lines[NB_SCREENS]; |
923 | int w, h; | 923 | int w, h, i; |
924 | int stat_height = global_settings.statusbar ? STATUSBAR_HEIGHT : 0; | 924 | int stat_height = global_settings.statusbar ? STATUSBAR_HEIGHT : 0; |
925 | /* array for y ordinate of peak_meter_draw_get_button | ||
926 | function in peakmeter.c*/ | ||
927 | int pm_y[NB_SCREENS]; | 925 | int pm_y[NB_SCREENS]; |
928 | 926 | ||
927 | int trig_xpos[NB_SCREENS]; | ||
928 | int trig_ypos[NB_SCREENS]; | ||
929 | int trig_width[NB_SCREENS]; | ||
930 | |||
931 | FOR_NB_SCREENS(i) | ||
932 | { | ||
933 | offset[i] = 0; | ||
934 | trig_xpos[i] = 0; | ||
935 | trig_ypos[i] = screens[i].height - stat_height - TRIG_HEIGHT; | ||
936 | pm_y[i] = screens[i].height - stat_height; | ||
937 | trig_width[i] = screens[i].width; | ||
938 | } | ||
939 | |||
929 | /* restart trigger with new values */ | 940 | /* restart trigger with new values */ |
930 | settings_apply_trigger(); | 941 | settings_apply_trigger(); |
931 | peak_meter_trigger (global_settings.rec_trigger_mode != TRIG_MODE_OFF); | 942 | peak_meter_trigger (global_settings.rec_trigger_mode != TRIG_MODE_OFF); |
932 | 943 | ||
933 | lcd_clear_display(); | 944 | FOR_NB_SCREENS(i) |
945 | { | ||
946 | screens[i].clear_display(); | ||
934 | 947 | ||
935 | old_x_margin = lcd_getxmargin(); | 948 | old_x_margin[i] = screens[i].getxmargin(); |
936 | old_y_margin = lcd_getymargin(); | 949 | old_y_margin[i] = screens[i].getymargin(); |
937 | if(global_settings.statusbar) | 950 | if(global_settings.statusbar) |
938 | lcd_setmargins(0, STATUSBAR_HEIGHT); | 951 | screens[i].setmargins(0, STATUSBAR_HEIGHT); |
939 | else | 952 | else |
940 | lcd_setmargins(0, 0); | 953 | screens[i].setmargins(0, 0); |
941 | 954 | ||
942 | lcd_getstringsize("M", &w, &h); | 955 | screens[i].getstringsize("M", &w, &h); |
943 | 956 | ||
944 | /* 16 pixels are reserved for peak meter and trigger status */ | 957 | // 16 pixels are reserved for peak meter and trigger status |
945 | option_lines = (LCD_HEIGHT - 16 - stat_height) / h; | 958 | option_lines[i] = MIN(((screens[i].height) - |
959 | stat_height - 16)/h, | ||
960 | TRIG_OPTION_COUNT); | ||
961 | } | ||
946 | 962 | ||
947 | while (!exit_request) { | 963 | while (!exit_request) { |
948 | int button, i; | 964 | int button, k; |
949 | const char *str; | 965 | const char *str; |
950 | char option_value[TRIG_OPTION_COUNT][7]; | 966 | char option_value[TRIG_OPTION_COUNT][9]; |
951 | 967 | ||
952 | snprintf( | 968 | snprintf( |
953 | option_value[TRIGGER_MODE], | 969 | option_value[TRIGGER_MODE], |
@@ -955,6 +971,18 @@ bool rectrigger(void) | |||
955 | "%s", | 971 | "%s", |
956 | P2STR(trigger_modes[global_settings.rec_trigger_mode])); | 972 | P2STR(trigger_modes[global_settings.rec_trigger_mode])); |
957 | 973 | ||
974 | snprintf( | ||
975 | option_value[TRIGGER_TYPE], | ||
976 | sizeof option_value[TRIGGER_TYPE], | ||
977 | "%s", | ||
978 | P2STR(trigger_types[global_settings.rec_trigger_type])); | ||
979 | |||
980 | snprintf( | ||
981 | option_value[TRIGGER_TYPE], | ||
982 | sizeof option_value[TRIGGER_TYPE], | ||
983 | "%s", | ||
984 | P2STR(trigger_types[global_settings.rec_trigger_type])); | ||
985 | |||
958 | snprintf ( | 986 | snprintf ( |
959 | option_value[PRERECORD_TIME], | 987 | option_value[PRERECORD_TIME], |
960 | sizeof option_value[PRERECORD_TIME], | 988 | sizeof option_value[PRERECORD_TIME], |
@@ -1003,41 +1031,51 @@ bool rectrigger(void) | |||
1003 | "%s", | 1031 | "%s", |
1004 | trig_durations[global_settings.rec_stop_gap]); | 1032 | trig_durations[global_settings.rec_stop_gap]); |
1005 | 1033 | ||
1034 | FOR_NB_SCREENS(i) | ||
1035 | { | ||
1036 | screens[i].set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID); | ||
1037 | screens[i].fillrect(0, stat_height, screens[i].width, | ||
1038 | screens[i].height - stat_height); | ||
1039 | screens[i].set_drawmode(DRMODE_SOLID); | ||
1040 | } | ||
1041 | |||
1006 | gui_syncstatusbar_draw(&statusbars, true); | 1042 | gui_syncstatusbar_draw(&statusbars, true); |
1007 | 1043 | ||
1008 | /* reselect FONT_SYSFONT as status_draw has changed the font */ | 1044 | /* reselect FONT_SYSFONT as status_draw has changed the font */ |
1009 | /*lcd_setfont(FONT_SYSFIXED);*/ | 1045 | /*lcd_setfont(FONT_SYSFIXED);*/ |
1010 | 1046 | ||
1011 | for (i = 0; i < option_lines; i++) { | 1047 | FOR_NB_SCREENS(i) |
1012 | int x, y; | 1048 | { |
1013 | 1049 | for (k = 0; k < option_lines[i]; k++) { | |
1014 | str = P2STR(option_name[i + offset]); | 1050 | int x, y; |
1015 | lcd_putsxy(5, stat_height + i * h, str); | 1051 | |
1016 | 1052 | str = P2STR(option_name[k + offset[i]]); | |
1017 | str = option_value[i + offset]; | 1053 | screens[i].putsxy((option_lines[i] < TRIG_OPTION_COUNT) ? 5 : 0, |
1018 | lcd_getstringsize(str, &w, NULL); | 1054 | stat_height + k * h, str); |
1019 | y = stat_height + i * h; | 1055 | |
1020 | x = LCD_WIDTH - w; | 1056 | str = option_value[k + offset[i]]; |
1021 | lcd_putsxy(x, y, str); | 1057 | screens[i].getstringsize(str, &w, &h); |
1022 | if ((int)selected == (i + offset)) { | 1058 | y = stat_height + k * h; |
1023 | lcd_set_drawmode(DRMODE_COMPLEMENT); | 1059 | x = screens[i].width - w; |
1024 | lcd_fillrect(x, y, w, h); | 1060 | screens[i].putsxy(x, y, str); |
1025 | lcd_set_drawmode(DRMODE_SOLID); | 1061 | if ((int)selected == (k + offset[i])) { |
1062 | screens[i].set_drawmode(DRMODE_COMPLEMENT); | ||
1063 | screens[i].fillrect(x, y, w, h); | ||
1064 | screens[i].set_drawmode(DRMODE_SOLID); | ||
1065 | } | ||
1026 | } | 1066 | } |
1067 | if (option_lines[i] < TRIG_OPTION_COUNT) | ||
1068 | gui_scrollbar_draw(&screens[i], 0, stat_height, | ||
1069 | 4, screens[i].height - 16 - stat_height, | ||
1070 | TRIG_OPTION_COUNT, offset[i], offset[i] + option_lines[i], | ||
1071 | VERTICAL); | ||
1027 | } | 1072 | } |
1028 | 1073 | ||
1029 | scrollbar(0, stat_height, | 1074 | peak_meter_draw_trig(trig_xpos, trig_ypos, trig_width, NB_SCREENS); |
1030 | 4, option_lines * h, | ||
1031 | TRIG_OPTION_COUNT, offset, offset + option_lines, | ||
1032 | VERTICAL); | ||
1033 | |||
1034 | peak_meter_draw_trig(0, LCD_HEIGHT - 8 - TRIG_HEIGHT); | ||
1035 | |||
1036 | FOR_NB_SCREENS(i) | ||
1037 | pm_y[i] = screens[i].height - 8; | ||
1038 | button = peak_meter_draw_get_btn(0, pm_y, 8, NB_SCREENS); | 1075 | button = peak_meter_draw_get_btn(0, pm_y, 8, NB_SCREENS); |
1039 | 1076 | ||
1040 | lcd_update(); | 1077 | FOR_NB_SCREENS(i) |
1078 | screens[i].update(); | ||
1041 | 1079 | ||
1042 | switch (button) { | 1080 | switch (button) { |
1043 | case ACTION_STD_CANCEL: | 1081 | case ACTION_STD_CANCEL: |
@@ -1049,6 +1087,7 @@ bool rectrigger(void) | |||
1049 | global_settings.rec_stop_postrec = old_stop_postrec; | 1087 | global_settings.rec_stop_postrec = old_stop_postrec; |
1050 | global_settings.rec_stop_gap = old_stop_gap; | 1088 | global_settings.rec_stop_gap = old_stop_gap; |
1051 | global_settings.rec_trigger_mode = old_trigger_mode; | 1089 | global_settings.rec_trigger_mode = old_trigger_mode; |
1090 | global_settings.rec_trigger_type = old_trigger_type; | ||
1052 | exit_request = true; | 1091 | exit_request = true; |
1053 | break; | 1092 | break; |
1054 | 1093 | ||
@@ -1059,15 +1098,21 @@ bool rectrigger(void) | |||
1059 | case ACTION_STD_PREV: | 1098 | case ACTION_STD_PREV: |
1060 | selected += TRIG_OPTION_COUNT - 1; | 1099 | selected += TRIG_OPTION_COUNT - 1; |
1061 | selected %= TRIG_OPTION_COUNT; | 1100 | selected %= TRIG_OPTION_COUNT; |
1062 | offset = MIN(offset, (int)selected); | 1101 | FOR_NB_SCREENS(i) |
1063 | offset = MAX(offset, (int)selected - option_lines + 1); | 1102 | { |
1103 | offset[i] = MIN(offset[i], (int)selected); | ||
1104 | offset[i] = MAX(offset[i], (int)selected - option_lines[i] + 1); | ||
1105 | } | ||
1064 | break; | 1106 | break; |
1065 | 1107 | ||
1066 | case ACTION_STD_NEXT: | 1108 | case ACTION_STD_NEXT: |
1067 | selected ++; | 1109 | selected ++; |
1068 | selected %= TRIG_OPTION_COUNT; | 1110 | selected %= TRIG_OPTION_COUNT; |
1069 | offset = MIN(offset, (int)selected); | 1111 | FOR_NB_SCREENS(i) |
1070 | offset = MAX(offset, (int)selected - option_lines + 1); | 1112 | { |
1113 | offset[i] = MIN(offset[i], (int)selected); | ||
1114 | offset[i] = MAX(offset[i], (int)selected - option_lines[i] + 1); | ||
1115 | } | ||
1071 | break; | 1116 | break; |
1072 | 1117 | ||
1073 | case ACTION_SETTINGS_INC: | 1118 | case ACTION_SETTINGS_INC: |
@@ -1077,6 +1122,11 @@ bool rectrigger(void) | |||
1077 | global_settings.rec_trigger_mode %= TRIGGER_MODE_COUNT; | 1122 | global_settings.rec_trigger_mode %= TRIGGER_MODE_COUNT; |
1078 | break; | 1123 | break; |
1079 | 1124 | ||
1125 | case TRIGGER_TYPE: | ||
1126 | global_settings.rec_trigger_type ++; | ||
1127 | global_settings.rec_trigger_type %= TRIGGER_TYPE_COUNT; | ||
1128 | break; | ||
1129 | |||
1080 | case PRERECORD_TIME: | 1130 | case PRERECORD_TIME: |
1081 | global_settings.rec_prerecord_time ++; | 1131 | global_settings.rec_prerecord_time ++; |
1082 | global_settings.rec_prerecord_time %= PRERECORD_TIMES_COUNT; | 1132 | global_settings.rec_prerecord_time %= PRERECORD_TIMES_COUNT; |
@@ -1120,6 +1170,11 @@ bool rectrigger(void) | |||
1120 | global_settings.rec_trigger_mode %= TRIGGER_MODE_COUNT; | 1170 | global_settings.rec_trigger_mode %= TRIGGER_MODE_COUNT; |
1121 | break; | 1171 | break; |
1122 | 1172 | ||
1173 | case TRIGGER_TYPE: | ||
1174 | global_settings.rec_trigger_type+=TRIGGER_TYPE_COUNT-1; | ||
1175 | global_settings.rec_trigger_type %= TRIGGER_TYPE_COUNT; | ||
1176 | break; | ||
1177 | |||
1123 | case PRERECORD_TIME: | 1178 | case PRERECORD_TIME: |
1124 | global_settings.rec_prerecord_time += PRERECORD_TIMES_COUNT - 1; | 1179 | global_settings.rec_prerecord_time += PRERECORD_TIMES_COUNT - 1; |
1125 | global_settings.rec_prerecord_time %= PRERECORD_TIMES_COUNT; | 1180 | global_settings.rec_prerecord_time %= PRERECORD_TIMES_COUNT; |
@@ -1159,11 +1214,9 @@ bool rectrigger(void) | |||
1159 | settings_apply_trigger(); | 1214 | settings_apply_trigger(); |
1160 | break; | 1215 | break; |
1161 | 1216 | ||
1162 | #ifdef TRIG_RESET_SIM | ||
1163 | case ACTION_REC_F2: | 1217 | case ACTION_REC_F2: |
1164 | peak_meter_trigger(true); | 1218 | peak_meter_trigger(true); |
1165 | break; | 1219 | break; |
1166 | #endif | ||
1167 | 1220 | ||
1168 | case SYS_USB_CONNECTED: | 1221 | case SYS_USB_CONNECTED: |
1169 | if(default_event_handler(button) == SYS_USB_CONNECTED) { | 1222 | if(default_event_handler(button) == SYS_USB_CONNECTED) { |
@@ -1175,8 +1228,11 @@ bool rectrigger(void) | |||
1175 | } | 1228 | } |
1176 | 1229 | ||
1177 | peak_meter_trigger(false); | 1230 | peak_meter_trigger(false); |
1178 | lcd_setfont(FONT_UI); | 1231 | FOR_NB_SCREENS(i) |
1179 | lcd_setmargins(old_x_margin, old_y_margin); | 1232 | { |
1233 | screens[i].setfont(FONT_UI); | ||
1234 | screens[i].setmargins(old_x_margin[i], old_y_margin[i]); | ||
1235 | } | ||
1180 | action_signalscreenchange(); | 1236 | action_signalscreenchange(); |
1181 | return retval; | 1237 | return retval; |
1182 | } | 1238 | } |
@@ -1205,9 +1261,7 @@ bool recording_menu(bool no_source) | |||
1205 | #ifdef CONFIG_BACKLIGHT | 1261 | #ifdef CONFIG_BACKLIGHT |
1206 | { ID2P(LANG_CLIP_LIGHT), cliplight }, | 1262 | { ID2P(LANG_CLIP_LIGHT), cliplight }, |
1207 | #endif | 1263 | #endif |
1208 | #if !defined(SIMULATOR) && CONFIG_CODEC == MAS3587F | ||
1209 | { ID2P(LANG_RECORD_TRIGGER), rectrigger }, | 1264 | { ID2P(LANG_RECORD_TRIGGER), rectrigger }, |
1210 | #endif | ||
1211 | #ifdef HAVE_AGC | 1265 | #ifdef HAVE_AGC |
1212 | { ID2P(LANG_RECORD_AGC_PRESET), agc_preset }, | 1266 | { ID2P(LANG_RECORD_AGC_PRESET), agc_preset }, |
1213 | { ID2P(LANG_RECORD_AGC_CLIPTIME), agc_cliptime }, | 1267 | { ID2P(LANG_RECORD_AGC_CLIPTIME), agc_cliptime }, |