Infrared4Arduino 1.2.3
Loading...
Searching...
No Matches
IrSenderPwmHard.h
Go to the documentation of this file.
1/*
2Copyright (C) 2015 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#pragma once
19
20#include <Arduino.h>
21#include "IrSenderPwm.h"
22#include "Board.h"
23
24#ifndef HAS_HARDWARE_PWM
25#error Current board does not support hardware PWM and thus not the class IrSendPwm. Consider using IrSenderSoftPwm or IrSenderSpin instead.
26#endif
27
34public:
35 IrSenderPwmHard(pin_t outputPin = Board::getInstance()->defaultPwmPin());
36 virtual ~IrSenderPwmHard();
37
38private:
39 static IrSenderPwmHard *instance;
40 void enable(frequency_t frequency, dutycycle_t dutyCycle = Board::defaultDutyCycle);
41 void disable();
42 //void sendSpace(microseconds_t time);
43 void sendMark(microseconds_t time);
44
45 static void barfForInvalidPin(pin_t outputPin) { if (outputPin != Board::getInstance()->defaultPwmPin()) {/*error("Silly pin")*/};};
46
47public:
52 static IrSenderPwmHard *getInstance(bool create = false, pin_t ouputPin = Board::getInstance()->defaultPwmPin());
53
58 static IrSenderPwmHard *newInstance(pin_t ouputPin = Board::getInstance()->defaultPwmPin());
59
60 static void deleteInstance() {
61 delete instance;
62 instance = nullptr;
63 }
64};
int8_t dutycycle_t
Type for duty cycle in percent.
Definition: InfraredTypes.h:36
uint16_t microseconds_t
Type for durations in micro seconds.
Definition: InfraredTypes.h:15
uint32_t frequency_t
Type for modulation frequency in Hz.
Definition: InfraredTypes.h:31
uint8_t pin_t
Type for GPIO pin, compatible with Arduino libs.
Definition: InfraredTypes.h:41
static Board * getInstance()
Definition: Board.h:53
static constexpr dutycycle_t defaultDutyCycle
Default duty cycle to use.
Definition: Board.h:69
Sending function using timer PWM.
static void deleteInstance()
virtual ~IrSenderPwmHard()
static IrSenderPwmHard * newInstance(pin_t ouputPin=Board::getInstance() ->defaultPwmPin())
Creates a new instance (if not existing) and returns it.
static IrSenderPwmHard * getInstance(bool create=false, pin_t ouputPin=Board::getInstance() ->defaultPwmPin())
Returns a pointer to the instance, or nullptr if not initialized.
Sending function using timer PWM.
Definition: IrSenderPwm.h:29