static_array.hpp 812 B

123456789101112131415161718192021222324252627282930
  1. // ArduinoJson - https://arduinojson.org
  2. // Copyright © 2014-2022, Benoit BLANCHON
  3. // MIT License
  4. #pragma once
  5. #include <ArduinoJson/Configuration.hpp>
  6. #if ARDUINOJSON_ENABLE_PROGMEM
  7. # include <ArduinoJson/Polyfills/pgmspace_generic.hpp>
  8. # ifndef ARDUINOJSON_DEFINE_PROGMEM_ARRAY
  9. # define ARDUINOJSON_DEFINE_PROGMEM_ARRAY(type, name, value) \
  10. static type const name[] PROGMEM = value;
  11. # endif
  12. # define ARDUINOJSON_DEFINE_STATIC_ARRAY ARDUINOJSON_DEFINE_PROGMEM_ARRAY
  13. # define ARDUINOJSON_READ_STATIC_ARRAY(type, name, index) \
  14. pgm_read<type>(name + index)
  15. #else // i.e. ARDUINOJSON_ENABLE_PROGMEM == 0
  16. # define ARDUINOJSON_DEFINE_STATIC_ARRAY(type, name, value) \
  17. static type const name[] = value;
  18. # define ARDUINOJSON_READ_STATIC_ARRAY(type, name, index) name[index]
  19. #endif