Infrared4Arduino 1.2.3
Loading...
Searching...
No Matches
IrSenderPwmSoftDelay.cpp
Go to the documentation of this file.
1/*
2Copyright (C) 2020 Bengt Martensson.
3
4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation; either version 2 of the License, or (at
7your option) any later version.
8
9This program is distributed in the hope that it will be useful, but
10WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12General Public License for more details.
13
14You should have received a copy of the GNU General Public License along with
15this program. If not, see http://www.gnu.org/licenses/.
16*/
17
18#include <Arduino.h>
19
21
23}
24
25void inline IrSenderPwmSoftDelay::sleepMicros(microseconds_t us) {
26 if (us > 0U) // Is this necessary? (Official docu https://www.arduino.cc/en/Reference/DelayMicroseconds does not tell.)
28}
29
30void inline IrSenderPwmSoftDelay::sleepUntilMicros(uint32_t targetTime) {
31 int32_t time = targetTime - micros();
32 if (time < 0)
33 return;
34 delay(time/1000UL);
35 int32_t rest = targetTime - micros();
36 if (rest >= 4)
37 ::delayMicroseconds(rest);
38}
uint16_t microseconds_t
Type for durations in micro seconds.
Definition: InfraredTypes.h:15
uint8_t pin_t
Type for GPIO pin, compatible with Arduino libs.
Definition: InfraredTypes.h:41
static void delayMicroseconds(microseconds_t)
Version of delayMicroseconds able to grok more than 16383 micros.
Definition: Board.cpp:25
IrSenderPwmSoftDelay(pin_t outpitPin)
Sending function using timer PWM.