2023-09-09 08:03:56 +01:00
|
|
|
/* Copyright 2023 Dual Tachyon
|
|
|
|
* https://github.com/DualTachyon
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
2023-10-24 11:47:49 +01:00
|
|
|
#ifdef ENABLE_FMRADIO
|
2023-09-14 09:56:30 +01:00
|
|
|
#include "app/fm.h"
|
|
|
|
#endif
|
2023-09-09 08:03:56 +01:00
|
|
|
#include "driver/eeprom.h"
|
2023-10-27 10:52:32 +01:00
|
|
|
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
|
|
|
|
#include "driver/uart.h"
|
|
|
|
#endif
|
2023-09-09 08:03:56 +01:00
|
|
|
#include "misc.h"
|
|
|
|
#include "settings.h"
|
|
|
|
|
2023-10-08 20:23:37 +01:00
|
|
|
eeprom_config_t g_eeprom;
|
2023-09-09 08:03:56 +01:00
|
|
|
|
2023-10-24 11:47:49 +01:00
|
|
|
#ifdef ENABLE_FMRADIO
|
2023-10-19 14:21:37 +01:00
|
|
|
void SETTINGS_save_fm(void)
|
2023-09-09 08:03:56 +01:00
|
|
|
{
|
2023-09-14 09:56:30 +01:00
|
|
|
unsigned int i;
|
2023-09-28 13:26:27 +01:00
|
|
|
|
2023-09-14 09:56:30 +01:00
|
|
|
struct
|
|
|
|
{
|
2023-10-08 17:14:13 +01:00
|
|
|
uint16_t frequency;
|
|
|
|
uint8_t channel;
|
|
|
|
bool is_channel_selected;
|
|
|
|
uint8_t padding[4];
|
|
|
|
} state;
|
|
|
|
|
|
|
|
memset(&state, 0xFF, sizeof(state));
|
|
|
|
state.channel = g_eeprom.fm_selected_channel;
|
|
|
|
state.frequency = g_eeprom.fm_selected_frequency;
|
|
|
|
state.is_channel_selected = g_eeprom.fm_is_channel_mode;
|
|
|
|
|
2023-10-19 19:00:57 +01:00
|
|
|
EEPROM_WriteBuffer8(0x0E88, &state);
|
2023-10-08 17:14:13 +01:00
|
|
|
|
2023-09-14 09:56:30 +01:00
|
|
|
for (i = 0; i < 5; i++)
|
2023-10-19 19:00:57 +01:00
|
|
|
EEPROM_WriteBuffer8(0x0E40 + (i * 8), &g_fm_channels[i * 4]);
|
2023-09-14 09:56:30 +01:00
|
|
|
}
|
|
|
|
#endif
|
2023-09-09 08:03:56 +01:00
|
|
|
|
2023-10-19 14:21:37 +01:00
|
|
|
void SETTINGS_save_vfo_indices(void)
|
2023-09-09 08:03:56 +01:00
|
|
|
{
|
|
|
|
uint8_t State[8];
|
|
|
|
|
2023-09-20 08:29:11 +01:00
|
|
|
#ifndef ENABLE_NOAA
|
|
|
|
EEPROM_ReadBuffer(0x0E80, State, sizeof(State));
|
|
|
|
#endif
|
2023-09-28 13:26:27 +01:00
|
|
|
|
2023-10-08 17:14:13 +01:00
|
|
|
State[0] = g_eeprom.screen_channel[0];
|
|
|
|
State[1] = g_eeprom.user_channel[0];
|
|
|
|
State[2] = g_eeprom.freq_channel[0];
|
|
|
|
State[3] = g_eeprom.screen_channel[1];
|
|
|
|
State[4] = g_eeprom.user_channel[1];
|
|
|
|
State[5] = g_eeprom.freq_channel[1];
|
2023-09-14 09:56:30 +01:00
|
|
|
#ifdef ENABLE_NOAA
|
2023-10-08 17:14:13 +01:00
|
|
|
State[6] = g_eeprom.noaa_channel[0];
|
|
|
|
State[7] = g_eeprom.noaa_channel[1];
|
2023-09-09 08:03:56 +01:00
|
|
|
#endif
|
|
|
|
|
2023-10-19 19:00:57 +01:00
|
|
|
EEPROM_WriteBuffer8(0x0E80, State);
|
2023-09-09 08:03:56 +01:00
|
|
|
}
|
|
|
|
|
2023-10-12 12:34:01 +01:00
|
|
|
// *************************************************
|
|
|
|
|
2023-10-11 00:08:58 +01:00
|
|
|
#if 0
|
2023-10-12 12:34:01 +01:00
|
|
|
|
2023-10-10 23:47:05 +01:00
|
|
|
const uint8_t calib1[] =
|
|
|
|
{ // my first radios calibration data
|
|
|
|
0x0A, 0x4B, 0x53, 0x56, 0x59, 0x5C, 0x5F, 0x62, 0x64, 0x66, 0xFF, 0xFF,
|
|
|
|
0xFF, 0xFF, 0xFF, 0xFF, 0x05, 0x46, 0x50, 0x53, 0x56, 0x59, 0x5C, 0x5F,
|
|
|
|
0x62, 0x64, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x5A, 0x2D, 0x29, 0x26,
|
|
|
|
0x23, 0x20, 0x1D, 0x1A, 0x17, 0x14, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
|
|
|
0x64, 0x30, 0x2D, 0x29, 0x26, 0x23, 0x20, 0x1D, 0x1A, 0x17, 0xFF, 0xFF,
|
|
|
|
0xFF, 0xFF, 0xFF, 0xFF, 0x5A, 0x14, 0x11, 0x0E, 0x0B, 0x08, 0x03, 0x02,
|
|
|
|
0x02, 0x02, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x64, 0x11, 0x0E, 0x0B,
|
|
|
|
0x08, 0x05, 0x05, 0x04, 0x04, 0x04, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
|
|
|
0x32, 0x68, 0x6B, 0x6E, 0x6F, 0x72, 0x75, 0x77, 0x79, 0x7B, 0xFF, 0xFF,
|
|
|
|
0xFF, 0xFF, 0xFF, 0xFF, 0x28, 0x64, 0x67, 0x6A, 0x6C, 0x6E, 0x71, 0x73,
|
|
|
|
0x76, 0x78, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0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xFF, 0xFF,
|
|
|
|
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
|
|
|
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
|
|
|
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
|
|
|
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
|
|
|
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
|
|
|
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
|
|
|
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
|
|
|
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF
|
|
|
|
};
|
|
|
|
|
|
|
|
void SETTINGS_restore_calibration(void)
|
|
|
|
{
|
|
|
|
// const uint8_t buf[8] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
|
|
|
|
unsigned int index = 0;
|
|
|
|
while (index < sizeof(calib2))
|
|
|
|
{
|
|
|
|
const unsigned int addr = 0x1E00 + index;
|
2023-10-19 19:00:57 +01:00
|
|
|
EEPROM_WriteBuffer8(addr, &calib2[index]);
|
|
|
|
// EEPROM_WriteBuffer8(addr, buf);
|
2023-10-10 23:47:05 +01:00
|
|
|
index += 8;
|
|
|
|
}
|
|
|
|
}
|
2023-10-12 12:34:01 +01:00
|
|
|
|
2023-10-11 00:08:58 +01:00
|
|
|
#endif
|
2023-10-10 23:47:05 +01:00
|
|
|
|
2023-10-12 12:34:01 +01:00
|
|
|
// *************************************************
|
|
|
|
|
2023-10-19 14:21:37 +01:00
|
|
|
void SETTINGS_save(void)
|
2023-09-09 08:03:56 +01:00
|
|
|
{
|
2023-10-06 22:16:03 +01:00
|
|
|
uint8_t State[8];
|
2023-10-19 19:00:57 +01:00
|
|
|
|
2023-10-08 17:14:13 +01:00
|
|
|
State[0] = g_eeprom.chan_1_call;
|
|
|
|
State[1] = g_eeprom.squelch_level;
|
|
|
|
State[2] = g_eeprom.tx_timeout_timer;
|
2023-09-14 09:56:30 +01:00
|
|
|
#ifdef ENABLE_NOAA
|
2023-10-08 20:23:37 +01:00
|
|
|
State[3] = g_eeprom.noaa_auto_scan;
|
2023-09-09 08:03:56 +01:00
|
|
|
#else
|
|
|
|
State[3] = false;
|
|
|
|
#endif
|
2023-10-20 21:40:17 +08:00
|
|
|
|
|
|
|
#ifdef ENABLE_KEYLOCK
|
|
|
|
State[4] = g_eeprom.key_lock;
|
|
|
|
#else
|
|
|
|
State[4] = false;
|
|
|
|
#endif
|
2023-10-04 11:57:34 +01:00
|
|
|
#ifdef ENABLE_VOX
|
2023-10-08 17:14:13 +01:00
|
|
|
State[5] = g_eeprom.vox_switch;
|
|
|
|
State[6] = g_eeprom.vox_level;
|
2023-10-04 11:57:34 +01:00
|
|
|
#else
|
|
|
|
State[5] = false;
|
|
|
|
State[6] = 0;
|
|
|
|
#endif
|
2023-10-08 17:14:13 +01:00
|
|
|
State[7] = g_eeprom.mic_sensitivity;
|
2023-10-19 19:00:57 +01:00
|
|
|
EEPROM_WriteBuffer8(0x0E70, State);
|
2023-09-09 08:03:56 +01:00
|
|
|
|
2023-10-18 11:31:30 +01:00
|
|
|
#ifdef ENABLE_CONTRAST
|
|
|
|
State[0] = g_setting_contrast;
|
|
|
|
#else
|
|
|
|
State[0] = 0xFF;
|
|
|
|
#endif
|
2023-10-08 17:14:13 +01:00
|
|
|
State[1] = g_eeprom.channel_display_mode;
|
|
|
|
State[2] = g_eeprom.cross_vfo_rx_tx;
|
|
|
|
State[3] = g_eeprom.battery_save;
|
|
|
|
State[4] = g_eeprom.dual_watch;
|
|
|
|
State[5] = g_eeprom.backlight;
|
|
|
|
State[6] = g_eeprom.tail_note_elimination;
|
|
|
|
State[7] = g_eeprom.vfo_open;
|
2023-10-19 19:00:57 +01:00
|
|
|
EEPROM_WriteBuffer8(0x0E78, State);
|
2023-09-09 08:03:56 +01:00
|
|
|
|
2023-10-08 17:14:13 +01:00
|
|
|
State[0] = g_eeprom.beep_control;
|
|
|
|
State[1] = g_eeprom.key1_short_press_action;
|
|
|
|
State[2] = g_eeprom.key1_long_press_action;
|
|
|
|
State[3] = g_eeprom.key2_short_press_action;
|
|
|
|
State[4] = g_eeprom.key2_long_press_action;
|
|
|
|
State[5] = g_eeprom.scan_resume_mode;
|
|
|
|
State[6] = g_eeprom.auto_keypad_lock;
|
|
|
|
State[7] = g_eeprom.pwr_on_display_mode;
|
2023-10-19 19:00:57 +01:00
|
|
|
EEPROM_WriteBuffer8(0x0E90, State);
|
2023-09-09 08:03:56 +01:00
|
|
|
|
2023-10-06 22:16:03 +01:00
|
|
|
{
|
|
|
|
struct {
|
2023-10-25 13:07:12 +01:00
|
|
|
uint32_t password;
|
|
|
|
#ifdef ENABLE_MDC1200
|
|
|
|
uint16_t mdc1200_id; // 1of11
|
|
|
|
uint8_t spare[2];
|
|
|
|
#else
|
|
|
|
uint8_t spare[4];
|
|
|
|
#endif
|
2023-10-06 22:16:03 +01:00
|
|
|
} __attribute__((packed)) array;
|
|
|
|
|
|
|
|
memset(&array, 0xff, sizeof(array));
|
|
|
|
#ifdef ENABLE_PWRON_PASSWORD
|
2023-10-08 17:14:13 +01:00
|
|
|
array.password = g_eeprom.power_on_password;
|
2023-10-06 22:16:03 +01:00
|
|
|
#endif
|
2023-10-25 13:07:12 +01:00
|
|
|
#ifdef ENABLE_MDC1200
|
|
|
|
array.mdc1200_id = g_eeprom.mdc1200_id;
|
|
|
|
#endif
|
2023-10-12 12:34:01 +01:00
|
|
|
|
2023-10-19 19:00:57 +01:00
|
|
|
EEPROM_WriteBuffer8(0x0E98, &array);
|
2023-10-06 22:16:03 +01:00
|
|
|
}
|
2023-10-12 12:34:01 +01:00
|
|
|
|
2023-09-14 09:56:30 +01:00
|
|
|
#ifdef ENABLE_VOICE
|
2023-09-09 08:03:56 +01:00
|
|
|
memset(State, 0xFF, sizeof(State));
|
2023-10-08 17:14:13 +01:00
|
|
|
State[0] = g_eeprom.voice_prompt;
|
2023-10-19 19:00:57 +01:00
|
|
|
EEPROM_WriteBuffer8(0x0EA0, State);
|
2023-09-09 08:03:56 +01:00
|
|
|
#endif
|
|
|
|
|
2023-10-12 12:34:01 +01:00
|
|
|
// *****************************
|
|
|
|
|
|
|
|
{
|
|
|
|
struct {
|
|
|
|
uint8_t alarm_mode;
|
|
|
|
uint8_t roger_mode;
|
|
|
|
uint8_t repeater_tail_tone_elimination;
|
|
|
|
uint8_t tx_vfo;
|
|
|
|
uint32_t air_copy_freq;
|
|
|
|
} __attribute__((packed)) array;
|
|
|
|
|
|
|
|
memset(&array, 0xff, sizeof(array));
|
|
|
|
|
|
|
|
#if defined(ENABLE_ALARM) || defined(ENABLE_TX1750)
|
|
|
|
array.alarm_mode = g_eeprom.alarm_mode;
|
|
|
|
#else
|
|
|
|
array.alarm_mode = false;
|
|
|
|
#endif
|
|
|
|
array.roger_mode = g_eeprom.roger_mode;
|
|
|
|
array.repeater_tail_tone_elimination = g_eeprom.repeater_tail_tone_elimination;
|
|
|
|
array.tx_vfo = g_eeprom.tx_vfo;
|
2023-10-18 11:31:30 +01:00
|
|
|
#ifdef ENABLE_AIRCOPY_REMEMBER_FREQ
|
2023-10-12 12:34:01 +01:00
|
|
|
// remember the AIRCOPY frequency
|
2023-10-12 14:55:10 +01:00
|
|
|
array.air_copy_freq = g_aircopy_freq;
|
2023-10-12 12:34:01 +01:00
|
|
|
#endif
|
|
|
|
|
2023-10-19 19:00:57 +01:00
|
|
|
EEPROM_WriteBuffer8(0x0EA8, &array);
|
2023-10-12 12:34:01 +01:00
|
|
|
}
|
2023-09-09 08:03:56 +01:00
|
|
|
|
2023-10-08 20:23:37 +01:00
|
|
|
State[0] = g_eeprom.dtmf_side_tone;
|
|
|
|
State[1] = g_eeprom.dtmf_separate_code;
|
|
|
|
State[2] = g_eeprom.dtmf_group_call_code;
|
|
|
|
State[3] = g_eeprom.dtmf_decode_response;
|
|
|
|
State[4] = g_eeprom.dtmf_auto_reset_time;
|
|
|
|
State[5] = g_eeprom.dtmf_preload_time / 10U;
|
|
|
|
State[6] = g_eeprom.dtmf_first_code_persist_time / 10U;
|
|
|
|
State[7] = g_eeprom.dtmf_hash_code_persist_time / 10U;
|
2023-10-19 19:00:57 +01:00
|
|
|
EEPROM_WriteBuffer8(0x0ED0, State);
|
2023-09-09 08:03:56 +01:00
|
|
|
|
|
|
|
memset(State, 0xFF, sizeof(State));
|
2023-10-08 20:23:37 +01:00
|
|
|
State[0] = g_eeprom.dtmf_code_persist_time / 10U;
|
|
|
|
State[1] = g_eeprom.dtmf_code_interval_time / 10U;
|
2023-10-08 17:14:13 +01:00
|
|
|
State[2] = g_eeprom.permit_remote_kill;
|
2023-10-19 19:00:57 +01:00
|
|
|
EEPROM_WriteBuffer8(0x0ED8, State);
|
2023-09-09 08:03:56 +01:00
|
|
|
|
2023-10-08 17:14:13 +01:00
|
|
|
State[0] = g_eeprom.scan_list_default;
|
|
|
|
State[1] = g_eeprom.scan_list_enabled[0];
|
|
|
|
State[2] = g_eeprom.scan_list_priority_ch1[0];
|
|
|
|
State[3] = g_eeprom.scan_list_priority_ch2[0];
|
|
|
|
State[4] = g_eeprom.scan_list_enabled[1];
|
|
|
|
State[5] = g_eeprom.scan_list_priority_ch1[1];
|
|
|
|
State[6] = g_eeprom.scan_list_priority_ch2[1];
|
2023-09-09 08:03:56 +01:00
|
|
|
State[7] = 0xFF;
|
2023-10-19 19:00:57 +01:00
|
|
|
EEPROM_WriteBuffer8(0x0F18, State);
|
2023-09-09 08:03:56 +01:00
|
|
|
|
|
|
|
memset(State, 0xFF, sizeof(State));
|
2023-10-11 16:02:45 +01:00
|
|
|
State[0] = g_setting_freq_lock;
|
2023-10-08 20:23:37 +01:00
|
|
|
State[1] = g_setting_350_tx_enable;
|
2023-10-16 22:29:23 +01:00
|
|
|
#ifdef ENABLE_KILL_REVIVE
|
|
|
|
State[2] = g_setting_radio_disabled;
|
|
|
|
#else
|
|
|
|
State[2] = false;
|
|
|
|
#endif
|
2023-10-16 06:43:42 +01:00
|
|
|
State[3] = g_setting_174_tx_enable;
|
|
|
|
State[4] = g_setting_470_tx_enable;
|
2023-10-08 20:23:37 +01:00
|
|
|
State[5] = g_setting_350_enable;
|
2023-10-17 12:04:54 +01:00
|
|
|
if (!g_setting_scramble_enable) State[6] &= ~(1u << 0);
|
2023-10-18 11:31:30 +01:00
|
|
|
#ifdef ENABLE_RX_SIGNAL_BAR
|
2023-10-17 12:04:54 +01:00
|
|
|
if (!g_setting_rssi_bar) State[6] &= ~(1u << 1);
|
|
|
|
#endif
|
2023-10-08 23:08:18 +01:00
|
|
|
if (!g_setting_tx_enable) State[7] &= ~(1u << 0);
|
2023-10-17 12:04:54 +01:00
|
|
|
if (!g_setting_live_dtmf_decoder) State[7] &= ~(1u << 1);
|
2023-10-08 20:23:37 +01:00
|
|
|
State[7] = (State[7] & ~(3u << 2)) | ((g_setting_battery_text & 3u) << 2);
|
2023-10-18 11:31:30 +01:00
|
|
|
#ifdef ENABLE_TX_AUDIO_BAR
|
2023-10-08 20:23:37 +01:00
|
|
|
if (!g_setting_mic_bar) State[7] &= ~(1u << 4);
|
2023-09-21 07:31:29 +01:00
|
|
|
#endif
|
2023-09-21 23:25:46 +01:00
|
|
|
#ifdef ENABLE_AM_FIX
|
2023-10-24 18:36:29 +01:00
|
|
|
// if (!g_setting_am_fix) State[7] &= ~(1u << 5);
|
2023-09-21 23:06:47 +01:00
|
|
|
#endif
|
2023-10-08 20:23:37 +01:00
|
|
|
State[7] = (State[7] & ~(3u << 6)) | ((g_setting_backlight_on_tx_rx & 3u) << 6);
|
2023-10-19 19:00:57 +01:00
|
|
|
EEPROM_WriteBuffer8(0x0F40, State);
|
2023-10-19 14:21:37 +01:00
|
|
|
|
2023-10-17 11:05:41 +01:00
|
|
|
memset(State, 0xFF, sizeof(State));
|
|
|
|
State[0] = g_eeprom.scan_hold_time_500ms;
|
2023-10-19 19:00:57 +01:00
|
|
|
EEPROM_WriteBuffer8(0x0F48, State);
|
2023-09-09 08:03:56 +01:00
|
|
|
}
|
|
|
|
|
2023-10-19 19:00:57 +01:00
|
|
|
void SETTINGS_save_channel(const unsigned int channel, const unsigned int vfo, const vfo_info_t *p_vfo, const unsigned int mode)
|
2023-09-09 08:03:56 +01:00
|
|
|
{
|
2023-10-19 19:00:57 +01:00
|
|
|
unsigned int eeprom_addr = channel * 16;
|
|
|
|
t_channel m_channel;
|
2023-10-08 23:08:18 +01:00
|
|
|
|
2023-10-19 19:30:53 +01:00
|
|
|
if (IS_NOAA_CHANNEL(channel))
|
2023-10-16 06:43:42 +01:00
|
|
|
return;
|
2023-09-09 08:03:56 +01:00
|
|
|
|
2023-10-19 14:21:37 +01:00
|
|
|
if (mode < 2 && channel <= USER_CHANNEL_LAST)
|
2023-10-08 23:08:18 +01:00
|
|
|
return;
|
2023-09-09 08:03:56 +01:00
|
|
|
|
2023-10-19 19:00:57 +01:00
|
|
|
if (IS_FREQ_CHANNEL(channel))
|
|
|
|
eeprom_addr = 0x0C80 + (16 * vfo) + ((channel - FREQ_CHANNEL_FIRST) * 16 * 2); // a VFO
|
|
|
|
|
2023-10-08 23:08:18 +01:00
|
|
|
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
|
2023-10-19 19:00:57 +01:00
|
|
|
// UART_printf("sav_chan %04X %3u %u %u\r\n", eeprom_addr, channel, vfo, mode);
|
2023-10-08 23:08:18 +01:00
|
|
|
#endif
|
|
|
|
|
2023-10-19 19:30:53 +01:00
|
|
|
// ****************
|
2023-10-19 19:00:57 +01:00
|
|
|
|
2023-10-19 19:30:53 +01:00
|
|
|
if (p_vfo != NULL)
|
|
|
|
{
|
|
|
|
memset(&m_channel, 0, sizeof(m_channel));
|
|
|
|
m_channel.frequency = p_vfo->freq_config_rx.frequency;
|
|
|
|
m_channel.offset = p_vfo->tx_offset_freq;
|
|
|
|
m_channel.rx_ctcss_cdcss_code = p_vfo->freq_config_rx.code;
|
|
|
|
m_channel.tx_ctcss_cdcss_code = p_vfo->freq_config_tx.code;
|
|
|
|
m_channel.rx_ctcss_cdcss_type = p_vfo->freq_config_rx.code_type;
|
|
|
|
// m_channel.unused1:2
|
|
|
|
m_channel.tx_ctcss_cdcss_type = p_vfo->freq_config_tx.code_type;
|
2023-10-25 19:26:22 +01:00
|
|
|
#ifdef ENABLE_MDC1200
|
|
|
|
m_channel.mdc1200_mode = p_vfo->mdc1200_mode;
|
|
|
|
#endif
|
2023-10-19 19:30:53 +01:00
|
|
|
m_channel.tx_offset_dir = p_vfo->tx_offset_freq_dir;
|
|
|
|
// m_channel.unused3:2
|
|
|
|
m_channel.am_mode = p_vfo->am_mode & 1u;
|
|
|
|
// m_channel.unused4:3
|
|
|
|
m_channel.frequency_reverse = p_vfo->frequency_reverse;
|
|
|
|
m_channel.channel_bandwidth = p_vfo->channel_bandwidth;
|
|
|
|
m_channel.tx_power = p_vfo->output_power;
|
|
|
|
m_channel.busy_channel_lock = p_vfo->busy_channel_lock;
|
|
|
|
// m_channel.unused5:1
|
|
|
|
m_channel.compand = p_vfo->compand;
|
|
|
|
m_channel.dtmf_decoding_enable = p_vfo->dtmf_decoding_enable;
|
|
|
|
m_channel.dtmf_ptt_id_tx_mode = p_vfo->dtmf_ptt_id_tx_mode;
|
|
|
|
// m_channel.unused6:4
|
|
|
|
m_channel.step_setting = p_vfo->step_setting;
|
|
|
|
m_channel.scrambler = p_vfo->scrambling_type;
|
2023-10-19 20:03:12 +01:00
|
|
|
m_channel.squelch_level = p_vfo->squelch_level;
|
2023-10-19 19:30:53 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
if (channel <= USER_CHANNEL_LAST)
|
|
|
|
{ // user channel
|
|
|
|
memset(&m_channel, 0xff, sizeof(m_channel));
|
|
|
|
}
|
2023-10-19 19:33:26 +01:00
|
|
|
|
2023-10-19 19:00:57 +01:00
|
|
|
EEPROM_WriteBuffer8(eeprom_addr + 0, (uint8_t *)(&m_channel) + 0);
|
|
|
|
EEPROM_WriteBuffer8(eeprom_addr + 8, (uint8_t *)(&m_channel) + 8);
|
2023-10-19 14:21:37 +01:00
|
|
|
|
2023-10-19 19:30:53 +01:00
|
|
|
// ****************
|
2023-10-19 19:33:26 +01:00
|
|
|
|
2023-10-19 14:21:37 +01:00
|
|
|
SETTINGS_save_chan_attribs_name(channel, p_vfo);
|
|
|
|
|
2023-10-19 19:00:57 +01:00
|
|
|
if (channel <= USER_CHANNEL_LAST)
|
|
|
|
{ // user channel, it has a channel name
|
|
|
|
const unsigned int eeprom_addr = 0x0F50 + (channel * 16);
|
|
|
|
uint8_t name[16];
|
2023-10-12 12:34:01 +01:00
|
|
|
|
2023-10-19 19:30:53 +01:00
|
|
|
memset(name, (p_vfo != NULL) ? 0x00 : 0xff, sizeof(name));
|
2023-10-19 19:00:57 +01:00
|
|
|
|
|
|
|
#ifndef ENABLE_KEEP_MEM_NAME
|
|
|
|
// clear/reset the channel name
|
|
|
|
EEPROM_WriteBuffer8(eeprom_addr + 0, name + 0);
|
|
|
|
EEPROM_WriteBuffer8(eeprom_addr + 8, name + 8);
|
|
|
|
#else
|
2023-10-19 19:30:53 +01:00
|
|
|
if (p_vfo != NULL)
|
2023-10-24 11:40:35 +02:00
|
|
|
memcpy(name, p_vfo->name, 10);
|
2023-10-19 19:30:53 +01:00
|
|
|
if (mode >= 3 || p_vfo == NULL)
|
|
|
|
{ // save the channel name
|
2023-10-19 19:00:57 +01:00
|
|
|
EEPROM_WriteBuffer8(eeprom_addr + 0, name + 0);
|
|
|
|
EEPROM_WriteBuffer8(eeprom_addr + 8, name + 8);
|
|
|
|
}
|
|
|
|
#endif
|
2023-10-19 14:21:37 +01:00
|
|
|
}
|
2023-09-09 08:03:56 +01:00
|
|
|
}
|
|
|
|
|
2023-10-19 19:00:57 +01:00
|
|
|
void SETTINGS_save_chan_attribs_name(const unsigned int channel, const vfo_info_t *p_vfo)
|
2023-09-09 08:03:56 +01:00
|
|
|
{
|
2023-10-19 19:30:53 +01:00
|
|
|
if (channel >= ARRAY_SIZE(g_user_channel_attributes))
|
2023-10-19 14:21:37 +01:00
|
|
|
return;
|
2023-10-08 23:08:18 +01:00
|
|
|
|
2023-10-19 14:21:37 +01:00
|
|
|
if (IS_NOAA_CHANNEL(channel))
|
2023-10-16 06:43:42 +01:00
|
|
|
return;
|
2023-10-12 12:34:01 +01:00
|
|
|
|
2023-10-19 19:30:53 +01:00
|
|
|
if (p_vfo != NULL)
|
2023-10-19 14:21:37 +01:00
|
|
|
{ // channel attributes
|
2023-10-12 12:34:01 +01:00
|
|
|
|
2023-10-19 14:21:37 +01:00
|
|
|
const uint8_t attribs =
|
|
|
|
((p_vfo->scanlist_1_participation & 1u) << 7) |
|
|
|
|
((p_vfo->scanlist_2_participation & 1u) << 6) |
|
|
|
|
((3u) << 4) |
|
|
|
|
((p_vfo->band & 7u) << 0);
|
|
|
|
|
2023-10-19 19:30:53 +01:00
|
|
|
const unsigned int index = channel & ~7ul; // eeprom writes are always 8 bytes in length
|
2023-10-19 19:41:59 +01:00
|
|
|
g_user_channel_attributes[channel] = attribs; // remember new attributes
|
2023-10-19 19:00:57 +01:00
|
|
|
EEPROM_WriteBuffer8(0x0D60 + index, g_user_channel_attributes + index);
|
2023-09-09 08:03:56 +01:00
|
|
|
}
|
2023-10-19 19:30:53 +01:00
|
|
|
else
|
2023-10-19 19:33:26 +01:00
|
|
|
if (channel <= USER_CHANNEL_LAST)
|
|
|
|
{ // user channel
|
2023-10-19 19:30:53 +01:00
|
|
|
const unsigned int index = channel & ~7ul; // eeprom writes are always 8 bytes in length
|
|
|
|
g_user_channel_attributes[channel] = 0xff;
|
|
|
|
EEPROM_WriteBuffer8(0x0D60 + index, g_user_channel_attributes + index);
|
|
|
|
}
|
2023-10-19 19:33:26 +01:00
|
|
|
|
2023-10-19 14:21:37 +01:00
|
|
|
if (channel <= USER_CHANNEL_LAST)
|
|
|
|
{ // user memory channel
|
|
|
|
const unsigned int index = channel * 16;
|
|
|
|
uint8_t name[16];
|
2023-10-12 12:34:01 +01:00
|
|
|
|
2023-10-19 19:30:53 +01:00
|
|
|
if (p_vfo != NULL)
|
|
|
|
{
|
|
|
|
memset(name, 0, sizeof(name));
|
2023-10-24 11:40:35 +02:00
|
|
|
memcpy(name, p_vfo->name, 10);
|
2023-10-19 19:30:53 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
memset(name, 0xff, sizeof(name));
|
|
|
|
}
|
2023-10-19 19:33:26 +01:00
|
|
|
|
2023-10-19 19:00:57 +01:00
|
|
|
EEPROM_WriteBuffer8(0x0F50 + 0 + index, name + 0);
|
|
|
|
EEPROM_WriteBuffer8(0x0F50 + 8 + index, name + 8);
|
2023-10-19 14:21:37 +01:00
|
|
|
}
|
2023-09-09 08:03:56 +01:00
|
|
|
}
|