OSDN Git Service

[ADC] Measure battery with MCU's FIXED-VOLTAGE-REFERENCE, not use AKC6955's ADC.
[openi2cradio/OpenI2CRadio.git] / menu.h
1 /*
2  * OpenI2CRADIO
3  * Menu sub-routines.
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 #ifndef MENU_H
30 #define MENU_H
31
32 #include <stdarg.h>
33 #include <stdio.h>
34 #include <stdlib.h>
35 #include <string.h>
36 #if defined(__SDCC)
37 #include <sdcc-lib.h>
38 #include <pic18fregs.h> /* ONLY FOR PIC18x */
39 #include <delay.h>
40 #else
41 #include <xc.h>
42 #endif
43
44 #include "iodef.h"
45 #include "idle.h"
46 #include "i2c_io.h"
47 #include "akc6955.h"
48 #include "lcd_acm1602.h"
49 #include "ui.h"
50 #include "eeprom.h"
51 #include "ioports.h"
52 #include "helps.h"
53 #include "menu_ui.h"
54 #include "eeprom_util.h"
55
56 #ifdef  __cplusplus
57 extern "C" {
58 #endif
59
60     
61 #define USER_MEMORY_NUM 28
62 #define USER_MEMORY_BANKS 24
63     typedef struct {
64         unsigned char band;
65         unsigned char fm;
66         unsigned int freq;
67     } _memoryfreq_t;
68     /*
69      * main.c
70      */
71
72 typedef struct {
73         unsigned char mode3k; // mode3k if am
74         unsigned char start;
75         unsigned char stop;
76         unsigned int freq;
77         unsigned char reserve[3];
78 } _userband_t;
79
80 #define USER_BAND_NUM 10
81 typedef struct {
82     unsigned int magic;
83     unsigned int version;
84     _userband_t am_usrbands[USER_BAND_NUM];
85     _userband_t fm_usrbands[USER_BAND_NUM];
86     unsigned int checksum;
87 } __userband_t_t;
88
89 // Frequencyset of 1Sector.
90 // Below v1.0.
91 typedef struct {
92     unsigned int magic;
93     unsigned int version;
94     unsigned int pagenum;
95     _memoryfreq_t memoryfreqs[USER_MEMORY_NUM];
96     unsigned int checksum;
97 } __freqset_t;
98
99 typedef struct {
100     unsigned int amfreq;
101     unsigned int fmfreq;
102     unsigned int amfreq_bank[AKC6955_BAND_AMEND];
103     unsigned int fmfreq_bank[AKC6955_BAND_FMEND];
104     unsigned char amband;
105     unsigned char fmband;
106     unsigned char fm;
107     unsigned char am_mode3k;
108     unsigned char am_userbandnum;
109     unsigned char fm_userbandnum;
110     unsigned char threshold_amcnr; // Reg 0x08
111     unsigned char threshold_fmcnr; // Reg 0x08
112     unsigned char threshold_width; // Reg 0x08
113     unsigned char threshold_fmstereo; // Reg 0x08
114     banddesc am_userband_freq[USER_BAND_NUM];
115     banddesc fm_userband_freq[USER_BAND_NUM];
116     unsigned char stereo;
117     unsigned char volume;
118     unsigned char prevolume;
119     unsigned char fmbandwidth;
120     unsigned char lowboost;
121     int backlight_long;
122     int backlight_level;
123     unsigned int ui_idlecount;
124     unsigned int memorynum;
125     unsigned char fm_tunepitch;
126     unsigned int pagenum;
127 } __radioset_t;
128
129
130     extern __radioset_t setup;
131     extern __freqset_t freqset;
132     extern __freqset_t freqset_temp;
133     extern __userband_t_t userband;
134     extern const banddesc ambands[19];
135     extern const banddesc fmbands[8];
136     extern unsigned char scanflag;
137
138     extern unsigned char stereoflag;
139     extern unsigned char tuneflag;
140     extern unsigned char cnrlevel;
141     extern int diffstat;
142     extern unsigned int batlevel_6955;
143     extern unsigned int battlevel;
144
145     extern int recv_signal;
146     extern int backlight_counter;
147     extern unsigned char backlight_level;
148     extern unsigned char pollkeybuf[33];
149     extern unsigned char scanflag;
150
151     /*
152      * ui_updown.c
153      */
154     extern void setfreq_updown(unsigned char ctlword);
155     extern void setdefault(void);
156
157     /*
158      * menu_userband.c
159      */
160     extern void input_userband(void);
161     extern void set_userband(void);
162     extern void call_userband(unsigned char num);
163     extern void list_userband(void);
164
165     /*
166      * menu_scan.c
167      */
168     extern void scan_start(void);
169     /*
170      * menu_volume.c
171      */
172     extern void set_volume(void);
173
174     /*
175      * menu_defs.c
176      */
177     extern void setdefault(void);
178     extern void valinit(void);
179
180
181     /*
182      * menu.c
183      */
184     extern void toggle_amfm(void);
185     extern void set_stereomode(void);
186     extern void set_stereo(void);
187     extern void setband_direct(void);
188     extern void setfreq_direct(void);
189     extern void menu_poweroff(void);
190     extern void setup_akc6955(void);
191     extern void main_menu(void);
192
193     /*
194      * menu_setup.c
195      */
196     extern void setup_menu(void);
197     extern void menu_load(void);
198     extern void menu_save(void);
199
200
201 #ifdef  __cplusplus
202 }
203 #endif
204
205 #endif  /* MENU_H */
206