diff --git a/Makefile b/Makefile index 255dd92..6662458 100644 --- a/Makefile +++ b/Makefile @@ -29,7 +29,7 @@ ENABLE_NOAA := 0 ENABLE_VOICE := 0 ENABLE_MUTE_RADIO_FOR_VOICE := 0 # Tx on Voice 1.0 kB -ENABLE_VOX := 0 +ENABLE_VOX := 1 ENABLE_VOX_MORE_SENSITIVE := 1 ENABLE_REDUCE_LOW_MID_TX_POWER := 1 # Tx Alarm 600 B diff --git a/app/main.c b/app/main.c index a2ed4b2..d300700 100644 --- a/app/main.c +++ b/app/main.c @@ -194,7 +194,6 @@ void toggle_chan_scanlist(void) void processFKeyFunction(const key_code_t Key) { - uint8_t Band; uint8_t vfo = g_eeprom.config.setting.tx_vfo_num; if (g_current_function == FUNCTION_TRANSMIT || g_current_display_screen == DISPLAY_MENU) @@ -245,23 +244,28 @@ void processFKeyFunction(const key_code_t Key) APP_stop_scan(); - Band = g_tx_vfo->channel_attributes.band + 1; - if (g_eeprom.config.setting.enable_350 || Band != BAND5_350MHz) { - if (Band > BAND7_470MHz) - Band = BAND1_50MHz; // wrap-a-round - } - else - Band = BAND6_400MHz; // jump to next band - g_tx_vfo->channel_attributes.band = Band; + unsigned int band = g_tx_vfo->channel_attributes.band; - g_eeprom.config.setting.indices.vfo[vfo].screen = FREQ_CHANNEL_FIRST + Band; - g_eeprom.config.setting.indices.vfo[vfo].frequency = FREQ_CHANNEL_FIRST + Band; + #if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG) + UART_printf("band %u\r\n", band); + #endif + + if (++band > BAND7_470MHz) + band = BAND1_50MHz; + if (!g_eeprom.config.setting.enable_350 && band == BAND5_350MHz) + band = BAND6_400MHz; // jump to next band + g_tx_vfo->channel_attributes.band = band; + + g_eeprom.config.setting.indices.vfo[vfo].screen = FREQ_CHANNEL_FIRST + band; + g_eeprom.config.setting.indices.vfo[vfo].frequency = FREQ_CHANNEL_FIRST + band; + } g_request_save_vfo = true; g_vfo_configure_mode = VFO_CONFIGURE_RELOAD; g_request_display_screen = DISPLAY_MAIN; + break; case KEY_2: // A/B @@ -836,12 +840,12 @@ void MAIN_Key_STAR(bool key_pressed, bool key_held) if (g_scan_state_dir != SCAN_STATE_DIR_OFF) { // RF scanning - + #ifdef ENABLE_SCAN_IGNORE_LIST if (scanning_paused()) { FI_add_freq_ignored(g_rx_vfo->freq_config_rx.frequency); - + // immediately continue the scan g_scan_pause_tick_10ms = 0; g_scan_pause_time_mode = false; @@ -987,7 +991,7 @@ void MAIN_Key_UP_DOWN(bool key_pressed, bool key_held, scan_state_dir_t directio const frequency_band_t band = FREQUENCY_GetBand(freq); const uint32_t upper = FREQ_BAND_TABLE[band].upper; const uint32_t lower = FREQ_BAND_TABLE[band].lower; - + freq += step * direction; // wrap-a-round diff --git a/driver/i2c.c b/driver/i2c.c index 373f61f..eb844d2 100644 --- a/driver/i2c.c +++ b/driver/i2c.c @@ -56,31 +56,31 @@ uint8_t I2C_Read_fast(bool bFinal) for (i = 0; i < 8; i++) { GPIO_ClearBit(&GPIOA->DATA, GPIOA_PIN_I2C_SCL); - SYSTICK_Delay250ns(1); + SYSTICK_Delay250ns(2); GPIO_SetBit(&GPIOA->DATA, GPIOA_PIN_I2C_SCL); - SYSTICK_Delay250ns(1); + SYSTICK_Delay250ns(2); Data <<= 1; - SYSTICK_Delay250ns(1); + SYSTICK_Delay250ns(2); if (GPIO_CheckBit(&GPIOA->DATA, GPIOA_PIN_I2C_SDA)) Data |= 1U; GPIO_ClearBit(&GPIOA->DATA, GPIOA_PIN_I2C_SCL); - SYSTICK_Delay250ns(1); + SYSTICK_Delay250ns(2); } PORTCON_PORTA_IE &= ~PORTCON_PORTA_IE_A11_MASK; PORTCON_PORTA_OD |= PORTCON_PORTA_OD_A11_BITS_ENABLE; GPIOA->DIR |= GPIO_DIR_11_BITS_OUTPUT; GPIO_ClearBit(&GPIOA->DATA, GPIOA_PIN_I2C_SCL); - SYSTICK_Delay250ns(1); + SYSTICK_Delay250ns(2); if (bFinal) GPIO_SetBit(&GPIOA->DATA, GPIOA_PIN_I2C_SDA); else GPIO_ClearBit(&GPIOA->DATA, GPIOA_PIN_I2C_SDA); - SYSTICK_Delay250ns(1); + SYSTICK_Delay250ns(2); GPIO_SetBit(&GPIOA->DATA, GPIOA_PIN_I2C_SCL); - SYSTICK_Delay250ns(1); + SYSTICK_Delay250ns(2); GPIO_ClearBit(&GPIOA->DATA, GPIOA_PIN_I2C_SCL); - SYSTICK_Delay250ns(1); + SYSTICK_Delay250ns(2); return Data; } diff --git a/firmware.bin b/firmware.bin index 9c733a0..debdc45 100644 Binary files a/firmware.bin and b/firmware.bin differ diff --git a/firmware.packed.bin b/firmware.packed.bin index ee170b3..e875900 100644 Binary files a/firmware.packed.bin and b/firmware.packed.bin differ diff --git a/misc.c b/misc.c index 73a419e..f24d733 100644 --- a/misc.c +++ b/misc.c @@ -90,8 +90,6 @@ bool g_monitor_enabled; bool g_has_aes_key; uint32_t g_challenge[4]; -uint16_t g_eeprom_rssi_calib[7][4]; - volatile uint16_t g_schedule_power_save_tick_10ms = battery_save_count_10ms; volatile bool g_schedule_power_save; diff --git a/misc.h b/misc.h index c1ef239..309305b 100644 --- a/misc.h +++ b/misc.h @@ -183,8 +183,6 @@ extern const uint32_t g_default_aes_key[4]; extern bool g_has_aes_key; extern uint32_t g_challenge[4]; -extern uint16_t g_eeprom_rssi_calib[7][4]; - extern volatile uint16_t g_schedule_power_save_tick_10ms; extern volatile bool g_schedule_power_save; diff --git a/radio.c b/radio.c index bb6252b..1ae352d 100644 --- a/radio.c +++ b/radio.c @@ -350,9 +350,9 @@ void RADIO_configure_channel(const unsigned int VFO, const unsigned int configur RADIO_ConfigureSquelchAndOutputPower(p_vfo); #ifdef ENABLE_AM_FIX + AM_fix_reset(VFO); if (p_vfo->channel.am_mode > 0 && g_eeprom.config.setting.am_fix) { - AM_fix_reset(VFO); AM_fix_10ms(VFO); } else diff --git a/settings.c b/settings.c index c0ef899..d8da3fb 100644 --- a/settings.c +++ b/settings.c @@ -329,7 +329,6 @@ void SETTINGS_read_eeprom(void) // EEPROM cleaning #if 1 - memset(&g_eeprom.config.unused13, 0xff, sizeof(g_eeprom.config.unused13)); memset(&g_eeprom.unused, 0xff, sizeof(g_eeprom.unused)); @@ -347,38 +346,25 @@ void SETTINGS_read_eeprom(void) { // used channel g_eeprom.config.channel_attributes[index].unused = 0x00; memset(g_eeprom.config.channel_name[index].unused, 0x00, sizeof(g_eeprom.config.channel_name[index].unused)); + + // ensure the channel band attribute is correct + if (g_eeprom.config.channel[index].frequency > 0 && g_eeprom.config.channel[index].frequency < 0xffffffff) + g_eeprom.config.channel_attributes[index].band = FREQUENCY_GetBand(g_eeprom.config.channel[index].frequency); } } -#endif - -#if 1 - // ensure the channel band attribute is correct - for (index = 0; index < 200; index++) - if (g_eeprom.config.channel_attributes[index].band <= BAND7_470MHz && - g_eeprom.config.channel[index].frequency > 0 && - g_eeprom.config.channel[index].frequency < 0xffffffff) - g_eeprom.config.channel_attributes[index].band = FREQUENCY_GetBand(g_eeprom.config.channel[index].frequency); - - // 0D60 .. force default VFO attributes - for (index = 0; index < 7; index++) - g_eeprom.config.channel_attributes[200 + index].attributes = 0xC0 | index; - g_eeprom.config.channel_attributes[200 + 7].attributes = 0x00; -#endif + // force default VFO attributes + for (index = 200; index < 207; index++) + g_eeprom.config.channel_attributes[index].attributes = 0xC0 | (index - 200); + g_eeprom.config.channel_attributes[207].attributes = 0x00; SETTINGS_save_attributes(); +#endif // **************************************** + // eeprom calibration data - memset(&g_eeprom.calib.unused3, 0xff, sizeof(g_eeprom.calib.unused3)); - - memcpy(&g_eeprom_rssi_calib[0], &g_eeprom.calib.rssi_band_123, 8); - memcpy(&g_eeprom_rssi_calib[1], &g_eeprom_rssi_calib[0], 8); - memcpy(&g_eeprom_rssi_calib[2], &g_eeprom_rssi_calib[0], 8); - memcpy(&g_eeprom_rssi_calib[3], &g_eeprom.calib.rssi_band_4567, 8); - memcpy(&g_eeprom_rssi_calib[4], &g_eeprom_rssi_calib[3], 8); - memcpy(&g_eeprom_rssi_calib[5], &g_eeprom_rssi_calib[3], 8); - memcpy(&g_eeprom_rssi_calib[6], &g_eeprom_rssi_calib[3], 8); +// memset(&g_eeprom.calib.unused3, 0xff, sizeof(g_eeprom.calib.unused3)); if (g_eeprom.calib.battery[0] >= 5000) { diff --git a/settings.h b/settings.h index b1af319..0171e9b 100644 --- a/settings.h +++ b/settings.h @@ -455,9 +455,11 @@ typedef struct { uint8_t unused6[6]; // 0xff's } __attribute__((packed)) squelch_band[2]; // 0 = bands 4567, 1 = bands 123 - // 0x1EC0 - uint16_t rssi_band_4567[4]; // RSSI bargraph thresholds .. (dBm + 160) * 2 - uint16_t rssi_band_123[4]; // RSSI bargraph thresholds .. (dBm + 160) * 2 + // 0x1EC0 .. mine = 006E 0078 0082 008C 0086 00AA 00CE 00F2 + struct { // RSSI bargraph thresholds .. (dBm + 160) * 2 + uint16_t band_4567[4]; // + uint16_t band_123[4]; // + } __attribute__((packed)) rssi_cal; // 0x1ED0 struct diff --git a/ui/main.c b/ui/main.c index d4c98b0..0eac516 100644 --- a/ui/main.c +++ b/ui/main.c @@ -285,56 +285,62 @@ void UI_update_rssi(const int16_t rssi, const uint16_t glitch, const uint16_t no { // original little RS bars // const int16_t dBm = (rssi / 2) - 160; - const uint8_t Line = (vfo == 0) ? 3 : 7; - uint8_t *p_line = g_frame_buffer[Line - 1]; - uint8_t rssi_level = 0; - - // TODO: sort out all 8 values from the eeprom + const uint8_t line = (vfo == 0) ? 3 : 7; + uint8_t *pline = g_frame_buffer[line - 1]; + unsigned int rssi_level = 0; + int16_t rssi_cal[7]; #if 1 - const unsigned int band = g_rx_vfo->channel_attributes.band; - const int16_t level0 = g_eeprom_rssi_calib[band][0]; - const int16_t level1 = g_eeprom_rssi_calib[band][1]; - const int16_t level2 = g_eeprom_rssi_calib[band][2]; - const int16_t level3 = g_eeprom_rssi_calib[band][3]; + if (g_tx_vfo->channel_attributes.band < 3) + { + rssi_cal[0] = g_eeprom.calib.rssi_cal.band_123[0]; + rssi_cal[2] = g_eeprom.calib.rssi_cal.band_123[1]; + rssi_cal[4] = g_eeprom.calib.rssi_cal.band_123[2]; + rssi_cal[6] = g_eeprom.calib.rssi_cal.band_123[3]; + } + else + { + rssi_cal[0] = g_eeprom.calib.rssi_cal.band_4567[0]; + rssi_cal[2] = g_eeprom.calib.rssi_cal.band_4567[1]; + rssi_cal[4] = g_eeprom.calib.rssi_cal.band_4567[2]; + rssi_cal[6] = g_eeprom.calib.rssi_cal.band_4567[3]; + } #else - const int16_t level0 = (-115 + 160) * 2; // -115dBm - const int16_t level1 = ( -89 + 160) * 2; // -89dBm - const int16_t level2 = ( -64 + 160) * 2; // -64dBm - const int16_t level3 = ( -39 + 160) * 2; // -39dBm + rssi_cal[0] = (-110 + 160) * 2; // -110 dBm + rssi_cal[2] = ( -90 + 160) * 2; // -90 dBm + rssi_cal[4] = ( -70 + 160) * 2; // -70 dBm + rssi_cal[6] = ( -50 + 160) * 2; // -50 dBm #endif - // create intermediate threshold values (linear interpolation) to make full use of the available RSSI bars/graphics - const int16_t level01 = (level0 + level1) / 2; - const int16_t level12 = (level1 + level2) / 2; - const int16_t level23 = (level2 + level3) / 2; + // linear interpolate the 4 values into 7 + rssi_cal[1] = (rssi_cal[0] + rssi_cal[2]) / 2; + rssi_cal[3] = (rssi_cal[2] + rssi_cal[4]) / 2; + rssi_cal[5] = (rssi_cal[4] + rssi_cal[6]) / 2; g_vfo_rssi[vfo] = rssi; - if (rssi >= level3) + if (rssi >= rssi_cal[6]) rssi_level = 7; else - if (rssi >= level23) + if (rssi >= rssi_cal[5]) rssi_level = 6; else - if (rssi >= level2) + if (rssi >= rssi_cal[4]) rssi_level = 5; else - if (rssi >= level12) + if (rssi >= rssi_cal[3]) rssi_level = 4; else - if (rssi >= level1) + if (rssi >= rssi_cal[2]) rssi_level = 3; else - if (rssi >= level01) + if (rssi >= rssi_cal[1]) rssi_level = 2; else - if (rssi >= level0 || g_current_function == FUNCTION_NEW_RECEIVE) - { + if (rssi >= rssi_cal[0] || g_current_function == FUNCTION_NEW_RECEIVE) rssi_level = 1; - } - if (g_vfo_rssi_bar_level[vfo] == rssi_level) - return; +// if (g_vfo_rssi_bar_level[vfo] == rssi_level) +// return; g_vfo_rssi_bar_level[vfo] = rssi_level; @@ -348,18 +354,18 @@ void UI_update_rssi(const int16_t rssi, const uint16_t glitch, const uint16_t no if (g_current_function == FUNCTION_TRANSMIT || g_current_display_screen != DISPLAY_MAIN) return; // display is in use - p_line = g_frame_buffer[Line - 1]; + pline = g_frame_buffer[line - 1]; - memset(p_line, 0, 23); + memset(pline, 0, 23); // untested !!! if (rssi_level == 0) - p_line = NULL; + pline = NULL; else - UI_drawBars(p_line, rssi_level); + UI_drawBars(pline, rssi_level); - ST7565_DrawLine(0, Line, 23, p_line); + ST7565_DrawLine(0, line, 23, pline); } } @@ -768,31 +774,20 @@ void UI_DisplayMain(void) const uint8_t freq_in_channel = g_vfo_info[vfo_num].freq_in_channel; // const uint8_t freq_in_channel = SETTINGS_find_channel(frequency); // currently way to slow -// if (g_vfo_info[vfo_num].channel.compand) - { - strcpy(str, " "); + strcpy(str, " "); - #ifdef ENABLE_SCAN_IGNORE_LIST - if (FI_freq_ignored(frequency) >= 0) - str[0] = 'I'; // frequency is in the ignore list - #endif + #ifdef ENABLE_SCAN_IGNORE_LIST + if (FI_freq_ignored(frequency) >= 0) + str[0] = 'I'; // frequency is in the ignore list + #endif - if (is_freq_chan && freq_in_channel <= USER_CHANNEL_LAST) - str[1] = 'F'; // channel number that contains this VFO frequency + if (is_freq_chan && freq_in_channel <= USER_CHANNEL_LAST) + str[1] = 'F'; // this VFO frequency is also found in a channel - if (g_vfo_info[vfo_num].channel.compand) - str[2] = 'C'; // compander is enabled + if (g_vfo_info[vfo_num].channel.compand) + str[2] = 'C'; // compander is enabled - UI_PrintStringSmall(str, LCD_WIDTH - (7 * 3), 0, line + 1); - } -// else -// { -// if (is_freq_chan && freq_in_channel <= USER_CHANNEL_LAST) -// { // channel number that contains this VFO frequency -// sprintf(str, "%03u", freq_in_channel); -// UI_PrintStringSmall(str, LCD_WIDTH - (7 * 3), 0, line + 1); -// } -// } + UI_PrintStringSmall(str, LCD_WIDTH - (7 * 3), 0, line + 1); } #endif }