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.
pull/254/head
Michael Richters 7 years ago
parent 00df66d30a
commit e822c6afad

@ -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) {

Loading…
Cancel
Save