Skip to content

Commit

Permalink
Add SetOption68 to enable multi-channel PWM instead of a single light (
Browse files Browse the repository at this point in the history
  • Loading branch information
s-hadinger committed Aug 6, 2019
1 parent d6e475e commit 81ca44d
Show file tree
Hide file tree
Showing 8 changed files with 377 additions and 125 deletions.
1 change: 1 addition & 0 deletions sonoff/_changelog.ino
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* Add define USE_ENERGY_POWER_LIMIT to disable Energy Power Limit detection while Energy Margin detection is active
* Add allow repeat/longpress for IRSend raw, introduced IRSend<r> option (#6074)
* Change Store AWS IoT Private Key and Certificate in SPI Flash avoiding device-specific compilations
* Add SetOption68 to enable multi-channel PWM instead of a single light (#6134)
*
* 6.6.0.2 20190714
* Change commands Var and Mem to show all parameters when no index is given (#6107)
Expand Down
2 changes: 1 addition & 1 deletion sonoff/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ typedef union { // Restricted by MISRA-C Rule 18.4 bu
uint32_t tuya_show_dimmer : 1; // bit 15 (v6.5.0.15) - SetOption65 - Enable or Disable Dimmer slider control
uint32_t tuya_dimmer_range_255 : 1; // bit 16 (v6.6.0.1) - SetOption66 - Enable or Disable Dimmer range 255 slider control
uint32_t buzzer_enable : 1; // bit 17 (v6.6.0.1) - SetOption67 - Enable buzzer when available
uint32_t spare18 : 1;
uint32_t pmw_multi_channels : 1; // bit 18 (v6.6.0.3) - SetOption68 - Enable multi-channels PWM insteas of Color PWM
uint32_t spare19 : 1;
uint32_t spare20 : 1;
uint32_t spare21 : 1;
Expand Down
3 changes: 2 additions & 1 deletion sonoff/sonoff.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ const uint8_t MAX_COUNTERS = 4; // Max number of counter sensors
const uint8_t MAX_TIMERS = 16; // Max number of Timers
const uint8_t MAX_PULSETIMERS = 8; // Max number of supported pulse timers
const uint8_t MAX_FRIENDLYNAMES = 4; // Max number of Friendly names
const uint8_t MAX_HUE_DEVICES = 15; // Max number of Philips Hue device per emulation
const uint8_t MAX_DOMOTICZ_IDX = 4; // Max number of Domoticz device, key and switch indices
const uint8_t MAX_DOMOTICZ_SNS_IDX = 12; // Max number of Domoticz sensors indices
const uint8_t MAX_KNX_GA = 10; // Max number of KNX Group Addresses to read that can be set
Expand Down Expand Up @@ -264,7 +265,7 @@ const uint8_t kDefaultRfCode[9] PROGMEM = { 0x21, 0x16, 0x01, 0x0E, 0x03, 0x48,
\*********************************************************************************************/

extern uint8_t light_device; // Light device number
extern uint8_t light_power; // Light power
extern power_t light_power; // Light power
extern uint8_t rotary_changed; // Rotary switch changed

#endif // _SONOFF_H_
7 changes: 7 additions & 0 deletions sonoff/sonoff.ino
Original file line number Diff line number Diff line change
Expand Up @@ -1451,6 +1451,13 @@ void GpioInit(void)
light_type |= LT_SM16716;
}
#endif // USE_SM16716

// post-process for lights
if (Settings.flag3.pmw_multi_channels) {
uint32_t pwm_channels = (light_type & 7) > LST_MAX ? LST_MAX : (light_type & 7);
if (0 == pwm_channels) pwm_channels = 1;
devices_present += pwm_channels - 1; // add the pwm channels controls at the end
}
#endif // USE_LIGHT
if (!light_type) {
for (uint32_t i = 0; i < MAX_PWMS; i++) { // Basic PWM control only
Expand Down
3 changes: 3 additions & 0 deletions sonoff/support_command.ino
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,9 @@ void CmndSetoption(void)
if (10 == pindex) { // SetOption60 enable or disable traditional sleep
WiFiSetSleepMode(); // Update WiFi sleep mode accordingly
}
if (18 == pindex) { // SetOption68 for multi-channel PWM, requires a reboot
restart_flag = 2;
}
}
}
else { // SetOption32 .. 49
Expand Down
7 changes: 7 additions & 0 deletions sonoff/xdrv_01_webserver.ino
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ uint8_t *efm8bb1_update = nullptr;

enum UploadTypes { UPL_TASMOTA, UPL_SETTINGS, UPL_EFM8BB1 };

static const char * HEADER_KEYS[] = { "User-Agent", };

const char HTTP_HEAD[] PROGMEM =
"<!DOCTYPE html><html lang=\"" D_HTML_LANGUAGE "\" class=\"\">"
"<head>"
Expand Down Expand Up @@ -543,6 +545,11 @@ void StartWebserver(int type, IPAddress ipweb)
#endif // Not FIRMWARE_MINIMAL
}
reset_web_log_flag = false;

// Collect User-Agent for Alexa Hue Emulation
// This is used in xdrv_20_hue.ino in function findEchoGeneration()
WebServer->collectHeaders(HEADER_KEYS, sizeof(HEADER_KEYS)/sizeof(char*));

WebServer->begin(); // Web server start
}
if (webserver_state != type) {
Expand Down
Loading

0 comments on commit 81ca44d

Please sign in to comment.