OSDN Git Service

[SCHEMATIC] Modify SW/MW/LW Preamp, insert galbanic-isolator replace of common-mode...
[openi2cradio/OpenI2CRadio.git] / menu.c
diff --git a/menu.c b/menu.c
index bf89e82..da99968 100644 (file)
--- a/menu.c
+++ b/menu.c
@@ -82,9 +82,9 @@ void setfreq_direct(void)
 {
     unsigned long val;
     _CLS();
-    _LOCATE(0,0);
+//    _LOCATE(0,0);
     printstr("Set Freq:");
-    _LOCATE(0,1);
+    _LOCATE_0_1();
     if(setup.fm != 0){
         // FM
         printstr("FM ");
@@ -108,45 +108,58 @@ void setband_direct(void)
     unsigned long band;
     unsigned char band2;
     unsigned int freq;
+    unsigned char mode3k;
+
     _CLS();
-    _LOCATE(0,0);
+//    _LOCATE(0,0);
     if(setup.fm != 0){
         printstr("Set Band:FM#");
         band2 = setup.fmband & 7;
+        if(band2 == AKC6955_BAND_FMUSER) {
+            userband.fm_usrbands[setup.fm_userbandnum].freq = setup.fmfreq;
+        }
         setup.fmfreq_bank[setup.fmband] = setup.fmfreq;
         band2 = pollkey_numeric(band2);
-        if(band2 < 8) {
-            setup.fmband = band2 & 7;
-            setup.fmfreq = setup.fmfreq_bank[setup.fmband];
-            akc6955_set_fmband(setup.fmband);
-            freq = setup.fmfreq;
+        band2 &= 7;
+        if(band2 == AKC6955_BAND_FMUSER) {
+            call_userband(setup.fm_userbandnum);
+            freq = userband.fm_usrbands[setup.fm_userbandnum].freq;
+        } else {
+            freq = setup.fmfreq_bank[band2];
         }
-        akc6955_set_fmband(setup.fmband);
-        freq = setup.fmfreq;
+        setup.fmband = band2;
+        akc6955_set_fmband(band2);
+        setup.fmfreq = freq;
     } else {
         printstr("Set Band:AM#");
         band = setup.amband & 0x1f;
-        setup.amfreq_bank[setup.amband] = setup.amfreq;
+        setup.amfreq_bank[band] = setup.amfreq;
+        if(band == AKC6955_BAND_AMUSER) {
+            userband.am_usrbands[setup.am_userbandnum].freq = setup.amfreq;
+        }
         band = read_numeric(band, 2, 7, 1);
         if((band & 0x80000000) != 0) return;
-        setup.amband = band & 0x1f;
-        setup.amfreq = setup.amfreq_bank[setup.amband];
+        band &= 0x1f;
+        setup.amband = band;
+        freq = setup.amfreq_bank[setup.amband];
         switch(band) {
         case AKC6955_BAND_LW:
         case AKC6955_BAND_MW2:
-          setup.am_mode3k = 0xff;
-          break;
-        case AKC6955_BAND_MW1:
-        case AKC6955_BAND_MW3:
-        case AKC6955_BAND_MW4:
-          setup.am_mode3k = 0x00;
+          mode3k = 0xff;
           break;
+         case AKC6955_BAND_AMUSER:
+            call_userband(setup.am_userbandnum);
+            mode3k = userband.am_usrbands[setup.am_userbandnum].mode3k;
+            freq = userband.am_usrbands[setup.am_userbandnum].freq;
+            break;
         default:
+            mode3k = 0x00;
           break;
        }
-
-        akc6955_set_amband(setup.amband);
-        freq = setup.amfreq;
+        akc6955_mode3k(mode3k);
+        akc6955_set_amband(band);
+        setup.amfreq = freq;
+        setup.am_mode3k = mode3k;
     }
     akc6955_do_tune();
     akc6955_set_freq(freq);
@@ -161,6 +174,24 @@ void menu_poweroff(void)
     }
 }
 
+void menu_setfmresolution(void)
+{
+   unsigned char c;
+    if(setup.fm != 0){
+       _CLS();
+//       _LOCATE(0,0);
+        c = akc6955_get_scanrate_fm();
+        printstr("FM pitch:");
+        _PUTCHAR('0' + c);
+        printstr("->");
+        c = pollkey_numeric(c);
+        setup.fm_tunepitch = c & 3;
+        akc6955_set_scanrate_fm(c);
+        _CLS();
+//        _LOCATE(0,0);
+    }
+}
+
 void setup_akc6955(void)
 {
     akc6955_writecmd(AKC6955_POWER, 0xc0);  // You musto *not* mute, set b2 to '0".
@@ -186,6 +217,7 @@ void setup_akc6955(void)
     akc6955_set_thresh_fmstereo(setup.threshold_fmstereo);
     akc6955_setvolumemode(0);
     akc6955_set_lowboost(setup.lowboost);
+    akc6955_set_scanrate_fm(setup.fm_tunepitch);
     set_stereomode();
 }
 
@@ -244,6 +276,9 @@ void main_menu(void)
         case charcode_d:
             input_userband();
             break;
+        case charcode_e:
+            menu_setfmresolution();
+            break;
         case charcode_f:
             mainmenu_help();
             // HELP
@@ -252,6 +287,6 @@ void main_menu(void)
             break;
         }
        _CLS();
-       _LOCATE(0,0);
+       _LOCATE_0_0();
 }