Deluge Firmware 1.3.0
Build date: 2025.04.16
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
27#define OLED_LOG_TIMING (0 && ENABLE_TEXT_OUTPUT)
28
29#if OLED_LOG_TIMING
30#include "io/debug/log.h"
31#endif
32
33namespace deluge::hid::display {
34class OLED : public Display {
35public:
36 OLED() : Display(DisplayType::OLED) {
37 if (l10n::chosenLanguage == nullptr || l10n::chosenLanguage == &l10n::built_in::seven_segment) {
38 l10n::chosenLanguage = &l10n::built_in::english;
39 }
40 }
41
47 static void clearMainImage();
48
49 static void setupBlink(int32_t minX, int32_t width, int32_t minY, int32_t maxY, bool shouldBlinkImmediately);
50 static void stopBlink();
51
52 static void sendMainImage();
53
54 static void setupPopup(int32_t width, int32_t height);
55 static void removePopup();
56 static void popupText(std::string_view text, bool persistent = false, PopupType type = PopupType::GENERAL);
57 static bool isPopupPresent();
58 static bool isPopupPresentOfType(PopupType type = PopupType::GENERAL);
59 static bool isPermanentPopupPresent();
60
61 static void displayWorkingAnimation(std::string_view word);
62
63 static int32_t setupConsole(int32_t height);
64 static void drawConsoleTopLine();
65
66 static void stopScrollingAnimation();
67 static void setupSideScroller(int32_t index, std::string_view text, int32_t startX, int32_t endX, int32_t startY,
68 int32_t endY, int32_t textSpacingX, int32_t textSizeY, bool doHighlight);
69 static void drawPermanentPopupLookingText(std::string_view);
70
73 static void markChanged() {
74#if OLED_LOG_TIMING
75 if (!needsSending) {
76 D_PRINTLN("Fresh dirty mark");
77 }
78#endif
79 needsSending = true;
80 }
81
82 void consoleTimerEvent();
83 static void scrollingAndBlinkingTimerEvent();
84
85 static void renderEmulated7Seg(const std::array<uint8_t, kNumericDisplayLength>& display);
86
87 static oled_canvas::Canvas main;
88 static oled_canvas::Canvas popup;
89 static oled_canvas::Canvas console;
90
91 // pointer to one of the three above (the one currently displayed)
92 static uint8_t (*oledCurrentImage)[OLED_MAIN_WIDTH_PIXELS];
93
94 static const uint8_t folderIcon[];
95 static const uint8_t waveIcon[];
96 static const uint8_t songIcon[];
97 static const uint8_t synthIcon[];
98 static const uint8_t kitIcon[];
99 static const uint8_t midiIcon[];
100 static const uint8_t midiIconPt2[];
101 static const uint8_t downArrowIcon[];
102 static const uint8_t rightArrowIcon[];
103 static const uint8_t lockIcon[];
104 static const uint8_t checkedBoxIcon[];
105 static const uint8_t uncheckedBoxIcon[];
106 static const uint8_t submenuArrowIcon[];
107 static const uint8_t metronomeIcon[];
108
109 void removeWorkingAnimation() override;
110 void timerRoutine() override;
111 void consoleText(std::string_view text) override;
112 void freezeWithError(std::string_view) override;
113
114 //************************ Display Interface stuff ***************************/
115
116 constexpr size_t getNumBrowserAndMenuLines() override { return 3; }
117
118 void displayPopup(std::string_view newText, int8_t numFlashes = 3, bool = false, uint8_t = 255, int32_t = 1,
119 PopupType type = PopupType::GENERAL) override {
120 popupText(newText, !numFlashes, type);
121 }
122
123 void popupText(std::string_view text, PopupType type = PopupType::GENERAL) override { popupText(text, true, type); }
124 void popupTextTemporary(std::string_view text, PopupType type = PopupType::GENERAL) override {
125 popupText(text, false, type);
126 }
127
128 void cancelPopup() override { removePopup(); }
129 bool isLayerCurrentlyOnTop(NumericLayer* layer) override { return (!this->hasPopup()); }
130 void displayError(Error error) override;
131
132 // Loading animations
133 void displayLoadingAnimationText(std::string_view text, bool delayed = false, bool transparent = false) override {
134 displayWorkingAnimation(text);
135 }
136 void removeLoadingAnimation() override { removeWorkingAnimation(); }
137
138 bool hasPopup() override { return isPopupPresent(); }
139 bool hasPopupOfType(PopupType type) override { return isPopupPresentOfType(type); }
140
141private:
142 static bool needsSending;
143};
144
145} // namespace deluge::hid::display
146#endif