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