Control Surface  1.1.0
MIDI Control Surface library for Arduino
ExtendedInputOutput.hpp
Go to the documentation of this file.
1 /* ✔ */
2 
3 #pragma once
4 
6 AH_DIAGNOSTIC_WERROR() // Enable errors on warnings
7 
9 #include <Arduino.h> // pin functions and constants
11 
12 #include "ExtendedIOElement.hpp"
13 
15 
16 #define AH_EXT_PIN(x) (x + NUM_DIGITAL_PINS + NUM_ANALOG_INPUTS)
17 
18 namespace detail {
19 const static uint8_t tmp_HIGH = HIGH;
20 const static uint8_t tmp_LOW = LOW;
21 const static uint8_t tmp_INPUT = INPUT;
22 const static uint8_t tmp_OUTPUT = OUTPUT;
23 const static uint8_t tmp_INPUT_PULLUP = INPUT_PULLUP;
24 }
25 
27 
28 #ifndef ARDUINO_API_VERSION
29 #ifdef HIGH
30 #undef HIGH
31 #endif
32 #ifdef LOW
33 #undef LOW
34 #endif
35 
36 #ifdef INPUT
37 #undef INPUT
38 #endif
39 #ifdef OUTPUT
40 #undef OUTPUT
41 #endif
42 #ifdef INPUT_PULLUP
43 #undef INPUT_PULLUP
44 #endif
45 
46 const uint8_t HIGH = AH::detail::tmp_HIGH;
47 const uint8_t LOW = AH::detail::tmp_LOW;
48 
49 const uint8_t INPUT = AH::detail::tmp_INPUT;
52 #endif
53 
55 
56 /**
57  * @brief A namespace with alternatives to the standard Arduino IO functions
58  * that can be used with extended IO pin numbers.
59  */
60 namespace ExtIO {
61 /**
62  * @brief Find the IO element of a given extended IO pin number.
63  *
64  * @param pin
65  * The extended IO pin number to find the IO element of.
66  * @return A pointer to the extended IO element that the given pin belongs to.
67  */
68 extern ExtendedIOElement &getIOElementOfPin(pin_t pin);
69 /// An ExtIO version of the Arduino function
70 extern void pinMode(pin_t pin, uint8_t mode);
71 /// An ExtIO version of the Arduino function
72 extern void pinMode(int pin, uint8_t mode);
73 /// An ExtIO version of the Arduino function
74 extern void digitalWrite(pin_t pin, uint8_t val);
75 /// An ExtIO version of the Arduino function
76 extern void digitalWrite(int pin, uint8_t val);
77 /// An ExtIO version of the Arduino function
78 extern int digitalRead(pin_t pin);
79 /// An ExtIO version of the Arduino function
80 extern int digitalRead(int pin);
81 /// An ExtIO version of the Arduino function
82 extern void shiftOut(pin_t dataPin, pin_t clockPin, uint8_t bitOrder,
83  uint8_t val);
84 /// An ExtIO version of the Arduino function
85 extern void shiftOut(int dataPin, int clockPin, uint8_t bitOrder, uint8_t val);
86 /// An ExtIO version of the Arduino function
87 extern analog_t analogRead(pin_t pin);
88 /// An ExtIO version of the Arduino function
89 extern analog_t analogRead(int pin);
90 /// An ExtIO version of the Arduino function
91 extern void analogWrite(pin_t pin, analog_t val);
92 /// An ExtIO version of the Arduino function
93 extern void analogWrite(int pin, analog_t val);
94 /// An ExtIO version of the Arduino function
95 extern void analogWrite(int pin, int val);
96 /// An ExtIO version of the Arduino function
97 extern void analogWrite(pin_t pin, int val);
98 
99 } // namespace ExtIO
100 
102 
INPUT_PULLUP
const uint8_t INPUT_PULLUP
Definition: ExtendedInputOutput.hpp:51
Warnings.hpp
AH::detail::tmp_OUTPUT
const static uint8_t tmp_OUTPUT
Definition: ExtendedInputOutput.hpp:22
AH::analog_t
uint16_t analog_t
The type returned from analogRead and similar functions.
Definition: Hardware-Types.hpp:15
AH::ExtIO::pinMode
void pinMode(pin_t pin, uint8_t mode)
An ExtIO version of the Arduino function.
Definition: ExtendedInputOutput.cpp:36
AH::ExtIO::analogWrite
void analogWrite(pin_t pin, analog_t val)
An ExtIO version of the Arduino function.
Definition: ExtendedInputOutput.cpp:97
AH_DIAGNOSTIC_POP
#define AH_DIAGNOSTIC_POP()
Definition: Warnings.hpp:17
HIGH
const uint8_t HIGH
Definition: ExtendedInputOutput.hpp:46
LOW
const uint8_t LOW
Definition: ExtendedInputOutput.hpp:47
AH::ExtIO::getIOElementOfPin
ExtendedIOElement & getIOElementOfPin(pin_t pin)
Find the IO element of a given extended IO pin number.
Definition: ExtendedInputOutput.cpp:17
AH_DIAGNOSTIC_EXTERNAL_HEADER
#define AH_DIAGNOSTIC_EXTERNAL_HEADER()
Definition: Warnings.hpp:18
AH::ExtIO::analogRead
analog_t analogRead(pin_t pin)
An ExtIO version of the Arduino function.
Definition: ExtendedInputOutput.cpp:86
AH::pin_t
uint16_t pin_t
The type for Arduino pins (and ExtendedIOElement pins).
Definition: Hardware-Types.hpp:17
AH::ExtIO::digitalRead
int digitalRead(pin_t pin)
An ExtIO version of the Arduino function.
Definition: ExtendedInputOutput.cpp:58
AH::detail::tmp_INPUT
const static uint8_t tmp_INPUT
Definition: ExtendedInputOutput.hpp:21
AH::ExtIO::shiftOut
void shiftOut(pin_t dataPin, pin_t clockPin, uint8_t bitOrder, uint8_t val)
An ExtIO version of the Arduino function.
Definition: ExtendedInputOutput.cpp:69
INPUT
const uint8_t INPUT
Definition: ExtendedInputOutput.hpp:49
AH_DIAGNOSTIC_WERROR
#define AH_DIAGNOSTIC_WERROR()
Definition: Warnings.hpp:16
BEGIN_AH_NAMESPACE
#define BEGIN_AH_NAMESPACE
Definition: AH/Settings/NamespaceSettings.hpp:9
OUTPUT
const uint8_t OUTPUT
Definition: ExtendedInputOutput.hpp:50
END_AH_NAMESPACE
#define END_AH_NAMESPACE
Definition: AH/Settings/NamespaceSettings.hpp:10
AH::detail::tmp_INPUT_PULLUP
const static uint8_t tmp_INPUT_PULLUP
Definition: ExtendedInputOutput.hpp:23
AH::detail::tmp_HIGH
const static uint8_t tmp_HIGH
Definition: ExtendedInputOutput.hpp:19
AH::detail::tmp_LOW
const static uint8_t tmp_LOW
Definition: ExtendedInputOutput.hpp:20
AH::ExtIO::digitalWrite
void digitalWrite(pin_t pin, uint8_t val)
An ExtIO version of the Arduino function.
Definition: ExtendedInputOutput.cpp:47