Browse Source

New feature: ESPuino can now tell you its IP-address

master
Torsten Stauder 4 years ago
parent
commit
2335f9c907
  1. 2
      README.md
  2. 1
      changelog.md
  3. 2
      platformio.ini
  4. 31
      src/AudioPlayer.cpp
  5. 3
      src/AudioPlayer.h
  6. 16
      src/Cmd.cpp
  7. 35
      src/Led.cpp
  8. 1
      src/LogMessages_DE.cpp
  9. 1
      src/LogMessages_EN.cpp
  10. 1
      src/logmessages.h
  11. 2
      src/revision.h
  12. 6
      src/settings.h
  13. 1
      src/values.h

2
README.md

@ -13,9 +13,9 @@ I started this project back in october 2019 and never expected it to become that
* Partition-layout for ESP32 is changed along with this branch. This step was necessary in order to resize (enlarge) the memory-region where especially the assignments for the RFID-tags are saved. As all permanent settings (e.g. WiFi-settings) are saved there too, it's necessary to re-enter WiFi-credentials after update. But the most important thing is to recover the assignments for the RFID-tags. Please consult my [migration-document](https://forum.espuino.de/t/wechsel-zum-refactoring-branch-was-ist-zu-beachten/510).
## Changelog
Last three events:
* 13.11.2021: Command `CMD_TELL_IP_ADDRESS` can now be assigned to buttons in order to get information about the currently used IP-address via speech.
* 28.10.2021: Added feature `SAVE_PLAYPOS_WHEN_RFID_CHANGE`. When enabled last playposition for audiobook is saved when new RFID-tag is applied. Without having this feature enabled, it's necessary to press pause first, in order to do this manually.
* 27.10.2021: Added feature `SAVE_PLAYPOS_BEFORE_SHUTDOWN`. When enabled last playposition for audiobook is saved when shutdown is initiated. Without having this feature enabled, it's necessary to press pause first, in order to do this manually.
* 30.09.2021: Added feature `PAUSE_WHEN_RFID_REMOVED` for RC522 after having it already for PN5180 (thanks @elmar-ops for contribution)
## Known bugs
* Some webstreams don't run. Guess it's a combination of saturated connection-pool and lack of heap-memory. Works probably better if ESP32-WROVER (e.g. Lolin D32 pro) is used, as this chip has PSRAM. Advice: Don't enable modules (e.g. MQTT) if you don't need them as this could save memory (and trouble).
* For ESPuinos making use of SPI for SD (instead of SD_MMC), there's currently a problem that sometimes leads to incomplete file-transfers via webtransfer or FTP. I'm about to [investigate...](https://forum.espuino.de/t/probleme-beim-webtransfer/542)

1
changelog.md

@ -13,6 +13,7 @@
* 30.09.2021: Added feature `PAUSE_WHEN_RFID_REMOVED` for RC522 after having it already for PN5180 (thanks @elmar-ops for contribution)
* 27.10.2021: Added feature `SAVE_PLAYPOS_BEFORE_SHUTDOWN`. When enabled last playposition for audiobook is saved when shutdown is initiated. Without having this feature enabled, it's necessary to press pause first, in order to do this manually.
* 28.10.2021: Added feature `SAVE_PLAYPOS_WHEN_RFID_CHANGE`. When enabled last playposition for audiobook is saved when new RFID-tag is applied. Without having this feature enabled, it's necessary to press pause first, in order to do this manually.
* 13.11.2021: Command `CMD_TELL_IP_ADDRESS` can now be assigned to buttons in order to get information about the currently used IP-address via speech.
## Old (monolithic main.cpp)
* 11.07.2020: Added support for reversed Neopixel addressing.
* 09.10.2020: mqttUser / mqttPassword can now be configured via webgui.

2
platformio.ini

@ -17,7 +17,7 @@ extra_scripts = pre:processHtml.py
lib_deps =
SPI
Wire
https://github.com/schreibfaul1/ESP32-audioI2S.git#10e7eb6
https://github.com/schreibfaul1/ESP32-audioI2S.git#e77e750
https://github.com/madhephaestus/ESP32Encoder.git#06fbeb3
https://github.com/knolleary/pubsubclient.git#2d228f2
https://github.com/biologist79/ESP32FTPServer

31
src/AudioPlayer.cpp

@ -649,6 +649,30 @@ void AudioPlayer_Task(void *parameter) {
gPlayProperties.seekmode = SEEK_NORMAL;
}
// Handle IP-announcement
if (gPlayProperties.tellIpAddress) {
gPlayProperties.tellIpAddress = false;
char ipBuf[16];
Wlan_GetIpAddress().toCharArray(ipBuf, sizeof(ipBuf));
bool speechOk;
#if (LANGUAGE == DE)
speechOk = audio->connecttospeech(ipBuf, "de");
#else
speechOk = audio->connecttospeech(ipBuf, "en");
#endif
if (!speechOk) {
System_IndicateError();
}
}
// If speech is over, go back to predefined state
if (!gPlayProperties.currentSpeechActive && gPlayProperties.lastSpeechActive) {
gPlayProperties.lastSpeechActive = false;
if (gPlayProperties.playMode != NO_PLAYLIST) {
AudioPlayer_TrackControlToQueueSender(STOP);
}
}
// Handle if mono/stereo should be changed (e.g. if plugging headphones)
if (gPlayProperties.newPlayMono != gPlayProperties.currentPlayMono) {
gPlayProperties.currentPlayMono = gPlayProperties.newPlayMono;
@ -1056,8 +1080,7 @@ void audio_showstation(const char *info) {
#endif
}
void audio_showstreamtitle(const char *info)
{
void audio_showstreamtitle(const char *info) {
snprintf(Log_Buffer, Log_BufferLength, "streamtitle : %s", info);
Log_Println(Log_Buffer, LOGLEVEL_INFO);
}
@ -1081,3 +1104,7 @@ void audio_lasthost(const char *info) { //stream URL played
snprintf(Log_Buffer, Log_BufferLength, "lasthost : %s", info);
Log_Println(Log_Buffer, LOGLEVEL_INFO);
}
void audio_eof_speech(const char *info){
gPlayProperties.currentSpeechActive = false;
}

3
src/AudioPlayer.h

@ -21,6 +21,9 @@ typedef struct { // Bit field
bool newPlayMono: 1; // true if mono; false if stereo (helper)
bool currentPlayMono: 1; // true if mono; false if stereo
bool isWebstream: 1; // Indicates if track currenty played is a webstream
bool tellIpAddress: 1; // If true current IP-address is spoken
bool currentSpeechActive: 1; // If speech-play is active
bool lastSpeechActive: 1; // If speech-play was active
} playProps;
extern playProps gPlayProperties;

16
src/Cmd.cpp

@ -266,6 +266,22 @@ void Cmd_Action(const uint16_t mod) {
}
#endif
case CMD_TELL_IP_ADDRESS: {
if (Wlan_IsConnected()) {
if (!gPlayProperties.pausePlay) {
AudioPlayer_TrackControlToQueueSender(PAUSEPLAY);
}
gPlayProperties.tellIpAddress = true;
gPlayProperties.currentSpeechActive = true;
gPlayProperties.lastSpeechActive = true;
System_IndicateOk();
} else {
Log_Println(unableToTellIpAddress, LOGLEVEL_ERROR);
System_IndicateError();
}
break;
}
case CMD_PLAYPAUSE: {
if (OPMODE_NORMAL == System_GetOperationMode()) {
AudioPlayer_TrackControlToQueueSender(PAUSEPLAY);

35
src/Led.cpp

@ -154,6 +154,8 @@ static void Led_Task(void *parameter) {
static bool redrawProgress = false;
static uint8_t lastLedBrightness = Led_Brightness;
static CRGB::HTMLColorCode idleColor;
static CRGB::HTMLColorCode speechColor = CRGB::Yellow;
static CRGB::HTMLColorCode generalColor;
static CRGB leds[NUM_LEDS];
FastLED.addLeds<CHIPSET, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalSMD5050);
FastLED.setBrightness(Led_Brightness);
@ -491,10 +493,14 @@ static void Led_Task(void *parameter) {
if (System_GetOperationMode() == OPMODE_BLUETOOTH) {
idleColor = CRGB::Blue;
} else {
if (Wlan_IsConnected()) {
idleColor = CRGB::White;
if (Wlan_IsConnected() && gPlayProperties.currentSpeechActive) {
idleColor = speechColor;
} else {
idleColor = CRGB::Green;
if (Wlan_IsConnected()) {
idleColor = CRGB::White;
} else {
idleColor = CRGB::Green;
}
}
}
if (hlastVolume == AudioPlayer_GetCurrentVolume() && lastLedBrightness == Led_Brightness) {
@ -601,11 +607,16 @@ static void Led_Task(void *parameter) {
}
}
if (gPlayProperties.pausePlay) {
leds[Led_Address(0)] = CRGB::Orange;
generalColor = CRGB::Orange;
if (gPlayProperties.currentSpeechActive) {
generalColor = speechColor;
}
leds[Led_Address(0)] = generalColor;
if (NUM_LEDS > 1) {
leds[(Led_Address(NUM_LEDS / 4)) % NUM_LEDS] = CRGB::Orange;
leds[(Led_Address(NUM_LEDS / 2)) % NUM_LEDS] = CRGB::Orange;
leds[(Led_Address(NUM_LEDS / 4 * 3)) % NUM_LEDS] = CRGB::Orange;
leds[(Led_Address(NUM_LEDS / 4)) % NUM_LEDS] = generalColor;
leds[(Led_Address(NUM_LEDS / 2)) % NUM_LEDS] = generalColor;
leds[(Led_Address(NUM_LEDS / 4 * 3)) % NUM_LEDS] = generalColor;
}
break;
}
@ -634,11 +645,15 @@ static void Led_Task(void *parameter) {
leds[(Led_Address(ledPosWebstream) + NUM_LEDS / 2) % NUM_LEDS].setHue(webstreamColor++);
}
} else if (gPlayProperties.pausePlay) {
generalColor = CRGB::Orange;
if (gPlayProperties.currentSpeechActive) {
generalColor = speechColor;
}
if (NUM_LEDS == 1) {
leds[0] = CRGB::Orange;
leds[0] = generalColor;
} else {
leds[Led_Address(ledPosWebstream)] = CRGB::Orange;
leds[(Led_Address(ledPosWebstream) + NUM_LEDS / 2) % NUM_LEDS] = CRGB::Orange;
leds[Led_Address(ledPosWebstream)] = generalColor;
leds[(Led_Address(ledPosWebstream) + NUM_LEDS / 2) % NUM_LEDS] = generalColor;
}
}
}

1
src/LogMessages_DE.cpp

@ -185,6 +185,7 @@
const char lowPowerCardSuccess[] PROGMEM = "Kartenerkennung via 'low power' erfolgreich durchgeführt";
const char rememberLastVolume[] PROGMEM = "Lautstärke vor dem letzten Shutdown wird wiederhergestellt. Dies überschreibt die Einstellung der initialen Lautstärke aus der GUI.";
const char unableToStartFtpServer[] PROGMEM = "Der FTP-Server konnte nicht gestartet werden. Entweder weil er ist bereits gestartet oder kein WLAN verfügbar ist.";
const char unableToTellIpAddress[] PROGMEM = "IP-Adresse kann nicht angesagt werden, da keine WLAN-Verbindung besteht.";
const char newPlayModeStereo[] PROGMEM = "Neuer Modus: stereo";
const char newPlayModeMono[] PROGMEM = "Neuer Modus: mono";
const char portExpanderFound[] PROGMEM = "Port-expander gefunden";

1
src/LogMessages_EN.cpp

@ -185,6 +185,7 @@
const char lowPowerCardSuccess[] PROGMEM = "Switch to low power card-detection: success";
const char rememberLastVolume[] PROGMEM = "Restored volume used before last shutdown. This overwrites the initial volume configured via webgui.";
const char unableToStartFtpServer[] PROGMEM = "FTP-server cannot be started. This is because FTP-service is already active of because WiFi is unavailable.";
const char unableToTellIpAddress[] PROGMEN = "IP-address can't be announced as there's no WiFi-connection available.";
const char newPlayModeStereo[] PROGMEM = "New mode: stereo";
const char newPlayModeMono[] PROGMEM = "New mode: mono";
const char portExpanderFound[] PROGMEM = "Port-expander found";

1
src/logmessages.h

@ -205,3 +205,4 @@ extern const char otaNotSupportedWebsite[];
extern const char noPlaylist[];
extern const char rfidTagRemoved[];
extern const char rfidTagReapplied[];
extern const char unableToTellIpAddress[];

2
src/revision.h

@ -1,4 +1,4 @@
#ifndef __REVISION_H__
#define __REVISION_H__
constexpr const char softwareRevision[] PROGMEM = "Software-revision: 20211111-1";
constexpr const char softwareRevision[] PROGMEM = "Software-revision: 20211113-1";
#endif

6
src/settings.h

@ -110,8 +110,8 @@
#define BUTTON_1_SHORT CMD_PREVTRACK
#define BUTTON_2_SHORT CMD_PLAYPAUSE
#define BUTTON_3_SHORT CMD_MEASUREBATTERY
#define BUTTON_4_SHORT CMD_NOTHING
#define BUTTON_5_SHORT CMD_NOTHING
#define BUTTON_4_SHORT CMD_SEEK_BACKWARDS
#define BUTTON_5_SHORT CMD_SEEK_FORWARDS
#define BUTTON_0_LONG CMD_LASTTRACK
#define BUTTON_1_LONG CMD_FIRSTTRACK
@ -125,7 +125,7 @@
#define BUTTON_MULTI_03 CMD_NOTHING
#define BUTTON_MULTI_04 CMD_NOTHING
#define BUTTON_MULTI_05 CMD_NOTHING
#define BUTTON_MULTI_12 CMD_NOTHING
#define BUTTON_MULTI_12 CMD_TELL_IP_ADDRESS
#define BUTTON_MULTI_13 CMD_NOTHING
#define BUTTON_MULTI_14 CMD_NOTHING
#define BUTTON_MULTI_15 CMD_NOTHING

1
src/values.h

@ -45,6 +45,7 @@
#define CMD_TOGGLE_WIFI_STATUS 130 // Toggles WiFi-status
#define CMD_TOGGLE_BLUETOOTH_MODE 140 // Toggles Normal/Bluetooth Mode
#define CMD_ENABLE_FTP_SERVER 150 // Enables FTP-server
#define CMD_TELL_IP_ADDRESS 151 // Command: ESPuino announces its IP-address via speech
#define CMD_PLAYPAUSE 170 // Command: play/pause
#define CMD_PREVTRACK 171 // Command: previous track

Loading…
Cancel
Save