Skip to content

Commit

Permalink
Unify naming for USERPREFS defines
Browse files Browse the repository at this point in the history
  • Loading branch information
jp-bennett committed Jul 28, 2024
1 parent b96bc1f commit 024b9d1
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 26 deletions.
4 changes: 2 additions & 2 deletions src/graphics/Screen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,8 @@ static void drawIconScreen(const char *upperMsg, OLEDDisplay *display, OLEDDispl

display->setFont(FONT_MEDIUM);
display->setTextAlignment(TEXT_ALIGN_LEFT);
#ifdef SPLASH_TITLE
const char *title = SPLASH_TITLE;
#ifdef SPLASH_TITLE_USERPREFS
const char *title = SPLASH_TITLE_USERPREFS;
#else
const char *title = "meshtastic.org";
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/graphics/img/icon.xbm
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#ifndef HAS_CUSTOM_SPLASH
#ifndef HAS_USERPREFS_SPLASH
#define icon_width 50
#define icon_height 28
static uint8_t icon_bits[] = {
Expand Down
20 changes: 12 additions & 8 deletions src/mesh/Channels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ void Channels::initDefaultChannel(ChannelIndex chIndex)
loraConfig.modem_preset = meshtastic_Config_LoRaConfig_ModemPreset_LONG_FAST; // Default to Long Range & Fast
loraConfig.use_preset = true;
loraConfig.tx_power = 0; // default
loraConfig.channel_num = 0;
uint8_t defaultpskIndex = 1;
channelSettings.psk.bytes[0] = defaultpskIndex;
channelSettings.psk.size = 1;
Expand All @@ -101,23 +102,26 @@ void Channels::initDefaultChannel(ChannelIndex chIndex)
ch.has_settings = true;
ch.role = meshtastic_Channel_Role_PRIMARY;

#ifdef CONFIG_LORA_MODEM_PRESET
loraConfig.modem_preset = CONFIG_LORA_MODEM_PRESET;
#ifdef LORACONFIG_MODEM_PRESET_USERPREFS
loraConfig.modem_preset = LORACONFIG_MODEM_PRESET_USERPREFS;
#endif
#ifdef LORACONFIG_CHANNEL_NUM_USERPREFS
loraConfig.channel_num = LORACONFIG_CHANNEL_NUM_USERPREFS;
#endif

// Install custom defaults. Will eventually support setting multiple default channels
if (chIndex == 0) {
#ifdef CHANNEL_0_DEFAULT_PSK
static const uint8_t defaultpsk[] = CHANNEL_0_DEFAULT_PSK;
#ifdef CHANNEL_0_PSK_USERPREFS
static const uint8_t defaultpsk[] = CHANNEL_0_PSK_USERPREFS;
memcpy(channelSettings.psk.bytes, defaultpsk, sizeof(defaultpsk));
channelSettings.psk.size = sizeof(defaultpsk);

#endif
#ifdef CHANNEL_0_DEFAULT_NAME
strcpy(channelSettings.name, CHANNEL_0_DEFAULT_NAME);
#ifdef CHANNEL_0_NAME_USERPREFS
strcpy(channelSettings.name, CHANNEL_0_NAME_USERPREFS);
#endif
#ifdef CHANNEL_0_PRECISION_DEFAULT
channelSettings.module_settings.position_precision = CHANNEL_0_PRECISION_DEFAULT;
#ifdef CHANNEL_0_PRECISION_USERPREFS
channelSettings.module_settings.position_precision = CHANNEL_0_PRECISION_USERPREFS;
#endif
}
}
Expand Down
12 changes: 6 additions & 6 deletions src/mesh/NodeDB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,19 +238,19 @@ void NodeDB::installDefaultConfig()
config.lora.tx_enabled =
true; // FIXME: maybe false in the future, and setting region to enable it. (unset region forces it off)
config.lora.override_duty_cycle = false;
#ifdef CONFIG_LORA_REGION_DEFAULT
config.lora.region = CONFIG_LORA_REGION_DEFAULT;
#ifdef CONFIG_LORA_REGION_USERPREFS
config.lora.region = CONFIG_LORA_REGION_USERPREFS;
#else
config.lora.region = meshtastic_Config_LoRaConfig_RegionCode_UNSET;
#endif
#ifdef CONFIG_LORA_MODEM_PRESET
config.lora.modem_preset = CONFIG_LORA_MODEM_PRESET;
#ifdef LORACONFIG_MODEM_PRESET_USERPREFS
config.lora.modem_preset = LORACONFIG_MODEM_PRESET_USERPREFS;
#else
config.lora.modem_preset = meshtastic_Config_LoRaConfig_ModemPreset_LONG_FAST;
#endif
config.lora.hop_limit = HOP_RELIABLE;
#ifdef CONFIG_LORA_IGNORE_MQTT_DEFAULT
config.lora.ignore_mqtt = CONFIG_LORA_IGNORE_MQTT_DEFAULT;
#ifdef CONFIG_LORA_IGNORE_MQTT_USERPREFS
config.lora.ignore_mqtt = CONFIG_LORA_IGNORE_MQTT_USERPREFS;
#else
config.lora.ignore_mqtt = false;
#endif
Expand Down
18 changes: 9 additions & 9 deletions userPrefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,24 @@
#define _USERPREFS_
// Uncomment and modify to set device defaults

// #define CONFIG_LORA_REGION_DEFAULT meshtastic_Config_LoRaConfig_RegionCode_US
// #define CONFIG_LORA_MODEM_PRESET meshtastic_Config_LoRaConfig_ModemPreset_SHORT_FAST
// #define CONFIG_LORA_CHANNELNUM_DEFAULT 31
// #define CONFIG_LORA_IGNORE_MQTT_DEFAULT true
// #define CONFIG_LORA_REGION_USERPREFS meshtastic_Config_LoRaConfig_RegionCode_US
// #define LORACONFIG_MODEM_PRESET_USERPREFS meshtastic_Config_LoRaConfig_ModemPreset_SHORT_FAST
// #define LORACONFIG_CHANNEL_NUM_USERPREFS 31
// #define CONFIG_LORA_IGNORE_MQTT_USERPREFS true
/*
#define CHANNEL_0_DEFAULT_PSK \
#define CHANNEL_0_PSK_USERPREFS \
{ \
0x38, 0x4b, 0xbc, 0xc0, 0x1d, 0xc0, 0x22, 0xd1, 0x81, 0xbf, 0x36, 0xb8, 0x61, 0x21, 0xe1, 0xfb, 0x96, 0xb7, 0x2e, 0x55, \
0xbf, 0x74, 0x22, 0x7e, 0x9d, 0x6a, 0xfb, 0x48, 0xd6, 0x4c, 0xb1, 0xa1 \
}
*/
// #define CHANNEL_0_DEFAULT_NAME "DEFCONnect"
// #define CHANNEL_0_PRECISION_DEFAULT 13
// #define CHANNEL_0_NAME_USERPREFS "DEFCONnect"
// #define CHANNEL_0_PRECISION_USERPREFS 13

// #define SPLASH_TITLE "DEFCONtastic"
// #define SPLASH_TITLE_USERPREFS "DEFCONtastic"
// #define icon_width 34
// #define icon_height 29
// #define HAS_CUSTOM_SPLASH
// #define HAS_USERPREFS_SPLASH
/*
static unsigned char icon_bits[] = {
0x00, 0xC0, 0x0F, 0x00, 0x00, 0x00, 0xF0, 0x3F, 0x00, 0x00, 0x00, 0xF8, 0x7F, 0x00, 0x00, 0x00, 0xFC, 0xFF, 0x00, 0x00, 0x00,
Expand Down

0 comments on commit 024b9d1

Please sign in to comment.