OSDN Git Service

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