From: K.Ohta Date: Tue, 13 Aug 2013 16:11:30 +0000 (+0900) Subject: [UI][Func] ADD User-memory frequency, feature v1.0 is completed ;-) X-Git-Url: http://git.osdn.net/view?p=openi2cradio%2FOpenI2CRadio.git;a=commitdiff_plain;h=31313fac9d22c910f3eab9bb06a89397953863ef [UI][Func] ADD User-memory frequency, feature v1.0 is completed ;-) --- diff --git a/helps.c b/helps.c index f53efd4..1b837ce 100644 --- a/helps.c +++ b/helps.c @@ -56,11 +56,12 @@ const char *setup_helpstr[14] = { const char *mainmenu_helpstr[14] = { "Help", "F=exit any=continue", "0: Setup", "1: Band", - "3: Freq", "5: Scan" - "7: Power Off", "9: Width", - "a: AM/FM", "b: Cancel", - "c: Set user", "d: Input user", - "e: Reserve", "f: (Exit) Help" + "3: Freq", "5: " + "4: Call user", "6: Set user", + "7: Power Off", "8: Volume", + "9: Width", "a: AM/FM", + "b: Cancel","c: Set user", + "d: Input user","f: (Exit) Help" }; const char *numeric_helpstr[10] = { @@ -124,7 +125,7 @@ void mainmenu_help(void) c = printhelp_2lines(mainmenu_helpstr[l], mainmenu_helpstr[l + 1]); if(c == charcode_f) return; l += 2; - if(l >= 18) { + if(l >= 16) { c = numeric_help(); if(c == charcode_f) return; l = 0; diff --git a/menu.c b/menu.c index c68ec19..0e5228c 100644 --- a/menu.c +++ b/menu.c @@ -27,6 +27,7 @@ */ #include "menu.h" +#include "menu_memoryfreq.h" #include "power.h" #include "commondef.h" @@ -593,8 +594,14 @@ void main_menu(void) } else if(c == charcode_3){ // Band setfreq_direct(); + }else if(c == charcode_4){ + on_call_userfreq(); + // Scan }else if(c == charcode_5){ - scan_start(); + // scan_start(); + // Scan + }else if(c == charcode_6){ + on_set_userfreq(); // Scan } else if(c == charcode_7){ menu_poweroff(); diff --git a/menu.h b/menu.h index e78081d..3eb9537 100644 --- a/menu.h +++ b/menu.h @@ -61,6 +61,13 @@ extern "C" { unsigned char stop; unsigned int freq; } _userband_t; + +#define USER_MEMORY_NUM 22 + typedef struct { + unsigned char band; + unsigned char fm; + unsigned int freq; + } _memoryfreq_t; /* * main.c */ @@ -91,6 +98,7 @@ typedef struct { int backlight_long; int backlight_level; unsigned int ui_idlecount; + _memoryfreq_t memoryfreqs[USER_MEMORY_NUM]; } __radioset_t; extern __radioset_t setup; diff --git a/menu_defs.c b/menu_defs.c index 17a37b3..7c2068f 100644 --- a/menu_defs.c +++ b/menu_defs.c @@ -110,20 +110,26 @@ void setdefault(void) p->threshold_fmcnr = 0; p->threshold_fmstereo = 0; p->threshold_width = 0; - for(i = 0; i < 4; i++){ + for(i = 0; i < USER_BAND_NUM; i++){ p->am_usrbands[i].start = 0x19; p->am_usrbands[i].stop = 0x32; } - for(i = 0; i < 4; i++){ + for(i = 0; i < USER_BAND_NUM; i++){ p->fm_usrbands[i].start = 0x19; p->fm_usrbands[i].stop = 0x32; } - for(i =0; i < 18; i++){ + for(i =0; i < AKC6955_BAND_AMEND; i++){ p->amfreq_bank[i] = ((ambands[i].end - ambands[i].start) / 2) + ambands[i].start; } - for(i =0; i < 8; i++){ + for(i =0; i < AKC6955_BAND_FMEND ; i++){ p->fmfreq_bank[i] = ((fmbands[i].end - fmbands[i].start) / 2) + fmbands[i].start; } + for(i = 0; i < USER_MEMORY_NUM; i++) { + p->memoryfreqs[i].band = AKC6955_BAND_MW2; + p->memoryfreqs[i].fm = 0; + p->memoryfreqs[i].freq = 594; // NHK1 Tokyo. + } + p->fmfreq = p->fmfreq_bank[p->fmband]; p->amfreq = p->amfreq_bank[p->amband]; p->stereo = 0xff; // Auto diff --git a/menu_memoryfreq.c b/menu_memoryfreq.c new file mode 100644 index 0000000..d2e9377 --- /dev/null +++ b/menu_memoryfreq.c @@ -0,0 +1,103 @@ +/* + * OpenI2CRADIO + * Menu sub-routines: Memory Freq. + * Copyright (C) 2013-08-14 K.Ohta + * License: GPL2+LE + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, + * or (at your option) any later version. + * This library / program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this library; see the file COPYING. If not, write to the + * Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + * + * As a special exception, if you link this(includeed from sdcc) library + * with other files, some of which are compiled with SDCC, + * to produce an executable, this library does not by itself cause + * the resulting executable to be covered by the GNU General Public License. + * This exception does not however invalidate any other reasons why + * the executable file might be covered by the GNU General Public License. + */ + +#include "menu.h" +#include "power.h" +#include "commondef.h" +#include "eeprom.h" + + +void call_freqbank(unsigned char num) +{ + unsigned char _fm; + unsigned char _band; + unsigned char _userband; + if(num >= USER_MEMORY_NUM) return; + _fm = setup.memoryfreqs[num].fm; + _userband = setup.memoryfreqs[num].band; + _band = _userband & 0x1f; + _userband = (_userband >> 5) & 0x07; + if(_fm) { // AM + setup.fmband = _band; + setup.fm_userbandnum = _userband; + } else { + setup.amband = _band; + setup.am_userbandnum = _userband; + } + akc6955_chg_fm(_fm, setup.memoryfreqs[num].freq); +} + + +void set_freqbank(unsigned char num) +{ + unsigned char _fm; + unsigned char _band; + unsigned char _userband; + unsigned int _freq; + + if(num >= USER_MEMORY_NUM) return; + + _fm = setup.fm; + _freq = setup.amfreq; + _userband = setup.am_userbandnum; + _band = setup.amband; + if(_fm){ + _userband = setup.fm_userbandnum; + _band = setup.fmband; + _freq = setup.fmfreq; + } + setup.memoryfreqs[num].fm = _fm; + setup.memoryfreqs[num].band = (_userband << 5) | (_band & 0x1f); + setup.memoryfreqs[num].freq = _freq; +} + + +void on_call_userfreq(void) +{ + unsigned int val = USER_MEMORY_NUM; + _CLS(); + _LOCATE(0,0); + printstr("Mem: 00-"); + print_numeric_nosupress(USER_MEMORY_NUM - 1, 2); + val = read_numeric(val, 2, 4, 1); + if(val >= USER_MEMORY_NUM) return; + call_freqbank(val); +} + +void on_set_userfreq(void) +{ + unsigned int val = USER_MEMORY_NUM; + _CLS(); + _LOCATE(0,0); + printstr("Set Mem: 00-"); + print_numeric_nosupress(USER_MEMORY_NUM - 1, 2); + val = read_numeric(val, 2, 4, 1); + if(val >= USER_MEMORY_NUM) return; + set_freqbank(val); + save_eeprom(); +} \ No newline at end of file diff --git a/menu_memoryfreq.h b/menu_memoryfreq.h new file mode 100644 index 0000000..b254e7e --- /dev/null +++ b/menu_memoryfreq.h @@ -0,0 +1,46 @@ +/* + * OpenI2CRADIO + * Menu sub-routines: Memory Freq. + * Copyright (C) 2013-08-14 K.Ohta + * License: GPL2+LE + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, + * or (at your option) any later version. + * This library / program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this library; see the file COPYING. If not, write to the + * Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + * + * As a special exception, if you link this(includeed from sdcc) library + * with other files, some of which are compiled with SDCC, + * to produce an executable, this library does not by itself cause + * the resulting executable to be covered by the GNU General Public License. + * This exception does not however invalidate any other reasons why + * the executable file might be covered by the GNU General Public License. + */ + +#ifndef MENU_MEMORYFREQ_H +#define MENU_MEMORYFREQ_H + +#ifdef __cplusplus +extern "C" { +#endif + +extern void call_freqbank(unsigned char num); +extern void set_freqbank(unsigned char num); +extern void on_call_userfreq(void); +extern void on_set_userfreq(void); + +#ifdef __cplusplus +} +#endif + +#endif /* MENU_MEMORYFREQ_H */ + diff --git a/nbproject/Makefile-default.mk b/nbproject/Makefile-default.mk index 608c3c6..874ef83 100644 --- a/nbproject/Makefile-default.mk +++ b/nbproject/Makefile-default.mk @@ -45,17 +45,17 @@ OBJECTDIR=build/${CND_CONF}/${IMAGE_TYPE} DISTDIR=dist/${CND_CONF}/${IMAGE_TYPE} # Source Files Quoted if spaced -SOURCEFILES_QUOTED_IF_SPACED=ui.c i2c_io.c main.c idle.c lcd_acm1602.c akc6955.c eeprom.c ioports.c menu.c power.c adc_int.c menu_defs.c eepromutil.c ui_updown.c ui_display.c radio_getstat.c helps.c +SOURCEFILES_QUOTED_IF_SPACED=ui.c i2c_io.c main.c idle.c lcd_acm1602.c akc6955.c eeprom.c ioports.c menu.c power.c adc_int.c menu_defs.c eepromutil.c ui_updown.c ui_display.c radio_getstat.c helps.c menu_memoryfreq.c # Object Files Quoted if spaced -OBJECTFILES_QUOTED_IF_SPACED=${OBJECTDIR}/ui.o ${OBJECTDIR}/i2c_io.o ${OBJECTDIR}/main.o ${OBJECTDIR}/idle.o ${OBJECTDIR}/lcd_acm1602.o ${OBJECTDIR}/akc6955.o ${OBJECTDIR}/eeprom.o ${OBJECTDIR}/ioports.o ${OBJECTDIR}/menu.o ${OBJECTDIR}/power.o ${OBJECTDIR}/adc_int.o ${OBJECTDIR}/menu_defs.o ${OBJECTDIR}/eepromutil.o ${OBJECTDIR}/ui_updown.o ${OBJECTDIR}/ui_display.o ${OBJECTDIR}/radio_getstat.o ${OBJECTDIR}/helps.o -POSSIBLE_DEPFILES=${OBJECTDIR}/ui.o.d ${OBJECTDIR}/i2c_io.o.d ${OBJECTDIR}/main.o.d ${OBJECTDIR}/idle.o.d ${OBJECTDIR}/lcd_acm1602.o.d ${OBJECTDIR}/akc6955.o.d ${OBJECTDIR}/eeprom.o.d ${OBJECTDIR}/ioports.o.d ${OBJECTDIR}/menu.o.d ${OBJECTDIR}/power.o.d ${OBJECTDIR}/adc_int.o.d ${OBJECTDIR}/menu_defs.o.d ${OBJECTDIR}/eepromutil.o.d ${OBJECTDIR}/ui_updown.o.d ${OBJECTDIR}/ui_display.o.d ${OBJECTDIR}/radio_getstat.o.d ${OBJECTDIR}/helps.o.d +OBJECTFILES_QUOTED_IF_SPACED=${OBJECTDIR}/ui.o ${OBJECTDIR}/i2c_io.o ${OBJECTDIR}/main.o ${OBJECTDIR}/idle.o ${OBJECTDIR}/lcd_acm1602.o ${OBJECTDIR}/akc6955.o ${OBJECTDIR}/eeprom.o ${OBJECTDIR}/ioports.o ${OBJECTDIR}/menu.o ${OBJECTDIR}/power.o ${OBJECTDIR}/adc_int.o ${OBJECTDIR}/menu_defs.o ${OBJECTDIR}/eepromutil.o ${OBJECTDIR}/ui_updown.o ${OBJECTDIR}/ui_display.o ${OBJECTDIR}/radio_getstat.o ${OBJECTDIR}/helps.o ${OBJECTDIR}/menu_memoryfreq.o +POSSIBLE_DEPFILES=${OBJECTDIR}/ui.o.d ${OBJECTDIR}/i2c_io.o.d ${OBJECTDIR}/main.o.d ${OBJECTDIR}/idle.o.d ${OBJECTDIR}/lcd_acm1602.o.d ${OBJECTDIR}/akc6955.o.d ${OBJECTDIR}/eeprom.o.d ${OBJECTDIR}/ioports.o.d ${OBJECTDIR}/menu.o.d ${OBJECTDIR}/power.o.d ${OBJECTDIR}/adc_int.o.d ${OBJECTDIR}/menu_defs.o.d ${OBJECTDIR}/eepromutil.o.d ${OBJECTDIR}/ui_updown.o.d ${OBJECTDIR}/ui_display.o.d ${OBJECTDIR}/radio_getstat.o.d ${OBJECTDIR}/helps.o.d ${OBJECTDIR}/menu_memoryfreq.o.d # Object Files -OBJECTFILES=${OBJECTDIR}/ui.o ${OBJECTDIR}/i2c_io.o ${OBJECTDIR}/main.o ${OBJECTDIR}/idle.o ${OBJECTDIR}/lcd_acm1602.o ${OBJECTDIR}/akc6955.o ${OBJECTDIR}/eeprom.o ${OBJECTDIR}/ioports.o ${OBJECTDIR}/menu.o ${OBJECTDIR}/power.o ${OBJECTDIR}/adc_int.o ${OBJECTDIR}/menu_defs.o ${OBJECTDIR}/eepromutil.o ${OBJECTDIR}/ui_updown.o ${OBJECTDIR}/ui_display.o ${OBJECTDIR}/radio_getstat.o ${OBJECTDIR}/helps.o +OBJECTFILES=${OBJECTDIR}/ui.o ${OBJECTDIR}/i2c_io.o ${OBJECTDIR}/main.o ${OBJECTDIR}/idle.o ${OBJECTDIR}/lcd_acm1602.o ${OBJECTDIR}/akc6955.o ${OBJECTDIR}/eeprom.o ${OBJECTDIR}/ioports.o ${OBJECTDIR}/menu.o ${OBJECTDIR}/power.o ${OBJECTDIR}/adc_int.o ${OBJECTDIR}/menu_defs.o ${OBJECTDIR}/eepromutil.o ${OBJECTDIR}/ui_updown.o ${OBJECTDIR}/ui_display.o ${OBJECTDIR}/radio_getstat.o ${OBJECTDIR}/helps.o ${OBJECTDIR}/menu_memoryfreq.o # Source Files -SOURCEFILES=ui.c i2c_io.c main.c idle.c lcd_acm1602.c akc6955.c eeprom.c ioports.c menu.c power.c adc_int.c menu_defs.c eepromutil.c ui_updown.c ui_display.c radio_getstat.c helps.c +SOURCEFILES=ui.c i2c_io.c main.c idle.c lcd_acm1602.c akc6955.c eeprom.c ioports.c menu.c power.c adc_int.c menu_defs.c eepromutil.c ui_updown.c ui_display.c radio_getstat.c helps.c menu_memoryfreq.c CFLAGS= @@ -162,6 +162,11 @@ ${OBJECTDIR}/helps.o: helps.c nbproject/Makefile-${CND_CONF}.mk ${RM} ${OBJECTDIR}/helps.o ${MP_CC} --debug-ralloc --use-non-free --verbose -V --pstack-model=small --obanksel=2 --optimize-cmp --optimize-df libc18f.lib libio18f45k20.lib -c -mpic16 -p18f45k20 helps.c -o${OBJECTDIR}/helps.o +${OBJECTDIR}/menu_memoryfreq.o: menu_memoryfreq.c nbproject/Makefile-${CND_CONF}.mk + ${MKDIR} ${OBJECTDIR} + ${RM} ${OBJECTDIR}/menu_memoryfreq.o + ${MP_CC} --debug-ralloc --use-non-free --verbose -V --pstack-model=small --obanksel=2 --optimize-cmp --optimize-df libc18f.lib libio18f45k20.lib -c -mpic16 -p18f45k20 menu_memoryfreq.c -o${OBJECTDIR}/menu_memoryfreq.o + else ${OBJECTDIR}/ui.o: ui.c nbproject/Makefile-${CND_CONF}.mk ${MKDIR} ${OBJECTDIR} @@ -248,6 +253,11 @@ ${OBJECTDIR}/helps.o: helps.c nbproject/Makefile-${CND_CONF}.mk ${RM} ${OBJECTDIR}/helps.o ${MP_CC} --debug-ralloc --use-non-free --verbose -V --pstack-model=small --obanksel=2 --optimize-cmp --optimize-df libc18f.lib libio18f45k20.lib -c -mpic16 -p18f45k20 helps.c -o${OBJECTDIR}/helps.o +${OBJECTDIR}/menu_memoryfreq.o: menu_memoryfreq.c nbproject/Makefile-${CND_CONF}.mk + ${MKDIR} ${OBJECTDIR} + ${RM} ${OBJECTDIR}/menu_memoryfreq.o + ${MP_CC} --debug-ralloc --use-non-free --verbose -V --pstack-model=small --obanksel=2 --optimize-cmp --optimize-df libc18f.lib libio18f45k20.lib -c -mpic16 -p18f45k20 menu_memoryfreq.c -o${OBJECTDIR}/menu_memoryfreq.o + endif # ------------------------------------------------------------------------------------ diff --git a/nbproject/Makefile-genesis.properties b/nbproject/Makefile-genesis.properties index e0454cd..1143fe3 100644 --- a/nbproject/Makefile-genesis.properties +++ b/nbproject/Makefile-genesis.properties @@ -1,5 +1,5 @@ # -#Tue Aug 13 23:15:40 JST 2013 +#Wed Aug 14 00:57:03 JST 2013 default.languagetoolchain.dir=/usr/local/bin default.br-unifei-rmaalmeida-toolchainSDCC-SDCCtoolchain.md5=b67cce1ad75b450308d7806e430931b3 com-microchip-mplab-nbide-embedded-makeproject-MakeProject.md5=1c49f19f6a43b876c317e0d8d41c0854 diff --git a/nbproject/configurations.xml b/nbproject/configurations.xml index 54bcca6..e142bd1 100644 --- a/nbproject/configurations.xml +++ b/nbproject/configurations.xml @@ -56,6 +56,8 @@ radio_getstat.c helps.c helps.h + menu_memoryfreq.c + menu_memoryfreq.h /usr/local/share/sdcc/lib/src/pic16/libc