From a10397c845124992b5531acfb83e07f9fa97dfc7 Mon Sep 17 00:00:00 2001 From: Elfish Date: Sun, 2 Apr 2023 12:45:44 +0200 Subject: [PATCH] Merge clean up --- platformio.ini | 1 - src/Apps.h | 4 ++-- src/MenuManager.cpp | 17 ++++++++++++----- src/PeripheryManager.cpp | 24 ++++-------------------- src/PeripheryManager.h | 2 ++ 5 files changed, 20 insertions(+), 28 deletions(-) diff --git a/platformio.ini b/platformio.ini index 4b532f9..0518140 100644 --- a/platformio.ini +++ b/platformio.ini @@ -22,7 +22,6 @@ lib_deps = fastled/FastLED@^3.5.0 marcmerlin/FastLED NeoMatrix@^1.2 knolleary/PubSubClient@^2.8 - plerup/EspSoftwareSerial@^8.0.1 [env:awtrix_upgrade] platform = https://github.com/platformio/platform-espressif32.git diff --git a/src/Apps.h b/src/Apps.h index 1e4f3e7..63fbe33 100644 --- a/src/Apps.h +++ b/src/Apps.h @@ -254,7 +254,7 @@ void AlarmApp(FastLED_NeoMatrix *matrix, MatrixDisplayUiState *state) { #ifdef ULANZI PeripheryManager.playFromFile("/MELODIES/" + ALARM_SOUND + ".txt"); -else +#else PeripheryManager.playFromFile(DFMINI_MP3_ALARM); #endif } @@ -280,7 +280,7 @@ void TimerApp(FastLED_NeoMatrix *matrix, MatrixDisplayUiState *state) { #ifdef ULANZI PeripheryManager.playFromFile("/MELODIES/" + TIMER_SOUND + ".txt"); -else +#else PeripheryManager.playFromFile(DFMINI_MP3_TIMER); #endif } diff --git a/src/MenuManager.cpp b/src/MenuManager.cpp index 029c4a2..80a6f1f 100644 --- a/src/MenuManager.cpp +++ b/src/MenuManager.cpp @@ -28,8 +28,12 @@ enum MenuState WeekdayMenu, TempMenu, Appmenu, - SoundMenu, +#ifdef ULANZI + SoundMenu +#else + SoundMenu, VolumeMenu +#endif }; const char *menuItems[] PROGMEM = { @@ -250,10 +254,12 @@ void MenuManager_::rightButton() case TempMenu: IS_CELSIUS = !IS_CELSIUS; break; +#ifndef ULANZI case VolumeMenu: VOLUME_PERCENT = (VOLUME_PERCENT % 100) + 1; VOLUME = map(VOLUME_PERCENT, 0, 100, 0, 30); PeripheryManager.setVolume(VOLUME); +#endif default: break; } @@ -314,10 +320,12 @@ void MenuManager_::leftButton() case SoundMenu: SOUND_ACTIVE = !SOUND_ACTIVE; break; +#ifndef ULANZI case VolumeMenu: VOLUME_PERCENT = (VOLUME_PERCENT % 100) + 1; VOLUME = map(VOLUME_PERCENT, 0, 100, 0, 30); PeripheryManager.setVolume(VOLUME); +#endif default: break; } @@ -372,11 +380,10 @@ void MenuManager_::selectButton() currentState = SoundMenu; break; case 12: -#ifdef AWTRIX_UPGRADE +#ifndef ULANZI currentState = VolumeMenu; break; -#endif - +#endif case 13: if (UpdateManager.checkUpdate(true)) { @@ -454,8 +461,8 @@ void MenuManager_::selectButtonLong() DisplayManager.applyAllSettings(); saveSettings(); break; +#ifndef ULANZI case VolumeMenu: -#ifdef AWTRIX_UPGRADE VOLUME = map(VOLUME_PERCENT, 0, 100, 0, 30); saveSettings(); #endif diff --git a/src/PeripheryManager.cpp b/src/PeripheryManager.cpp index 6d893e9..808e5f0 100644 --- a/src/PeripheryManager.cpp +++ b/src/PeripheryManager.cpp @@ -41,14 +41,7 @@ #ifdef ULANZI Adafruit_SHT31 sht31; #else - -class Mp3Notify -{ -}; Adafruit_BME280 bme280; -SoftwareSerial mySoftwareSerial(D7, D5); // RX, TX -typedef DFMiniMp3 DfMp3; -DfMp3 dfmp3(mySoftwareSerial); #endif EasyButton button_left(BUTTON_UP_PIN); @@ -57,9 +50,6 @@ EasyButton button_select(BUTTON_SELECT_PIN); #ifdef ULANZI MelodyPlayer player(BUZZER_PIN, LOW); #else -// implement a notification class, -// its member methods will get called -// class Mp3Notify{}; SoftwareSerial mySoftwareSerial(DFPLAYER_RX, DFPLAYER_TX); // RX, TX DFMiniMp3 dfmp3(mySoftwareSerial); @@ -88,11 +78,6 @@ float sampleSum = 0.0; float sampleAverage = 0.0; float brightnessPercent = 0.0; -#ifdef awrtrix_upgrade -class Mp3Notify; -SoftwareSerial mySoftwareSerial(D7, D5); // RX, TX -#endif - // The getter for the instantiated singleton instance PeripheryManager_ &PeripheryManager_::getInstance() { @@ -168,13 +153,12 @@ void PeripheryManager_::playBootSound() if (BOOT_SOUND == "") { #ifdef ULANZI + // no standardsound 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 -// no standardsound #endif } else @@ -198,12 +182,12 @@ void PeripheryManager_::stopSound() #endif } +#ifndef ULANZI void PeripheryManager_::setVolume(uint8_t vol) { -#ifdef AWTRIX_UPGRADE dfmp3.setVolume(vol); -#endif } +#endif void PeripheryManager_::playFromFile(String file) { @@ -258,7 +242,7 @@ void PeripheryManager_::setup() #else dfmp3.begin(); delay(50); - dfmp3.setVolume(20); + dfmp3.setVolume(20); // Set initial value to saved setting MISSING! #endif button_left.begin(); button_right.begin(); diff --git a/src/PeripheryManager.h b/src/PeripheryManager.h index d55c1a4..b713cd0 100644 --- a/src/PeripheryManager.h +++ b/src/PeripheryManager.h @@ -35,7 +35,9 @@ public: void playFromFile(String file); bool isPlaying(); void stopSound(); +#ifndef ULANZI void setVolume(uint8_t); +#endif const char *readUptime(); };