Deluge Firmware 1.3.0
Build date: 2026.03.02
Loading...
Searching...
No Matches
oled.h
1/*
2 * Copyright © 2020-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 "gui/l10n/language.h"
21#ifdef __cplusplus
22#include "definitions_cxx.hpp"
23#include "display.h"
24#include "oled_canvas/canvas.h"
25#include <sys/types.h>
26#include <vector>
27
28#define OLED_LOG_TIMING (0 && ENABLE_TEXT_OUTPUT)
29
30#if OLED_LOG_TIMING
31#include "io/debug/log.h"
32#endif
33
34namespace deluge::hid::display {
35
36struct Icon {
37 const uint8_t* data;
38 uint8_t width;
39 uint8_t height;
40 uint8_t numBytesTall;
41};
42
43class OLED : public Display {
44public:
45 OLED() : Display(DisplayType::OLED) {
46 if (l10n::chosenLanguage == nullptr || l10n::chosenLanguage == &l10n::built_in::seven_segment) {
47 l10n::chosenLanguage = &l10n::built_in::english;
48 }
49 }
50
56 static void clearMainImage();
57
58 static void setupBlink(int32_t minX, int32_t width, int32_t minY, int32_t maxY, bool shouldBlinkImmediately);
59 static void stopBlink();
60
61 static void sendMainImage();
62
63 static void setupPopup(PopupType type, int32_t width, int32_t height, std::optional<int32_t> startX = std::nullopt,
64 std::optional<int32_t> startY = std::nullopt);
65 static void removePopup();
66 static void popupText(char const* text, bool persistent = false, PopupType type = PopupType::GENERAL);
67 static bool isPopupPresent();
68 static bool isPopupPresentOfType(PopupType type = PopupType::GENERAL);
69 static bool isPermanentPopupPresent();
70
71 static void displayWorkingAnimation(char const* word);
72
73 static int32_t setupConsole(int32_t height);
74 static void drawConsoleTopLine();
75
76 static void stopScrollingAnimation();
77 static void setupSideScroller(int32_t index, std::string_view text, int32_t startX, int32_t endX, int32_t startY,
78 int32_t endY, int32_t textSpacingX, int32_t textSizeY, bool doHighlight);
79 static void drawPermanentPopupLookingText(char const* text);
80
83 static void markChanged() {
84#if OLED_LOG_TIMING
85 if (!needsSending) {
86 D_PRINTLN("Fresh dirty mark");
87 }
88#endif
89 needsSending = true;
90 }
91
92 void consoleTimerEvent();
93 static void scrollingAndBlinkingTimerEvent();
94
95 static void renderEmulated7Seg(const std::array<uint8_t, kNumericDisplayLength>& display);
96
97 static oled_canvas::Canvas main;
98 static oled_canvas::Canvas popup;
99 static oled_canvas::Canvas console;
100
101 // pointer to one of the three above (the one currently displayed)
102 static uint8_t (*oledCurrentImage)[OLED_MAIN_WIDTH_PIXELS];
103
104 static const uint8_t folderIcon[];
105 static const uint8_t waveIcon[];
106 static const uint8_t songIcon[];
107 static const uint8_t synthIcon[];
108 static const uint8_t kitIcon[];
109 static const uint8_t midiIcon[];
110 static const uint8_t midiIconPt2[];
111 static const uint8_t downArrowIcon[];
112 static const uint8_t rightArrowIcon[];
113 static const uint8_t lockIcon[];
114 static const uint8_t checkedBoxIcon[];
115 static const uint8_t uncheckedBoxIcon[];
116 static const uint8_t submenuArrowIcon[];
117 static const uint8_t submenuArrowIconBold[];
118 static const uint8_t metronomeIcon[];
119 static const Icon sineIcon;
120 static const Icon squareIcon;
121 static const Icon sawIcon;
122 static const Icon triangleIcon;
123 static const Icon sampleHoldIcon;
124 static const Icon randomWalkIcon;
125 static const Icon warblerIcon;
126 static const Icon syncTypeEvenIcon;
127 static const Icon syncTypeDottedIcon;
128 static const Icon syncTypeTripletsIcon;
129 static const Icon switcherIconOff;
130 static const Icon switcherIconOn;
131 static const Icon arpModeIconUp;
132 static const Icon arpModeIconUpDown;
133 static const Icon arpModeIconWalk;
134 static const Icon arpModeIconCustom;
135 static const Icon lockedIconBig;
136 static const Icon unlockedIconBig;
137 static const Icon diceIcon;
138 static const Icon directionIcon;
139 static const Icon knobArcIcon;
140 static const Icon infinityIcon;
141 static const Icon sampleIcon;
142 static const Icon wavetableIcon;
143 static const Icon inputIcon;
144 static const Icon micIcon;
145 static const Icon folderIconBig;
146 static const Icon loopPointIcon;
147 static const Icon sampleModeCutIcon;
148 static const Icon sampleModeOnceIcon;
149 static const Icon sampleModeLoopIcon;
150 static const Icon sampleModeStretchIcon;
151 static const Icon keyboardIcon;
152 static const Icon crossedOutKeyboardIcon;
153
154 void removeWorkingAnimation() override;
155 void timerRoutine() override;
156 void consoleText(char const* text) override;
157 void freezeWithError(char const* text) override;
158
159 //************************ Display Interface stuff ***************************/
160
161 constexpr size_t getNumBrowserAndMenuLines() override { return 3; }
162
163 void displayPopup(char const* newText, int8_t numFlashes = 3, bool = false, uint8_t = 255, int32_t = 1,
164 PopupType type = PopupType::GENERAL) override {
165 popupText(newText, !numFlashes, type);
166 }
167
168 void popupText(char const* text, PopupType type = PopupType::GENERAL) override { popupText(text, true, type); }
169 void popupTextTemporary(char const* text, PopupType type = PopupType::GENERAL) override {
170 popupText(text, false, type);
171 }
172
173 void cancelPopup() override { removePopup(); }
174 bool isLayerCurrentlyOnTop(NumericLayer* layer) override { return (!this->hasPopup()); }
175 void displayError(Error error) override;
176
177 // Loading animations
178 void displayLoadingAnimationText(char const* text, bool delayed = false, bool transparent = false) override {
179 displayWorkingAnimation(text);
180 }
181 void removeLoadingAnimation() override { removeWorkingAnimation(); }
182
183 bool hasPopup() override { return isPopupPresent(); }
184 bool hasPopupOfType(PopupType type) override { return isPopupPresentOfType(type); }
185
186 // Horizontal menus
187 void displayNotification(std::string_view param_title, std::optional<std::string_view> param_value) override;
188
189private:
190 static bool needsSending;
191};
192
193} // namespace deluge::hid::display
194#endif