From: K.Ohta Date: Fri, 27 Sep 2013 17:34:20 +0000 (+0900) Subject: [EEPROM][V2.0] DO NOT CLEAR USERBAND on initializing. X-Git-Url: http://git.osdn.net/view?p=openi2cradio%2FOpenI2CRadio.git;a=commitdiff_plain;h=df818b11d5f376b68deaffb61dad1d6adffbaecc [EEPROM][V2.0] DO NOT CLEAR USERBAND on initializing. [UI][V2.0][USERBANDS] Add "Yes = A" on setting userband. --- diff --git a/eepromutil.c b/eepromutil.c index 77332f8..c239da4 100644 --- a/eepromutil.c +++ b/eepromutil.c @@ -242,7 +242,7 @@ void save_userbands(void) unsigned int sum; // Pass 0 Calc checksum - userband.magic = EEPROM_FREQSET_MAGIC; + userband.magic = EEPROM_BANDSET_MAGIC; userband.version = 0x0001; sum = calcsum_userband(&userband, 0x5a5a); userband.checksum = sum; @@ -257,15 +257,15 @@ void format_userbands(void) for(i = 0; i < USER_BAND_NUM; i++) { userband.am_usrbands[i].start = 0x19; userband.am_usrbands[i].stop = 0x32; - userband.am_usrbands[i].freq = 1216; //0x32 - (0x32-0x19) / 2 *32 + userband.am_usrbands[i].freq = 5600; //(0x32 - (0x32-0x19) / 2 *32) * 5 userband.am_usrbands[i].mode3k = 0; - } - for(i = 0; i < USER_BAND_NUM; i++) { + // userband.fm_usrbands[i].start = 0x19; userband.fm_usrbands[i].stop = 0x32; - userband.fm_usrbands[i].freq = 1216; //0x32 - (0x32-0x19) / 2 *32 + userband.fm_usrbands[i].freq = 8600; userband.fm_usrbands[i].mode3k = 0; } + save_userbands(); // Re-init } diff --git a/menu.h b/menu.h index fee0df7..ce3a0d7 100644 --- a/menu.h +++ b/menu.h @@ -153,6 +153,7 @@ typedef struct { */ extern void setfreq_updown(unsigned char ctlword); extern void setdefault(void); + extern void setdefault_userbands(void); /* * menu_userband.c diff --git a/menu_defs.c b/menu_defs.c index 03906fc..53192c3 100644 --- a/menu_defs.c +++ b/menu_defs.c @@ -97,6 +97,23 @@ unsigned char scanflag; /* * */ +void setdefault_userband(void) +{ + char i; +#if 0 + for(i = 0; i < USER_BAND_NUM; i++){ + userband.am_usrbands[i].start = 0x19; + userband.am_usrbands[i].stop = 0x32; + userband.am_usrbands[i].freq = (0x0a + 0x19) << 5; + userband.am_usrbands[i].mode3k = 0; + userband.fm_usrbands[i].start = 0x19; + userband.fm_usrbands[i].stop = 0x32; + userband.fm_usrbands[i].freq = ((0x0a + 0x19) << 5) + 3000; + } +#endif +} + + void setdefault(void) { char i; @@ -113,12 +130,6 @@ void setdefault(void) setup.threshold_fmcnr = 0; setup.threshold_fmstereo = 0; setup.threshold_width = 0; - for(i = 0; i < USER_BAND_NUM; i++){ - userband.am_usrbands[i].start = 0x19; - userband.am_usrbands[i].stop = 0x32; - userband.fm_usrbands[i].start = 0x19; - userband.fm_usrbands[i].stop = 0x32; - } for(i =0; i < AKC6955_BAND_AMEND; i++){ setup.amfreq_bank[i] = ((ambands[i].end - ambands[i].start) / 2) + ambands[i].start; } @@ -127,12 +138,13 @@ void setdefault(void) } setup.memorynum = 0x00; setup.pagenum = 0x00; +#if 0 for(i = 0; i < USER_MEMORY_NUM; i++) { freqset.memoryfreqs[i].band = AKC6955_BAND_MW2; freqset.memoryfreqs[i].fm = 0; freqset.memoryfreqs[i].freq = 594; // NHK1 Tokyo. } - +#endif setup.fmfreq = setup.fmfreq_bank[setup.fmband]; setup.amfreq = setup.amfreq_bank[setup.amband]; setup.stereo = 0xff; // Auto diff --git a/menu_userband.c b/menu_userband.c index f6157cc..3cb9133 100644 --- a/menu_userband.c +++ b/menu_userband.c @@ -72,11 +72,14 @@ void call_userband(unsigned char num) void set_userband(void) { - unsigned long from,to, tmp; + unsigned long from,to; unsigned char c; unsigned char pp; unsigned char mode3k; - char cc; + unsigned int freq; + unsigned int _from, _to, tmp; + unsigned char cc; + unsigned char fm = setup.fm; _CLS(); _LOCATE(0,0); @@ -85,30 +88,13 @@ void set_userband(void) c = pollkey_numeric(c); if(c >= USER_BAND_NUM) return; - if(setup.fm != 0){ + if(fm != 0){ from = userband.fm_usrbands[c].start * 80 + 3000; // 32*25/10 to = userband.fm_usrbands[c].stop * 80 + 3000; _CLS(); _LOCATE(0,0); printstr("FM#"); print_numeric_nosupress(c, 1); - _LOCATE(0,1); - printstr(" From:"); - from = read_numeric(from, 5, 7, 1); - if((from & 0x80000000) != 0) goto _l0; - _LOCATE(0,1); - printstr(" To: "); - to = read_numeric(to, 5, 7, 1); - if((to & 0x80000000) != 0) goto _l0; - if(from > to){ - tmp = to; - to = from; - from = tmp; - } - userband.fm_usrbands[c].start = (from - 3000) / 80; - userband.fm_usrbands[c].stop = (to - 3000) / 80 + 1; - userband.fm_usrbands[c].freq = from; - setup.fm_userbandnum = c; } else { mode3k = userband.am_usrbands[c].mode3k; pp = 96; // 3*32 @@ -120,6 +106,11 @@ void set_userband(void) printstr("AM#"); print_numeric_nosupress(c, 1); printstr(" Step:"); + if(mode3k == 0){ + printstr("5K->"); + } else { + printstr("3K->"); + } _LOCATE(0,1); printstr("0=3k 1=5k"); cc = pollkey_single(); @@ -129,28 +120,66 @@ void set_userband(void) } else if(cc == charcode_1) { pp = 160; mode3k = 0; + } else { + goto _l0; } - _CLS(); - _LOCATE(0,0); - printstr("AM#"); - print_numeric_nosupress(c, 1); - _LOCATE(0,1); - printstr(" From:"); - from = read_numeric(from, 5, 7, 1); - if((from & 0x80000000) != 0) goto _l0; - _LOCATE(0,1); - printstr(" To: "); - to = read_numeric(to, 5, 7, 1); - if((to & 0x80000000) != 0) goto _l0; - if(from > to){ - tmp = to; - to = from; - from = tmp; + _LOCATE(11,0); + if(mode3k == 0){ + printstr("5K "); + } else { + printstr("3K "); } - userband.am_usrbands[c].start = from / pp; - userband.am_usrbands[c].stop = to / pp + 1; + } + + _LOCATE(0,1); + printstr("From:"); + from = read_numeric(from, 5, 7, 1); + if((from & 0xffff0000) != 0) goto _l0; + _LOCATE(0,1); + printstr("To: "); + to = read_numeric(to, 5, 7, 1); + if((to & 0xffff0000) != 0) goto _l0; + + _from = (unsigned int)from; + _to = (unsigned int)to; + if(_from > _to){ + tmp = _to; + _to = _from; + _from = tmp; + } + freq = (_to - _from) / 2 + _from; + + _CLS(); + if(fm != 0){ + printstr("FM"); + } else { + printstr("AM"); + } + _PUTCHAR('#'); + _PUTCHAR('0' + c); + printstr(" A=OK"); + _LOCATE(0,1); + print_numeric_nosupress(_from, 5); + printstr("->"); + print_numeric_nosupress(_to, 5); + cc = pollkey_single(); + if(cc != charcode_a) goto _l0; + if(fm != 0) + { + if((_from <= 3000) || (_from >= 28000)) goto _l0; + if((_to <= 3000) || (_to >= 28000)) goto _l0; + userband.fm_usrbands[c].start = (_from - 3000) / 80; + userband.fm_usrbands[c].stop = (_to - 3000) / 80 + 1; + userband.fm_usrbands[c].freq = freq; + userband.fm_usrbands[c].mode3k = 0; + setup.fm_userbandnum = c; + } else { + if((_from <100) || (_from >= 28000)) goto _l0; + if((_to < 100) || (_to >= 28000)) goto _l0; + userband.am_usrbands[c].start = _from / pp; + userband.am_usrbands[c].stop = _to / pp + 1; userband.am_usrbands[c].mode3k = mode3k; - userband.am_usrbands[c].freq = from; + userband.am_usrbands[c].freq = freq; setup.am_userbandnum = c; } save_userbands();