Skip to content
Permalink
Browse files

set P.I and PN.I to less than pattern length if too long

  • Loading branch information
samdoshi committed Jun 2, 2017
1 parent 02a02c6 commit fc11f6ca8e10a8df1f422868a91673b297c081e5
Showing with 4 additions and 3 deletions.
  1. +1 −0 CHANGELOG.md
  2. +3 −3 src/ops/patterns.c
@@ -22,6 +22,7 @@
- **FIX**: divide by zero errors now explicitly return a 0 (e.g. `DIV 5 0` now returns 0 instead of -1), previously the behaviour was undefined and would crash the simulator
- **FIX**: numerous crashing bugs with text entry
- **FIX**: `i2c` bus crashes under high `M` times with external triggers
- **FIX**: `P.I` and `PN.I` no longer set values longer than allowed

## v1.4.1
- **NEW**: added Ansible remote commands `LV.CV` and `CY.CV`
@@ -295,10 +295,10 @@ static void p_i_set(scene_state_t *ss, int16_t pn, int16_t i) {
pn = normalise_pn(pn);
i = normalise_idx(ss, pn, i);
int16_t len = ss_get_pattern_len(ss, pn);
if (i < 0)
if (i < 0 || len == 0)
ss_set_pattern_idx(ss, pn, 0);
else if (i > len)
ss_set_pattern_idx(ss, pn, len);
else if (i >= len)
ss_set_pattern_idx(ss, pn, len - 1);
else
ss_set_pattern_idx(ss, pn, i);
}

0 comments on commit fc11f6c

Please sign in to comment.