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 |
M5StackNode.ino (1267B)
1 2 // M5Stack Node support 3 // thanks to Cellie - issue #35 25.Apr.2020 4 // M5Stack board with Node base also need a MCLK signal on GPIO0. 5 6 #include <wm8978.h> /* https://github.com/CelliesProjects/wm8978-esp32 */ 7 #include <Audio.h> /* https://github.com/schreibfaul1/ESP32-audioI2S */ 8 9 /* M5Stack Node WM8978 I2C pins */ 10 #define I2C_SDA 21 11 #define I2C_SCL 22 12 13 /* M5Stack Node I2S pins */ 14 #define I2S_BCK 5 15 #define I2S_WS 13 16 #define I2S_DOUT 2 17 #define I2S_DIN 34 18 19 /* M5Stack WM8978 MCLK gpio number */ 20 #define I2S_MCLKPIN 0 21 22 WM8978 dac; 23 Audio audio; 24 25 void setup() { 26 /* Setup wm8978 I2C interface */ 27 if (!dac.begin(I2C_SDA, I2C_SCL)) { 28 ESP_LOGE(TAG, "Error setting up dac. System halted"); 29 while (1) delay(100); 30 } 31 32 /* Setup wm8978 I2S interface */ 33 audio.setPinout(I2S_BCK, I2S_WS, I2S_DOUT, I2S_DIN); 34 35 /* Setup wm8978 MCLK - for example M5Stack Node needs MCLK on GPIO 0 */ 36 audio.i2s_mclk_pin_select(I2S_MCLKPIN); 37 38 WiFi.begin("xxx", "xxx"); 39 while (!WiFi.isConnected()) { 40 delay(10); 41 } 42 ESP_LOGI(TAG, "Connected"); 43 44 ESP_LOGI(TAG, "Starting MP3...\n"); 45 audio.connecttohost("http://icecast.omroep.nl/3fm-bb-mp3"); 46 47 dac.setSPKvol(40); /* max 63 */ 48 dac.setHPvol(32, 32); 49 } 50 51 void loop() { 52 audio.loop(); 53 }