acid-drop- Hacking the planet from a LilyGo T-Deck using custom firmware |
git clone git://git.acid.vegas/acid-drop.git |
Log | Files | Refs | Archive | README | LICENSE |
I2Saudio.ino (3526B)
1 //********************************************************************************************************** 2 //* audioI2S-- I2S audiodecoder for ESP32, * 3 //********************************************************************************************************** 4 // 5 // first release on 11/2018 6 // Version 3 , Jul.02/2020 7 // 8 // 9 // THE SOFTWARE IS PROVIDED "AS IS" FOR PRIVATE USE ONLY, IT IS NOT FOR COMMERCIAL USE IN WHOLE OR PART OR CONCEPT. 10 // FOR PERSONAL USE IT IS SUPPLIED WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 11 // WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHOR 12 // OR COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 13 // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE 14 // 15 16 #include "Arduino.h" 17 #include "WiFiMulti.h" 18 #include "Audio.h" 19 #include "SPI.h" 20 #include "SD.h" 21 #include "FS.h" 22 23 // Digital I/O used 24 #define SD_CS 5 25 #define SPI_MOSI 23 26 #define SPI_MISO 19 27 #define SPI_SCK 18 28 #define I2S_DOUT 25 29 #define I2S_BCLK 27 30 #define I2S_LRC 26 31 32 Audio audio; 33 WiFiMulti wifiMulti; 34 String ssid = "xxxxx"; 35 String password = "xxxxx"; 36 37 38 void setup() { 39 pinMode(SD_CS, OUTPUT); digitalWrite(SD_CS, HIGH); 40 SPI.begin(SPI_SCK, SPI_MISO, SPI_MOSI); 41 SPI.setFrequency(1000000); 42 Serial.begin(115200); 43 SD.begin(SD_CS); 44 WiFi.mode(WIFI_STA); 45 wifiMulti.addAP(ssid.c_str(), password.c_str()); 46 wifiMulti.run(); 47 if(WiFi.status() != WL_CONNECTED){ 48 WiFi.disconnect(true); 49 wifiMulti.run(); 50 } 51 audio.setPinout(I2S_BCLK, I2S_LRC, I2S_DOUT); 52 audio.setVolume(12); // 0...21 53 54 // audio.connecttoFS(SD, "/320k_test.mp3"); 55 // audio.connecttoFS(SD, "test.wav"); 56 // audio.connecttohost("http://www.wdr.de/wdrlive/media/einslive.m3u"); 57 // audio.connecttohost("http://macslons-irish-pub-radio.com/media.asx"); 58 // audio.connecttohost("http://mp3.ffh.de/radioffh/hqlivestream.aac"); // 128k aac 59 audio.connecttohost("http://mp3.ffh.de/radioffh/hqlivestream.mp3"); // 128k mp3 60 } 61 62 void loop() 63 { 64 audio.loop(); 65 if(Serial.available()){ // put streamURL in serial monitor 66 audio.stopSong(); 67 String r=Serial.readString(); r.trim(); 68 if(r.length()>5) audio.connecttohost(r.c_str()); 69 log_i("free heap=%i", ESP.getFreeHeap()); 70 } 71 } 72 73 // optional 74 void audio_info(const char *info){ 75 Serial.print("info "); Serial.println(info); 76 } 77 void audio_id3data(const char *info){ //id3 metadata 78 Serial.print("id3data ");Serial.println(info); 79 } 80 void audio_eof_mp3(const char *info){ //end of file 81 Serial.print("eof_mp3 ");Serial.println(info); 82 } 83 void audio_showstation(const char *info){ 84 Serial.print("station ");Serial.println(info); 85 } 86 void audio_showstreamtitle(const char *info){ 87 Serial.print("streamtitle ");Serial.println(info); 88 } 89 void audio_bitrate(const char *info){ 90 Serial.print("bitrate ");Serial.println(info); 91 } 92 void audio_commercial(const char *info){ //duration in sec 93 Serial.print("commercial ");Serial.println(info); 94 } 95 void audio_icyurl(const char *info){ //homepage 96 Serial.print("icyurl ");Serial.println(info); 97 } 98 void audio_lasthost(const char *info){ //stream URL played 99 Serial.print("lasthost ");Serial.println(info); 100 }