4 * Copyright (C) 2013-06-10 K.Ohta <whatisthis.sowhat ai gmail.com>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2,
10 * or (at your option) any later version.
11 * This library / program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14 * See the GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this library; see the file COPYING. If not, write to the
18 * Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
21 * As a special exception, if you link this(includeed from sdcc) library
22 * with other files, some of which are compiled with SDCC,
23 * to produce an executable, this library does not by itself cause
24 * the resulting executable to be covered by the GNU General Public License.
25 * This exception does not however invalidate any other reasons why
26 * the executable file might be covered by the GNU General Public License.
35 #include <pic18fregs.h> /* ONLY FOR PIC18x */
46 #include "lcd_acm1602.h"
51 #include "menu_memoryfreq.h"
54 #include "backlight.h"
56 static void setfreq_updown_amsub(void)
58 if(setup.amband >= AKC6955_BAND_AMEND) {
61 akc6955_set_amband(setup.amband);
62 setup.amfreq = setup.amfreq_bank[setup.amband];
63 // idle_time_62_5ms(); // 62.5ms
65 akc6955_mode3k(setup.am_mode3k);
66 akc6955_set_freq(setup.amfreq);
69 static void setfreq_updown_fmsub(void)
71 if(setup.fmband >= AKC6955_BAND_FMEND) {
74 akc6955_set_fmband(setup.fmband);
75 setup.fmfreq = setup.fmfreq_bank[setup.fmband];
76 // idle_time_62_5ms(); // 62.5ms
78 akc6955_set_freq(setup.fmfreq);
81 static void setband_updown(unsigned char updown)
84 if(setup.fm == 0){ // MW
85 band = setup.amband + 1;
86 if(setup.amband == AKC6955_BAND_AMUSER){
87 userband.am_usrbands[setup.am_userbandnum].freq = setup.amfreq;
89 setup.amfreq_bank[setup.amband] = setup.amfreq;
90 if(updown == 0) { // down
92 band = AKC6955_BAND_AMEND + 1;
97 switch(setup.amband) {
99 case AKC6955_BAND_MW2:
100 setup.am_mode3k = 0xff;
102 case AKC6955_BAND_AMUSER:
103 call_userband(setup.am_userbandnum);
106 setup.am_mode3k = 0x00;
109 setfreq_updown_amsub();
111 if(setup.fmband == AKC6955_BAND_FMUSER){
112 userband.fm_usrbands[setup.fm_userbandnum].freq = setup.fmfreq;
114 band = setup.fmband + 1;
115 setup.fmfreq_bank[setup.fmband] = setup.fmfreq;
116 if(updown == 0) { // down
118 band = AKC6955_BAND_FMEND + 1;
123 if(setup.fmband == AKC6955_BAND_FMUSER){
124 // setup.fmfreq = fm_usrbands[fm_userbandnum].freq;
125 call_userband(setup.fm_userbandnum);
127 setfreq_updown_fmsub();
131 void setfreq_updown(unsigned char ctlword)
134 unsigned int start, end;
136 backlight_reset(ctlword);
140 case charcode_8: // Up band
141 setband_updown(0xff);
143 case charcode_2: // Down band
144 setband_updown(0x00);
146 case charcode_6: // Up Middle;
147 case charcode_4: // Down Middle;
148 freq = 9; // 27KHz@3K/9KStep.
150 switch(setup.fm_tunepitch & 3) {
152 freq = 20; // 500KHz excepts TV1/TV2.
153 if((setup.fmband == AKC6955_BAND_TV1) || (setup.fmband == AKC6955_BAND_TV2)) {
161 } else if(setup.am_mode3k == 0){
164 if(ctlword == charcode_6) {
165 akc6955_up_freq(freq); // 225 or 27 or 45KHz
167 akc6955_down_freq(freq); // 225 or 27 or 45KHz
170 case charcode_9: // Up Fast;
171 case charcode_7: // Down Fast;
172 freq = 33; // 99KHz@3K/9KStep.
174 switch(setup.fm_tunepitch & 3) {
176 freq = 80; // 2MHz excepts TV1/TV2.
177 if((setup.fmband == AKC6955_BAND_TV1) || (setup.fmband == AKC6955_BAND_TV2)) {
185 } else if(setup.am_mode3k == 0){
188 if(ctlword == charcode_9) {
189 akc6955_up_freq(freq); // 825 or 90 or 165KHz
191 akc6955_down_freq(freq); // 825 or 90 or 165KHz
194 case charcode_3: // Up Slow;
195 case charcode_1: // Down Slow;
197 switch(setup.fm_tunepitch & 3) {
208 freq = 8; // 200KHz excepts TV1/TV2.
209 if((setup.fmband == AKC6955_BAND_TV1) || (setup.fmband == AKC6955_BAND_TV2)) {
215 freq = 1; // 5KHz or 3KHz
216 if(setup.amband == AKC6955_BAND_MW2) {
218 } else if((setup.amband == AKC6955_BAND_MW3) || (setup.amband == AKC6955_BAND_MW4)) {
222 if(ctlword == charcode_1) {
223 akc6955_down_freq(freq);
225 akc6955_up_freq(freq);
228 case charcode_0: // Step
229 setup.threshold_width++;
230 akc6955_set_thresh_width(setup.threshold_width);
233 case charcode_a: // Toggle FM
238 on_updown_userfreq();