20#include "gui/l10n/language.h"
22#include "definitions_cxx.hpp"
24#include "oled_canvas/canvas.h"
28#define OLED_LOG_TIMING (0 && ENABLE_TEXT_OUTPUT)
31#include "io/debug/log.h"
34namespace deluge::hid::display {
43class OLED :
public Display {
45 OLED() : Display(DisplayType::OLED) {
46 if (l10n::chosenLanguage ==
nullptr || l10n::chosenLanguage == &l10n::built_in::seven_segment) {
47 l10n::chosenLanguage = &l10n::built_in::english;
56 static void clearMainImage();
58 static void setupBlink(int32_t minX, int32_t width, int32_t minY, int32_t maxY,
bool shouldBlinkImmediately);
59 static void stopBlink();
61 static void sendMainImage();
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();
71 static void displayWorkingAnimation(
char const* word);
73 static int32_t setupConsole(int32_t height);
74 static void drawConsoleTopLine();
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);
83 static void markChanged() {
86 D_PRINTLN(
"Fresh dirty mark");
92 void consoleTimerEvent();
93 static void scrollingAndBlinkingTimerEvent();
95 static void renderEmulated7Seg(
const std::array<uint8_t, kNumericDisplayLength>& display);
97 static oled_canvas::Canvas main;
98 static oled_canvas::Canvas popup;
99 static oled_canvas::Canvas console;
102 static uint8_t (*oledCurrentImage)[OLED_MAIN_WIDTH_PIXELS];
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;
154 void removeWorkingAnimation()
override;
155 void timerRoutine()
override;
156 void consoleText(
char const* text)
override;
157 void freezeWithError(
char const* text)
override;
161 constexpr size_t getNumBrowserAndMenuLines()
override {
return 3; }
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);
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);
173 void cancelPopup()
override { removePopup(); }
174 bool isLayerCurrentlyOnTop(NumericLayer* layer)
override {
return (!this->hasPopup()); }
175 void displayError(Error error)
override;
178 void displayLoadingAnimationText(
char const* text,
bool delayed =
false,
bool transparent =
false)
override {
179 displayWorkingAnimation(text);
181 void removeLoadingAnimation()
override { removeWorkingAnimation(); }
183 bool hasPopup()
override {
return isPopupPresent(); }
184 bool hasPopupOfType(PopupType type)
override {
return isPopupPresentOfType(type); }
187 void displayNotification(std::string_view param_title, std::optional<std::string_view> param_value)
override;
190 static bool needsSending;