Skip to content

Commit 9c2dbe2

Browse files
committedNov 13, 2019
Add header with digital* APIs compatible with legacy code
TODO: mark as deprecated
1 parent fc0c12d commit 9c2dbe2

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed
 

‎api/Compat.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#ifndef __COMPAT_H__
2+
#define __COMPAT_H__
3+
4+
namespace arduino {
5+
6+
inline void pinMode(pin_size_t pinNumber, int mode) {
7+
pinMode(pinNumber, (PinMode)mode);
8+
};
9+
10+
inline void digitalWrite(pin_size_t pinNumber, int status) {
11+
digitalWrite(pinNumber, (PinStatus)status);
12+
};
13+
14+
}
15+
16+
#endif

2 commit comments

Comments
 (2)

bperrybap commented on Apr 14, 2020

@bperrybap

This commit does not solve the issue of the missing #define macros as mentioned in issue #25
as there is existing code that checks for the existence of certain symbols like INPUT_PULLDOWN

If the enums are going to stay around, then my recommendation would be create #define macro symbols for every enum value in all the enums.

bperrybap commented on Apr 14, 2020

@bperrybap

Also, wouldn't it be a good thing to mark these compatibility functions as deprecated so that code that is abusing the API by not using the proper types gets a warning?
i.e. use

 __attribute__ ((deprecated));
Please sign in to comment.