3 * Menu sub-routines / USER BAND.
4 * Copyright (C) 2013-09-11 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.
30 #include "menu_memoryfreq.h"
32 #include "commondef.h"
33 #include "backlight.h"
34 #include "eeprom_util.h"
36 void call_userband(unsigned char num)
46 if(num >= USER_BAND_NUM) return;
49 p = &(userband.fm_usrbands[num]);
52 ch = ((freq - 3000) / 5) * 2;
53 setup.fmband = AKC6955_BAND_FMUSER;
56 p = &(userband.am_usrbands[num]);
60 if(mode3k != 0) q = 3;
62 setup.amband = AKC6955_BAND_AMUSER;
64 setup.am_mode3k = mode3k;
70 akc6955_set_userband(start, end, ch, mode3k);
73 void set_userband(void)
75 unsigned long from,to;
80 unsigned int _from, _to, tmp;
82 unsigned char fm = setup.fm;
88 c = pollkey_numeric(c);
89 if(c >= USER_BAND_NUM) goto _l0;
92 from = userband.fm_usrbands[c].start * 80 + 3000; // 32*25/10
93 to = userband.fm_usrbands[c].stop * 80 + 3000;
97 print_numeric_nosupress(c, 1);
99 mode3k = userband.am_usrbands[c].mode3k;
101 if(mode3k == 0) pp = 160; // 5*32
102 from = userband.am_usrbands[c].start * pp;
103 to = userband.am_usrbands[c].stop * pp;
107 print_numeric_nosupress(c, 1);
115 printstr("0=3k 1=5k");
116 cc = pollkey_single();
117 if(cc == charcode_0){
120 } else if(cc == charcode_1) {
136 from = read_numeric(from, 5, 7, 1);
137 if((from & 0xffff0000) != 0) goto _l0;
140 to = read_numeric(to, 5, 7, 1);
141 if((to & 0xffff0000) != 0) goto _l0;
143 _from = (unsigned int)from;
144 _to = (unsigned int)to;
150 freq = (_to - _from) / 2 + _from;
162 print_numeric_nosupress(_from, 5);
164 print_numeric_nosupress(_to, 5);
165 cc = pollkey_single();
166 if(cc != charcode_a) goto _l0;
169 if((_from <= 3000) || (_from >= 28000)) goto _l0;
170 if((_to <= 3000) || (_to >= 28000)) goto _l0;
171 userband.fm_usrbands[c].start = (_from - 3000) / 80;
172 userband.fm_usrbands[c].stop = (_to - 3000) / 80 + 1;
173 userband.fm_usrbands[c].freq = freq;
174 userband.fm_usrbands[c].mode3k = 0;
175 setup.fm_userbandnum = c;
177 if((_from <100) || (_from >= 28000)) goto _l0;
178 if((_to < 100) || (_to >= 28000)) goto _l0;
179 userband.am_usrbands[c].start = _from / pp;
180 userband.am_usrbands[c].stop = _to / pp + 1;
181 userband.am_usrbands[c].mode3k = mode3k;
182 userband.am_usrbands[c].freq = freq;
183 setup.am_userbandnum = c;
191 void input_userband(void)
195 c = printhelp_2lines("User Band", " #");
196 if((c > charcode_a) && (c <= charcode_f)){
200 d = load_userbands();
201 if(d < 0) format_userbands();
204 if(c == charcode_0) {
209 setup.fm_userbandnum = c;
211 setup.am_userbandnum = c;
219 void list_userband(void)
225 for(i = 0; i < USER_BAND_NUM; i ++){
230 print_numeric_nosupress(userband.fm_usrbands[i].start * 80 + 3000, 5);
232 print_numeric_nosupress(userband.fm_usrbands[i].stop * 80 + 3000, 5);
233 c = pollkey_single();
234 if(c == charcode_a) {
238 for(i = 0; i < USER_BAND_NUM; i ++){
243 if(userband.am_usrbands[i].mode3k != 0){
248 print_numeric_nosupress(userband.am_usrbands[i].start * q, 5);
250 print_numeric_nosupress(userband.am_usrbands[i].stop * q, 5);
251 c = pollkey_single();
252 if(c == charcode_a) {