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"
54 void setfreq_updown(unsigned char ctlword)
57 case charcode_8: // Change band
59 amfreq_bank[amband] = amfreq;
60 if(amband >= AKC6955_BAND_MW4) {
65 amfreq = amfreq_bank[amband];
66 akc6955_set_amband(amband);
67 akc6955_set_freq(amfreq);
68 idle_time_62_5ms(); // 62.5ms
69 amband = akc6955_get_amband();
70 amfreq = akc6955_get_freq();
72 fmfreq_bank[fmband] = fmfreq;
73 if(fmband >= AKC6955_BAND_FMUSER) {
78 fmfreq = fmfreq_bank[fmband];
79 akc6955_set_fmband(fmband);
80 idle_time_62_5ms(); // 62.5ms
81 akc6955_set_freq(fmfreq);
82 fmband = akc6955_get_fmband();
83 fmfreq = akc6955_get_freq();
86 case charcode_2: // Change band
88 amfreq_bank[amband] = amfreq;
90 amband = AKC6955_BAND_MW4;
91 } else if(amband > AKC6955_BAND_MW4) {
92 amband = AKC6955_BAND_MW4;
96 amfreq = amfreq_bank[amband];
97 akc6955_set_amband(amband);
98 akc6955_set_freq(amfreq);
99 idle_time_62_5ms(); // 62.5ms
100 amband = akc6955_get_amband();
101 amfreq = akc6955_get_freq();
103 fmfreq_bank[fmband] = fmfreq;
105 fmband = AKC6955_BAND_FMUSER;
106 } else if(fmband > AKC6955_BAND_FMUSER) {
107 fmband = AKC6955_BAND_FMUSER;
111 fmfreq = fmfreq_bank[fmband];
112 akc6955_set_fmband(fmband);
113 idle_time_62_5ms(); // 62.5ms
114 akc6955_set_freq(fmfreq);
115 fmband = akc6955_get_fmband();
116 fmfreq = akc6955_get_freq();
119 case charcode_4: // Down Freq;
121 fmfreq = akc6955_down_freq(25); // DOWN 250KHz
123 amfreq = akc6955_down_freq(30); // DOWN 30KHz
126 case charcode_6: // Down Freq;
129 fmfreq = akc6955_up_freq(25); // UP 250KHz
132 amfreq = akc6955_up_freq(30); // UP 30KHz
135 case charcode_9: // Down Fast;
138 fmfreq = akc6955_up_freq(50); // DOWN 500KHz
141 amfreq = akc6955_up_freq(100); // DOWN 100KHz
144 case charcode_7: // Down Fast;
147 fmfreq = akc6955_down_freq(50); // UP 500KHz
150 amfreq = akc6955_down_freq(100); // UP 10KHz
153 case charcode_1: // Down Slow;
156 fmfreq = akc6955_down_freq(3); // DOWN 30KHz
159 if(amband == AKC6955_BAND_MW2) {
160 amfreq = akc6955_down_freq(9);
161 } else if(amband == AKC6955_BAND_MW3) {
162 amfreq = akc6955_down_freq(10);
163 } else if(am_mode3k == 0x00) {
164 amfreq = akc6955_down_freq(3); // DOWN 50KHz
166 amfreq = akc6955_down_freq(5); // DOWN 50KHz
170 case charcode_3: // Down Slow;
173 fmfreq = akc6955_up_freq(3); // UP 30KHz
176 if(amband == AKC6955_BAND_MW2){
177 amfreq = akc6955_up_freq(9);
178 } else if(amband == AKC6955_BAND_MW3) {
179 amfreq = akc6955_up_freq(10);
180 } else if(am_mode3k == 0x00) {
181 amfreq = akc6955_up_freq(3); // DOWN 50KHz
183 amfreq = akc6955_up_freq(5); // DOWN 50KHz
187 case charcode_0: // Step
194 amfreq = akc6955_mode3k(am_mode3k);
197 case charcode_a: // Toggle FM
211 case charcode_e: // Backlight ON/OFF
212 if(backlight_counter > 0) {
213 backlight_counter = 0;
215 backlight_counter = backlight_long;