PlatformIO package of the Teensy core framework compatible with GCC 10 & C++20
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

82 rindas
2.3KB

  1. #ifndef __INC_FL_PROGMEM_H
  2. #define __INC_FL_PROGMEM_H
  3. #include "FastLED.h"
  4. ///@file fastled_progmem.h
  5. /// wrapper definitions to allow seamless use of PROGMEM in environmens that have it
  6. FASTLED_NAMESPACE_BEGIN
  7. // Compatibility layer for devices that do or don't
  8. // have "PROGMEM" and the associated pgm_ accessors.
  9. //
  10. // If a platform supports PROGMEM, it should define
  11. // "FASTLED_USE_PROGMEM" as 1, otherwise FastLED will
  12. // fall back to NOT using PROGMEM.
  13. //
  14. // Whether or not pgmspace.h is #included is separately
  15. // controllable by FASTLED_INCLUDE_PGMSPACE, if needed.
  16. // If FASTLED_USE_PROGMEM is 1, we'll map FL_PROGMEM
  17. // and the FL_PGM_* accessors to the Arduino equivalents.
  18. #if FASTLED_USE_PROGMEM == 1
  19. #ifndef FASTLED_INCLUDE_PGMSPACE
  20. #define FASTLED_INCLUDE_PGMSPACE 1
  21. #endif
  22. #if FASTLED_INCLUDE_PGMSPACE == 1
  23. #include <avr/pgmspace.h>
  24. #endif
  25. #define FL_PROGMEM PROGMEM
  26. // Note: only the 'near' memory wrappers are provided.
  27. // If you're using 'far' memory, you already have
  28. // portability issues to work through, but you could
  29. // add more support here if needed.
  30. #define FL_PGM_READ_BYTE_NEAR(x) (pgm_read_byte_near(x))
  31. #define FL_PGM_READ_WORD_NEAR(x) (pgm_read_word_near(x))
  32. #define FL_PGM_READ_DWORD_NEAR(x) (pgm_read_dword_near(x))
  33. // Workaround for http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34734
  34. #if __GNUC__ < 4 || (__GNUC__ == 4 && (__GNUC_MINOR__ < 6))
  35. #ifdef FASTLED_AVR
  36. #ifdef PROGMEM
  37. #undef PROGMEM
  38. #define PROGMEM __attribute__((section(".progmem.data")))
  39. #endif
  40. #endif
  41. #endif
  42. #else
  43. // If FASTLED_USE_PROGMEM is 0 or undefined,
  44. // we'll use regular memory (RAM) access.
  45. //empty PROGMEM simulation
  46. #define FL_PROGMEM
  47. #define FL_PGM_READ_BYTE_NEAR(x) (*((const uint8_t*)(x)))
  48. #define FL_PGM_READ_WORD_NEAR(x) (*((const uint16_t*)(x)))
  49. #define FL_PGM_READ_DWORD_NEAR(x) (*((const uint32_t*)(x)))
  50. #endif
  51. // On some platforms, most notably ARM M0, unaligned access
  52. // to 'PROGMEM' for multibyte values (eg read dword) is
  53. // not allowed and causes a crash. This macro can help
  54. // force 4-byte alignment as needed. The FastLED gradient
  55. // palette code uses 'read dword', and now uses this macro
  56. // to make sure that gradient palettes are 4-byte aligned.
  57. #if defined(FASTLED_ARM) || defined(ESP32) || defined(ESP8266)
  58. #define FL_ALIGN_PROGMEM __attribute__ ((aligned (4)))
  59. #else
  60. #define FL_ALIGN_PROGMEM
  61. #endif
  62. FASTLED_NAMESPACE_END
  63. #endif