Skip to content

Commit 8dd6c52

Browse files
committed
Merge remote-tracking branch 'adafruit/master' into pyportal_alarm_clock
2 parents 96ca4e4 + 7a7cdd5 commit 8dd6c52

38 files changed

Lines changed: 208044 additions & 24 deletions

Adafruit_ESP32_Arduino_Demos/WiFiWebClient/WiFiWebClient.ino

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,17 @@
2424
#include <SPI.h>
2525
#include <WiFiNINA.h>
2626

27+
// if the wifi definition isnt in the board variant
28+
#if !defined(SPIWIFI_SS)
29+
// Don't change the names of these #define's! they match the variant ones
30+
#define SPIWIFI_SS 10
31+
#define SPIWIFI_ACK 7
32+
#define ESP32_RESETN 5
33+
#define ESP32_GPIO0 -1
34+
#define SPIWIFI SPI
35+
#endif
36+
37+
2738
#include "arduino_secrets.h"
2839
///////please enter your sensitive data in the Secret tab/arduino_secrets.h
2940
char ssid[] = SECRET_SSID; // your network SSID (name)
@@ -51,17 +62,18 @@ void setup() {
5162
}
5263

5364
// check for the WiFi module:
65+
WiFi.setPins(SPIWIFI_SS, SPIWIFI_ACK, ESP32_RESETN, ESP32_GPIO0, &SPIWIFI);
5466
while (WiFi.status() == WL_NO_MODULE) {
5567
Serial.println("Communication with WiFi module failed!");
5668
// don't continue
5769
delay(1000);
58-
5970
}
6071

6172
String fv = WiFi.firmwareVersion();
6273
if (fv < "1.0.0") {
6374
Serial.println("Please upgrade the firmware");
6475
}
76+
Serial.print("Found firmware "); Serial.println(fv);
6577

6678
// attempt to connect to Wifi network:
6779
Serial.print("Attempting to connect to SSID: ");

Adafruit_ESP32_Arduino_Demos/streaming_mp3_player/streaming_mp3_player.ino

Lines changed: 40 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,29 @@
1010
char ssid[] = SECRET_SSID; // your network SSID (name)
1111
char pass[] = SECRET_PASS; // your network password (use for WPA, or use as key for WEP)
1212

13+
//#define DEBUG
1314

14-
// http://ice1.somafm.com/u80s-128-mp3
15-
const char *host = "ice1.somafm.com";
16-
const char *path = "/u80s-128-mp3";
15+
// SOMA FM Radio 80's http://ice1.somafm.com/u80s-128-mp3
16+
//const char *host = "ice1.somafm.com";
17+
//const char *path = "/u80s-128-mp3";
1718
//const char *path = "/doomed-128-mp3";
18-
int httpPort = 80;
19+
//int httpPort = 80;
20+
21+
// WMBR radio http://wmbr.org:8000/med
22+
const char *host = "wmbr.org";
23+
const char *path = "/med";
24+
int httpPort = 8000;
1925

2026
// These are the pins used
2127
#define VS1053_RESET -1 // VS1053 reset pin (not used!)
2228
#define VS1053_CS 7 // VS1053 chip select pin (output)
2329
#define VS1053_DCS 6 // VS1053 Data/command select pin (output)
2430
#define VS1053_DREQ 3 // VS1053 Data request, ideally an Interrupt pin
31+
#define ESP_CS 10
32+
#define ESP_READY 9
33+
#define ESP_RESET 8
34+
#define ESP_GPIO0 -1
35+
2536

2637
Adafruit_VS1053 musicPlayer = Adafruit_VS1053(VS1053_RESET, VS1053_CS, VS1053_DCS, VS1053_DREQ);
2738

@@ -30,20 +41,25 @@ WiFiClient client;
3041

3142
int lastvol = 30;
3243

33-
#define BUFFER_SIZE 1500
44+
#if defined (__AVR__)
45+
#define BUFFER_SIZE 128
46+
#else
47+
#define BUFFER_SIZE 1500
48+
#endif
49+
3450
CircularBuffer<uint8_t, BUFFER_SIZE> buffer;
3551

