Skip to content

Commit 4ca70b1

Browse files
committed
Bumped version to 1.0.0
1 parent afaddbc commit 4ca70b1

18 files changed

+176
-128
lines changed

README.md

Lines changed: 92 additions & 60 deletions
Large diffs are not rendered by default.

extras/VoltAndOhmmeter.fzz

1.78 KB
Binary file not shown.

extras/VoltAndOhmmeter_Schaltplan.png

13.2 KB
Loading
-3.13 KB
Loading

src/ADCUtils.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,4 +143,3 @@ float getTemperature(void);
143143
#endif // defined(ADATE)
144144
#endif // defined(__AVR__)
145145
#endif // _ADC_UTILS_H
146-
#pragma once

src/ADCUtils.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
* with INTERNAL you can calibrate your ADC readout. For my Nanos I measured e.g. 1060 mV and 1093 mV.
3535
*/
3636
#if !defined(ADC_INTERNAL_REFERENCE_MILLIVOLT)
37-
#define ADC_INTERNAL_REFERENCE_MILLIVOLT 1100L // Value measured at the AREF pin
37+
#define ADC_INTERNAL_REFERENCE_MILLIVOLT 1100L // Value measured at the AREF pin. If value > real AREF voltage, measured values are > real values
3838
#endif
3939

4040
// Union to speed up the combination of low and high bytes to a word

src/ATtinyUtils.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,4 +115,3 @@ void changeDigisparkClock();
115115

116116
#endif // defined(__AVR_ATtiny85__)
117117
#endif // _ATTINY_UTILS_H
118-
#pragma once

src/AVRUtils.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,3 @@ bool isAddressInRAM(void *aAddressToCheck);
5353
bool isAddressBelowHeap(void *aAddressToCheck);
5454
#endif // defined(__AVR__)
5555
#endif // _AVR_UTILS_H
56-
#pragma once

src/BlinkLed.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,3 @@ class BlinkLed {
7474
};
7575

7676
#endif // _BLINK_LED_H
77-
#pragma once

src/DebugLevel.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,3 @@
4848
#endif
4949

5050
#endif // _DEBUGLEVEL_H
51-
#pragma once

src/HCSR04.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ unsigned int getCentimeterFromUSMicroSeconds(unsigned int aDistanceMicros) {
152152
}
153153

154154
/**
155-
* @param aTimeoutMicros timeout of 5825 micros is equivalent to 1 meter, default timeout of 20000 micro seconds is 3.43 meter
155+
* @param aTimeoutMicros timeout of 5825 micros is equivalent to 1 meter, 10000 is 1.71 m, default timeout of 20000 micro seconds is 3.43 meter
156156
* @return Distance in centimeter @20 degree celsius (time in us/58.25)
157157
* 0 / DISTANCE_TIMEOUT_RESULT if timeout or pins are not initialized
158158
*/

src/HCSR04.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,3 @@ extern volatile unsigned long sUSPulseMicros;
6666
extern uint8_t sHCSR04Mode;
6767

6868
#endif // _HCSR04_H
69-
#pragma once

src/LongUnion.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323

2424
#if !defined(_WORD_UNION_H) || !defined(_LONG_UNION_H)
2525

26-
#include <Arduino.h>
2726
#include <stdint.h>
2827

2928
#ifndef _WORD_UNION_H

src/MillisUtils.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,3 @@ bool areMillisGone(unsigned int aMillis);
6060
bool areMillisGone(unsigned int aMillis, unsigned long * aLastMillisPtr);
6161

6262
#endif // _MILLIS_UTILS_H
63-
#pragma once

