OSDN Git Service

[MENU] Split help routines/datas to helps.[c|h].
[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 const char *updown_helpstr[20] = {
34         "Help", "F=exit any=continue",
35         "5: Menu", " ",
36         "1: Slow Down", "3: Slow Up",
37         "4: Down", "6: Up",
38         "7: Fast Down", "9: Fast Up",
39         "2: Band Down", "8: Band Up",
40         "0: Mode3K", " ",
41         "a: AM/FM", "b: Volume",
42         "c: Scan", "d: Stereo mode",
43         "e: Backlight", "f: (Exit) Help",
44     };
45
46 const char *setup_helpstr[16] = {
47         "Help", "F=exit any=continue",
48         "0: Power OFF", "C: Save status",
49         "d: Reset default", "E: BL time",
50         "A: Load", "",
51         "1: FM CNR", "2: AM CNR"
52         "3: FM STEREO", "4: Reserve"
53         "6: Reserve", "7: Reserve",
54         "8: Reserve", "9: Reserve",
55         "5: Cancel", "f: (Exit) Help",
56     };
57
58 const char *mainmenu_helpstr[18] = {
59         "Help", "F=exit any=continue",
60         "0: Setup", "1: Reserve",
61         "2: Band", "3: Freq",
62         "4: Reserve", "5: Scan"
63         "6: Gain", "7: Volume",
64         "8: FM Wide/Narrow", "9: Reserved",
65         "a: PowOFF", "b: Cancel",
66         "c: Set user", "d: Input user",
67         "e: AM/FM", "f: (Exit) Help"
68 };
69
70 const char *numeric_helpstr[10] = {
71      "On numeric input", " ",
72     "0-9: Numeric", "f: enter",
73     "a: Delete", "b: Reset value",
74     "d: Left", "e: Right",
75     "Press any key", " to continue."
76 };
77
78
79 void setup_help(void)
80 {
81     unsigned char c;
82     char l;
83     l = 0;
84     do {
85         c = printhelp_2lines(setup_helpstr[l], setup_helpstr[l + 1]);
86         if(c == charcode_f) return;
87         l += 2;
88         if(l >= 16) {
89             c = numeric_help();
90             if(c == charcode_f) return;
91             l = 0;
92         }
93     } while(1);
94
95 }
96
97 unsigned char printhelp_2lines(char *l1, char *l2)
98 {
99     _CLS();
100     _LOCATE(0,0);
101     printstr(l1);
102     _LOCATE(0,1);
103     printstr(l2);
104     _HOME();
105     return pollkey_single();
106 }
107
108 unsigned char numeric_help(void)
109 {
110     unsigned char c;
111     char l;
112     l = 0;
113     do {
114         c = printhelp_2lines(numeric_helpstr[l], numeric_helpstr[l + 1]);
115         if(c == charcode_f) return charcode_f;
116         l += 2;
117     } while(l < 10);
118     return c;
119 }
120
121 void mainmenu_help(void)
122 {
123     unsigned char c;
124
125     char l;
126     l = 0;
127     do {
128         c = printhelp_2lines(mainmenu_helpstr[l], mainmenu_helpstr[l + 1]);
129         if(c == charcode_f) return;
130         l += 2;
131         if(l >= 18) {
132             c = numeric_help();
133             if(c == charcode_f) return;
134             l = 0;
135         }
136     } while(1);
137 }
138
139 void updown_help(void)
140 {
141     unsigned char c;
142     char l;
143
144     l = 0;
145     do {
146         c = printhelp_2lines(updown_helpstr[l], updown_helpstr[l + 1]);
147         if(c == charcode_f) return;
148         l += 2;
149         if(l >= 20) {
150             c = numeric_help();
151             if(c == charcode_f) return;
152             l = 0;
153         }
154     } while(1);
155 }