3 * Menu sub-routines: Memory Freq.
4 * Copyright (C) 2013-08-14 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.
31 #include "commondef.h"
35 void call_freqbank(unsigned int num)
39 unsigned char _userband;
40 unsigned int bank = num / USER_MEMORY_NUM;
41 unsigned int n = num % USER_MEMORY_NUM;
43 if(num >= (USER_MEMORY_NUM * USER_MEMORY_BANKS)) return;
45 if(bank != setup.pagenum){ // Swap memory
46 // save_frequencies();
47 load_frequencies(bank, 0x00);
50 _fm = freqset.memoryfreqs[n].fm;
51 _userband = freqset.memoryfreqs[n].band;
52 _band = _userband & 0x1f;
53 _userband = _userband >> 5;
56 setup.fm_userbandnum = _userband;
59 setup.am_userbandnum = _userband;
61 setup.memorynum = num;
62 akc6955_chg_fm(_fm, freqset.memoryfreqs[n].freq);
66 void set_freqbank(unsigned int num)
70 unsigned char _userband;
72 unsigned int bank = num / USER_MEMORY_NUM;
73 unsigned int n = num % USER_MEMORY_NUM;
75 if(num >= (USER_MEMORY_NUM * USER_MEMORY_BANKS)) return;
77 if(bank != setup.pagenum){ // Save now bank, and load using bank
79 load_frequencies(bank, 0x00);
84 _userband = setup.am_userbandnum;
87 _userband = setup.fm_userbandnum;
91 freqset.memoryfreqs[n].fm = _fm;
92 freqset.memoryfreqs[n].band = (_userband << 5) | (_band & 0x1f);
93 freqset.memoryfreqs[n].freq = _freq;
99 void on_call_userfreq(void)
101 unsigned int val = USER_MEMORY_NUM * USER_MEMORY_BANKS;
104 printstr("Mem: 000-");
105 print_numeric_nosupress(val - 1, 3);
106 val = read_numeric(val, 3, 4, 1);
110 void on_set_userfreq(void)
112 unsigned int val = USER_MEMORY_NUM * USER_MEMORY_BANKS;
117 printstr("Set Mem: 000-");
118 print_numeric_nosupress(val - 1, 3);
119 val = read_numeric(val, 3, 4, 1);
122 printstr("OK? A=OK ");
124 n = pollkeys(pollkeybuf, 19, 1);
127 if(c != charcode_a) return;
132 void on_updown_userfreq(void)
137 unsigned char _userband;
142 _freq = setup.amfreq;
143 _userband = setup.am_userbandnum;
144 _band = setup.amband;
146 _userband = setup.fm_userbandnum;
147 _band = setup.fmband;
148 _freq = setup.fmfreq;
155 print_numeric_nosupress(setup.memorynum, 3);
160 c = pollkey_single_timeout(44, 1); // About 1s
162 case charcode_7: // UP 1CH
164 if(setup.memorynum >= (USER_MEMORY_NUM * USER_MEMORY_BANKS)) setup.memorynum = 0;
165 call_freqbank(setup.memorynum);
167 case charcode_1: // Down 1CH
168 if(setup.memorynum == 0) setup.memorynum = USER_MEMORY_NUM * USER_MEMORY_BANKS;
170 call_freqbank(setup.memorynum);
172 case charcode_9: // Up CH FAST
173 setup.memorynum += 100;
174 if(setup.memorynum > (USER_MEMORY_NUM * USER_MEMORY_BANKS)) {
175 setup.memorynum = setup.memorynum % 100;
177 call_freqbank(setup.memorynum);
179 case charcode_3: // Down CH FAST
180 if(setup.memorynum < 100) {
181 setup.memorynum = (((USER_MEMORY_NUM * USER_MEMORY_BANKS) / 100 - 1) * 100) + (setup.memorynum % 100);
183 setup.memorynum -= 100;
185 call_freqbank(setup.memorynum);
187 case charcode_8: // Up CH FAST
188 setup.memorynum += USER_MEMORY_NUM;
189 if(setup.memorynum >= (USER_MEMORY_NUM * USER_MEMORY_BANKS)) {
190 setup.memorynum = setup.memorynum - USER_MEMORY_NUM * USER_MEMORY_BANKS;
192 call_freqbank(setup.memorynum);
194 case charcode_2: // Down CH FAST
195 if(setup.memorynum < USER_MEMORY_NUM) {
196 setup.memorynum = (USER_MEMORY_NUM * USER_MEMORY_BANKS) - USER_MEMORY_NUM + setup.memorynum;
198 setup.memorynum -= USER_MEMORY_NUM;
200 call_freqbank(setup.memorynum);
202 case charcode_5: // Reset
204 setup.fmband = _band;
205 setup.fm_userbandnum = _userband;
206 setup.fmfreq = _freq;
208 setup.amband = _band;
209 setup.am_userbandnum = _userband;
210 setup.amfreq = _freq;
212 akc6955_chg_fm(_fm, _freq);