mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-27 12:46:34 +00:00
Add changes from https://github.com/esp8266/Arduino/commit/a6798691
to be compatible with Arduino master.
This commit is contained in:
parent
ba79dc0415
commit
3b7305f20c
@ -29,15 +29,21 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
||||||
static uint32_t analogMap = 0;
|
static uint32_t analogMap = 0;
|
||||||
static int32_t analogScale = PWMRANGE;
|
static int32_t analogScale = 255; // Match upstream default, breaking change from 2.x.x
|
||||||
static uint16_t analogFreq = 1000;
|
static uint16_t analogFreq = 1000;
|
||||||
|
|
||||||
extern void __analogWriteRange(uint32_t range) {
|
extern void __analogWriteRange(uint32_t range) {
|
||||||
if (range > 0) {
|
if ((range >= 15) && (range <= 65535)) {
|
||||||
analogScale = range;
|
analogScale = range;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern void __analogWriteResolution(int res) {
|
||||||
|
if ((res >= 4) && (res <= 16)) {
|
||||||
|
analogScale = (1 << res) - 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
extern void __analogWriteFreq(uint32_t freq) {
|
extern void __analogWriteFreq(uint32_t freq) {
|
||||||
if (freq < 40) {
|
if (freq < 40) {
|
||||||
analogFreq = 40;
|
analogFreq = 40;
|
||||||
@ -61,6 +67,10 @@ extern void __analogWrite(uint8_t pin, int val) {
|
|||||||
val = analogScale;
|
val = analogScale;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Per the Arduino docs at https://www.arduino.cc/reference/en/language/functions/analog-io/analogwrite/
|
||||||
|
// val: the duty cycle: between 0 (always off) and 255 (always on).
|
||||||
|
// So if val = 0 we have digitalWrite(LOW), if we have val==range we have digitalWrite(HIGH)
|
||||||
|
|
||||||
if (analogMap & 1UL << pin) {
|
if (analogMap & 1UL << pin) {
|
||||||
analogMap &= ~(1 << pin);
|
analogMap &= ~(1 << pin);
|
||||||
}
|
}
|
||||||
@ -79,6 +89,7 @@ extern void __analogWrite(uint8_t pin, int val) {
|
|||||||
extern void analogWrite(uint8_t pin, int val) __attribute__((weak, alias("__analogWrite")));
|
extern void analogWrite(uint8_t pin, int val) __attribute__((weak, alias("__analogWrite")));
|
||||||
extern void analogWriteFreq(uint32_t freq) __attribute__((weak, alias("__analogWriteFreq")));
|
extern void analogWriteFreq(uint32_t freq) __attribute__((weak, alias("__analogWriteFreq")));
|
||||||
extern void analogWriteRange(uint32_t range) __attribute__((weak, alias("__analogWriteRange")));
|
extern void analogWriteRange(uint32_t range) __attribute__((weak, alias("__analogWriteRange")));
|
||||||
|
extern void analogWriteResolution(int res) __attribute__((weak, alias("__analogWriteResolution")));
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user