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_set_freq(setup.amfreq);
68 static void setfreq_updown_fmsub(void)
70 if(setup.fmband >= AKC6955_BAND_FMEND) {
73 akc6955_set_fmband(setup.fmband);
74 setup.fmfreq = setup.fmfreq_bank[setup.fmband];
75 // idle_time_62_5ms(); // 62.5ms
77 akc6955_set_freq(setup.fmfreq);
80 static void setband_updown(unsigned char updown)
83 if(setup.fm == 0){ // MW
84 band = setup.amband + 1;
85 if(setup.amband == AKC6955_BAND_AMUSER){
86 setup.am_usrbands[setup.am_userbandnum].freq = setup.amfreq;
88 setup.amfreq_bank[setup.amband] = setup.amfreq;
89 if(updown == 0) { // down
91 band = AKC6955_BAND_AMEND - 1;
96 switch(setup.amband) {
98 case AKC6955_BAND_MW2:
99 setup.am_mode3k = 0xff;
101 case AKC6955_BAND_MW1:
102 case AKC6955_BAND_MW3:
103 case AKC6955_BAND_MW4:
104 setup.am_mode3k = 0x00;
106 case AKC6955_BAND_AMUSER:
107 call_userband(setup.am_userbandnum);
112 if(setup.amband == AKC6955_BAND_AMUSER){
113 // amfreq = am_usrbands[am_userbandnum].freq;
114 call_userband(setup.am_userbandnum);
116 setfreq_updown_amsub();
118 if(setup.fmband == AKC6955_BAND_FMUSER){
119 setup.fm_usrbands[setup.fm_userbandnum].freq = setup.fmfreq;
121 band = setup.fmband + 1;
122 setup.fmfreq_bank[setup.fmband] = setup.fmfreq;
123 if(updown == 0) { // down
125 band = AKC6955_BAND_FMEND - 1;
130 if(setup.fmband == AKC6955_BAND_FMUSER){
131 // setup.fmfreq = fm_usrbands[fm_userbandnum].freq;
132 call_userband(setup.fm_userbandnum);
134 setfreq_updown_fmsub();
138 void setfreq_updown(unsigned char ctlword)
142 backlight_reset(ctlword);
147 case charcode_8: // Up band
148 setband_updown(0xff);
150 case charcode_2: // Down band
151 setband_updown(0x00);
153 case charcode_4: // Down Freq;
154 freq = 9; // 27KHz@3K/9KStep.
157 } else if(setup.am_mode3k == 0){
160 akc6955_down_freq(freq);
162 case charcode_6: // Down Freq;
163 freq = 9; // 27KHz@3K/9KStep.
166 } else if(setup.am_mode3k == 0){
169 akc6955_up_freq(freq); // 225 or 27 or 45KHz
171 case charcode_9: // Down Fast;
172 freq = 33; // 99KHz@3K/9KStep.
175 } else if(setup.am_mode3k == 0){
178 akc6955_up_freq(freq); // 825 or 90 or 165KHz
180 case charcode_7: // Down Fast;
181 freq = 33; // 99KHz@3K/9KStep.
184 } else if(setup.am_mode3k == 0){
187 akc6955_down_freq(freq); // 825 or 90 or 165KHz
189 case charcode_1: // Down Slow;
191 freq = 4; // DOWN 100KHz
193 freq = 1; // 5KHz or 3KHz
194 if(setup.amband == AKC6955_BAND_MW2) {
198 akc6955_down_freq(freq);
200 case charcode_3: // Up Slow;
202 freq = 4; // DOWN 100KHz
204 freq = 1; // 5KHz or 3KHz
205 if(setup.amband == AKC6955_BAND_MW2) {
209 akc6955_up_freq(freq);
211 case charcode_0: // Step
212 setup.threshold_width++;
213 akc6955_set_thresh_width(setup.threshold_width);
216 case charcode_a: // Toggle FM
221 on_updown_userfreq();