forked from MobiFlight/MobiFlight-FirmwareSource
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathMFOutput.cpp
More file actions
44 lines (38 loc) · 647 Bytes
/
MFOutput.cpp
File metadata and controls
44 lines (38 loc) · 647 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
//
// Output.cpp
//
// (C) MobiFlight Project 2022
//
#include "MFOutput.h"
MFOutput::MFOutput()
{
_value = false;
}
void MFOutput::attach(uint8_t pin)
{
_pin = pin;
#if defined(ARDUINO_ARCH_RP2040)
pinMode(_pin, OUTPUT_12MA);
#else
pinMode(_pin, OUTPUT);
#endif
set(LOW);
}
void MFOutput::set(uint8_t value)
{
_value = value;
if (_value == 0xFF)
digitalWrite(_pin, HIGH);
else if (_value == 0x00)
digitalWrite(_pin, LOW);
else
analogWrite(_pin, _value);
}
void MFOutput::powerSavingMode(bool state)
{
if (state)
set(0);
else
set(_value);
}
// Output.cpp