Minh Nguyen / ArduinoJson
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers static_array.hpp Source File

static_array.hpp

00001 // ArduinoJson - arduinojson.org
00002 // Copyright Benoit Blanchon 2014-2021
00003 // MIT License
00004 
00005 #pragma once
00006 
00007 #include <ArduinoJson/Configuration.hpp>
00008 
00009 #if ARDUINOJSON_ENABLE_PROGMEM
00010 
00011 #include <ArduinoJson/Polyfills/pgmspace_generic.hpp>
00012 
00013 #ifndef ARDUINOJSON_DEFINE_STATIC_ARRAY
00014 #define ARDUINOJSON_DEFINE_STATIC_ARRAY(type, name, value) \
00015   static type const name[] PROGMEM = value;
00016 #endif
00017 
00018 #ifndef ARDUINOJSON_READ_STATIC_ARRAY
00019 #define ARDUINOJSON_READ_STATIC_ARRAY(type, name, index) \
00020   pgm_read<type>(name + index)
00021 #endif
00022 
00023 #else  // i.e. ARDUINOJSON_ENABLE_PROGMEM == 0
00024 
00025 #ifndef ARDUINOJSON_DEFINE_STATIC_ARRAY
00026 #define ARDUINOJSON_DEFINE_STATIC_ARRAY(type, name, value) \
00027   static type const name[] = value;
00028 #endif
00029 
00030 #ifndef ARDUINOJSON_READ_STATIC_ARRAY
00031 #define ARDUINOJSON_READ_STATIC_ARRAY(type, name, index) name[index]
00032 #endif
00033 
00034 #endif