OSDN Git Service

[v2.0] Port to fm-tune-pitch from v1.0.
[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     }
42 }
43
44 void menu_load(void)
45 {
46     unsigned char c;
47     c = printhelp_2lines("Load settings", "A=Yes B=Init");
48     if(c == charcode_a) {
49         c = load_eeprom();
50         if( c != 0xff) {
51             _CLS();
52             _LOCATE(0,0);
53             c = printhelp_2lines("X) Load Error", "A=Fix");
54             setdefault();
55             if(c == charcode_a){
56                 save_eeprom();
57             }
58         }
59         setup_akc6955();
60     } else if(c == charcode_b){
61         setdefault();
62         setup_akc6955();
63     }
64 }
65
66 void setup_menu(void)
67 {
68     unsigned char c;
69     unsigned long val;
70
71     c = printhelp_2lines("Setup F=HELP", "5=Return");
72     _CLS();
73     _LOCATE(0,0);
74     switch(c){
75         case charcode_3:
76             printstr("BL Level:");
77             val = read_numeric(setup.backlight_level, 3, 0,1);
78             if((val & 0x80000000) == 0) {
79                 if(val > 255) val = 255;
80                 if(val < 15) val = 15;
81                 setup.backlight_level = (unsigned char)val;
82             }
83             break;
84         case charcode_4:
85             printstr("FM Bandwidth:");
86             akc6955_get_fmbandwidth(c);
87             setup.fmbandwidth = pollkey_numeric(c) & 3;
88             akc6955_set_fmbandwidth(setup.fmbandwidth);
89             break;
90         case charcode_5:
91             break;
92         case charcode_7:
93             printstr("FM-CNR:");
94             c = setup.threshold_fmcnr;
95             c = pollkey_numeric(c);
96             akc6955_set_thresh_fmcnr(c & 3);
97             break;
98         case charcode_8:
99             printstr("AM-CNR:");
100             c = setup.threshold_amcnr;
101             c = pollkey_numeric(c);
102             akc6955_set_thresh_amcnr(c & 3);
103             break;
104         case charcode_9:
105             printstr("Stereo th:");
106             c  = setup.threshold_fmstereo;
107             c = pollkey_numeric(c);
108             akc6955_set_thresh_fmstereo(c & 3);
109             break;
110         case charcode_0:
111             menu_poweroff();
112             break;
113         case charcode_a:
114             menu_load();
115             break;
116         case charcode_c:
117             menu_save();
118             break;
119         case charcode_d:
120             setdefault();
121             break;
122         case charcode_e:
123             printstr("BL Long:");
124             val = read_numeric(setup.backlight_long, 3, 0,1);
125             if((val & 0x80000000) == 0) {
126                 if(val > 999) val = 999;
127                 setup.backlight_long = val;
128             }
129             break;
130         case charcode_f:
131             setup_help();
132             break;
133         default:
134             break;
135     }
136     _CLS();
137     _LOCATE(0,0);
138 }
139