src/ShowInfo.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -310,9 +310,9 @@ void Information(void) {
310310
#endif
311311

312312
Serial.println(F("UTF-8 test:"));
313-
Serial.println(F(" Micro µ µ µ µ µ µ µ µ µ µ"));
314-
Serial.println(F(" Euro € € € € € € € € € €"));
315-
Serial.println(F(" (c) © © © © © © © © © ©"));
313+
Serial.println(F(" Micro µ"));
314+
Serial.println(F(" Euro €"));
315+
Serial.println(F(" (c) ©"));
316316

317317
Serial.println(F("-----------"));
318318
#endif

src/ShowInfo.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,4 +88,3 @@ void TimerRegisterDump(void);
8888
#endif // !defined(__AVR_ATmega32U4__)
8989

9090
#endif // _SHOW_INFO_H
91-
#pragma once

src/SimpleEMAFilters.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,4 +76,3 @@ void printFiltersResults(uint16_t aPrintMask = PRINT_ALL_FILTERS);
7676
void doFiltersStep(int16_t aInputValue);
7777

7878
#endif // _SIMPLE_EMA_FILTERS_H
79-
#pragma once

src/digitalWriteFast.h

Lines changed: 79 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
/*
2-
Optimized digital functions for AVR microcontrollers
3-
by Watterott electronic (www.watterott.com)
4-
based on http://code.google.com/p/digitalwritefast
2+
* digitalWriteFast.h
3+
*
4+
* Optimized digital functions for AVR microcontrollers
5+
* by Watterott electronic (www.watterott.com)
6+
* based on https://code.google.com/p/digitalwritefast
57
*/
68

79
#ifndef __digitalWriteFast_h_
@@ -40,7 +42,6 @@
4042
# define BIN (2)
4143
#endif
4244

43-
4445
// workarounds for ARM microcontrollers
4546
#if (!defined(__AVR__) || \
4647
defined(ARDUINO_ARCH_SAM) || \
@@ -99,15 +100,13 @@
99100

100101
#endif
101102

102-
103103
// digital functions
104104
//#if !defined(digitalPinToPortReg)
105105
#define SPI_SW_SS_PIN (10) //SS on Uno (for software SPI)
106106
#define SPI_SW_MOSI_PIN (11) //MOSI on Uno (for software SPI)
107107
#define SPI_SW_MISO_PIN (12) //MISO on Uno (for software SPI)
108108
#define SPI_SW_SCK_PIN (13) //SCK on Uno (for software SPI)
109109

110-
111110
// --- Arduino Due and SAM3X8E based boards ---
112111
#if (defined(ARDUINO_SAM_DUE) || \
113112
defined(__SAM3X8E__))
@@ -165,7 +164,7 @@
165164
((((P) >= 10 && (P) <= 13) || ((P) >= 50 && (P) <= 53)) ? &PORTB : \
166165
(((P) >= 30 && (P) <= 37) ? &PORTC : \
167166
((((P) >= 18 && (P) <= 21) || (P) == 38) ? &PORTD : \
168-
((((P) >= 0 && (P) <= 3) || (P) == 5) ? &PORTE : \
167+
((((P) <= 3) || (P) == 5) ? &PORTE : \
169168
(((P) >= 54 && (P) <= 61) ? &PORTF : \
170169
((((P) >= 39 && (P) <= 41) || (P) == 4) ? &PORTG : \
171170
((((P) >= 6 && (P) <= 9) || (P) == 16 || (P) == 17) ? &PORTH : \
@@ -177,7 +176,7 @@
177176
((((P) >= 10 && (P) <= 13) || ((P) >= 50 && (P) <= 53)) ? &DDRB : \
178177
(((P) >= 30 && (P) <= 37) ? &DDRC : \
179178
((((P) >= 18 && (P) <= 21) || (P) == 38) ? &DDRD : \
180-
((((P) >= 0 && (P) <= 3) || (P) == 5) ? &DDRE : \
179+
((((P) <= 3) || (P) == 5) ? &DDRE : \
181180
(((P) >= 54 && (P) <= 61) ? &DDRF : \
182181
((((P) >= 39 && (P) <= 41) || (P) == 4) ? &DDRG : \
183182
((((P) >= 6 && (P) <= 9) || (P) == 16 || (P) == 17) ? &DDRH : \
@@ -189,7 +188,7 @@
189188
((((P) >= 10 && (P) <= 13) || ((P) >= 50 && (P) <= 53)) ? &PINB : \
190189
(((P) >= 30 && (P) <= 37) ? &PINC : \
191190
((((P) >= 18 && (P) <= 21) || (P) == 38) ? &PIND : \
192-
((((P) >= 0 && (P) <= 3) || (P) == 5) ? &PINE : \
191+
((((P) <= 3) || (P) == 5) ? &PINE : \
193192
(((P) >= 54 && (P) <= 61) ? &PINF : \
194193
((((P) >= 39 && (P) <= 41) || (P) == 4) ? &PING : \
195194
((((P) >= 6 && (P) <= 9) || (P) == 16 || (P) == 17) ? &PINH : \
@@ -244,31 +243,31 @@
244243

245244
#if defined(__AVR_ATmega324PB__)
246245
#define __digitalPinToPortReg(P) \
247-
(((P) >= 0 && (P) <= 7) ? &PORTB : (((P) >= 8 && (P) <= 15) ? &PORTD : (((P) >= 16 && (P) <= 23) ? &PORTC : (((P) >= 24 && (P) <= 31) ? &PORTA : &PORTE))))
246+
(((P) <= 7) ? &PORTB : (((P) >= 8 && (P) <= 15) ? &PORTD : (((P) >= 16 && (P) <= 23) ? &PORTC : (((P) >= 24 && (P) <= 31) ? &PORTA : &PORTE))))
248247
#define __digitalPinToDDRReg(P) \
249-
(((P) >= 0 && (P) <= 7) ? &DDRB : (((P) >= 8 && (P) <= 15) ? &DDRD : (((P) >= 16 && (P) <= 23) ? &DDRC : (((P) >= 24 && (P) <= 31) ? &DDRA : &DDRE))))
248+
(((P) <= 7) ? &DDRB : (((P) >= 8 && (P) <= 15) ? &DDRD : (((P) >= 16 && (P) <= 23) ? &DDRC : (((P) >= 24 && (P) <= 31) ? &DDRA : &DDRE))))
250249
#define __digitalPinToPINReg(P) \
251-
(((P) >= 0 && (P) <= 7) ? &PINB : (((P) >= 8 && (P) <= 15) ? &PIND : (((P) >= 16 && (P) <= 23) ? &PINC : (((P) >= 24 && (P) <= 31) ? &PINA : &PINE))))
250+
(((P) <= 7) ? &PINB : (((P) >= 8 && (P) <= 15) ? &PIND : (((P) >= 16 && (P) <= 23) ? &PINC : (((P) >= 24 && (P) <= 31) ? &PINA : &PINE))))
252251
# if defined(SANGUINO_PINOUT)
253252
#define __digitalPinToBit(P) \
254-
(((P) >= 0 && (P) <= 7) ? (P) : (((P) >= 8 && (P) <= 15) ? (P) - 8 : (((P) >= 16 && (P) <= 23) ? (P) - 16 : (((P) >= 16 && (P) <= 23) ? (7 - ((P) - 24)) : (P) - 32))))
253+
(((P) <= 7) ? (P) : (((P) >= 8 && (P) <= 15) ? (P) - 8 : (((P) >= 16 && (P) <= 23) ? (P) - 16 : (((P) >= 16 && (P) <= 23) ? (7 - ((P) - 24)) : (P) - 32))))
255254
# else //MightyCore Pinout
256255
#define __digitalPinToBit(P) \
257-
(((P) >= 0 && (P) <= 7) ? (P) : (((P) >= 8 && (P) <= 15) ? (P) - 8 : (((P) >= 16 && (P) <= 23) ? (P) - 16 : (((P) >= 16 && (P) <= 23) ? (P) - 24 : (P) - 32))))
256+
(((P) <= 7) ? (P) : (((P) >= 8 && (P) <= 15) ? (P) - 8 : (((P) >= 16 && (P) <= 23) ? (P) - 16 : (((P) >= 16 && (P) <= 23) ? (P) - 24 : (P) - 32))))
258257
# endif
259258
#else
260259
#define __digitalPinToPortReg(P) \
261-
(((P) >= 0 && (P) <= 7) ? &PORTB : (((P) >= 8 && (P) <= 15) ? &PORTD : (((P) >= 16 && (P) <= 23) ? &PORTC : &PORTA)))
260+
(((P) <= 7) ? &PORTB : (((P) >= 8 && (P) <= 15) ? &PORTD : (((P) >= 16 && (P) <= 23) ? &PORTC : &PORTA)))
262261
#define __digitalPinToDDRReg(P) \
263-
(((P) >= 0 && (P) <= 7) ? &DDRB : (((P) >= 8 && (P) <= 15) ? &DDRD : (((P) >= 16 && (P) <= 23) ? &DDRC : &DDRA)))
262+
(((P) <= 7) ? &DDRB : (((P) >= 8 && (P) <= 15) ? &DDRD : (((P) >= 16 && (P) <= 23) ? &DDRC : &DDRA)))
264263
#define __digitalPinToPINReg(P) \
265-
(((P) >= 0 && (P) <= 7) ? &PINB : (((P) >= 8 && (P) <= 15) ? &PIND : (((P) >= 16 && (P) <= 23) ? &PINC : &PINA)))
264+
(((P) <= 7) ? &PINB : (((P) >= 8 && (P) <= 15) ? &PIND : (((P) >= 16 && (P) <= 23) ? &PINC : &PINA)))
266265
# if defined(SANGUINO_PINOUT)
267266
#define __digitalPinToBit(P) \
268-
(((P) >= 0 && (P) <= 7) ? (P) : (((P) >= 8 && (P) <= 15) ? (P) - 8 : (((P) >= 16 && (P) <= 23) ? (P) - 16 : (7 - ((P) - 24)))))
267+
(((P) <= 7) ? (P) : (((P) >= 8 && (P) <= 15) ? (P) - 8 : (((P) >= 16 && (P) <= 23) ? (P) - 16 : (7 - ((P) - 24)))))
269268
# else //MightyCore Pinout
270269
#define __digitalPinToBit(P) \
271-
(((P) >= 0 && (P) <= 7) ? (P) : (((P) >= 8 && (P) <= 15) ? (P) - 8 : (((P) >= 16 && (P) <= 23) ? (P) - 16 : (P) - 24)))
270+
(((P) <= 7) ? (P) : (((P) >= 8 && (P) <= 15) ? (P) - 8 : (((P) >= 16 && (P) <= 23) ? (P) - 16 : (P) - 24)))
272271
# endif
273272
#endif
274273

@@ -277,6 +276,34 @@
277276
#elif (defined(ARDUINO_AVR_LEONARDO) || \
278277
defined(__AVR_ATmega16U4__) || \
279278
defined(__AVR_ATmega32U4__))
279+
# if defined(TEENSYDUINO)
280+
#define UART_RX_PIN (7) //PD2
281+
#define UART_TX_PIN (8) //PD3
282+
283+
#define I2C_SDA_PIN (6) //PD1
284+
#define I2C_SCL_PIN (5) //PD0
285+
286+
#define SPI_HW_SS_PIN (0) //PB0
287+
#define SPI_HW_MOSI_PIN (2) //PB2
288+
#define SPI_HW_MISO_PIN (3) //PB3
289+
#define SPI_HW_SCK_PIN (1) //PB1
290+
291+
#define __digitalPinToPortReg(P) \
292+
((((P) <= 4) || ((P) >= 13 && (P) <= 15)) ? &PORTB : (((P) == 9 || (P) == 10) ? &PORTC : (((P) >= 16 && (P) <= 21)) ? &PORTF : &PORTD))
293+
#define __digitalPinToDDRReg(P) \
294+
((((P) <= 4) || ((P) >= 13 && (P) <= 15)) ? &DDRB : (((P) == 9 || (P) == 10) ? &DDRC : (((P) >= 16 && (P) <= 21)) ? &DDRF : &DDRD))
295+
#define __digitalPinToPINReg(P) \
296+
((((P) <= 4) || ((P) >= 13 && (P) <= 15)) ? &PINB : (((P) == 9 || (P) == 10) ? &PINC : (((P) >= 16 && (P) <= 21)) ? &PINF : &PIND))
297+
#define __digitalPinToBit(P) \
298+
(((P) <= 3) ? (P) : \
299+
(((P) == 4 || (P) == 12) ? 7 : \
300+
(((P) <= 8) ? (P) - 5 : \
301+
(((P) <= 10) ? (P) - 3 : \
302+
(((P) == 11) ? 6 : \
303+
(((P) <= 15) ? (P) - 9 : \
304+
(((P) <= 19) ? 23 - (P) : \
305+
(((P) <= 21) ? 21 - (P) : (P) - 18))))))))
306+
# else
280307

281308
#define UART_RX_PIN (0) //PD2
282309
#define UART_TX_PIN (1) //PD3
@@ -290,14 +317,18 @@
290317
#define SPI_HW_SCK_PIN (15) //PB1
291318

292319
#define __digitalPinToPortReg(P) \
293-
((((P) >= 0 && (P) <= 4) || (P) == 6 || (P) == 12 || (P) == 24 || (P) == 25 || (P) == 29) ? &PORTD : (((P) == 5 || (P) == 13) ? &PORTC : (((P) >= 18 && (P) <= 23)) ? &PORTF : (((P) == 7) ? &PORTE : &PORTB)))
320+
((((P) <= 4) || (P) == 6 || (P) == 12 || (P) == 24 || (P) == 25 || (P) == 29) ? &PORTD : (((P) == 5 || (P) == 13) ? &PORTC : (((P) >= 18 && (P) <= 23)) ? &PORTF : (((P) == 7) ? &PORTE : &PORTB)))
294321
#define __digitalPinToDDRReg(P) \
295-
((((P) >= 0 && (P) <= 4) || (P) == 6 || (P) == 12 || (P) == 24 || (P) == 25 || (P) == 29) ? &DDRD : (((P) == 5 || (P) == 13) ? &DDRC : (((P) >= 18 && (P) <= 23)) ? &DDRF : (((P) == 7) ? &DDRE : &DDRB)))
322+
((((P) <= 4) || (P) == 6 || (P) == 12 || (P) == 24 || (P) == 25 || (P) == 29) ? &DDRD : (((P) == 5 || (P) == 13) ? &DDRC : (((P) >= 18 && (P) <= 23)) ? &DDRF : (((P) == 7) ? &DDRE : &DDRB)))
296323
#define __digitalPinToPINReg(P) \
297-
((((P) >= 0 && (P) <= 4) || (P) == 6 || (P) == 12 || (P) == 24 || (P) == 25 || (P) == 29) ? &PIND : (((P) == 5 || (P) == 13) ? &PINC : (((P) >= 18 && (P) <= 23)) ? &PINF : (((P) == 7) ? &PINE : &PINB)))
324+
((((P) <= 4) || (P) == 6 || (P) == 12 || (P) == 24 || (P) == 25 || (P) == 29) ? &PIND : (((P) == 5 || (P) == 13) ? &PINC : (((P) >= 18 && (P) <= 23)) ? &PINF : (((P) == 7) ? &PINE : &PINB)))
298325
#define __digitalPinToBit(P) \
299-
(((P) >= 8 && (P) <= 11) ? (P) - 4 : (((P) >= 18 && (P) <= 21) ? 25 - (P) : (((P) == 0) ? 2 : (((P) == 1) ? 3 : (((P) == 2) ? 1 : (((P) == 3) ? 0 : (((P) == 4) ? 4 : (((P) == 6) ? 7 : (((P) == 13) ? 7 : (((P) == 14) ? 3 : (((P) == 15) ? 1 : (((P) == 16) ? 2 : (((P) == 17) ? 0 : (((P) == 22) ? 1 : (((P) == 23) ? 0 : (((P) == 24) ? 4 : (((P) == 25) ? 7 : (((P) == 26) ? 4 : (((P) == 27) ? 5 : 6 )))))))))))))))))))
300-
326+
(((P) >= 8 && (P) <= 11) ? (P) - 4 : \
327+
(((P) >= 18 && (P) <= 21) ? 25 - (P) : \
328+
(((P) == 0) ? 2 : (((P) == 1) ? 3 : (((P) == 2) ? 1 : (((P) == 3) ? 0 : (((P) == 4) ? 4 : (((P) == 6) ? 7 : (((P) == 13) ? 7 : \
329+
(((P) == 14) ? 3 : (((P) == 15) ? 1 : (((P) == 16) ? 2 : (((P) == 17) ? 0 : (((P) == 22) ? 1 : (((P) == 23) ? 0 : \
330+
(((P) == 24) ? 4 : (((P) == 25) ? 7 : (((P) == 26) ? 4 : (((P) == 27) ? 5 : 6 )))))))))))))))))))
331+
# endif
301332

302333
// --- Arduino Uno and ATmega168/328 based boards ---
303334
#elif (defined(ARDUINO_AVR_UNO) || \
@@ -328,25 +359,24 @@
328359

329360
#if defined(__AVR_ATmega48PB__) || defined(__AVR_ATmega88PB__) || defined(__AVR_ATmega168PB__) || defined(__AVR_ATmega328PB__)
330361
#define __digitalPinToPortReg(P) \
331-
(((P) >= 0 && (P) <= 7) ? &PORTD : (((P) >= 8 && (P) <= 13) ? &PORTB : (((P) >= 14 && (P) <= 19) ? &PORTC : &PORTE)))
362+
(((P) <= 7) ? &PORTD : (((P) >= 8 && (P) <= 13) ? &PORTB : (((P) >= 14 && (P) <= 19) ? &PORTC : &PORTE)))
332363
#define __digitalPinToDDRReg(P) \
333-
(((P) >= 0 && (P) <= 7) ? &DDRD : (((P) >= 8 && (P) <= 13) ? &DDRB : (((P) >= 14 && (P) <= 19) ? &DDRC : &DDRE)))
364+
(((P) <= 7) ? &DDRD : (((P) >= 8 && (P) <= 13) ? &DDRB : (((P) >= 14 && (P) <= 19) ? &DDRC : &DDRE)))
334365
#define __digitalPinToPINReg(P) \
335-
(((P) >= 0 && (P) <= 7) ? &PIND : (((P) >= 8 && (P) <= 13) ? &PINB : (((P) >= 14 && (P) <= 19) ? &PINC : &PINE)))
366+
(((P) <= 7) ? &PIND : (((P) >= 8 && (P) <= 13) ? &PINB : (((P) >= 14 && (P) <= 19) ? &PINC : &PINE)))
336367
#define __digitalPinToBit(P) \
337-
(((P) >= 0 && (P) <= 7) ? (P) : (((P) >= 8 && (P) <= 13) ? (P) - 8 : (((P) >= 14 && (P) <= 19) ? (P) - 14 : (((P) >= 20 && (P) <= 21) ? (P) - 18 : (P) - 22))))
368+
(((P) <= 7) ? (P) : (((P) >= 8 && (P) <= 13) ? (P) - 8 : (((P) >= 14 && (P) <= 19) ? (P) - 14 : (((P) >= 20 && (P) <= 21) ? (P) - 18 : (P) - 22))))
338369
#else
339370
#define __digitalPinToPortReg(P) \
340-
(((P) >= 0 && (P) <= 7) ? &PORTD : (((P) >= 8 && (P) <= 13) ? &PORTB : &PORTC))
371+
(((P) <= 7) ? &PORTD : (((P) >= 8 && (P) <= 13) ? &PORTB : &PORTC))
341372
#define __digitalPinToDDRReg(P) \
342-
(((P) >= 0 && (P) <= 7) ? &DDRD : (((P) >= 8 && (P) <= 13) ? &DDRB : &DDRC))
373+
(((P) <= 7) ? &DDRD : (((P) >= 8 && (P) <= 13) ? &DDRB : &DDRC))
343374
#define __digitalPinToPINReg(P) \
344-
(((P) >= 0 && (P) <= 7) ? &PIND : (((P) >= 8 && (P) <= 13) ? &PINB : &PINC))
375+
(((P) <= 7) ? &PIND : (((P) >= 8 && (P) <= 13) ? &PINB : &PINC))
345376
#define __digitalPinToBit(P) \
346-
(((P) >= 0 && (P) <= 7) ? (P) : (((P) >= 8 && (P) <= 13) ? (P) - 8 : (P) - 14))
377+
(((P) <= 7) ? (P) : (((P) >= 8 && (P) <= 13) ? (P) - 8 : (P) - 14))
347378
#endif
348379

349-
350380
// --- Arduino Uno WiFi Rev 2, Nano Every ---
351381
#elif defined(__AVR_ATmega4809__)
352382

@@ -437,23 +467,21 @@
437467
#endif
438468
//#endif //#if !defined(digitalPinToPortReg)
439469

440-
441470
#if !defined(digitalWriteFast)
442-
#if (defined(__AVR__) || defined(ARDUINO_ARCH_AVR)) && defined(__digitalPinToPortReg)
471+
# if (defined(__AVR__) || defined(ARDUINO_ARCH_AVR)) && defined(__digitalPinToPortReg)
443472
#define digitalWriteFast(P, V) \
444473
if (__builtin_constant_p(P)) { \
445474
BIT_WRITE(*__digitalPinToPortReg(P), __digitalPinToBit(P), (V)); \
446475
} else { \
447476
digitalWrite((P), (V)); \
448477
}
449-
#else
478+
# else
450479
#define digitalWriteFast digitalWrite
480+
# endif
451481
#endif
452-
#endif
453-
454482

455483
#if !defined(pinModeFast)
456-
#if (defined(__AVR__) || defined(ARDUINO_ARCH_AVR)) && defined(__digitalPinToPortReg)
484+
# if (defined(__AVR__) || defined(ARDUINO_ARCH_AVR)) && defined(__digitalPinToPortReg)
457485
#define pinModeFast(P, V) \
458486
if (__builtin_constant_p(P) && __builtin_constant_p(V)) { \
459487
if (V == INPUT_PULLUP) {\
@@ -465,37 +493,35 @@ if (__builtin_constant_p(P) && __builtin_constant_p(V)) { \
465493
} else { \
466494
pinMode((P), (V)); \
467495
}
468-
#else
496+
# else
469497
#define pinModeFast pinMode
470-
#endif
471-
#endif
472-
498+
# endif
499+
#endif // !defined(pinModeFast)
473500

474501
#if !defined(digitalReadFast)
475-
#if (defined(__AVR__) || defined(ARDUINO_ARCH_AVR))
502+
# if (defined(__AVR__) || defined(ARDUINO_ARCH_AVR)) && defined(__digitalPinToPINReg)
476503
#define digitalReadFast(P) ( (int) __digitalReadFast((P)) )
504+
// since we have return values, it is easier to implement it by ?:
477505
#define __digitalReadFast(P ) \
478506
(__builtin_constant_p(P) ) ? \
479507
(( BIT_READ(*__digitalPinToPINReg(P), __digitalPinToBit(P))) ? HIGH:LOW ) : \
480508
digitalRead((P))
481-
#else
509+
# else
482510
#define digitalReadFast digitalRead
483-
#endif
484-
#endif
485-
511+
# endif
512+
#endif // !defined(digitalReadFast)
486513

487514
#if !defined(digitalToggleFast)
488-
#if (defined(__AVR__) || defined(ARDUINO_ARCH_AVR))
515+
# if (defined(__AVR__) || defined(ARDUINO_ARCH_AVR)) && defined(__digitalPinToPINReg)
489516
#define digitalToggleFast(P) \
490517
if (__builtin_constant_p(P)) { \
491518
BIT_SET(*__digitalPinToPINReg(P), __digitalPinToBit(P)); \
492519
} else { \
493520
digitalWrite(P, ! digitalRead(P)); \
494521
}
495-
#else
522+
# else
496523
#define digitalToggleFast(P) digitalWrite(P, ! digitalRead(P))
497-
#endif
498-
#endif
499-
524+
# endif
525+
#endif // !defined(digitalToggleFast)
500526

501527
#endif //__digitalWriteFast_h_

0 commit comments

Comments
 (0)