OSDN Git Service

[SCHEMATIC] Modify SW/MW/LW Preamp, insert galbanic-isolator replace of common-mode...
[openi2cradio/OpenI2CRadio.git] / menu_setup.c
1 /*
2  * OpenI2CRADIO
3  * Menu sub-routines / Setup.
4  * Copyright (C) 2013-09-11 K.Ohta <whatisthis.sowhat ai gmail.com>
5  * License: GPL2+LE
6  *
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.
15  *
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,
19  *  MA 02110-1301, USA.
20  *
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.
27  */
28
29 #include "menu.h"
30 #include "menu_memoryfreq.h"
31 #include "power.h"
32 #include "commondef.h"
33 #include "backlight.h"
34
35 void menu_save(void)
36 {
37     unsigned char c;
38     c = printhelp_2lines("Save settings", "A=Yes");
39     if(c == charcode_a) {
40         save_eeprom();
41         save_userbands();
42     }
43 }
44
45 void menu_load(void)
46 {
47     unsigned char c;
48     c = printhelp_2lines("Load settings", "A=Yes B=Init");
49     if(c == charcode_a) {
50         c = load_eeprom();
51         load_userbands();
52         if( c != 0xff) {
53             _CLS();
54 //            _LOCATE(0,0);
55             c = printhelp_2lines("X) Load Error", "A=Fix");
56             setdefault();
57             if(c == charcode_a){
58                 save_eeprom();
59                 save_userbands();
60             }
61         }
62         setup_akc6955();
63     } else if(c == charcode_b){
64         setdefault();
65         setup_akc6955();
66     }
67 }
68
69 void setup_menu(void)
70 {
71     unsigned char c;
72     unsigned long val;
73     unsigned int val2;
74
75     c = printhelp_2lines("Setup F=HELP", "5=Return");
76     _CLS();
77    // _LOCATE(0,0);
78     switch(c){
79         case charcode_1:
80             list_userband();
81             break;
82         case charcode_3:
83             printstr("BL Level:");
84             val = read_numeric(setup.backlight_level, 3, 0,1);
85             if((val & 0x80000000) == 0) {
86                 val2 = val;
87                 if(val2 > 255) val2 = 255;
88                 if(val2 < 15) val2 = 15;
89                 setup.backlight_level = (unsigned char)val2;
90             }
91             break;
92         case charcode_4:
93             printstr("FM Bandwidth:");
94 //            c = akc6955_get_fmbandwidth();
95             setup.fmbandwidth = pollkey_numeric(0);
96             akc6955_set_fmbandwidth(setup.fmbandwidth);
97             break;
98         case charcode_5:
99             break;
100         case charcode_6:
101             printstr("UI Update:");
102             val = read_numeric(setup.ui_idlecount, 4, 0, 1);
103             if((val & 0x80000000) == 0) {
104                val2 = val;
105                if(val2 < 100) val2 = 100;
106                if(val2 > 5000) val2 = 5000;
107                setup.ui_idlecount = val2;
108                ui_idlekey = val2 / 92; // 23*4
109                ui_idlepad = val2 % 23;
110             } 
111             break;
112         case charcode_7:
113             printstr("FM-CNR:");
114             c = setup.threshold_fmcnr;
115             c = pollkey_numeric(c);
116             akc6955_set_thresh_fmcnr(c);
117             break;
118         case charcode_8:
119             printstr("AM-CNR:");
120             c = setup.threshold_amcnr;
121             c = pollkey_numeric(c);
122             akc6955_set_thresh_amcnr(c);
123             break;
124         case charcode_9:
125             printstr("Stereo th:");
126             c  = setup.threshold_fmstereo;
127             c = pollkey_numeric(c);
128             akc6955_set_thresh_fmstereo(c);
129             break;
130         case charcode_0:
131             menu_poweroff();
132             break;
133         case charcode_a:
134             menu_load();
135             break;
136         case charcode_c:
137             menu_save();
138             break;
139         case charcode_d:
140             setdefault();
141             break;
142         case charcode_e:
143             printstr("BL Long:");
144             val = read_numeric(setup.backlight_long, 3, 0,1);
145             if((val & 0x80000000) == 0) {
146                 val2 = val;
147                 if(val2 > 999) val2 = 999;
148                 setup.backlight_long = val2;
149             }
150             break;
151         case charcode_f:
152             setup_help();
153             break;
154         default:
155             break;
156     }
157     _CLS();
158     _LOCATE_0_0();
159 }
160