Infrared4Arduino 1.2.3
Loading...
Searching...
No Matches
IrSenderPwmHard.cpp
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#include <Arduino.h>
19#include "Board.h"
20
21#ifdef HAS_HARDWARE_PWM
22#include "IrSenderPwmHard.h"
23
24IrSenderPwmHard *IrSenderPwmHard::instance = nullptr;
25
26IrSenderPwmHard::IrSenderPwmHard(pin_t outputPin __attribute__((unused))) : IrSenderPwm(PWM_PIN) {
27}
28
30 disable();
31}
32
34 if (instance != nullptr)
35 return nullptr;
36 instance = new IrSenderPwmHard(outputPin);
37 return instance;
38}
39
41 if (instance == nullptr && create)
42 instance = new IrSenderPwmHard(outputPin);
43 return instance;
44}
45
46void IrSenderPwmHard::enable(frequency_t frequency, dutycycle_t dutyCycle) {
47 Board::getInstance()->enablePwm(getPin(), frequency, dutyCycle);
48}
49
50void IrSenderPwmHard::disable() {
52}
53
54void inline IrSenderPwmHard::sendMark(milliseconds_t time) {
56}
57
58#endif // HAS_HARDWARE_PWM
#define PWM_PIN
Definition: ATmega328P.h:108
int8_t dutycycle_t
Type for duty cycle in percent.
Definition: InfraredTypes.h:36
uint32_t frequency_t
Type for modulation frequency in Hz.
Definition: InfraredTypes.h:31
uint16_t milliseconds_t
Type for durations in milli seconds.
Definition: InfraredTypes.h:24
uint8_t pin_t
Type for GPIO pin, compatible with Arduino libs.
Definition: InfraredTypes.h:41
void sendPwmMark(microseconds_t time)
Definition: Board.h:106
void enablePwm(pin_t pin, frequency_t frequency, dutycycle_t dutyCycle)
Start PWM, making output active.
Definition: Board.h:93
static Board * getInstance()
Definition: Board.h:53
void disablePwm()
Turn off PWM.
Definition: Board.h:103
Sending function using timer PWM.
virtual ~IrSenderPwmHard()
IrSenderPwmHard(pin_t outputPin=Board::getInstance() ->defaultPwmPin())
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
pin_t getPin() const
Definition: IrSender.h:32