about summary refs log tree commit diff
diff options
context:
space:
mode:
authorZach DeCook <zachdecook@librem.one>2023-03-11 15:56:50 -0500
committerJared DeCook <jareddecook@Jareds-MacBook-Pro.local>2023-03-11 16:02:20 -0500
commit478a13aa41474f9b611f3e6f41235887bc2ecc0f (patch)
tree947071d2e163bdc12c2fb60aa2a9e3ef3624d81a
parent144f801ebe9f1e293fc8a43ff5698791f2e6a832 (diff)
downloadHexBoard-478a13aa41474f9b611f3e6f41235887bc2ecc0f.tar.gz
sequencer: Check for out of bounds on lane
-rw-r--r--HexBoard_V1.1.ino5
1 files changed, 3 insertions, 2 deletions
diff --git a/HexBoard_V1.1.ino b/HexBoard_V1.1.ino
index fb43375..4c438d3 100644
--- a/HexBoard_V1.1.ino
+++ b/HexBoard_V1.1.ino
@@ -205,7 +205,8 @@ typedef struct {
   bool bank = 0;
   int state = 0;// TODO: change to enum: normal, mute, solo, mute&solo
 } Lane;
-Lane lanes[7];
+#define NLANES 7
+Lane lanes[NLANES];
 
 bool sequencerMode=1;
 
@@ -629,7 +630,7 @@ void sequencerToggleThingies() {
       if (activeButtons[i]){
         int stripN = i / 20;
         int step = map2step(i % 20);
-        if (step >= 0){
+        if (step >= 0 && stripN < NLANES){
           int offset = lanes[stripN].bank*16;
           lanes[stripN].steps[step+offset] = !lanes[stripN].steps[step+offset];
           int color = 0;