Deluge Firmware 1.3.0
Build date: 2025.04.16
Loading...
Searching...
No Matches
ui_timer_manager.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 "util/misc.h"
21#include <array>
22#include <cstdint>
23enum class TimerName {
24 DISPLAY,
25 MIDI_LEARN_FLASH,
26 DEFAULT_ROOT_NOTE,
27 TAP_TEMPO_SWITCH_OFF,
28 PLAY_ENABLE_FLASH,
29 LED_BLINK,
30 LED_BLINK_TYPE_1,
31 LEVEL_INDICATOR_BLINK,
32 SHORTCUT_BLINK,
33 MATRIX_DRIVER,
34 UI_SPECIFIC,
35 BACK_MENU_EXIT,
36 DISPLAY_AUTOMATION,
37 READ_INPUTS,
38 BATT_LED_BLINK,
39 GRAPHICS_ROUTINE,
40 OLED_LOW_LEVEL,
41 OLED_CONSOLE,
42 OLED_SCROLLING_AND_BLINKING,
43 SYSEX_DISPLAY,
44 METER_INDICATOR_BLINK,
45 SEND_MIDI_FEEDBACK_FOR_AUTOMATION,
46 INTERPOLATION_SHORTCUT_BLINK,
47 PAD_SELECTION_SHORTCUT_BLINK,
48 NOTE_ROW_BLINK,
49 LOADING_ANIMATION,
50 SELECTED_CLIP_PULSE,
52 NUM_TIMERS
53};
54
55struct Timer {
56 bool active;
57 uint32_t triggerTime;
58};
59
60class UITimerManager {
61public:
62 UITimerManager();
63
64 void routine();
65 void setTimer(TimerName which, int32_t ms);
66 void setTimerSamples(TimerName which, int32_t samples);
67 void unsetTimer(TimerName which);
68
69 bool isTimerSet(TimerName which);
70 void setTimerByOtherTimer(TimerName which, TimerName fromTimer);
71
72private:
73 uint32_t timeNextEvent;
74 std::array<Timer, util::to_underlying(TimerName::NUM_TIMERS)> timers_;
75 void workOutNextEventTime();
76
77public:
78 [[gnu::always_inline]] inline Timer& getTimer(TimerName which) { return timers_[util::to_underlying(which)]; }
79};
80
81extern UITimerManager uiTimerManager;
Definition ui_timer_manager.h:60
Definition ui_timer_manager.h:55