
【主 题】:添加库文件 【描 述】: [原因]: [过程]: [影响]: 【结 束】 # 类型 包含: # feat:新功能(feature) # fix:修补bug # docs:文档(documentation) # style: 格式(不影响代码运行的变动) # refactor:重构(即不是新增功能,也不是修改bug的代码变动) # test:增加测试 # chore:构建过程或辅助工具的变动
30 lines
909 B
C++
30 lines
909 B
C++
// ArduinoJson - https://arduinojson.org
|
|
// Copyright © 2014-2022, Benoit BLANCHON
|
|
// MIT License
|
|
|
|
#include <stdint.h> // uint8_t
|
|
|
|
#define PROGMEM
|
|
|
|
class __FlashStringHelper;
|
|
|
|
inline const void* convertPtrToFlash(const void* s) {
|
|
return reinterpret_cast<const char*>(s) + 42;
|
|
}
|
|
|
|
inline const void* convertFlashToPtr(const void* s) {
|
|
return reinterpret_cast<const char*>(s) - 42;
|
|
}
|
|
|
|
#define PSTR(X) reinterpret_cast<const char*>(convertPtrToFlash(X))
|
|
#define F(X) reinterpret_cast<const __FlashStringHelper*>(PSTR(X))
|
|
|
|
inline uint8_t pgm_read_byte(const void* p) {
|
|
return *reinterpret_cast<const uint8_t*>(convertFlashToPtr(p));
|
|
}
|
|
|
|
#define ARDUINOJSON_DEFINE_PROGMEM_ARRAY(type, name, value) \
|
|
static type const ARDUINOJSON_CONCAT2(name, _progmem)[] = value; \
|
|
static type const* name = reinterpret_cast<type const*>( \
|
|
convertPtrToFlash(ARDUINOJSON_CONCAT2(name, _progmem)));
|