Deluge Firmware 1.3.0
Build date: 2026.11.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
59 static uint32_t getMainImageGeneration() { return mainImageGeneration; }
60
61 static void setupBlink(int32_t minX, int32_t width, int32_t minY, int32_t maxY, bool shouldBlinkImmediately);
62 static void stopBlink();
63
64 static void sendMainImage();
65
66 static void setupPopup(PopupType type, int32_t width, int32_t height, std::optional<int32_t> startX = std::nullopt,
67 std::optional<int32_t> startY = std::nullopt);
68 static void removePopup();
69 static void popupText(char const* text, bool persistent = false, PopupType type = PopupType::GENERAL);
70 static bool isPopupPresent();
71 static bool isPopupPresentOfType(PopupType type = PopupType::GENERAL);
72 static bool isPermanentPopupPresent();
73
75 static bool isWorkingAnimationPresent();
76
77 static void displayWorkingAnimation(char const* word);
78
79 static int32_t setupConsole(int32_t height);
80 static void drawConsoleTopLine();
81
82 static void stopScrollingAnimation();
83 static void setupSideScroller(int32_t index, std::string_view text, int32_t startX, int32_t endX, int32_t startY,
84 int32_t endY, int32_t textSpacingX, int32_t textSizeY, bool doHighlight);
85 static void drawPermanentPopupLookingText(char const* text);
86
89 static void markChanged() {
90#if OLED_LOG_TIMING
91 if (!needsSending) {
92 D_PRINTLN("Fresh dirty mark");
93 }
94#endif
95 needsSending = true;
96 }
97
98 void consoleTimerEvent();
99 static void scrollingAndBlinkingTimerEvent();
100
101 static void renderEmulated7Seg(const std::array<uint8_t, kNumericDisplayLength>& display);
102
103 static oled_canvas::Canvas main;
104 static oled_canvas::Canvas popup;
105 static oled_canvas::Canvas console;
106
107 // pointer to one of the three above (the one currently displayed)
108 static uint8_t (*oledCurrentImage)[OLED_MAIN_WIDTH_PIXELS];
109
110 static const uint8_t folderIcon[];
111 static const uint8_t waveIcon[];
112 static const uint8_t songIcon[];
113 static const uint8_t synthIcon[];
114 static const uint8_t kitIcon[];
115 static const uint8_t midiIcon[];
116 static const uint8_t midiIconPt2[];
117 static const uint8_t downArrowIcon[];
118 static const uint8_t rightArrowIcon[];
119 static const uint8_t lockIcon[];
120 static const uint8_t checkedBoxIcon[];
121 static const uint8_t uncheckedBoxIcon[];
122 static const uint8_t submenuArrowIcon[];
123 static const uint8_t submenuArrowIconBold[];
124 static const uint8_t metronomeIcon[];
125 static const Icon sineIcon;
126 static const Icon squareIcon;
127 static const Icon sawIcon;
128 static const Icon triangleIcon;
129 static const Icon sampleHoldIcon;
130 static const Icon randomWalkIcon;
131 static const Icon warblerIcon;
132 static const Icon syncTypeEvenIcon;
133 static const Icon syncTypeDottedIcon;
134 static const Icon syncTypeTripletsIcon;
135 static const Icon switcherIconOff;
136 static const Icon switcherIconOn;
137 static const Icon arpModeIconUp;
138 static const Icon arpModeIconUpDown;
139 static const Icon arpModeIconWalk;
140 static const Icon arpModeIconCustom;
141 static const Icon lockedIconBig;
142 static const Icon unlockedIconBig;
143 static const Icon diceIcon;
144 static const Icon directionIcon;
145 static const Icon knobArcIcon;
146 static const Icon infinityIcon;
147 static const Icon sampleIcon;
148 static const Icon wavetableIcon;
149 static const Icon inputIcon;
150 static const Icon micIcon;
151 static const Icon folderIconBig;
152 static const Icon loopPointIcon;
153 static const Icon sampleModeCutIcon;
154 static const Icon sampleModeOnceIcon;
155 static const Icon sampleModeLoopIcon;
156 static const Icon sampleModeStretchIcon;
157 static const Icon keyboardIcon;
158 static const Icon crossedOutKeyboardIcon;
159
160 void removeWorkingAnimation() override;
161 void timerRoutine() override;
162 void consoleText(char const* text) override;
163 void freezeWithError(char const* text) override;
164
165 //************************ Display Interface stuff ***************************/
166
167 constexpr size_t getNumBrowserAndMenuLines() override { return 3; }
168
169 void displayPopup(char const* newText, int8_t numFlashes = 3, bool = false, uint8_t = 255, int32_t = 1,
170 PopupType type = PopupType::GENERAL) override {
171 popupText(newText, !numFlashes, type);
172 }
173
174 void popupText(char const* text, PopupType type = PopupType::GENERAL) override { popupText(text, true, type); }
175 void popupTextTemporary(char const* text, PopupType type = PopupType::GENERAL) override {
176 popupText(text, false, type);
177 }
178
179 void cancelPopup() override { removePopup(); }
180 bool isLayerCurrentlyOnTop(NumericLayer* layer) override { return (!this->hasPopup()); }
181 void displayError(Error error) override;
182
183 // Loading animations
184 void displayLoadingAnimationText(char const* text, bool delayed = false, bool transparent = false) override {
185 displayWorkingAnimation(text);
186 }
187 void removeLoadingAnimation() override { removeWorkingAnimation(); }
188
189 bool hasPopup() override { return isPopupPresent(); }
190 bool hasPopupOfType(PopupType type) override { return isPopupPresentOfType(type); }
191
192 // Horizontal menus
193 void displayNotification(std::string_view param_title, std::optional<std::string_view> param_value) override;
194
195private:
196 static uint32_t mainImageGeneration;
197 static bool needsSending;
198};
199
200} // namespace deluge::hid::display
201#endif