AceTime  2.1.0
Date and time classes for Arduino that support timezones from the TZ Database.
compat.h
Go to the documentation of this file.
1 /*
2  * MIT License
3  * Copyright (c) 2018 Brian T. Park
4  */
5 
6 #ifndef ACE_TIME_COMMON_COMPAT_H
7 #define ACE_TIME_COMMON_COMPAT_H
8 
18 #include <stdint.h>
19 #include <string.h>
20 #include <WString.h> // FPSTR(), __FlashStringHelper
21 
23 #define ACE_TIME_USE_PROGMEM 1
24 #if ACE_TIME_USE_PROGMEM
25  #define ACE_TIME_PROGMEM PROGMEM
26 #else
27  #define ACE_TIME_PROGMEM
28 #endif
29 
30 // Include the correct pgmspace.h depending on architecture.
31 #if defined(ARDUINO_ARCH_AVR)
32  #include <avr/pgmspace.h>
33  #define FPSTR(p) (reinterpret_cast<const __FlashStringHelper *>(p))
34 
35 #elif defined(ARDUINO_ARCH_SAMD)
36  #include <avr/pgmspace.h>
37  #define FPSTR(p) (reinterpret_cast<const __FlashStringHelper *>(p))
38 
39  // Set this to 1 to clobber SERIAL_PORT_MONITOR to SerialUSB on
40  // an original Arduino Zero when using the Native port. See USER_GUIDE.md for
41  // more info.
42  #define ACE_TIME_CLOBBER_SERIAL_PORT_MONITOR 0
43  #if ACE_TIME_CLOBBER_SERIAL_PORT_MONITOR && defined(ARDUINO_SAMD_ZERO)
44  #undef SERIAL_PORT_MONITOR
45  #define SERIAL_PORT_MONITOR SerialUSB
46  #endif
47 
48 #elif defined(TEENSYDUINO)
49  #include <avr/pgmspace.h>
50  #define FPSTR(p) (reinterpret_cast<const __FlashStringHelper *>(p))
51 
52 #elif defined(ESP8266)
53  #include <pgmspace.h>
54 
55 #elif defined(ESP32)
56  #include <pgmspace.h>
57 
58  // ESP32 does not define SERIAL_PORT_MONITOR. Define it unless another
59  // library has already defined it.
60  #if ! defined(SERIAL_PORT_MONITOR)
61  #define SERIAL_PORT_MONITOR Serial
62  #endif
63 
64 #elif defined(ARDUINO_ARCH_STM32)
65  #include <avr/pgmspace.h>
66  #define FPSTR(p) (reinterpret_cast<const __FlashStringHelper *>(p))
67 
68  #undef SERIAL_PORT_MONITOR
69  #define SERIAL_PORT_MONITOR Serial
70 
71 #elif defined(EPOXY_DUINO)
72  #include <pgmspace.h>
73 
74 #else
75  #warning Untested platform. AceTime may still work...
76 
77  #include <avr/pgmspace.h>
78 
79  #if ! defined(FPSTR)
80  #define FPSTR(p) (reinterpret_cast<const __FlashStringHelper *>(p))
81  #endif
82 
83  #if ! defined(SERIAL_PORT_MONITOR)
84  #define SERIAL_PORT_MONITOR Serial
85  #endif
86 
87 #endif
88 
89 #endif // ACE_TIME_COMMON_COMPAT_H