15
15
* JSON API (De)serialization
16
16
*/
17
17
18
- namespace {
19
- bool differs (const Segment& segment, const std::array<byte, sizeof (Segment)>& backup) {
20
- const Segment& segmentBackup = *reinterpret_cast <const Segment*>(backup.data ());
21
- if (segment.start != segmentBackup.start ) return true ;
22
- if (segment.stop != segmentBackup.stop ) return true ;
23
- if (segment.offset != segmentBackup.offset ) return true ;
24
- if (segment.grouping != segmentBackup.grouping ) return true ;
25
- if (segment.spacing != segmentBackup.spacing ) return true ;
26
- if (segment.opacity != segmentBackup.opacity ) return true ;
27
- if (segment.mode != segmentBackup.mode ) return true ;
28
- if (segment.speed != segmentBackup.speed ) return true ;
29
- if (segment.intensity != segmentBackup.intensity ) return true ;
30
- if (segment.palette != segmentBackup.palette ) return true ;
31
- if (segment.custom1 != segmentBackup.custom1 ) return true ;
32
- if (segment.custom2 != segmentBackup.custom2 ) return true ;
33
- if (segment.custom3 != segmentBackup.custom3 ) return true ;
34
- if (segment.startY != segmentBackup.startY ) return true ;
35
- if (segment.stopY != segmentBackup.stopY ) return true ;
36
-
37
- // bit pattern: (msb first)
38
- // set:2, sound:2, mapping:3, transposed, mirrorY, reverseY, [reset,] paused, mirrored, on, reverse, [selected]
39
- if ((segment.options & 0b1111111111011110U ) != (segmentBackup.options & 0b1111111111011110U )) return true ;
40
- for (unsigned i = 0 ; i < NUM_COLORS; i++) if (segment.colors [i] != segmentBackup.colors [i]) return true ;
41
-
42
- return false ;
43
- }
44
- }
45
-
46
18
bool deserializeSegment (JsonObject elem, byte it, byte presetId)
47
19
{
48
20
byte id = elem[" id" ] | it;
@@ -61,10 +33,6 @@ bool deserializeSegment(JsonObject elem, byte it, byte presetId)
61
33
62
34
// DEBUG_PRINTLN(F("-- JSON deserialize segment."));
63
35
Segment& seg = strip.getSegment (id);
64
- // DEBUG_PRINTF_P(PSTR("-- Original segment: %p (%p)\n"), &seg, seg.data);
65
- alignas (Segment) std::array<byte, sizeof (Segment)> segmentBackup; // make a backup so we can tell if something changed (voiding copy constructor)
66
- memcpy (segmentBackup.data (), &seg, sizeof (Segment));
67
- // DEBUG_PRINTF_P(PSTR("-- Duplicate segment: %p (%p)\n"), &prev, prev.data);
68
36
69
37
int start = elem[" start" ] | seg.start ;
70
38
if (stop < 0 ) {
@@ -321,8 +289,6 @@ bool deserializeSegment(JsonObject elem, byte it, byte presetId)
321
289
seg.map1D2D = oldMap1D2D; // restore mapping
322
290
strip.trigger (); // force segment update
323
291
}
324
- // send UDP/WS if segment options changed (except selection; will also deselect current preset)
325
- stateChanged = stateChanged || differs (seg, segmentBackup);
326
292
327
293
return true ;
328
294
}
0 commit comments