Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Connections:
- Rotary Encoder:
- + -> 3.3v
- GND -> GND
- SW -> D32
- DT -> D34
- CLK -> D35
- OLD:
- SW -> D13
- DT -> D27
- CLK -> D14
- Amplifier/Speakers:
- LRC -> D25 (Both amps connected)
- BCLK -> D26 (Both amps connected)
- Din -> D22 (Both amps connected)
- Gain -> will use this later
- SD -> D33 (Left amp only! Connect from GPIO to right amp through resistors)
- GND -> GND
- VIN -> Din (5v)
- RGB LED:
- Red -> D14
- Green -> D13
- Blue -> D12
- SD Card:
- 3V3 -> 3.3v
- CS -> D5
- MOSI -> D23
- CLK -> D18
- MISO -> D19
- GND -> GND
- */
- #include "AudioTools.h"
- #include "AudioTools/AudioLibs/AudioSourceSD.h"
- #include "AudioTools/AudioCodecs/CodecMP3Helix.h"
- // Bluetooth Libraries==============================================================
- #include <ESP_I2S.h>
- #include <wav_header.h>
- #include "BluetoothA2DPSink.h"
- // Rotary Encoder Button Library (might not use this)===============================
- #include <BfButton.h>
- // RGB LEDs=========================================================================
- #define LED_red 14
- #define LED_green 13
- #define LED_blue 12
- // SD card Library and defines======================================================
- #include <SD.h>
- #define SD_sck 18
- #define SD_miso 19
- #define SD_mosi 23
- #define SD_cs 5
- I2SStream i2s;
- I2SStream i2s_NoOutput;
- auto SDConfig = i2s.defaultConfig(TX_MODE);
- auto BTConfig = i2s.defaultConfig(TX_MODE);
- AudioInfo BlueToothAudioInfo(44100, 2, 24);
- // =====SDCard Variables=====:
- const char *startFilePath="/";
- const char* ext="mp3";
- AudioSourceSD source(startFilePath, ext);
- MP3DecoderHelix decoder;
- AudioPlayer player(source, i2s, decoder);
- BluetoothA2DPSink a2dp_sink(i2s);
- // Other Libraries==================================================================
- #include <string>
- #include <cstdint>
- int RE_DT = 34;
- int RE_CLK = 35;
- int RE_Button = 32;
- int max_RE_Value = 98;
- int min_RE_Value = 0;
- BfButton btn(BfButton::STANDALONE_DIGITAL, RE_Button, true, LOW);
- int counter = 0;
- int aState;
- int aLastState;
- int reading = 0;
- uint32_t runTime = -99999;
- enum playbackMode
- {
- initBluetooth,
- bluetoothMode,
- deInitBluetooth,
- initSDCard,
- SDcardMode,
- deInitSDCard
- };
- playbackMode currentState = initBluetooth; // This determines what mode we start in and is a global to maintain state;
- // Function Prototypes =============================================================
- void handleBluetooth();
- void handleSDcard();
- void avrc_metadata_callback(uint8_t data1, const uint8_t *data2);
- void parseBluetoothData(uint8_t address, const uint8_t *data);
- void pressHandler (BfButton *btn, BfButton::press_pattern_t pattern);
- void printMetaData(MetaDataType type, const char* str, int len);
Advertisement
Add Comment
Please, Sign In to add comment