OSDN Git Service

[SCHEMATIC] Modify SW/MW/LW Preamp, insert galbanic-isolator replace of common-mode...
[openi2cradio/OpenI2CRadio.git] / helps.c
1 /*
2  * OpenI2CRADIO
3  * Menu:HELP.
4  * Copyright (C) 2013-06-21 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 "power.h"
31 #include "commondef.h"
32
33 #if 1
34 const char *userfreq_helpstr[16] = {
35 #else
36 const char *userfreq_helpstr[10] = {
37 #endif
38        "5: Reload", " ",
39         "1: -1", "7: +1",
40 #if 1
41         "2: -28", "8: +28",
42         "3: -100", "9: +100",
43 #endif
44         "4: Call direct", "6: Set",
45         "A: Exit",  "D: Reset",
46         "E: Backlight", "F: (Exit) Help",
47     };
48
49 const char *updown_helpstr[16] = {
50         "5: Menu", "0: Narrow/Broad",
51         "1: Slow Down", "3: Slow Up",
52         "4: Down", "6: Up",
53         "7: Fast Down", "9: Fast Up",
54         "2: Band Down", "8: Band Up",
55         "A: AM/FM", "B: User freq",
56         "C Scan", "D: Stereo mode",
57         "E: Backlight", "F: (Exit) Help",
58     };
59
60 const char *setup_helpstr[14] = {
61         "0: Power OFF",  "1: List userband",
62         "3: BL Level", "E: BL time",
63         "A: Load", "D: Reset default",
64         "C: Save status", "6: ",
65         "7: FM CNR", "8: AM CNR",
66         "9: FM STEREO", "4: FM BW",
67         "5: Cancel", "F: (Exit) Help",
68     };
69
70 const char *mainmenu_helpstr[16] = {
71         "0: Setup", "1: Band",
72         "2:Resv", "3: Freq",
73         "4: Call user", "6: Set user",
74         "7: Power Off", "8: Volume",
75         "9: Reload", "A: AM/FM",
76         "B: Cancel","C: Set user",
77         "D: Input user","E: FM PITCH",
78         " ", "F: (Exit) Help",
79 };
80
81 const char *numeric_helpstr[8] = {
82      "On numeric", "input",
83     "0-9: Numeric", "F: enter",
84     "A: Delete", "B: Reset value",
85     "D: Left", "E: Right",
86 };
87
88 const char *version_helpstr[8] = {
89     "Open I2C Radio", "V2.00pre",
90     "(C) 2013", "Kyuma Ohta",
91     "Licensed under", "GPLv2+LE",
92     "Press any key", " to continue.",
93 };
94
95 static unsigned char help_header(void)
96 {
97     return printhelp_2lines("Help", "F=exit any=continue");
98 }
99
100 static unsigned char help_version(void)
101 {
102     unsigned char c;
103     unsigned char i;
104     for(i = 0; i < 8; i += 2){
105         c = printhelp_2lines(version_helpstr[i], version_helpstr[i + 1]);
106         if(c == charcode_f) return c;
107     }
108     return help_header();
109 }
110
111
112 void setup_help(void)
113 {
114     unsigned char c;
115     char l;
116     l = 0;
117     if(help_header() == charcode_f) return;
118     do {
119         c = printhelp_2lines(setup_helpstr[l], setup_helpstr[l + 1]);
120         if(c == charcode_f) return;
121         l += 2;
122         if(l >= 14) {
123             c = numeric_help();
124             if(c == charcode_f) return;
125             if(help_version() == charcode_f) return;
126             l = 0;
127         }
128     } while(1);
129
130 }
131
132 unsigned char printhelp_2lines(const char *l1, const char *l2)
133 {
134     _CLS();
135     _LOCATE_0_0();
136     printstr(l1);
137     _LOCATE_0_1();
138     printstr(l2);
139     _HOME();
140     return pollkey_single();
141 }
142
143 unsigned char numeric_help(void)
144 {
145     unsigned char c;
146     char l;
147     l = 0;
148     do {
149         c = printhelp_2lines(numeric_helpstr[l], numeric_helpstr[l + 1]);
150         if(c == charcode_f) return charcode_f;
151         l += 2;
152     } while(l < 8);
153     return c;
154 }
155
156 void mainmenu_help(void)
157 {
158     unsigned char c;
159
160     char l;
161     l = 0;
162     if(help_header() == charcode_f) return;
163     do {
164         c = printhelp_2lines(mainmenu_helpstr[l], mainmenu_helpstr[l + 1]);
165         if(c == charcode_f) return;
166         l += 2;
167         if(l >= 16) {
168             c = numeric_help();
169             if(c == charcode_f) return;
170             if(help_version() == charcode_f) return;
171             l = 0;
172         }
173     } while(1);
174 }
175
176 void updown_help(void)
177 {
178     unsigned char c;
179     char l;
180
181     l = 0;
182     if(help_header() == charcode_f) return;
183     do {
184         c = printhelp_2lines(updown_helpstr[l], updown_helpstr[l + 1]);
185         if(c == charcode_f) return;
186         l += 2;
187         if(l >= 16) {
188             c = numeric_help();
189             if(c == charcode_f) return;
190            if(help_version() == charcode_f) return;
191             l = 0;
192         }
193     } while(1);
194 }
195
196
197 void userfreq_help(void)
198 {
199     unsigned char c;
200     char l;
201
202     l = 0;
203     if(help_header() == charcode_f) return;
204     do {
205         c = printhelp_2lines(userfreq_helpstr[l], userfreq_helpstr[l + 1]);
206         if(c == charcode_f) return;
207         l += 2;
208         if(l >= 16) {
209             c = numeric_help();
210             if(c == charcode_f) return;
211             if(help_version() == charcode_f) return;
212             l = 0;
213         }
214     } while(1);
215 }
216