Various changes for awtrix_update

This commit is contained in:
Elfish
2023-04-02 17:47:15 +02:00
parent a10397c845
commit a6ccac1cd3
8 changed files with 27 additions and 14 deletions

View File

@@ -106,8 +106,10 @@ const char HAramClass[] PROGMEM = {"data_size"};
const char HAramUnit[] PROGMEM = {"B"};
// JSON properites
#ifdef ULANZI
const char BatKey[] PROGMEM = {"bat"};
const char BatRawKey[] PROGMEM = {"bat_raw"};
#endif
const char LuxKey[] PROGMEM = {"lux"};
const char LDRRawKey[] PROGMEM = {"ldr_raw"};
const char BrightnessKey[] PROGMEM = {"bri"};

View File

@@ -106,8 +106,10 @@ extern const char HAramClass[];
extern const char HAramUnit[];
// JSON properites
#ifdef ULANZI
extern const char BatKey[];
extern const char BatRawKey[];
#endif
extern const char LuxKey[];
extern const char LDRRawKey[];
extern const char BrightnessKey[];

View File

@@ -266,7 +266,11 @@ void DisplayManager_::generateCustomPage(String name, const char *json)
if (doc.containsKey("sound"))
{
#ifdef ULANZI
customApp.sound = ("/" + doc["sound"].as<String>() + ".txt");
#else
customApp.sound = doc["sound"].as<String>();
#endif
}
else
{
@@ -820,17 +824,13 @@ void DisplayManager_::updateAppVector(const char *json)
callback = HumApp;
SHOW_HUM = show;
}
#ifdef ULANZI
else if (name == "bat")
{
callback = BatApp;
SHOW_BAT = show;
}
#endif
else
{
// If the app is not one of the built-in apps, check if it's already in the vector

View File

@@ -19,7 +19,9 @@ void startLittleFS()
{
if (LittleFS.begin())
{
#ifdef ULANZI
LittleFS.mkdir("/MELODIES");
#endif
LittleFS.mkdir("/ICONS");
}
else
@@ -32,7 +34,7 @@ void startLittleFS()
void loadDevSettings()
{
Serial.println("laodSettings");
Serial.println("loadSettings");
File file = LittleFS.open("/dev.json", "r");
if (!file)
{
@@ -185,7 +187,7 @@ bool ALARM_ACTIVE;
uint16_t TEXTCOLOR_565 = 0xFFFF;
bool SOUND_ACTIVE;
String BOOT_SOUND = "";
uint8_t VOLUME;
uint8_t VOLUME_PERCENT;
uint8_t VOLUME_PERCENT = 50;
uint8_t VOLUME = map(VOLUME_PERCENT, 0, 100, 0, 30);
int MATRIX_LAYOUT;
bool UPDATE_AVAILABLE = false;

View File

@@ -68,8 +68,8 @@ extern bool START_ON_MONDAY;
extern bool IS_CELSIUS;
extern bool SOUND_ACTIVE;
extern String BOOT_SOUND;
extern uint8_t VOLUME;
extern uint8_t VOLUME_PERCENT;
extern uint8_t VOLUME;
extern int MATRIX_LAYOUT;
extern bool UPDATE_AVAILABLE;
void loadSettings();

View File

@@ -357,16 +357,16 @@ void MQTTManager_::setup()
humidity->setName(HAhumName);
humidity->setDeviceClass(HAhumClass);
humidity->setUnitOfMeasurement(HAhumUnit);
#ifdef ULANZI
sprintf(batID, HAbatID, macStr);
battery = new HASensor(batID);
battery->setIcon(HAbatIcon);
battery->setName(HAbatName);
battery->setDeviceClass(HAbatClass);
battery->setUnitOfMeasurement(HAbatUnit);
#endif
#endif
sprintf(luxID, HAluxID, macStr);
illuminance = new HASensor(luxID);
illuminance->setIcon(HAluxIcon);
@@ -455,8 +455,8 @@ void MQTTManager_::sendStats()
#ifdef ULANZI
snprintf(buffer, 5, "%d", BATTERY_PERCENT);
battery->setValue(buffer);
#endif
#endif
snprintf(buffer, 5, "%.0f", CURRENT_TEMP);
temperature->setValue(buffer);

View File

@@ -153,12 +153,14 @@ void PeripheryManager_::playBootSound()
if (BOOT_SOUND == "")
{
#ifdef ULANZI
// no standardsound
// no standard sound
const int nNotes = 6;
String notes[nNotes] = {"E5", "C5", "G4", "E4", "G4", "C5"};
const int timeUnit = 150;
Melody melody = MelodyFactory.load("Bootsound", timeUnit, notes, nNotes);
player.playAsync(melody);
#else
playFromFile(DFMINI_MP3_BOOT);
#endif
}
else
@@ -166,7 +168,7 @@ void PeripheryManager_::playBootSound()
#ifdef ULANZI
playFromFile("/MELODIES/" + BOOT_SOUND + ".txt");
#else
dfmp3.playMp3FolderTrack(BOOT_SOUND.toInt());
playFromFile(BOOT_SOUND);
#endif
}
}
@@ -242,7 +244,7 @@ void PeripheryManager_::setup()
#else
dfmp3.begin();
delay(50);
dfmp3.setVolume(20); // Set initial value to saved setting MISSING!
setVolume(VOLUME);
#endif
button_left.begin();
button_right.begin();

View File

@@ -8,8 +8,13 @@
#include <Ticker.h>
#include "Globals.h"
#ifdef ULANZI
#define URL_fw_Version "https://raw.githubusercontent.com/Blueforcer/awtrix-light/main/version"
#define URL_fw_Bin "https://raw.githubusercontent.com/Blueforcer/awtrix-light/main/docs/flasher/firmware/firmware.bin"
#else
#define URL_fw_Version "todo"
#define URL_fw_Bin "todo"
#endif
Ticker UpdateTicker;