summaryrefslogtreecommitdiff
path: root/apps/sound_menu.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/sound_menu.c')
-rw-r--r--apps/sound_menu.c188
1 files changed, 121 insertions, 67 deletions
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)
812enum trigger_menu_option 812enum 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
825static char* create_thres_str(int threshold) 826static 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 },