Make Sonoff L1 MusicSync persistent (#12008)

This commit is contained in:
Theo Arends 2021-08-03 14:12:38 +02:00
parent 0d2432a15b
commit 45c4e57a03
4 changed files with 11 additions and 9 deletions

View File

@ -8,6 +8,9 @@ All notable changes to this project will be documented in this file.
- Inital support for Wi-Fi extender (#12784)
- Neopool commands ``NPPHRes``, ``NPCLRes`` and ``NPIonRes`` (#12813)
### Changed
- Make Sonoff L1 MusicSync persistent (#12008)
### Fixed
- Neopool communication error (#12813)

View File

@ -128,6 +128,7 @@ The latter links can be used for OTA upgrades too like ``OtaUrl http://ota.tasmo
- Extended supported sensor driver range to 128
- Disable PSRAM on unsupported hardware
- ESP32 remove GPIO initialization to INPUT from not used GPIOs to allow JTAG support
- Make Sonoff L1 MusicSync persistent [#12008](https://github.com/arendst/Tasmota/issues/12008)
- Simplified configuration for ir-full and removal of tasmota-ircustom [#12428](https://github.com/arendst/Tasmota/issues/12428)
- Refactor platformio [#12442](https://github.com/arendst/Tasmota/issues/12442)
- Allow buttons to work in AP normal mode [#12518](https://github.com/arendst/Tasmota/issues/12518)

View File

@ -247,7 +247,7 @@ typedef union {
uint32_t telegram_echo_enable : 1; // bit 2 (v9.4.0.3) - CMND_TMSTATE 4/5 - Enable Telegram echo
uint32_t range_extender : 1; // bit 3 (v9.5.0.5) - CMND_RGXSTATE - Enable range extender
uint32_t range_extender_napt : 1; // bit 4 (v9.5.0.5) - CMND_RGXNAPT - Enable range extender NAPT
uint32_t spare05 : 1; // bit 5
uint32_t sonoff_l1_music_sync : 1; // bit 5 (v9.5.0.5) - CMND_MUSICSYNC - Enable sync to music
uint32_t spare06 : 1; // bit 6
uint32_t spare07 : 1; // bit 7
uint32_t spare08 : 1; // bit 8

View File

@ -54,7 +54,6 @@ struct SNFL1 {
uint8_t dimmer;
uint8_t power;
uint8_t old_music_sync = 0;
uint8_t music_sync = 0;
uint8_t sensitive;
uint8_t speed;
} Snfl1;
@ -249,10 +248,10 @@ bool SnfL1SetChannels(void) {
Snfl1.color[i] = scale_col[i];
}
}
if (!power_changed && !dimmer_changed && !color_changed && (Snfl1.old_music_sync == Snfl1.music_sync)) { return true; }
if (!power_changed && !dimmer_changed && !color_changed && (Snfl1.old_music_sync == Settings->sbflag1.sonoff_l1_music_sync)) { return true; }
uint32_t mode = SONOFF_L1_MODE_COLORFUL;
if (Snfl1.music_sync) {
if (Settings->sbflag1.sonoff_l1_music_sync) {
mode = SONOFF_L1_MODE_SYNC_TO_MUSIC;
}
@ -291,7 +290,6 @@ bool SnfL1ModuleSelected(void) {
Snfl1.power = !Light.power;
Snfl1.dimmer = !light_state.getDimmer();
Snfl1.music_sync = 0;
Snfl1.sensitive = 5; // 1..10
Snfl1.speed = 50; // 1..100
@ -309,13 +307,13 @@ void CmndMusicSync(void) {
// Format is L1MusicSync on/off/toggle, sensitivity, speed
// sensitivity 1..10, speed 1..100
if (XdrvMailbox.data_len > 0) {
Snfl1.old_music_sync = Snfl1.music_sync;
Snfl1.old_music_sync = Settings->sbflag1.sonoff_l1_music_sync;
uint32_t parm[3] = { 0 };
ParseParameters(3, parm);
if (2 == parm[0]) {
Snfl1.music_sync ^= 1; // Toggle
Settings->sbflag1.sonoff_l1_music_sync ^= 1; // Toggle
} else {
Snfl1.music_sync = parm[0] & 1; // On or Off
Settings->sbflag1.sonoff_l1_music_sync = parm[0] & 1; // On or Off
}
if ((parm[1] > 0) && (parm[1] < 11)) {
Snfl1.sensitive = parm[1]; // 1..10
@ -326,7 +324,7 @@ void CmndMusicSync(void) {
SnfL1SetChannels();
}
Response_P(PSTR("{\"%s\":{\"Mode\":\"%s\",\"Sensitive\":%d,\"Speed\":%d}}"),
XdrvMailbox.command, GetStateText(Snfl1.music_sync), Snfl1.sensitive, Snfl1.speed);
XdrvMailbox.command, GetStateText(Settings->sbflag1.sonoff_l1_music_sync), Snfl1.sensitive, Snfl1.speed);
}
/*********************************************************************************************\