Skip to content

Commit

Permalink
add Raspberry Pi Pico W support
Browse files Browse the repository at this point in the history
  • Loading branch information
moononournation committed Jul 27, 2022
1 parent 656cdfd commit 41c0c74
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions examples/WiFiPhotoFrame/WiFiPhotoFrame.ino
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
*
* Dependent libraries:
* JPEGDEC: https://github.com/bitbank2/JPEGDEC.git
*
* Raspberry Pi Pico W dependent libraries:
* HttpClient: https://github.com/moononournation/HttpClient.git
*
* Setup steps:
* 1. Fill your own SSID_NAME, SSID_PASSWORD, HTTP_HOST, HTTP_PORT and HTTP_PATH_TEMPLATE
Expand Down Expand Up @@ -73,6 +76,12 @@ HTTPClient http;
#include <ESP8266HTTPClient.h>
WiFiClient client;
HTTPClient http;
#elif defined(ARDUINO_RASPBERRY_PI_PICO_W)
#include <WiFi.h>
#include <WiFiClient.h>
#include <HttpClient.h>
WiFiClient client;
HttpClient http(client);
#elif defined(RTL8722DM)
#include <WiFi.h>
#include <WiFiClient.h>
Expand Down Expand Up @@ -116,6 +125,9 @@ void setup()
#if defined(ESP32) || defined(ESP8266)
WiFi.mode(WIFI_STA);
WiFi.begin(SSID_NAME, SSID_PASSWORD);
#elif defined(ARDUINO_RASPBERRY_PI_PICO_W)
WiFi.mode(WIFI_STA);
WiFi.begin(SSID_NAME, SSID_PASSWORD);
#elif defined(RTL8722DM)
WiFi.begin((char *)SSID_NAME, (char *)SSID_PASSWORD);
#endif
Expand Down Expand Up @@ -162,7 +174,7 @@ void loop()
#if defined(ESP32) || defined(ESP8266)
http.begin(client, HTTP_HOST, HTTP_PORT, http_path);
int httpCode = http.GET();
#elif defined(RTL8722DM)
#elif defined(ARDUINO_RASPBERRY_PI_PICO_W) || defined(RTL8722DM)
http.get(HTTP_HOST, HTTP_PORT, http_path);
int httpCode = http.responseStatusCode();
http.skipResponseHeaders();
Expand All @@ -173,7 +185,9 @@ void loop()
// HTTP header has been send and Server response header has been handled
if (httpCode <= 0)
{
#if defined(ESP32) || defined(ESP8266)
Serial.printf("[HTTP] GET... failed, error: %s\n", http.errorToString(httpCode).c_str());
#endif
}
else
{
Expand All @@ -188,7 +202,7 @@ void loop()
// get lenght of document(is - 1 when Server sends no Content - Length header)
#if defined(ESP32) || defined(ESP8266)
int len = http.getSize();
#elif defined(RTL8722DM)
#elif defined(ARDUINO_RASPBERRY_PI_PICO_W) || defined(RTL8722DM)
int len = http.contentLength();
#endif
Serial.printf("[HTTP] size: %d\n", len);
Expand All @@ -209,7 +223,7 @@ void loop()
#if defined(ESP32) || defined(ESP8266)
static WiFiClient *http_stream = http.getStreamPtr();
jpeg_result = jpegOpenHttpStreamWithBuffer(http_stream, buf, len, jpegDrawCallback);
#else
#elif defined(ARDUINO_RASPBERRY_PI_PICO_W) || defined(RTL8722DM)
jpeg_result = jpegOpenHttpStreamWithBuffer(&client, buf, len, jpegDrawCallback);
#endif
if (jpeg_result)
Expand All @@ -225,7 +239,7 @@ void loop()
#if defined(ESP32) || defined(ESP8266)
static WiFiClient *http_stream = http.getStreamPtr();
jpeg_result = jpegOpenHttpStream(http_stream, len, jpegDrawCallback);
#else
#elif defined(ARDUINO_RASPBERRY_PI_PICO_W) || defined(RTL8722DM)
jpeg_result = jpegOpenHttpStream(&client, len, jpegDrawCallback);
#endif
if (jpeg_result)
Expand All @@ -240,7 +254,7 @@ void loop()
}
#if defined(ESP32) || defined(ESP8266)
http.end();
#elif defined(RTL8722DM)
#elif defined(ARDUINO_RASPBERRY_PI_PICO_W) || defined(RTL8722DM)
http.stop();
#endif

Expand All @@ -256,5 +270,7 @@ void loop()
feedLoopWDT();
#elif defined(ESP8266)
yield();
#elif defined(ARDUINO_RASPBERRY_PI_PICO_W)
yield();
#endif
}

0 comments on commit 41c0c74

Please sign in to comment.