Deluge Firmware 1.3.0
Build date: 2025.04.16
Loading...
Searching...
No Matches
indicator_leds.h
1/*
2 * Copyright © 2014-2023 Synthstrom Audible Limited
3 *
4 * This file is part of The Synthstrom Audible Deluge Firmware.
5 *
6 * The Synthstrom Audible Deluge Firmware is free software: you can redistribute it and/or modify it under the
7 * terms of the GNU General Public License as published by the Free Software Foundation,
8 * either version 3 of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
11 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 * See the GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License along with this program.
15 * If not, see <https://www.gnu.org/licenses/>.
16 */
17
18#pragma once
19
20#include "definitions_cxx.hpp"
21#include <cstdint>
22
23constexpr size_t numLedBlinkers = 6;
24
25namespace indicator_leds {
26
27constexpr uint8_t fromCartesian(Cartesian c) {
28 return c.x + c.y * NUM_LED_COLS;
29}
30
31constexpr uint8_t fromXY(int32_t x, int32_t y) {
32 return x + y * NUM_LED_COLS;
33}
34
35// clang-format off
36enum class LED : uint8_t {
37 AFFECT_ENTIRE = fromCartesian(affectEntireButtonCoord),
38 SESSION_VIEW = fromCartesian(sessionViewButtonCoord),
39 CLIP_VIEW = fromCartesian(clipViewButtonCoord),
40 SYNTH = fromCartesian(synthButtonCoord),
41 KIT = fromCartesian(kitButtonCoord),
42 MIDI = fromCartesian(midiButtonCoord),
43 CV = fromCartesian(cvButtonCoord),
44 KEYBOARD = fromCartesian(keyboardButtonCoord),
45 SCALE_MODE = fromCartesian(scaleModeButtonCoord),
46 CROSS_SCREEN_EDIT = fromCartesian(crossScreenEditButtonCoord),
47 BACK = fromCartesian(backButtonCoord),
48 LOAD = fromCartesian(loadButtonCoord),
49 SAVE = fromCartesian(saveButtonCoord),
50 LEARN = fromCartesian(learnButtonCoord),
51 TAP_TEMPO = fromCartesian(tapTempoButtonCoord),
52 SYNC_SCALING = fromCartesian(syncScalingButtonCoord),
53 TRIPLETS = fromCartesian(tripletsButtonCoord),
54 PLAY = fromCartesian(playButtonCoord),
55 RECORD = fromCartesian(recordButtonCoord),
56 SHIFT = fromCartesian(shiftButtonCoord),
57
58 MOD_0 = fromXY(1,0),
59 MOD_1 = fromXY(1,1),
60 MOD_2 = fromXY(1,2),
61 MOD_3 = fromXY(1,3),
62 MOD_4 = fromXY(2,0),
63 MOD_5 = fromXY(2,1),
64 MOD_6 = fromXY(2,2),
65 MOD_7 = fromXY(2,3),
66};
67// clang-format on
68
69const LED modLed[8] = {LED::MOD_0, LED::MOD_1, LED::MOD_2, LED::MOD_3, LED::MOD_4, LED::MOD_5, LED::MOD_6, LED::MOD_7};
70
71struct LedBlinker {
72 LED led;
73 bool active;
74 uint8_t blinksLeft;
75 bool returnToState;
76 uint8_t blinkingType;
77};
78
79extern bool ledBlinkState[];
80
81void setLedState(LED led, bool newState, bool allowContinuedBlinking = false);
82void blinkLed(LED led, uint8_t numBlinks = 255, uint8_t blinkingType = 0, bool initialState = true);
83void ledBlinkTimeout(uint8_t blinkingType, bool forceRestart = false, bool resetToState = true);
84void indicateAlertOnLed(LED led);
85void setMeterLevel(uint8_t whichKnob, uint8_t level);
86void setKnobIndicatorLevel(uint8_t whichKnob, uint8_t level, bool isBipolar = false);
87void actuallySetKnobIndicatorLevel(uint8_t whichKnob, uint8_t level, bool isBipolar = false);
88void clearKnobIndicatorLevels();
89void blinkKnobIndicator(int32_t whichKnob, bool isBipolar);
90void stopBlinkingKnobIndicator(int32_t whichKnob);
91void blinkKnobIndicatorLevelTimeout();
92uint8_t getLedBlinkerIndex(LED led);
93void stopLedBlinking(LED led, bool resetState = false);
94bool updateBlinkingLedStates(uint8_t blinkingType);
95bool isKnobIndicatorBlinking(int32_t whichKnob);
96int32_t getBipolarBrightnessOutputValue(int32_t whichIndicator, int32_t numIndicatorLedsFullyOn, int32_t brightness,
97 int32_t bipolarLevel);
98int32_t getBrightnessOutputValue(int32_t whichIndicator, int32_t numIndicatorLedsFullyOn, int32_t brightness);
99
100} // namespace indicator_leds
101
102using IndicatorLED = indicator_leds::LED;
Definition indicator_leds.h:71