3652
void setup() {
3753
Serial.begin(115200);
3854
while (!Serial);
3955
delay(100);
4056

41-
Serial.println("\n\nAdafruit VS1053 Feather WiFi Radio");
57+
Serial.println(F("\n\nAdafruit VS1053 Feather WiFi Radio"));
4258

4359
/************************* INITIALIZE MP3 Shield */
4460
if (! musicPlayer.begin()) { // initialise the music player
4561
Serial.println(F("Couldn't find VS1053, do you have the right pins defined?"));
46-
while (1) delay(10);
62+
//while (1) delay(10);
4763
}
4864

4965
Serial.println(F("VS1053 found"));
@@ -55,26 +71,27 @@ void setup() {
5571
// don't use an IRQ, we'll hand-feed
5672

5773
/************************* INITIALIZE WIFI */
58-
Serial.print("Connecting to SSID "); Serial.println(ssid);
74+
WiFi.setPins(ESP_CS, ESP_READY, ESP_RESET, ESP_GPIO0);
75+
Serial.print(F("Connecting to SSID ")); Serial.println(ssid);
5976
WiFi.begin(ssid, pass);
6077

6178
while (WiFi.status() != WL_CONNECTED) {
6279
delay(500);
6380
Serial.print(".");
6481
}
65-
Serial.println("WiFi connected");
66-
Serial.println("IP address: "); Serial.println(WiFi.localIP());
82+
Serial.println(F("WiFi connected"));
83+
Serial.println(F("IP address: ")); Serial.println(WiFi.localIP());
6784

6885
/************************* INITIALIZE STREAM */
69-
Serial.print("Connecting to "); Serial.println(host);
86+
Serial.print(F("Connecting to ")); Serial.println(host);
7087

7188
if (!client.connect(host, httpPort)) {
72-
Serial.println("Connection failed");
89+
Serial.println(F("Connection failed"));
7390
while (1);
7491
}
7592

7693
// We now create a URI for the request
77-
Serial.print("Requesting URL: "); Serial.println(path);
94+
Serial.print(F("Requesting URL: ")); Serial.println(path);
7895

7996
// This will send the request to the server
8097
client.print(String("GET ") + path + " HTTP/1.1\r\n" +
@@ -84,16 +101,19 @@ void setup() {
84101

85102

86103
void loop() {
87-
Serial.print("Client Avail: "); Serial.print(client.available());
88-
Serial.print("\tBuffer Avail: "); Serial.println(buffer.available());
104+
#if defined(DEBUG)
105+
Serial.print(F("Client Avail: ")); Serial.print(client.available());
106+
Serial.print(F("\tBuffer Avail: ")); Serial.println(buffer.available());
107+
#endif
89108

90109
// Prioritize reading data from the ESP32 into the buffer (it sometimes stalls)
91110
while (client.available() && buffer.available()) {
92111
uint8_t minibuff[BUFFER_SIZE];
93112

94113
int bytesread = client.read(minibuff, buffer.available());
95-
Serial.print("Client read: "); Serial.println(bytesread);
96-
114+
#if defined(DEBUG)
115+
Serial.print(F("Client read: ")); Serial.println(bytesread);
116+
#endif
97117
for (int i=0; i<bytesread; i++) {
98118
buffer.push(minibuff[i]); // push every byte we read
99119
}
@@ -105,7 +125,9 @@ void loop() {
105125
uint8_t mp3buff[32]; // vs1053 likes 32 bytes at a time
106126

107127
int byteswrite = min(32, buffer.size());
108-
Serial.print("MP3 write: "); Serial.println(byteswrite);
128+
#if defined(DEBUG)
129+
Serial.print(F("MP3 write: ")); Serial.println(byteswrite);
130+
#endif
109131

110132
// push to mp3
111133
for (int i=0; i<byteswrite; i++) {

0 commit comments

Comments
 (0)