diff --git a/datasheets/PCA9555.pdf b/datasheets/PCA9555.pdf new file mode 100644 index 0000000..6750a49 Binary files /dev/null and b/datasheets/PCA9555.pdf differ diff --git a/platformio.ini b/platformio.ini index 50b8a13..5c0df81 100644 --- a/platformio.ini +++ b/platformio.ini @@ -165,6 +165,26 @@ build_flags = -DHAL=5 platform_packages = platformio/framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#1.0.5 +[env:complete] +;https://docs.platformio.org/en/latest/boards/espressif32/esp-wrover-kit.html +platform = espressif32 +board = esp-wrover-kit +framework = arduino +monitor_speed = 115200 +board_build.partitions = huge_app.csv +lib_deps = + ${common.lib_deps_builtin} + ${common.lib_deps_external} + https://github.com/tueddy/PN5180-Library.git#0c200f5 +extra_scripts = ${env:common.extra_scripts} +upload_port = /dev/cu.SLAB_USBtoUART +monitor_port = /dev/cu.SLAB_USBtoUART +build_flags = -DHAL=6 + -DBOARD_HAS_PSRAM + -mfix-esp32-psram-cache-issue +platform_packages = + platformio/framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#1.0.5 + ;;; Change upload/monitor-port of your board regarding your operating-system and develboard! ;MAC: /dev/cu.SLAB_USBtoUART / /dev/cu.wchusbserial1420 / /dev/cu.wchusbserial1410 ;WINDOWS: COM3 diff --git a/src/AudioPlayer.cpp b/src/AudioPlayer.cpp index cf2a86c..d2eb936 100644 --- a/src/AudioPlayer.cpp +++ b/src/AudioPlayer.cpp @@ -82,7 +82,7 @@ void AudioPlayer_Init(void) { #ifdef HEADPHONE_ADJUST_ENABLE pinMode(HP_DETECT, INPUT); - AudioPlayer_HeadphoneLastDetectionState = Port_Read(HP_DETECT); + AudioPlayer_HeadphoneLastDetectionState = Port_Detect_Mode_HP(Port_Read(HP_DETECT)); // Get maximum volume for headphone from NVS uint32_t nvsAudioPlayer_MaxVolumeHeadphone = gPrefsSettings.getUInt("maxVolumeHp", 0); @@ -159,16 +159,30 @@ void AudioPlayer_SetupVolume(void) { AudioPlayer_MaxVolume = AudioPlayer_MaxVolumeSpeaker; return; #else - if (Port_Read(HP_DETECT)) { + if (Port_Detect_Mode_HP(Port_Read(HP_DETECT))) { AudioPlayer_MaxVolume = AudioPlayer_MaxVolumeSpeaker; // 1 if headphone is not connected #ifdef PLAY_MONO_SPEAKER gPlayProperties.newPlayMono = true; #else gPlayProperties.newPlayMono = false; #endif + + #ifdef GPIO_PA_EN + Port_Write(GPIO_PA_EN, true, true); + #endif + #ifdef GPIO_HP_EN + Port_Write(GPIO_HP_EN, false, true); + #endif } else { AudioPlayer_MaxVolume = AudioPlayer_MaxVolumeHeadphone; // 0 if headphone is connected (put to GND) gPlayProperties.newPlayMono = false; // always stereo for headphones! + + #ifdef GPIO_PA_EN + Port_Write(GPIO_PA_EN, false, true); + #endif + #ifdef GPIO_HP_EN + Port_Write(GPIO_HP_EN, true, true); + #endif } snprintf(Log_Buffer, Log_BufferLength, "%s: %u", (char *) FPSTR(maxVolumeSet), AudioPlayer_MaxVolume); Log_Println(Log_Buffer, LOGLEVEL_INFO); @@ -178,7 +192,7 @@ void AudioPlayer_SetupVolume(void) { void AudioPlayer_HeadphoneVolumeManager(void) { #ifdef HEADPHONE_ADJUST_ENABLE - bool currentHeadPhoneDetectionState = Port_Read(HP_DETECT); + bool currentHeadPhoneDetectionState = Port_Detect_Mode_HP(Port_Read(HP_DETECT)); if (AudioPlayer_HeadphoneLastDetectionState != currentHeadPhoneDetectionState && (millis() - AudioPlayer_HeadphoneLastDetectionTimestamp >= headphoneLastDetectionDebounce)) { if (currentHeadPhoneDetectionState) { @@ -188,12 +202,26 @@ void AudioPlayer_HeadphoneVolumeManager(void) { #else gPlayProperties.newPlayMono = false; #endif + + #ifdef GPIO_PA_EN + Port_Write(GPIO_PA_EN, true); + #endif + #ifdef GPIO_HP_EN + Port_Write(GPIO_HP_EN, false); + #endif } else { AudioPlayer_MaxVolume = AudioPlayer_MaxVolumeHeadphone; gPlayProperties.newPlayMono = false; // Always stereo for headphones if (AudioPlayer_GetCurrentVolume() > AudioPlayer_MaxVolume) { AudioPlayer_VolumeToQueueSender(AudioPlayer_MaxVolume, true); // Lower volume for headphone if headphone's maxvolume is exceeded by volume set in speaker-mode } + + #ifdef GPIO_PA_EN + Port_Write(GPIO_PA_EN, false); + #endif + #ifdef GPIO_HP_EN + Port_Write(GPIO_HP_EN, true); + #endif } AudioPlayer_HeadphoneLastDetectionState = currentHeadPhoneDetectionState; AudioPlayer_HeadphoneLastDetectionTimestamp = millis(); diff --git a/src/Button.cpp b/src/Button.cpp index 5a09842..90b0e1e 100644 --- a/src/Button.cpp +++ b/src/Button.cpp @@ -44,6 +44,9 @@ t_button gButtons[7]; // next + prev + pplay + rotEnc + button4 + button5 + dummy-button uint8_t gShutdownButton = 99; // Helper used for Neopixel: stores button-number of shutdown-button +#ifdef PORT_EXPANDER_ENABLE + extern bool Port_AllowReadFromPortExpander; +#endif static volatile SemaphoreHandle_t Button_TimerSemaphore; @@ -125,6 +128,9 @@ void Button_Cyclic() { } unsigned long currentTimestamp = millis(); + #ifdef PORT_EXPANDER_ENABLE + Port_Cyclic(); // todo: probably change behaviour to read from port-expander via interrupt + #endif // Buttons can be mixed between GPIO and port-expander. // But at the same time only one of them can be for example NEXT_BUTTON @@ -148,17 +154,12 @@ void Button_Cyclic() { #endif // Iterate over all buttons in struct-array - for (uint8_t i = 0; i < sizeof(gButtons) / sizeof(gButtons[0]); i++) - { - if (gButtons[i].currentState != gButtons[i].lastState && currentTimestamp - gButtons[i].lastPressedTimestamp > buttonDebounceInterval) - { - if (!gButtons[i].currentState) - { + for (uint8_t i = 0; i < sizeof(gButtons) / sizeof(gButtons[0]); i++) { + if (gButtons[i].currentState != gButtons[i].lastState && currentTimestamp - gButtons[i].lastPressedTimestamp > buttonDebounceInterval) { + if (!gButtons[i].currentState) { gButtons[i].isPressed = true; gButtons[i].lastPressedTimestamp = currentTimestamp; - } - else - { + } else { gButtons[i].isReleased = true; gButtons[i].lastReleasedTimestamp = currentTimestamp; } @@ -170,8 +171,7 @@ void Button_Cyclic() { } // Do corresponding actions for all buttons -void Button_DoButtonActions(void) -{ +void Button_DoButtonActions(void) { if (gButtons[0].isPressed && gButtons[1].isPressed) { gButtons[0].isPressed = false; gButtons[1].isPressed = false; diff --git a/src/LogMessages_DE.cpp b/src/LogMessages_DE.cpp index 80cf732..7ab2c91 100644 --- a/src/LogMessages_DE.cpp +++ b/src/LogMessages_DE.cpp @@ -185,5 +185,7 @@ 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 newPlayModeStereo[] PROGMEM = "Neuer Modus: stereo"; const char newPlayModeMono[] PROGMEM = "Neuer Modus: mono"; + const char portExpanderFound[] PROGMEM = "Port-expander gefunden"; + const char portExpanderNotFound[] PROGMEM = "Port-expander nicht gefunden"; #endif diff --git a/src/LogMessages_EN.cpp b/src/LogMessages_EN.cpp index 42062ff..ada7ba5 100644 --- a/src/LogMessages_EN.cpp +++ b/src/LogMessages_EN.cpp @@ -185,5 +185,7 @@ const char unableToStartFtpServer[] PROGMEM = "FTP-server cannot be started. This is because FTP-service is already active of because WiFi is unavailable."; const char newPlayModeStereo[] PROGMEM = "New mode: stereo"; const char newPlayModeMono[] PROGMEM = "New mode: mono"; + const char portExpanderFound[] PROGMEM = "Port-expander found"; + const char portExpanderNotFound[] PROGMEM = "Unable to detect port-expander"; #endif diff --git a/src/Mqtt.cpp b/src/Mqtt.cpp index 932617e..af71192 100644 --- a/src/Mqtt.cpp +++ b/src/Mqtt.cpp @@ -11,8 +11,8 @@ #include "Wlan.h" #ifdef MQTT_ENABLE -#define MQTT_SOCKET_TIMEOUT 1 // https://github.com/knolleary/pubsubclient/issues/403 -#include + #define MQTT_SOCKET_TIMEOUT 1 // https://github.com/knolleary/pubsubclient/issues/403 + #include #endif constexpr uint8_t stillOnlineInterval = 60u; // Interval 'I'm still alive' is sent via MQTT (in seconds) diff --git a/src/Port.cpp b/src/Port.cpp index a676c7b..6a96f91 100644 --- a/src/Port.cpp +++ b/src/Port.cpp @@ -2,15 +2,43 @@ #include #include "settings.h" #include "Port.h" +#include "Log.h" + +// Infos: +// PCA9555 has 16 channels that are subdivided into 2 ports with 8 channels each. +// Every channels is represented by a bit. +// Examples for ESPuino-configuration: +// 100 => port 0 channel/bit 0 +// 107 => port 0 channel/bit 7 +// 108 => port 1 channel/bit 0 +// 115 => port 1 channel/bit 7 #ifdef PORT_EXPANDER_ENABLE extern TwoWire i2cBusTwo; - uint8_t Port_ExpanderPorts[portsToRead]; + uint8_t Port_ExpanderPortsInputChannelStatus[portsToRead]; + static uint8_t Port_ExpanderPortsOutputChannelStatus[2] = {255, 255}; // Stores current configuration of output-channels locally bool Port_ExpanderHandler(void); + uint8_t Port_ChannelToBit(const uint8_t _channel); + void Port_WriteInitMaskForOutputChannels(void); + void Port_Test(void); #endif void Port_Init(void) { + #ifdef PORT_EXPANDER_ENABLE + Port_Test(); + Port_WriteInitMaskForOutputChannels(); + #endif + + // If automatic HP-detection is not used... + #ifndef HEADPHONE_ADJUST_ENABLE + #ifdef GPIO_PA_EN + Port_Write(GPIO_PA_EN, true, true); // ...but it's necessary to enable loudspeaker amp... + #endif + #ifdef GPIO_HP_EN + Port_Write(GPIO_HP_EN, true, true); // ...or headphones-amp + #endif + #endif } void Port_Cyclic(void) { @@ -27,12 +55,12 @@ bool Port_Read(const uint8_t _channel) { return digitalRead(_channel); #ifdef PORT_EXPANDER_ENABLE - case 100 ... 107: // Port-expander (port 0) - return (Port_ExpanderPorts[0] & (1 << (_channel - 100))); // Remove offset 100 (return false if pressed) + case 100 ... 107: // Port-expander (port 0) + return (Port_ExpanderPortsInputChannelStatus[0] & (1 << (_channel - 100))); // Remove offset 100 (return false if pressed) case 108 ... 115: // Port-expander (port 1) - if (portsToRead == 2) { // Make sure portsToRead != 1 when channel > 107 - return (Port_ExpanderPorts[1] & (1 << (_channel - 108))); // Remove offset 100 + 8 (return false if pressed) + if (portsToRead == 2) { // Make sure portsToRead != 1 when channel > 107 + return (Port_ExpanderPortsInputChannelStatus[1] & (1 << (_channel - 108))); // Remove offset 100 + 8 (return false if pressed) } else { return true; } @@ -43,22 +71,191 @@ bool Port_Read(const uint8_t _channel) { } } +// Wrapper-function to reverse detection of connected headphones. +// Normally headphones are supposed to be plugged in if a given GPIO/channel is LOW/false. +bool Port_Detect_Mode_HP(bool _state) { + #ifndef DETECT_HP_ON_HIGH + return _state; + #else + return !_state; + #endif +} + +// Configures OUTPUT-mode for GPIOs (non port-expander) +// Output-mode for port-channels is done via Port_WriteInitMaskForOutputChannels() +void Port_Write(const uint8_t _channel, const bool _newState, const bool _initGpio) { + if (_initGpio) { + switch (_channel) { + case 0 ... 39: { // GPIO + pinMode(_channel, OUTPUT); + Port_Write(_channel, _newState); + break; + } + + default: { + Port_Write(_channel, _newState); + break; + } + } + } +} + +// Wrapper: writes to GPIOs (via digitalWrite()) or to port-expander (if enabled) +void Port_Write(const uint8_t _channel, const bool _newState) { + switch (_channel) { + case 0 ... 39: { // GPIO + digitalWrite(_channel, _newState); + break; + } + + #ifdef PORT_EXPANDER_ENABLE + case 100 ... 115: { + uint8_t portOffset = 0; + if (_channel >= 108 && _channel <= 115) { + portOffset = 1; + } + + uint8_t oldPortBitmask = Port_ExpanderPortsOutputChannelStatus[portOffset]; + uint8_t newPortBitmask; + + i2cBusTwo.beginTransmission(expanderI2cAddress); + i2cBusTwo.write(0x02); // Pointer to output configuration-register + if (_newState) { + newPortBitmask = (oldPortBitmask | (1 << Port_ChannelToBit(_channel))); + Port_ExpanderPortsOutputChannelStatus[portOffset] = newPortBitmask; // Write back new status + } else { + newPortBitmask = (oldPortBitmask & ~(1 << Port_ChannelToBit(_channel))); + Port_ExpanderPortsOutputChannelStatus[portOffset] = newPortBitmask; // Write back new status + } + i2cBusTwo.write(Port_ExpanderPortsOutputChannelStatus[0]); + i2cBusTwo.write(Port_ExpanderPortsOutputChannelStatus[1]); + i2cBusTwo.endTransmission(); + break; + } + #endif + + default: { + break; + } + } +} + #ifdef PORT_EXPANDER_ENABLE + // Translates digitalWrite-style "GPIO" to bit + uint8_t Port_ChannelToBit(const uint8_t _channel) { + switch (_channel) { + case 100: + case 108: + return 0; + break; + case 101: + case 109: + return 1; + break; + case 102: + case 110: + return 2; + break; + case 103: + case 111: + return 3; + break; + case 104: + case 112: + return 4; + break; + case 105: + case 113: + return 5; + break; + case 106: + case 114: + return 6; + break; + case 107: + case 115: + return 7; + break; + + default: + return 255; // not valid! + } + } + + // Writes initial port-configuration (I/O) for port-expander PCA9555 + // If no output-channel is necessary, nothing has to be configured as all channels are in input-mode as per default (255) + // So every bit representing an output-channel needs to be set to 0. + void Port_WriteInitMaskForOutputChannels(void) { + const uint8_t portBaseValueBitMask = 255; + const uint8_t portsToWrite = 2; + uint8_t OutputBitMaskAsPerPort[portsToWrite] = { portBaseValueBitMask, portBaseValueBitMask }; // 255 => all channels set to input; [0]: port0, [1]: port1 + + #ifdef GPIO_PA_EN + if (GPIO_PA_EN >= 100 && GPIO_PA_EN <= 107) { + // Bits of channels to be configured as input are 1 by default. + // So in order to change I/O-direction to output we need to set those bits to 0. + OutputBitMaskAsPerPort[0] &= ~(1 << Port_ChannelToBit(GPIO_PA_EN)); + //Serial.printf("PA LO: %u\n", OutputBitMaskAsPerPort[0]); + } else if ((GPIO_PA_EN >= 108 && GPIO_PA_EN <= 115) && portsToRead > 1) { + OutputBitMaskAsPerPort[1] &= ~(1 << Port_ChannelToBit(GPIO_PA_EN)); + //Serial.printf("PA HI: %u\n", OutputBitMaskAsPerPort[1]); + } + #endif + + #ifdef GPIO_HP_EN + if (GPIO_HP_EN >= 100 && GPIO_HP_EN <= 107) { + OutputBitMaskAsPerPort[0] &= ~(1 << Port_ChannelToBit(GPIO_HP_EN)); + //Serial.printf("HP LO: %u\n", OutputBitMaskAsPerPort[0]); + } else if ((GPIO_HP_EN >= 108 && GPIO_HP_EN <= 115) && portsToRead > 1) { + OutputBitMaskAsPerPort[1] &= ~(1 << Port_ChannelToBit(GPIO_HP_EN)); + //Serial.printf("HP HI: %u\n", OutputBitMaskAsPerPort[1]); + } + #endif + + // Only change port-config if necessary (at least bitmask changed from base-default for one port) + if ((OutputBitMaskAsPerPort[0] != portBaseValueBitMask) || (OutputBitMaskAsPerPort[1] != portBaseValueBitMask)) { + i2cBusTwo.beginTransmission(expanderI2cAddress); + i2cBusTwo.write(0x06); + for (uint8_t i=0; i not necessary for single-SPI + #define SPISD_MISO 16 // GPIO for master in slave ou (SD) => not necessary for single-SPI + #define SPISD_SCK 14 // GPIO for clock-signal (SD) => not necessary for single-SPI + #endif +#endif + +// RFID (via SPI) +#define RST_PIN 22 // Not necessary but has to be set anyway; so let's use a dummy-number +#define RFID_CS 21 // GPIO for chip select (RFID) +#define RFID_MOSI 23 // GPIO for master out slave in (RFID) +#define RFID_MISO 19 // GPIO for master in slave out (RFID) +#define RFID_SCK 18 // GPIO for clock-signal (RFID) + +#ifdef RFID_READER_TYPE_PN5180 + #define RFID_BUSY 16 // PN5180 BUSY PIN + #define RFID_RST 22 // PN5180 RESET PIN + #define RFID_IRQ 39 // PN5180 IRQ PIN (only needed for low power card detection) +#endif +// I2S (DAC) +#define I2S_DOUT 25 // Digital out (I2S) +#define I2S_BCLK 27 // BCLK (I2S) +#define I2S_LRC 26 // LRC (I2S) + +// Rotary encoder +#ifdef USEROTARY_ENABLE + #define DREHENCODER_CLK 35 // If you want to reverse encoder's direction, just switch GPIOs of CLK with DT (in software or hardware) + #define DREHENCODER_DT 34 // Info: Lolin D32 / Lolin D32 pro 35 are using 35 for battery-voltage-monitoring! + #define DREHENCODER_BUTTON 105 // (set to 99 to disable; 0->39 for GPIO; 100->115 for port-expander) +#endif + +// Amp enable (optional) +#define GPIO_PA_EN 112 // To enable amp for loudspeaker (GPIO or port-channel) +#define GPIO_HP_EN 113 // To enable amp for headphones (GPIO or port-channel) + +// Control-buttons (set to 99 to DISABLE; 0->39 for GPIO; 100->115 for port-expander) +#define NEXT_BUTTON 102 // Button 0: GPIO to detect next +#define PREVIOUS_BUTTON 103 // Button 1: GPIO to detect previous (Important: as of 19.11.2020 changed from 33 to 2; make sure to change in SD-MMC-mode) +#define PAUSEPLAY_BUTTON 100 // Button 2: GPIO to detect pause/play +#define BUTTON_4 101 // Button 4: unnamed optional button +#define BUTTON_5 104 // Button 5: unnamed optional button + +// I2C-configuration (necessary for RC522 [only via i2c - not spi!] or port-expander) +#if defined(RFID_READER_TYPE_MFRC522_I2C) || defined(PORT_EXPANDER_ENABLE) + #define ext_IIC_CLK 33 // i2c-SCL (clock) + #define ext_IIC_DATA 5 // i2c-SDA (data) +#endif + +// Wake-up button => this also is the interrupt-pin if port-expander is enabled! +// Please note: only RTC-GPIOs (0, 4, 12, 13, 14, 15, 25, 26, 27, 32, 33, 34, 35, 36, 39, 99) can be used! Set to 99 to DISABLE. +// Please note #2: this button can be used as interrupt-pin for port-expander. If so, all pins connected to port-expander can wake up ESPuino. +#define WAKEUP_BUTTON DREHENCODER_BUTTON // Defines the button that is used to wake up ESPuino from deepsleep. + +// (optional) Power-control +#define POWER 13 // GPIO used to drive transistor-circuit, that switches off peripheral devices while ESP32-deepsleep + +// (optional) Neopixel +#define LED_PIN 12 // GPIO for Neopixel-signaling + +// (optinal) Headphone-detection +#ifdef HEADPHONE_ADJUST_ENABLE + #define DETECT_HP_ON_HIGH // Per default headphones are supposed to be connected if HT_DETECT is LOW. DETECT_HP_ON_HIGH will change this behaviour to HIGH. + #define HP_DETECT 107 // GPIO that detects, if there's a plug in the headphone jack or not +#endif + +// (optional) Monitoring of battery-voltage via ADC +#ifdef MEASURE_BATTERY_VOLTAGE + #define VOLTAGE_READ_PIN 33 // GPIO used to monitor battery-voltage. Change to 35 if you're using Lolin D32 or Lolin D32 pro as it's hard-wired there! + constexpr float referenceVoltage = 3.35; // Voltage between 3.3V and GND-pin at the develboard in battery-mode (disconnect USB!) + constexpr float offsetVoltage = 0.1; // If voltage measured by ESP isn't 100% accurate, you can add an correction-value here +#endif + +// (optional) For measuring battery-voltage a voltage-divider is necessary. Their values need to be configured here. +#ifdef MEASURE_BATTERY_VOLTAGE + constexpr uint8_t rdiv1 = 100; // Rdiv1 of voltage-divider (kOhms) (measure exact value with multimeter!) + constexpr uint16_t rdiv2 = 33; // Rdiv2 of voltage-divider (kOhms) (measure exact value with multimeter!) => used to measure voltage via ADC! +#endif + +// (Optional) remote control via infrared +#ifdef IR_CONTROL_ENABLE + #define IRLED_PIN 22 // GPIO where IR-receiver is connected (only tested with VS1838B) + #define IR_DEBOUNCE 200 // Interval in ms to wait at least for next signal (not used for actions volume up/down) + + // Actions available. Use your own remote control and have a look at the console for "Command=0x??". E.g. "Protocol=NEC Address=0x17F Command=0x68 Repeat gap=39750us" + // Make sure to define a hex-code not more than once as this will lead to a compile-error + // https://forum.espuino.de/t/neues-feature-fernsteuerung-per-infrarot-fernbedienung/265 + #define RC_PLAY 0x68 // command for play + #define RC_PAUSE 0x67 // command for pause + #define RC_NEXT 0x6b // command for next track of playlist + #define RC_PREVIOUS 0x6a // command for previous track of playlist + #define RC_FIRST 0x6c // command for first track of playlist + #define RC_LAST 0x6d // command for last track of playlist + #define RC_VOL_UP 0x1a // Command for volume up (one step) + #define RC_VOL_DOWN 0x1b // Command for volume down (one step) + #define RC_MUTE 0x1c // Command to mute ESPuino + #define RC_SHUTDOWN 0x2a // Command for deepsleep + #define RC_BLUETOOTH 0x72 // Command to enable/disable bluetooth + #define RC_FTP 0x65 // Command to enable FTP-server +#endif \ No newline at end of file diff --git a/src/settings-espa1s.h b/src/settings-espa1s.h index 41d48c3..3e947cb 100644 --- a/src/settings-espa1s.h +++ b/src/settings-espa1s.h @@ -52,8 +52,7 @@ #define IIC_DATA 33 // internal // Amp enable - #define GPIO_PA_EN GPIO_NUM_21 // internal - #define GPIO_SEL_PA_EN GPIO_SEL_21 + #define GPIO_PA_EN 21 // internal // Rotary encoder #ifdef USEROTARY_ENABLE @@ -84,6 +83,7 @@ // (optinal) Headphone-detection #ifdef HEADPHONE_ADJUST_ENABLE + //#define DETECT_HP_ON_HIGH // Per default headphones are supposed to be connected if HT_DETECT is LOW. DETECT_HP_ON_HIGH will change this behaviour to HIGH. #define HP_DETECT 39 // GPIO that detects, if there's a plug in the headphone jack or not #endif diff --git a/src/settings-lolin32.h b/src/settings-lolin32.h index 5e5d1a1..828b6af 100644 --- a/src/settings-lolin32.h +++ b/src/settings-lolin32.h @@ -1,3 +1,5 @@ +#ifndef __ESPUINO_SETTINGS_LOLIN32_H__ +#define __ESPUINO_SETTINGS_LOLIN32_H__ #include "Arduino.h" //######################### INFOS #################################### @@ -57,6 +59,10 @@ #define DREHENCODER_BUTTON 32 // (set to 99 to disable; 0->39 for GPIO; 100->115 for port-expander) #endif +// Amp enable (optional) +//#define GPIO_PA_EN 112 // To enable amp for loudspeaker (GPIO or port-channel) +//#define GPIO_HP_EN 113 // To enable amp for headphones (GPIO or port-channel) + // Control-buttons (set to 99 to DISABLE; 0->39 for GPIO; 100->115 for port-expander) #define NEXT_BUTTON 4 // Button 0: GPIO to detect next #define PREVIOUS_BUTTON 2 // Button 1: GPIO to detect previous (Important: as of 19.11.2020 changed from 33 to 2; make sure to change in SD-MMC-mode) @@ -83,6 +89,7 @@ // (optinal) Headphone-detection #ifdef HEADPHONE_ADJUST_ENABLE + //#define DETECT_HP_ON_HIGH // Per default headphones are supposed to be connected if HT_DETECT is LOW. DETECT_HP_ON_HIGH will change this behaviour to HIGH. #define HP_DETECT 22 // GPIO that detects, if there's a plug in the headphone jack or not #endif @@ -119,4 +126,5 @@ #define RC_SHUTDOWN 0x2a // Command for deepsleep #define RC_BLUETOOTH 0x72 // Command to enable/disable bluetooth #define RC_FTP 0x65 // Command to enable FTP-server +#endif #endif \ No newline at end of file diff --git a/src/settings-lolin_d32.h b/src/settings-lolin_d32.h index 592fbb3..a838543 100644 --- a/src/settings-lolin_d32.h +++ b/src/settings-lolin_d32.h @@ -59,7 +59,11 @@ #define DREHENCODER_BUTTON 32 // (set to 99 to disable; 0->39 for GPIO; 100->115 for port-expander) #endif -// Control-buttons (set to 99 to DISABLE; 0->39 for GPIO; 100->115 for port-expander) + // Amp enable (optional) + //#define GPIO_PA_EN 112 // To enable amp for loudspeaker (GPIO or port-channel) + //#define GPIO_HP_EN 113 // To enable amp for headphones (GPIO or port-channel) + + // Control-buttons (set to 99 to DISABLE; 0->39 for GPIO; 100->115 for port-expander) #define NEXT_BUTTON 4 // Button 0: GPIO to detect next #define PREVIOUS_BUTTON 2 // Button 1: GPIO to detect previous (Important: as of 19.11.2020 changed from 33 to 2; make sure to change in SD-MMC-mode) #define PAUSEPLAY_BUTTON 5 // Button 2: GPIO to detect pause/play @@ -85,6 +89,7 @@ // (optinal) Headphone-detection #ifdef HEADPHONE_ADJUST_ENABLE + //#define DETECT_HP_ON_HIGH // Per default headphones are supposed to be connected if HT_DETECT is LOW. DETECT_HP_ON_HIGH will change this behaviour to HIGH. #define HP_DETECT 22 // GPIO that detects, if there's a plug in the headphone jack or not #endif diff --git a/src/settings-lolin_d32_pro.h b/src/settings-lolin_d32_pro.h index fdfd68b..8e088c0 100644 --- a/src/settings-lolin_d32_pro.h +++ b/src/settings-lolin_d32_pro.h @@ -51,9 +51,13 @@ #ifdef USEROTARY_ENABLE #define DREHENCODER_CLK 34 // If you want to reverse encoder's direction, just switch GPIOs of CLK with DT (in software or hardware) #define DREHENCODER_DT 39 // 39 = 'VN'; Info: Lolin D32 pro is using 35 for battery-voltage-monitoring! - #define DREHENCODER_BUTTON 36 // (set to 99 to disable; 0->39 for GPIO; 100->115 for port-expander) + #define DREHENCODER_BUTTON 32 // (set to 99 to disable; 0->39 for GPIO; 100->115 for port-expander) #endif + // Amp enable (optional) + //#define GPIO_PA_EN 112 // To enable amp for loudspeaker (GPIO or port-channel) + //#define GPIO_HP_EN 113 // To enable amp for headphones (GPIO or port-channel) + // Control-buttons (set to 99 to DISABLE; 0->39 for GPIO; 100->115 for port-expander) #define NEXT_BUTTON 0 // Button 0: GPIO to detect next #define PREVIOUS_BUTTON 2 // Button 1: GPIO to detect previous (Important: as of 19.11.2020 changed from 33 to 2; make sure to change in SD-MMC-mode) @@ -80,6 +84,7 @@ // (optinal) Headphone-detection #ifdef HEADPHONE_ADJUST_ENABLE + //#define DETECT_HP_ON_HIGH // Per default headphones are supposed to be connected if HT_DETECT is LOW. DETECT_HP_ON_HIGH will change this behaviour to HIGH. #define HP_DETECT 22 // GPIO that detects, if there's a plug in the headphone jack or not #endif diff --git a/src/settings-ttgo_t8.h b/src/settings-ttgo_t8.h index dd27fbd..eacb6d3 100644 --- a/src/settings-ttgo_t8.h +++ b/src/settings-ttgo_t8.h @@ -54,6 +54,10 @@ #define DREHENCODER_BUTTON 32 // (set to 99 to disable; 0->39 for GPIO; 100->115 for port-expander) #endif +// Amp enable (optional) +//#define GPIO_PA_EN 112 // To enable amp for loudspeaker (GPIO or port-channel) +//#define GPIO_HP_EN 113 // To enable amp for headphones (GPIO or port-channel) + // Control-buttons (set to 99 to DISABLE; 0->39 for GPIO; 100->115 for port-expander) #define NEXT_BUTTON 0 // Button 0: GPIO to detect next #define PREVIOUS_BUTTON 36 // Button 1: GPIO to detect previous (Important: as of 19.11.2020 changed from 33 to 2; make sure to change in SD-MMC-mode) @@ -80,6 +84,7 @@ // (optinal) Headphone-detection #ifdef HEADPHONE_ADJUST_ENABLE + //#define DETECT_HP_ON_HIGH // Per default headphones are supposed to be connected if HT_DETECT is LOW. DETECT_HP_ON_HIGH will change this behaviour to HIGH. #define HP_DETECT 13 // GPIO that detects, if there's a plug in the headphone jack or not #endif diff --git a/src/settings.h b/src/settings.h index dc51994..83682e5 100644 --- a/src/settings.h +++ b/src/settings.h @@ -14,11 +14,12 @@ 3: Wemos Lolin D32 => settings-lolin_D32.h 4: Wemos Lolin D32 pro => settings-lolin_D32_pro.h 5: Lilygo T8 (V1.7) => settings-ttgo_t8.h + 6: ESPuino complete => settings-complete.h 99: custom => settings-custom.h more to come... */ #ifndef HAL // Will be set by platformio.ini. If using Arduini-IDE you have to set HAL according your needs! - #define HAL 1 // HAL 1 = LoLin32, 2 = ESP32-A1S-AudioKit, 3 = Lolin D32, 4 = Lolin D32 pro; 99 = custom + #define HAL 1 // HAL 1 = LoLin32, 2 = ESP32-A1S-AudioKit, 3 = Lolin D32, 4 = Lolin D32 pro; ... 99 = custom #endif @@ -137,7 +138,7 @@ // Static ip-configuration #ifdef STATIC_IP_ENABLE #define LOCAL_IP 192,168,2,100 // ESPuino's IP - #define GATEWAY_IP 192,168,2,1 // IP of the gateway/router + #define GATEWAY_IP 192,168,2,1 // IP of the gateway/router #define SUBNET_IP 255,255,255,0 // Netmask of your network (/24 => 255.255.255.0) #define DNS_IP 192,168,2,1 // DNS-server of your network; in private networks it's usually the gatewy's IP #endif @@ -228,6 +229,8 @@ #include "settings-lolin_d32_pro.h" // Contains all user-relevant settings for Wemos Lolin D32 pro #elif (HAL == 5) #include "settings-ttgo_t8.h" // Contains all user-relevant settings for Lilygo TTGO T8 1.7 + #elif (HAL == 6) + #include "settings-complete.h" // Contains all user-relevant settings for ESPuino complete #elif (HAL == 99) #include "settings-custom.h" // Contains all user-relevant settings custom-board #endif