mirror of
https://github.com/esphome/esphome.git
synced 2024-11-10 09:17:46 +01:00
Buffer allocation and TRUEFALSE templates (#1644)
This commit is contained in:
parent
c903eb2d01
commit
566c129435
2 changed files with 16 additions and 0 deletions
|
@ -319,3 +319,18 @@ template<typename T> class Parented {
|
||||||
uint32_t fnv1_hash(const std::string &str);
|
uint32_t fnv1_hash(const std::string &str);
|
||||||
|
|
||||||
} // namespace esphome
|
} // namespace esphome
|
||||||
|
|
||||||
|
template<typename T> T *new_buffer(size_t length) {
|
||||||
|
T *buffer;
|
||||||
|
#ifdef ARDUINO_ARCH_ESP32
|
||||||
|
if (psramFound()) {
|
||||||
|
buffer = (T *) ps_malloc(length);
|
||||||
|
} else {
|
||||||
|
buffer = new T[length];
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
buffer = new T[length];
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return buffer;
|
||||||
|
} // namespace esphome
|
||||||
|
|
|
@ -160,5 +160,6 @@ int esp_idf_log_vprintf_(const char *format, va_list args); // NOLINT
|
||||||
((byte) &0x08 ? '1' : '0'), ((byte) &0x04 ? '1' : '0'), ((byte) &0x02 ? '1' : '0'), ((byte) &0x01 ? '1' : '0')
|
((byte) &0x08 ? '1' : '0'), ((byte) &0x04 ? '1' : '0'), ((byte) &0x02 ? '1' : '0'), ((byte) &0x01 ? '1' : '0')
|
||||||
#define YESNO(b) ((b) ? "YES" : "NO")
|
#define YESNO(b) ((b) ? "YES" : "NO")
|
||||||
#define ONOFF(b) ((b) ? "ON" : "OFF")
|
#define ONOFF(b) ((b) ? "ON" : "OFF")
|
||||||
|
#define TRUEFALSE(b) ((b) ? "TRUE" : "FALSE")
|
||||||
|
|
||||||
} // namespace esphome
|
} // namespace esphome
|
||||||
|
|
Loading…
Reference in a new issue