Merged the loadPreferences and setDefaultPreferences functions
This commit is contained in:
parent
885c0f57c1
commit
12a437ff69
32
src/main.ino
32
src/main.ino
@ -135,7 +135,6 @@ void setup() {
|
||||
displayXBM();
|
||||
|
||||
// Initialize the preferences
|
||||
setDefaultPreferences();
|
||||
loadPreferences();
|
||||
|
||||
// Connect to WiFi if credentials are stored, otherwise scan for networks
|
||||
@ -226,60 +225,49 @@ void loop() {
|
||||
}
|
||||
|
||||
|
||||
void setDefaultPreferences() {
|
||||
void loadPreferences() {
|
||||
preferences.begin("config", false);
|
||||
|
||||
// IRC preferences
|
||||
if (!preferences.isKey("irc_nickname"))
|
||||
preferences.putString("irc_nickname", "ACID_" + String(random(1000, 10000)));
|
||||
irc_nickname = preferences.getString("irc_nickname");
|
||||
|
||||
if (!preferences.isKey("irc_username"))
|
||||
preferences.putString("irc_username", "tdeck");
|
||||
irc_username = preferences.getString("irc_username");
|
||||
|
||||
if (!preferences.isKey("irc_realname"))
|
||||
preferences.putString("irc_realname", "ACID DROP Firmware");
|
||||
irc_realname = preferences.getString("irc_realname");
|
||||
|
||||
if (!preferences.isKey("irc_server"))
|
||||
preferences.putString("irc_server", "irc.supernets.org");
|
||||
irc_server = preferences.getString("irc_server");
|
||||
|
||||
if (!preferences.isKey("irc_port"))
|
||||
preferences.putInt("irc_port", 6667);
|
||||
irc_port = preferences.getInt("irc_port");
|
||||
|
||||
if (!preferences.isKey("irc_tls"))
|
||||
preferences.putBool("irc_tls", false);
|
||||
irc_tls = preferences.getBool("irc_tls");
|
||||
|
||||
if (!preferences.isKey("irc_channel"))
|
||||
preferences.putString("irc_channel", "#comms");
|
||||
irc_channel = preferences.getString("irc_channel");
|
||||
|
||||
if (!preferences.isKey("irc_nickserv"))
|
||||
preferences.putString("irc_nickserv", "");
|
||||
irc_nickserv = preferences.getString("irc_nickserv");
|
||||
|
||||
// WiFi preferences
|
||||
if (!preferences.isKey("wifi_ssid"))
|
||||
preferences.putString("wifi_ssid", "");
|
||||
wifi_ssid = preferences.getString("wifi_ssid");
|
||||
|
||||
if (!preferences.isKey("wifi_password"))
|
||||
preferences.putString("wifi_password", "");
|
||||
|
||||
preferences.end();
|
||||
}
|
||||
|
||||
|
||||
void loadPreferences() {
|
||||
preferences.begin("config", true);
|
||||
|
||||
// IRC preferences
|
||||
irc_nickname = preferences.getString("irc_nickname");
|
||||
irc_username = preferences.getString("irc_username");
|
||||
irc_realname = preferences.getString("irc_realname");
|
||||
irc_server = preferences.getString("irc_server");
|
||||
irc_port = preferences.getInt("irc_port");
|
||||
irc_tls = preferences.getBool("irc_tls");
|
||||
irc_channel = preferences.getString("irc_channel");
|
||||
irc_nickserv = preferences.getString("irc_nickserv");
|
||||
|
||||
// WiFi preferences
|
||||
wifi_ssid = preferences.getString("wifi_ssid");
|
||||
wifi_password = preferences.getString("wifi_password");
|
||||
|
||||
preferences.end();
|
||||
|
Loading…
Reference in New Issue
Block a user