mirror of
https://github.com/meshtastic/firmware.git
synced 2025-04-23 17:13:38 +00:00
Adds a userPrefs.h file, default blank, used for default settings for custom builds (#4325)
* add a userPrefs.h file, default blank, which can be used to easily set defaults on custom builds. * Add Splash Screen to userPrefs * Add channel 0 defaults to userPrefs.h * CONFIG_LORA_IGNORE_MQTT_DEFAULT * Unify naming for USERPREFS defines --------- Co-authored-by: Ben Meadors <benmmeadors@gmail.com>
This commit is contained in:
parent
32bc2f1137
commit
1a1d545c38
@ -20,6 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
*/
|
||||
#include "Screen.h"
|
||||
#include "../userPrefs.h"
|
||||
#include "configuration.h"
|
||||
#if HAS_SCREEN
|
||||
#include <OLEDDisplay.h>
|
||||
@ -156,7 +157,11 @@ static void drawIconScreen(const char *upperMsg, OLEDDisplay *display, OLEDDispl
|
||||
|
||||
display->setFont(FONT_MEDIUM);
|
||||
display->setTextAlignment(TEXT_ALIGN_LEFT);
|
||||
#ifdef SPLASH_TITLE_USERPREFS
|
||||
const char *title = SPLASH_TITLE_USERPREFS;
|
||||
#else
|
||||
const char *title = "meshtastic.org";
|
||||
#endif
|
||||
display->drawString(x + getStringCenteredX(title), y + SCREEN_HEIGHT - FONT_HEIGHT_MEDIUM, title);
|
||||
display->setFont(FONT_SMALL);
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
#ifndef HAS_USERPREFS_SPLASH
|
||||
#define icon_width 50
|
||||
#define icon_height 28
|
||||
static uint8_t icon_bits[] = {
|
||||
@ -17,4 +18,5 @@ static uint8_t icon_bits[] = {
|
||||
0xFE, 0x00, 0x00, 0xFC, 0x01, 0x7E, 0x00, 0x7F, 0x00, 0x00, 0xF8, 0x01,
|
||||
0x7E, 0x00, 0x3E, 0x00, 0x00, 0xF8, 0x01, 0x38, 0x00, 0x3C, 0x00, 0x00,
|
||||
0x70, 0x00, 0x10, 0x00, 0x10, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, };
|
||||
0x00, 0x00, 0x00, 0x00, };
|
||||
#endif
|
@ -1,4 +1,5 @@
|
||||
#include "Channels.h"
|
||||
#include "../userPrefs.h"
|
||||
#include "CryptoEngine.h"
|
||||
#include "DisplayFormatters.h"
|
||||
#include "NodeDB.h"
|
||||
@ -90,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;
|
||||
@ -99,6 +101,29 @@ void Channels::initDefaultChannel(ChannelIndex chIndex)
|
||||
|
||||
ch.has_settings = true;
|
||||
ch.role = meshtastic_Channel_Role_PRIMARY;
|
||||
|
||||
#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_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_NAME_USERPREFS
|
||||
strcpy(channelSettings.name, CHANNEL_0_NAME_USERPREFS);
|
||||
#endif
|
||||
#ifdef CHANNEL_0_PRECISION_USERPREFS
|
||||
channelSettings.module_settings.position_precision = CHANNEL_0_PRECISION_USERPREFS;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
CryptoKey Channels::getKey(ChannelIndex chIndex)
|
||||
@ -330,4 +355,4 @@ bool Channels::decryptForHash(ChannelIndex chIndex, ChannelHash channelHash)
|
||||
int16_t Channels::setActiveByIndex(ChannelIndex channelIndex)
|
||||
{
|
||||
return setCrypto(channelIndex);
|
||||
}
|
||||
}
|
@ -1,3 +1,4 @@
|
||||
#include "../userPrefs.h"
|
||||
#include "configuration.h"
|
||||
#if !MESHTASTIC_EXCLUDE_GPS
|
||||
#include "GPS.h"
|
||||
@ -237,10 +238,22 @@ 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_USERPREFS
|
||||
config.lora.region = CONFIG_LORA_REGION_USERPREFS;
|
||||
#else
|
||||
config.lora.region = meshtastic_Config_LoRaConfig_RegionCode_UNSET;
|
||||
#endif
|
||||
#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_USERPREFS
|
||||
config.lora.ignore_mqtt = CONFIG_LORA_IGNORE_MQTT_USERPREFS;
|
||||
#else
|
||||
config.lora.ignore_mqtt = false;
|
||||
#endif
|
||||
#ifdef PIN_GPS_EN
|
||||
config.position.gps_en_gpio = PIN_GPS_EN;
|
||||
#endif
|
||||
|
33
userPrefs.h
Normal file
33
userPrefs.h
Normal file
@ -0,0 +1,33 @@
|
||||
#ifndef _USERPREFS_
|
||||
#define _USERPREFS_
|
||||
// Uncomment and modify to set device defaults
|
||||
|
||||
// #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_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_NAME_USERPREFS "DEFCONnect"
|
||||
// #define CHANNEL_0_PRECISION_USERPREFS 13
|
||||
|
||||
// #define SPLASH_TITLE_USERPREFS "DEFCONtastic"
|
||||
// #define icon_width 34
|
||||
// #define icon_height 29
|
||||
// #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,
|
||||
0x9E, 0xE7, 0x00, 0x00, 0x00, 0x0E, 0xC7, 0x01, 0x00, 0x1C, 0x0F, 0xC7, 0x01, 0x00, 0x1C, 0xDF, 0xE7, 0x63, 0x00, 0x1C, 0xFF,
|
||||
0xBF, 0xE1, 0x00, 0x3C, 0xF3, 0xBF, 0xE3, 0x00, 0x7F, 0xF7, 0xBF, 0xF1, 0x00, 0xFF, 0xF7, 0xBF, 0xF9, 0x03, 0xFF, 0xE7, 0x9F,
|
||||
0xFF, 0x03, 0xC0, 0xCF, 0xEF, 0xDF, 0x03, 0x00, 0xDF, 0xE3, 0x8F, 0x00, 0x00, 0x7C, 0xFB, 0x03, 0x00, 0x00, 0xF8, 0xFF, 0x00,
|
||||
0x00, 0x00, 0xE0, 0x0F, 0x00, 0x00, 0x00, 0xC0, 0x0F, 0x00, 0x00, 0x00, 0x78, 0x3F, 0x00, 0x00, 0x00, 0xFC, 0xFC, 0x00, 0x00,
|
||||
0x98, 0x3F, 0xF0, 0x23, 0x00, 0xFC, 0x0F, 0xE0, 0x7F, 0x00, 0xFC, 0x03, 0x80, 0xFF, 0x01, 0xFC, 0x00, 0x00, 0x3E, 0x00, 0x70,
|
||||
0x00, 0x00, 0x1C, 0x00, 0x70, 0x00, 0x00, 0x1C, 0x00, 0x70, 0x00, 0x00, 0x1C, 0x00, 0x70, 0x00, 0x00, 0x1C, 0x00};
|
||||
*/
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user