Browse Source

Adding global support for PA/HP_enable

master
Torsten Stauder 4 years ago
parent
commit
ce5360b1a3
  1. BIN
      datasheets/PCA9555.pdf
  2. 20
      platformio.ini
  3. 34
      src/AudioPlayer.cpp
  4. 22
      src/Button.cpp
  5. 2
      src/LogMessages_DE.cpp
  6. 2
      src/LogMessages_EN.cpp
  7. 4
      src/Mqtt.cpp
  8. 213
      src/Port.cpp
  9. 5
      src/Port.h
  10. 2
      src/logmessages.h
  11. 10
      src/main.cpp
  12. 123
      src/settings-complete.h
  13. 4
      src/settings-espa1s.h
  14. 8
      src/settings-lolin32.h
  15. 7
      src/settings-lolin_d32.h
  16. 7
      src/settings-lolin_d32_pro.h
  17. 5
      src/settings-ttgo_t8.h
  18. 7
      src/settings.h

BIN
datasheets/PCA9555.pdf

20
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

34
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();

22
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;

2
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

2
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

4
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 <PubSubClient.h>
#define MQTT_SOCKET_TIMEOUT 1 // https://github.com/knolleary/pubsubclient/issues/403
#include <PubSubClient.h>
#endif
constexpr uint8_t stillOnlineInterval = 60u; // Interval 'I'm still alive' is sent via MQTT (in seconds)

213
src/Port.cpp

@ -2,15 +2,43 @@
#include <Wire.h>
#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<portsToWrite; i++) {
i2cBusTwo.write(OutputBitMaskAsPerPort[i]);
//Serial.printf("Register %u - Mask: %u\n", 0x06+i, OutputBitMaskAsPerPort[i]);
}
i2cBusTwo.endTransmission();
i2cBusTwo.beginTransmission(expanderI2cAddress);
i2cBusTwo.write(0x02); // Pointer to configuration of output-channels
i2cBusTwo.write(0x00); // Set all output-channels (port0) to low as per default (channels configured as input aren't affected by this)
i2cBusTwo.write(0x00); // Set all output-channels (port1) to low as per default (channels configured as input aren't affected by this)
i2cBusTwo.endTransmission();
}
}
// Reads input from port-expander and writes output into global array
// Datasheet: https://www.nxp.com/docs/en/data-sheet/PCA9555.pdf
bool Port_ExpanderHandler() {
i2cBusTwo.beginTransmission(expanderI2cAddress);
for (uint8_t i = 0; i < portsToRead; i++) {
i2cBusTwo.write(0x00 + i); // Go to input-register...
i2cBusTwo.write(0x00 + i); // Pointer to input-register...
i2cBusTwo.endTransmission();
i2cBusTwo.requestFrom(expanderI2cAddress, 1); // ...and read its byte
i2cBusTwo.requestFrom(expanderI2cAddress, 1u); // ...and read its byte
if (i2cBusTwo.available()) {
Port_ExpanderPorts[i] = i2cBusTwo.read();
Port_ExpanderPortsInputChannelStatus[i] = i2cBusTwo.read();
} else {
return false;
}
}
return false;
}
// Tests if port-expander can be detected
void Port_Test(void) {
i2cBusTwo.beginTransmission(expanderI2cAddress);
i2cBusTwo.write(0x02);
if (!i2cBusTwo.endTransmission()) {
Log_Println(portExpanderFound, LOGLEVEL_NOTICE);
} else {
Log_Println(portExpanderNotFound, LOGLEVEL_ERROR);
}
}
#endif

5
src/Port.h

@ -2,4 +2,7 @@
void Port_Init(void);
void Port_Cyclic(void);
bool Port_Read(const uint8_t _channel);
bool Port_Read(const uint8_t _channel);
void Port_Write(const uint8_t _channel, const bool _newState, const bool _initGpio);
void Port_Write(const uint8_t _channel, const bool _newState);
bool Port_Detect_Mode_HP(bool _state);

2
src/logmessages.h

@ -181,3 +181,5 @@ extern const char rememberLastVolume[];
extern const char unableToStartFtpServer[];
extern const char newPlayModeStereo[];
extern const char newPlayModeMono[];
extern const char portExpanderFound[];
extern const char portExpanderNotFound[];

10
src/main.cpp

@ -136,7 +136,8 @@ void setup()
// Init 2nd i2c-bus if RC522 is used with i2c or if port-expander is enabled
#if defined(RFID_READER_TYPE_MFRC522_I2C) || defined(PORT_EXPANDER_ENABLE)
i2cBusTwo.begin(ext_IIC_DATA, ext_IIC_CLK, 40000);
i2cBusTwo.begin(ext_IIC_DATA, ext_IIC_CLK);
//i2cBusTwo.begin(ext_IIC_DATA, ext_IIC_CLK, 40000);
delay(50);
Log_Println((char *) FPSTR(rfidScannerReady), LOGLEVEL_DEBUG);
#endif
@ -149,7 +150,7 @@ void setup()
Serial.println(F(" | |___ ___) | | __/ | |_| | | | | | | | | (_) |"));
Serial.println(F(" |_____| |____/ |_| \\__,_| |_| |_| |_| \\___/ "));
Serial.println(F(" Rfid-controlled musicplayer\n"));
Serial.println(F(" Rev 20210502-1\n"));
Serial.println(F(" Rev 20210608-1\n"));
// print wake-up reason
printWakeUpReason();
@ -168,6 +169,9 @@ void setup()
}
Queues_Init();
#if defined(GPIO_PA_EN) || defined(GPIO_HP_EN)
Port_Init();
#endif
Ftp_Init();
AudioPlayer_Init();
Mqtt_Init();
@ -206,7 +210,7 @@ void loop() {
AudioPlayer_Cyclic();
Battery_Cyclic();
Port_Cyclic();
//Port_Cyclic(); // called by button (controlled via hw-timer)
Button_Cyclic();
System_Cyclic();
Rfid_PreferenceLookupHandler();

123
src/settings-complete.h

@ -0,0 +1,123 @@
#include "Arduino.h"
//######################### INFOS ####################################
/* This is a develboard-specific config-file for ESPuino complete with port-expander PCA9555.
PCB: tba
Infos: tba
Caveats: None
Status: untested / unfinished
*/
//################## GPIO-configuration ##############################
// Please note: GPIOs 34, 35, 36, 39 are input-only and don't have pullup-resistors.
// So if connecting a button to these, make sure to add a 10k-pullup-resistor for each button.
// Further infos: https://randomnerdtutorials.com/esp32-pinout-reference-gpios/
#ifdef SD_MMC_1BIT_MODE
// uSD-card-reader (via SD-MMC 1Bit)
//
// SD_MMC uses fixed pins
// MOSI 15
// SCK 14
// MISO 2
#else
// uSD-card-reader (via SPI)
#define SPISD_CS 15 // GPIO for chip select (SD)
#ifndef SINGLE_SPI_ENABLE
#define SPISD_MOSI 13 // GPIO for master out slave in (SD) => 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

4
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

8
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

7
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

7
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

5
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

7
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

Loading…
Cancel
Save