Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix "__FlashStringHelper is ambiguous" with arduino-pico
- Loading branch information
Showing
17 changed files
with
241 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// StreamUtils - github.com/bblanchon/ArduinoStreamUtils | ||
// Copyright Benoit Blanchon 2019-2023 | ||
// MIT License | ||
|
||
#pragma once | ||
|
||
#include "Common.h" | ||
#include "Print.h" | ||
#include "Stream.h" | ||
#include "WString.h" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// StreamUtils - github.com/bblanchon/ArduinoStreamUtils | ||
// Copyright Benoit Blanchon 2019-2023 | ||
// MIT License | ||
|
||
#pragma once | ||
|
||
#include "Stream.h" | ||
#include "WString.h" | ||
|
||
namespace arduino { | ||
|
||
using IPAddress = String; | ||
|
||
class Client : public Stream { | ||
public: | ||
virtual int connect(IPAddress ip, uint16_t port) = 0; | ||
virtual int connect(const char *host, uint16_t port) = 0; | ||
virtual uint8_t connected() = 0; | ||
virtual void stop() = 0; | ||
virtual operator bool() = 0; | ||
|
||
virtual int read() = 0; | ||
virtual int read(uint8_t *buf, size_t size) = 0; | ||
}; | ||
|
||
} // namespace arduino |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// StreamUtils - github.com/bblanchon/ArduinoStreamUtils | ||
// Copyright Benoit Blanchon 2019-2023 | ||
// MIT License | ||
|
||
#pragma once | ||
|
||
#include <time.h> | ||
|
||
inline unsigned long millis() { | ||
return static_cast<unsigned long>(time(NULL)); | ||
} | ||
|
||
inline void yield() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// StreamUtils - github.com/bblanchon/ArduinoStreamUtils | ||
// Copyright Benoit Blanchon 2019-2023 | ||
// MIT License | ||
|
||
#pragma once | ||
|
||
#include "WString.h" | ||
|
||
#include <stdint.h> | ||
#include <cstring> | ||
|
||
namespace arduino { | ||
|
||
struct Print { | ||
virtual size_t write(const uint8_t *buffer, size_t size) = 0; | ||
virtual size_t write(uint8_t data) = 0; | ||
virtual void flush() {} | ||
|
||
virtual int availableForWrite() { | ||
return 0; | ||
} | ||
|
||
size_t write(const char *buffer, size_t size) { | ||
return write((const uint8_t *)buffer, size); | ||
} | ||
|
||
size_t print(const String &s) { | ||
return write(s.c_str(), s.length()); | ||
} | ||
|
||
size_t print(const char *s) { | ||
return write(s, std::strlen(s)); | ||
} | ||
|
||
size_t println() { | ||
return 0; | ||
} | ||
|
||
template <typename T> | ||
size_t print(const T &value) { | ||
return print(String(value)); | ||
} | ||
|
||
template <typename T> | ||
size_t println(const T &value) { | ||
return print(value); | ||
} | ||
}; | ||
|
||
} // namespace arduino | ||
|
||
using namespace arduino; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// StreamUtils - github.com/bblanchon/ArduinoStreamUtils | ||
// Copyright Benoit Blanchon 2019-2023 | ||
// MIT License | ||
|
||
#pragma once | ||
|
||
#include "Print.h" | ||
|
||
namespace arduino { | ||
|
||
struct Stream : Print { | ||
virtual int available() = 0; | ||
virtual int read() = 0; | ||
virtual int peek() = 0; | ||
|
||
size_t readBytes(char *buffer, size_t length) { | ||
size_t count = 0; | ||
while (count < length) { | ||
int c = read(); | ||
if (c < 0) | ||
break; | ||
*buffer++ = (char)c; | ||
count++; | ||
} | ||
return count; | ||
} | ||
|
||
String readString() { | ||
String result; | ||
int c; | ||
while ((c = read()) >= 0) { | ||
result += static_cast<char>(c); | ||
} | ||
return result; | ||
} | ||
|
||
void setTimeout(unsigned long) {} | ||
}; | ||
|
||
} // namespace arduino |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// StreamUtils - github.com/bblanchon/ArduinoStreamUtils | ||
// Copyright Benoit Blanchon 2019-2023 | ||
// MIT License | ||
|
||
#pragma once | ||
|
||
#include <ostream> | ||
#include <string> | ||
|
||
#include "../avr/avr/pgmspace.h" | ||
|
||
namespace arduino { | ||
|
||
class __FlashStringHelper; | ||
#define F(s) (reinterpret_cast<const __FlashStringHelper*>(s + 42)) | ||
|
||
class String : private std::string { | ||
public: | ||
String() {} | ||
String(const String& s) : std::string(s) {} | ||
String(String&& s) : std::string(std::move(s)) {} | ||
String(const char* s) : std::string(s) {} | ||
String(int n) : std::string(std::to_string(n)) {} | ||
String(size_t n) : std::string(std::to_string(n)) {} | ||
|
||
String& operator=(const String& rhs) { | ||
std::string::operator=(rhs); | ||
return *this; | ||
} | ||
|
||
using std::string::c_str; | ||
using std::string::length; | ||
using std::string::operator+=; | ||
using std::string::operator[]; | ||
|
||
void remove(unsigned int index, unsigned int count) { | ||
erase(begin() + index, begin() + index + count); | ||
} | ||
|
||
friend bool operator==(const String& lhs, const char* rhs) { | ||
return static_cast<const std::string&>(lhs) == rhs; | ||
} | ||
|
||
friend std::ostream& operator<<(std::ostream& lhs, const String& rhs) { | ||
return lhs << static_cast<const std::string&>(rhs); | ||
} | ||
}; | ||
|
||
} // namespace arduino |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# StreamUtils - github.com/bblanchon/ArduinoStreamUtils | ||
# Copyright Benoit Blanchon 2019-2023 | ||
# MIT License | ||
|
||
add_library(Rp2040Core | ||
EEPROM.cpp | ||
EEPROM.h | ||
) | ||
|
||
target_include_directories(Rp2040Core | ||
PUBLIC | ||
${CMAKE_CURRENT_SOURCE_DIR} | ||
${CMAKE_CURRENT_SOURCE_DIR}/../coreapi | ||
) | ||
|
||
target_compile_definitions(Rp2040Core | ||
PUBLIC | ||
ARDUINO_ARCH_RP2040 | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
#include "../esp32/EEPROM.cpp" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
#include "../esp32/EEPROM.h" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters