FastLED  3.1
fastled_progmem.h
Go to the documentation of this file.
1 #ifndef __INC_FL_PROGMEM_H
2 #define __INC_FL_PROGMEM_H
3 
4 #include "FastLED.h"
5 
8 
9 FASTLED_NAMESPACE_BEGIN
10 
11 // Compatibility layer for devices that do or don't
12 // have "PROGMEM" and the associated pgm_ accessors.
13 //
14 // If a platform supports PROGMEM, it should define
15 // "FASTLED_USE_PROGMEM" as 1, otherwise FastLED will
16 // fall back to NOT using PROGMEM.
17 //
18 // Whether or not pgmspace.h is #included is separately
19 // controllable by FASTLED_INCLUDE_PGMSPACE, if needed.
20 
21 
22 // If FASTLED_USE_PROGMEM is 1, we'll map FL_PROGMEM
23 // and the FL_PGM_* accessors to the Arduino equivalents.
24 #if FASTLED_USE_PROGMEM == 1
25 #ifndef FASTLED_INCLUDE_PGMSPACE
26 #define FASTLED_INCLUDE_PGMSPACE 1
27 #endif
28 
29 #if FASTLED_INCLUDE_PGMSPACE == 1
30 #include <avr/pgmspace.h>
31 #endif
32 
33 #define FL_PROGMEM PROGMEM
34 
35 // Note: only the 'near' memory wrappers are provided.
36 // If you're using 'far' memory, you already have
37 // portability issues to work through, but you could
38 // add more support here if needed.
39 #define FL_PGM_READ_BYTE_NEAR(x) (pgm_read_byte_near(x))
40 #define FL_PGM_READ_WORD_NEAR(x) (pgm_read_word_near(x))
41 #define FL_PGM_READ_DWORD_NEAR(x) (pgm_read_dword_near(x))
42 
43 // Workaround for http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34734
44 #ifdef FASTLED_AVR
45 #ifdef PROGMEM
46 #undef PROGMEM
47 #define PROGMEM __attribute__((section(".progmem.data")))
48 #endif
49 #endif
50 
51 #else
52 // If FASTLED_USE_PROGMEM is 0 or undefined,
53 // we'll use regular memory (RAM) access.
54 
55 //empty PROGMEM simulation
56 #define FL_PROGMEM
57 #define FL_PGM_READ_BYTE_NEAR(x) (*((const uint8_t*)(x)))
58 #define FL_PGM_READ_WORD_NEAR(x) (*((const uint16_t*)(x)))
59 #define FL_PGM_READ_DWORD_NEAR(x) (*((const uint32_t*)(x)))
60 
61 #endif
62 
63 
64 FASTLED_NAMESPACE_END
65 
66 #endif
central include file for FastLED, defines the CFastLED class/object