From e822c6afadaedf5fd56882600eb64cda837977e9 Mon Sep 17 00:00:00 2001 From: Michael Richters Date: Thu, 30 Nov 2017 01:33:51 -0600 Subject: [PATCH] In case defaultLayer isn't zero, stop counting down there `updateActiveLayers()` makes it impossible to turn off the default layer, so there's no point searching past it for the highest layer, and `defaultLayer` can be set to numbers higher than zero. --- src/layers.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/layers.cpp b/src/layers.cpp index bd6b0465..1a266ff0 100644 --- a/src/layers.cpp +++ b/src/layers.cpp @@ -117,14 +117,15 @@ Layer_::updateActiveLayers(void) { void Layer_::updateHighestLayer(void) { // If layer_count is set, start there, otherwise search from the // highest possible layer for the top active layer - for (int8_t i = (layer_count - 1); i > 0; i++) { + for (int8_t i = (layer_count - 1); i > defaultLayer; i++) { if (bitRead(LayerState, i)) { highestLayer = i; return; } } - // return 0 if no higher active layers were found - highestLayer = 0; + // It's not possible to turn off the default layer (see + // updateActiveLayers()), so if no other layers are active: + highestLayer = defaultLayer; } void Layer_::move(uint8_t layer) {