From 2e25fc1e0360530446de35eb595a8f157865aa95 Mon Sep 17 00:00:00 2001 From: chillfactor032 <68230787+chillfactor032@users.noreply.github.com> Date: Sun, 2 Jun 2024 20:08:30 -0500 Subject: [PATCH] Support for array of seg and velocity state json can now support array of segments and velocity --- usermods/FlashEffect/flash_effect.h | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/usermods/FlashEffect/flash_effect.h b/usermods/FlashEffect/flash_effect.h index cb4841cf40..d7428a962a 100644 --- a/usermods/FlashEffect/flash_effect.h +++ b/usermods/FlashEffect/flash_effect.h @@ -22,6 +22,7 @@ bool flash_enable = true; struct FlashData { uint32_t start_ms; + uint8_t velocity; bool start_requested; }; @@ -102,13 +103,22 @@ struct FlashEffect : Usermod { } JsonObject flash = root["flash"]; if(flash.isNull()) return; - auto seg_obj = flash["seg_id"]; - if(seg_obj.isNull()) return; - uint16_t seg_id = seg_obj; - if (seg_id >= 256) return; - flash_data[seg_id].start_ms = millis(); - flash_data[seg_id].start_requested = true; - Serial.printf("flash_effect seg_id=%d\n", seg_id); + uint8_t velocity = 64; + if(!flash["vel"].isNull()){ + velocity = flash["vel"]; + } + JsonArray seg_arr = flash["seg"]; + if(seg_arr.isNull()) return; + uint8_t seg_id; + for(uint8_t i = 0; i < seg_arr.size(); i++){ + seg_id = flash["seg"][i]; + if(seg_id>=256) continue; + flash_data[seg_id].start_ms = millis(); + flash_data[seg_id].velocity = velocity; + flash_data[seg_id].start_requested = true; + Serial.printf("flash_effect seg_id=%d vel=%d\n", seg_id, velocity); + } + //Serial.printf("flash_effect seg_id=%d\n", seg_id); } /*