Merge pull request #4002 from ascillato/patch-1

Add PWM Freq Limits Config at Compile time
This commit is contained in:
Theo Arends 2018-10-07 20:19:50 +02:00 committed by GitHub
commit c78a35d984
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 1 deletions

View File

@ -80,6 +80,10 @@ typedef unsigned long power_t; // Power (Relay) type
//#define PWM_FREQ 1000 // 100..1000 Hz led refresh //#define PWM_FREQ 1000 // 100..1000 Hz led refresh
//#define PWM_FREQ 910 // 100..1000 Hz led refresh (iTead value) //#define PWM_FREQ 910 // 100..1000 Hz led refresh (iTead value)
#define PWM_FREQ 880 // 100..1000 Hz led refresh (BN-SZ01 value) #define PWM_FREQ 880 // 100..1000 Hz led refresh (BN-SZ01 value)
#define PWM_MAX 4000 // [PWM_MAX] Maximum frequency - Default: 4000
#define PWM_MIN 100 // [PWM_MIN] Minimum frequency - Default: 100
// For Dimmers use double of your mains AC frequecy (100 for 50Hz and 120 for 60Hz)
// For Controlling Servos use 50 and also set PWM_FREQ as 50 (DO NOT USE THESE VALUES FOR DIMMERS)
#define DEFAULT_POWER_DELTA 80 // Power change percentage #define DEFAULT_POWER_DELTA 80 // Power change percentage
#define MAX_POWER_HOLD 10 // Time in SECONDS to allow max agreed power #define MAX_POWER_HOLD 10 // Time in SECONDS to allow max agreed power

View File

@ -914,7 +914,7 @@ void MqttDataHandler(char* topic, byte* data, unsigned int data_len)
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s}"), mqtt_data); snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s}"), mqtt_data);
} }
else if (CMND_PWMFREQUENCY == command_code) { else if (CMND_PWMFREQUENCY == command_code) {
if ((1 == payload) || ((payload >= 100) && (payload <= 4000))) { if ((1 == payload) || ((payload >= PWM_MIN) && (payload <= PWM_MAX))) {
Settings.pwm_frequency = (1 == payload) ? PWM_FREQ : payload; Settings.pwm_frequency = (1 == payload) ? PWM_FREQ : payload;
analogWriteFreq(Settings.pwm_frequency); // Default is 1000 (core_esp8266_wiring_pwm.c) analogWriteFreq(Settings.pwm_frequency); // Default is 1000 (core_esp8266_wiring_pwm.c)
} }