Skip to content

Commit

Permalink
ESP8266 Core 3.0.0 compatibility
Browse files Browse the repository at this point in the history
Fixed for ESP8266 core 3.0.0 and backward compatible
  • Loading branch information
4D Systems committed Jun 3, 2021
1 parent 2ec778a commit 9b773f2
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 27 deletions.
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=GFX4d
version=1.0.3
version=1.0.4
author=4D Systems Pty Ltd
maintainer=4D Systems Pty Ltd <[email protected]>
sentence=Graphics Library for the gen4-IoD by 4D Systems
Expand Down
99 changes: 76 additions & 23 deletions src/GFX4d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* *
4D Systems GFX4d Library
* *
Date: 4th May 2021
Date: 4th June 2021
* *
Description: Provides Graphics, Touch Control and SD Card functions
for 4D Systems Gen4 IoD range of intelligent displays.
Expand Down Expand Up @@ -181,14 +181,21 @@
#include "wiring_private.h"
#include <SPI.h>
#ifndef ESP32

#include <ESP8266WiFi.h>

#include <ESP8266HTTPClient.h>
#include <WiFiClient.h>
#else
#include <WiFi.h>
#include <HTTPClient.h>
#include <WiFiClientSecure.h>
#if ARDUINO_ESP8266_GIT_VER > 0x2843a5ac
#include <WiFiClientSecureBearSSL.h>
#endif
#endif


#define hwSPI true

#define swap(a, b) { int16_t tab = a; a = b; b = tab; }
Expand Down Expand Up @@ -247,7 +254,7 @@ GFX4d::GFX4d()

SPISettings spiSettings = SPISettings(79000000, MSBFIRST, SPI_MODE0);
SPISettings spiSettingsD = SPISettings(79000000, MSBFIRST, SPI_MODE0);
SPISettings spiSettingsR = SPISettings(39000000, MSBFIRST, SPI_MODE0);
SPISettings spiSettingsR = SPISettings(49000000, MSBFIRST, SPI_MODE0);
SPISettings spiSettingsT = SPISettings(6900000, MSBFIRST, SPI_MODE0);
SPISettings spiSettingsT32 = SPISettings(4900000, MSBFIRST, SPI_MODE0);

Expand Down Expand Up @@ -343,24 +350,18 @@ void GFX4d::begin(void)
if (IPSDisplay) Invert(false);
Cls(0);
#ifndef USE_FS
//#ifndef ESP32
//#ifdef SDFS_H
if (SD.begin(_sd, spiSettings))
{
//#else
//if(SD.begin(_sd, 79000000)){
//#endif
//#else
//if(SD.begin(_sd, SPI, 79000000)){
//#endif
#if ARDUINO_ESP8266_GIT_VER > 0x2843a5ac
if (SD.begin(5, SD_SCK_MHZ(79)))
//if(SD.begin(SD_CONFIG))
#else
if (SD.begin(_sd, spiSettings))
#endif
{
#else
if (LittleFS.begin())
{
//if(SPIFFS.begin()){
#endif
sdok = true;
//print("FS Ok");
//delay(1000);
}
else
{
Expand Down Expand Up @@ -1325,29 +1326,60 @@ void GFX4d::ImageWifi(boolean local, String Address, uint16_t port, String hfile
newLine(lastfsh, textsizeht, 0);
}
HTTPClient http;
#if ARDUINO_ESP8266_GIT_VER > 0x2843a5ac
WiFiClient client;
#endif
if (local)
{
if (sha1 == "")
{
if (!http.begin(Address, port, hfile)) return;
}
#if ARDUINO_ESP8266_GIT_VER > 0x2843a5ac
if (!http.begin(client, Address, port, hfile)) return;
#else
if (!http.begin(Address, port, hfile)) return;
#endif
}
else
{
#ifndef ESP32
if (!http.begin(Address, port, hfile, sha1)) return;
#if ARDUINO_ESP8266_GIT_VER > 0x2843a5ac
std::unique_ptr<BearSSL::WiFiClientSecure>client(new BearSSL::WiFiClientSecure);
if(sha1 == "INSECURE"){
client->setInsecure();
} else {
client->setFingerprint((char*)sha1.c_str());
}
if (!http.begin(*client, Address, port, hfile)) return;
#else
if (!http.begin(Address, port, hfile, sha1)) return;
#endif
#endif
}
}
else
{
if (sha1 == "")
{
if (!http.begin(Address)) return;
#if ARDUINO_ESP8266_GIT_VER > 0x2843a5ac
if (!http.begin(client, Address)) return;
#else
if (!http.begin(Address)) return;
#endif
}
else
{
#ifndef ESP32
if (!http.begin(Address, sha1)) return;
#if ARDUINO_ESP8266_GIT_VER > 0x2843a5ac
std::unique_ptr<BearSSL::WiFiClientSecure>client(new BearSSL::WiFiClientSecure);
if(sha1 == "INSECURE"){
client->setInsecure();
} else {
client->setFingerprint((char*)sha1.c_str());
}
if (!http.begin(* client, Address)) return;
#else
if(!http.begin(Address, sha1)) return;
#endif
#endif
}
}
Expand Down Expand Up @@ -4338,20 +4370,41 @@ void GFX4d::Download(String Address, uint16_t port, String hfile, String Fname,
fs::File Dwnload;
#endif
HTTPClient http;
#if ARDUINO_ESP8266_GIT_VER > 0x2843a5ac
WiFiClient client;
#endif
if (port > 0)
{
http.begin(Address, port, hfile);
#if ARDUINO_ESP8266_GIT_VER > 0x2843a5ac
http.begin(client, Address, port, hfile);
#else
http.begin(Address, port, hfile);
#endif
}
else
{
if (sha1 == "")
{
http.begin(Address);
#if ARDUINO_ESP8266_GIT_VER > 0x2843a5ac
http.begin(client, Address);
#else
http.begin(Address);
#endif
}
else
{
#ifndef ESP32
http.begin(Address, sha1);
#if ARDUINO_ESP8266_GIT_VER > 0x2843a5ac
std::unique_ptr<BearSSL::WiFiClientSecure>client(new BearSSL::WiFiClientSecure);
if(sha1 == "INSECURE"){
client->setInsecure();
} else {
client->setFingerprint((char*)sha1.c_str());
}
if (!http.begin(* client, Address)) return;
#else
if(!http.begin(Address, sha1)) return;
#endif
#endif
}
}
Expand Down
13 changes: 10 additions & 3 deletions src/GFX4d.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* *
4D Systems GFX4d Library
* *
Date: 4th May 2021
Date: 4th June 2021
* *
Description: Provides Graphics, Touch Control and SD Card functions
for 4D Systems Gen4 IoD range of intelligent displays.
Expand Down Expand Up @@ -183,13 +183,20 @@
#include "Arduino.h"
#include "Print.h"
#ifndef USE_FS
//#include <SDFS.h>
#include <SD.h>
//#if ARDUINO_ESP8266_GIT_VER > 0x2843a5ac
// #include "SdFat.h"
// #include "sdios.h"
//#else
#include <SD.h>
//#endif
#else
//#define FS_NO_GLOBALS //allow spiffs to coexist with SD card, define BEFORE including FS.h
#include <LittleFS.h> //spiff file system
#endif


#define SD_CONFIG SdSpiConfig(5, SHARED_SPI, SPI_CLOCK)

#define MAX_WIDGETS 400

#ifdef USING_WS4_GCIOBJECTS
Expand Down

0 comments on commit 9b773f2

Please sign in to comment.