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 |
M5StickCPlus.ino (3168B)
1 //********************************************************************************************************** 2 //* audioI2S-- I2S audiodecoder for M5StickC Plus and SPK HAT * 3 //********************************************************************************************************** 4 // 5 // first release on May.12/2021 6 // 7 // 8 // THE SOFTWARE IS PROVIDED "AS IS" FOR PRIVATE USE ONLY, IT IS NOT FOR COMMERCIAL USE IN WHOLE OR PART OR CONCEPT. 9 // FOR PERSONAL USE IT IS SUPPLIED WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 10 // WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHOR 11 // OR COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 12 // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE 13 // 14 15 #include <M5StickCPlus.h> 16 #include "Audio.h" 17 18 Audio audio = Audio(true); 19 20 String ssid = "xxxxxxxx"; 21 String password = "xxxxxxxx"; 22 23 24 void setup() { 25 M5.begin(false); //Lcd disabled to reduce noise 26 M5.Axp.ScreenBreath(1); //Lower Lcd backlight 27 pinMode(36, INPUT); 28 gpio_pulldown_dis(GPIO_NUM_25); 29 gpio_pullup_dis(GPIO_NUM_25); 30 M5.Beep.tone(44100); //Built-in buzzer tone 31 M5.Beep.end(); //disabled 32 33 audio.setVolume(15); // 0...21 34 35 WiFi.mode(WIFI_STA); 36 WiFi.begin(ssid.c_str(), password.c_str()); 37 while (!WiFi.isConnected()) { 38 delay(10); 39 } 40 ESP_LOGI(TAG, "Connected"); 41 ESP_LOGI(TAG, "Starting MP3...\n"); 42 43 audio.connecttohost("http://air.ofr.fm:8008/jazz/mp3/128"); 44 // audio.connecttospeech("Миска вареників з картоплею та шкварками, змащених салом!", "uk-UA"); 45 } 46 47 void loop() { 48 audio.loop(); 49 if(Serial.available()){ // put streamURL in serial monitor 50 audio.stopSong(); 51 String r=Serial.readString(); 52 r.trim(); 53 if(r.length()>5) audio.connecttohost(r.c_str()); 54 log_i("free heap=%i", ESP.getFreeHeap()); 55 } 56 } 57 58 // optional 59 void audio_info(const char *info){ 60 Serial.print("info "); Serial.println(info); 61 } 62 void audio_id3data(const char *info){ //id3 metadata 63 Serial.print("id3data ");Serial.println(info); 64 } 65 void audio_eof_mp3(const char *info){ //end of file 66 Serial.print("eof_mp3 ");Serial.println(info); 67 } 68 void audio_showstation(const char *info){ 69 Serial.print("station ");Serial.println(info); 70 } 71 void audio_showstreamtitle(const char *info){ 72 Serial.print("streamtitle ");Serial.println(info); 73 } 74 void audio_bitrate(const char *info){ 75 Serial.print("bitrate ");Serial.println(info); 76 } 77 void audio_commercial(const char *info){ //duration in sec 78 Serial.print("commercial ");Serial.println(info); 79 } 80 void audio_icyurl(const char *info){ //homepage 81 Serial.print("icyurl ");Serial.println(info); 82 } 83 void audio_lasthost(const char *info){ //stream URL played 84 Serial.print("lasthost ");Serial.println(info); 85 } 86 void audio_eof_speech(const char *info){ 87 Serial.print("eof_speech ");Serial.println(info); 88 }