Cosmetic changes
This commit is contained in:
@@ -225,53 +225,56 @@ void printAllowedIds()
|
|||||||
|
|
||||||
bool loadBeaconSettings()
|
bool loadBeaconSettings()
|
||||||
{
|
{
|
||||||
Serial.println("laodSettings");
|
Serial.println("loadSettings");
|
||||||
File file = LittleFS.open("/beacons.json", "r");
|
if (LittleFS.exists("/beacons.json"))
|
||||||
if (!file)
|
|
||||||
{
|
{
|
||||||
return false;
|
File file = LittleFS.open("/beacons.json", "r");
|
||||||
}
|
DynamicJsonDocument doc(128);
|
||||||
DynamicJsonDocument doc(128);
|
DeserializationError error = deserializeJson(doc, file);
|
||||||
DeserializationError error = deserializeJson(doc, file);
|
if (error)
|
||||||
if (error)
|
|
||||||
{
|
|
||||||
Serial.println(F("Failed to read beacon settings"));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (doc.containsKey("room"))
|
|
||||||
{
|
|
||||||
room = doc["room"].as<String>();
|
|
||||||
Serial.println(room);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (doc.containsKey("trigger_distance"))
|
|
||||||
{
|
|
||||||
triggerDistance = doc["trigger_distance"].as<float>();
|
|
||||||
Serial.println(triggerDistance);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (doc.containsKey("allowed_ids"))
|
|
||||||
{
|
|
||||||
JsonArray allowedIdsJsonArray = doc["allowed_ids"];
|
|
||||||
for (const char *id : allowedIdsJsonArray)
|
|
||||||
{
|
{
|
||||||
allowedIds.push_back(String(id));
|
Serial.println(F("Failed to read beacon settings"));
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
printAllowedIds();
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
if (doc.containsKey("room"))
|
||||||
file.close();
|
{
|
||||||
}
|
room = doc["room"].as<String>();
|
||||||
|
Serial.println(room);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (doc.containsKey("trigger_distance"))
|
||||||
|
{
|
||||||
|
triggerDistance = doc["trigger_distance"].as<float>();
|
||||||
|
Serial.println(triggerDistance);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (doc.containsKey("allowed_ids"))
|
||||||
|
{
|
||||||
|
JsonArray allowedIdsJsonArray = doc["allowed_ids"];
|
||||||
|
for (const char *id : allowedIdsJsonArray)
|
||||||
|
{
|
||||||
|
allowedIds.push_back(String(id));
|
||||||
|
}
|
||||||
|
printAllowedIds();
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
file.close();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void BeaconScanner_::setup()
|
void BeaconScanner_::setup()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -90,7 +90,6 @@ void loadSettings()
|
|||||||
#endif
|
#endif
|
||||||
SOUND_ACTIVE = Settings.getBool("SOUND", true);
|
SOUND_ACTIVE = Settings.getBool("SOUND", true);
|
||||||
#ifndef ULANZI
|
#ifndef ULANZI
|
||||||
// Settings.putUInt("VOL", VOLUME_PERCENT);
|
|
||||||
VOLUME_PERCENT = Settings.getUInt("VOL", 50);
|
VOLUME_PERCENT = Settings.getUInt("VOL", 50);
|
||||||
VOLUME = map(VOLUME_PERCENT, 0, 100, 0, 30);
|
VOLUME = map(VOLUME_PERCENT, 0, 100, 0, 30);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -93,13 +93,12 @@ PeripheryManager_ &PeripheryManager = PeripheryManager.getInstance();
|
|||||||
|
|
||||||
void left_button_pressed()
|
void left_button_pressed()
|
||||||
{
|
{
|
||||||
#ifdef AWTRIX_UPGRADE
|
#ifndef ULANZI
|
||||||
PeripheryManager.playFromFile(DFMINI_MP3_CLICK);
|
PeripheryManager.playFromFile(DFMINI_MP3_CLICK);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (AP_MODE)
|
if (AP_MODE)
|
||||||
{
|
{
|
||||||
#ifdef AWTRIX_UPGRADE
|
#ifndef ULANZI
|
||||||
--MATRIX_LAYOUT;
|
--MATRIX_LAYOUT;
|
||||||
if (MATRIX_LAYOUT < 0)
|
if (MATRIX_LAYOUT < 0)
|
||||||
MATRIX_LAYOUT = 2;
|
MATRIX_LAYOUT = 2;
|
||||||
@@ -116,12 +115,12 @@ void left_button_pressed()
|
|||||||
|
|
||||||
void right_button_pressed()
|
void right_button_pressed()
|
||||||
{
|
{
|
||||||
#ifdef AWTRIX_UPGRADE
|
#ifndef ULANZI
|
||||||
PeripheryManager.playFromFile(DFMINI_MP3_CLICK);
|
PeripheryManager.playFromFile(DFMINI_MP3_CLICK);
|
||||||
#endif
|
#endif
|
||||||
if (AP_MODE)
|
if (AP_MODE)
|
||||||
{
|
{
|
||||||
#ifdef AWTRIX_UPGRADE
|
#ifndef ULANZI
|
||||||
++MATRIX_LAYOUT;
|
++MATRIX_LAYOUT;
|
||||||
if (MATRIX_LAYOUT > 2)
|
if (MATRIX_LAYOUT > 2)
|
||||||
MATRIX_LAYOUT = 0;
|
MATRIX_LAYOUT = 0;
|
||||||
@@ -138,7 +137,7 @@ void right_button_pressed()
|
|||||||
|
|
||||||
void select_button_pressed()
|
void select_button_pressed()
|
||||||
{
|
{
|
||||||
#ifdef AWTRIX_UPGRADE
|
#ifndef ULANZI
|
||||||
PeripheryManager.playFromFile(DFMINI_MP3_CLICK);
|
PeripheryManager.playFromFile(DFMINI_MP3_CLICK);
|
||||||
#endif
|
#endif
|
||||||
DisplayManager.selectButton();
|
DisplayManager.selectButton();
|
||||||
|
|||||||
Reference in New Issue
Block a user