mirror of
https://github.com/wled/WLED.git
synced 2025-04-23 22:37:18 +00:00
Remove clock/max bit overrides
Move contants into bus manager
This commit is contained in:
parent
779744bd8e
commit
52548542d2
@ -378,6 +378,31 @@ void BusDigital::cleanup() {
|
||||
}
|
||||
|
||||
|
||||
#ifdef ESP8266
|
||||
// 1 MHz clock
|
||||
#define CLOCK_FREQUENCY 1000000UL
|
||||
#else
|
||||
// Use XTAL clock if possible to avoid timer frequency error when setting APB clock < 80 Mhz
|
||||
// https://github.com/espressif/arduino-esp32/blob/2.0.2/cores/esp32/esp32-hal-ledc.c
|
||||
#ifdef SOC_LEDC_SUPPORT_XTAL_CLOCK
|
||||
#define CLOCK_FREQUENCY 40000000UL
|
||||
#else
|
||||
#define CLOCK_FREQUENCY 80000000UL
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef ESP8266
|
||||
#define MAX_BIT_WIDTH 10
|
||||
#else
|
||||
#ifdef SOC_LEDC_TIMER_BIT_WIDE_NUM
|
||||
// C6/H2/P4: 20 bit, S2/S3/C2/C3: 14 bit
|
||||
#define MAX_BIT_WIDTH SOC_LEDC_TIMER_BIT_WIDE_NUM
|
||||
#else
|
||||
// ESP32: 20 bit (but in reality we would never go beyond 16 bit as the frequency would be to low)
|
||||
#define MAX_BIT_WIDTH 20
|
||||
#endif
|
||||
#endif
|
||||
|
||||
BusPwm::BusPwm(BusConfig &bc)
|
||||
: Bus(bc.type, bc.start, bc.autoWhite, 1, bc.reversed)
|
||||
{
|
||||
@ -385,7 +410,7 @@ BusPwm::BusPwm(BusConfig &bc)
|
||||
unsigned numPins = NUM_PWM_PINS(bc.type);
|
||||
_frequency = bc.frequency ? bc.frequency : WLED_PWM_FREQ;
|
||||
// duty cycle resolution (_depth) can be extracted from this formula: CLOCK_FREQUENCY > _frequency * 2^_depth
|
||||
for (_depth=MAX_BIT_WIDTH; _depth>8; _depth--) if (((uint32_t(CLOCK_FREQUENCY)/_frequency)>>_depth) > 0) break;
|
||||
for (_depth = MAX_BIT_WIDTH; _depth > 8; _depth--) if (((CLOCK_FREQUENCY/_frequency) >> _depth) > 0) break;
|
||||
|
||||
#ifdef ESP8266
|
||||
analogWriteRange((1<<_depth)-1);
|
||||
|
@ -521,35 +521,6 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef CLOCK_FREQUENCY
|
||||
#ifdef ESP8266
|
||||
// 1 MHz clock
|
||||
#define CLOCK_FREQUENCY 1e6f
|
||||
#else
|
||||
// Use XTAL clock if possible to avoid timer frequency error when setting APB clock < 80 Mhz
|
||||
// https://github.com/espressif/arduino-esp32/blob/2.0.2/cores/esp32/esp32-hal-ledc.c
|
||||
#ifdef SOC_LEDC_SUPPORT_XTAL_CLOCK
|
||||
#define CLOCK_FREQUENCY 40e6f
|
||||
#else
|
||||
#define CLOCK_FREQUENCY 80e6f
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef MAX_BIT_WIDTH
|
||||
#ifdef ESP8266
|
||||
#define MAX_BIT_WIDTH 10
|
||||
#else
|
||||
#ifdef SOC_LEDC_TIMER_BIT_WIDE_NUM
|
||||
// C6/H2/P4: 20 bit, S2/S3/C2/C3: 14 bit
|
||||
#define MAX_BIT_WIDTH SOC_LEDC_TIMER_BIT_WIDE_NUM
|
||||
#else
|
||||
// ESP32: 20 bit
|
||||
#define MAX_BIT_WIDTH 20
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define TOUCH_THRESHOLD 32 // limit to recognize a touch, higher value means more sensitive
|
||||
|
||||
// Size of buffer for API JSON object (increase for more segments)
|
||||
|
Loading…
x
Reference in New Issue
Block a user