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();
72 static bool isWorkingAnimationPresent();
74 static void displayWorkingAnimation(
char const* word);
76 static int32_t setupConsole(int32_t height);
77 static void drawConsoleTopLine();
79 static void stopScrollingAnimation();
80 static void setupSideScroller(int32_t index, std::string_view text, int32_t startX, int32_t endX, int32_t startY,
81 int32_t endY, int32_t textSpacingX, int32_t textSizeY,
bool doHighlight);
82 static void drawPermanentPopupLookingText(
char const* text);
86 static void markChanged() {
89 D_PRINTLN(
"Fresh dirty mark");
95 void consoleTimerEvent();
96 static void scrollingAndBlinkingTimerEvent();
98 static void renderEmulated7Seg(
const std::array<uint8_t, kNumericDisplayLength>& display);
100 static oled_canvas::Canvas main;
101 static oled_canvas::Canvas popup;
102 static oled_canvas::Canvas console;
105 static uint8_t (*oledCurrentImage)[OLED_MAIN_WIDTH_PIXELS];
107 static const uint8_t folderIcon[];
108 static const uint8_t waveIcon[];
109 static const uint8_t songIcon[];
110 static const uint8_t synthIcon[];
111 static const uint8_t kitIcon[];
112 static const uint8_t midiIcon[];
113 static const uint8_t midiIconPt2[];
114 static const uint8_t downArrowIcon[];
115 static const uint8_t rightArrowIcon[];
116 static const uint8_t lockIcon[];
117 static const uint8_t checkedBoxIcon[];
118 static const uint8_t uncheckedBoxIcon[];
119 static const uint8_t submenuArrowIcon[];
120 static const uint8_t submenuArrowIconBold[];
121 static const uint8_t metronomeIcon[];
122 static const Icon sineIcon;
123 static const Icon squareIcon;
124 static const Icon sawIcon;
125 static const Icon triangleIcon;
126 static const Icon sampleHoldIcon;
127 static const Icon randomWalkIcon;
128 static const Icon warblerIcon;
129 static const Icon syncTypeEvenIcon;
130 static const Icon syncTypeDottedIcon;
131 static const Icon syncTypeTripletsIcon;
132 static const Icon switcherIconOff;
133 static const Icon switcherIconOn;
134 static const Icon arpModeIconUp;
135 static const Icon arpModeIconUpDown;
136 static const Icon arpModeIconWalk;
137 static const Icon arpModeIconCustom;
138 static const Icon lockedIconBig;
139 static const Icon unlockedIconBig;
140 static const Icon diceIcon;
141 static const Icon directionIcon;
142 static const Icon knobArcIcon;
143 static const Icon infinityIcon;
144 static const Icon sampleIcon;
145 static const Icon wavetableIcon;
146 static const Icon inputIcon;
147 static const Icon micIcon;
148 static const Icon folderIconBig;
149 static const Icon loopPointIcon;
150 static const Icon sampleModeCutIcon;
151 static const Icon sampleModeOnceIcon;
152 static const Icon sampleModeLoopIcon;
153 static const Icon sampleModeStretchIcon;
154 static const Icon keyboardIcon;
155 static const Icon crossedOutKeyboardIcon;
157 void removeWorkingAnimation()
override;
158 void timerRoutine()
override;
159 void consoleText(
char const* text)
override;
160 void freezeWithError(
char const* text)
override;
164 constexpr size_t getNumBrowserAndMenuLines()
override {
return 3; }
166 void displayPopup(
char const* newText, int8_t numFlashes = 3,
bool =
false, uint8_t = 255, int32_t = 1,
167 PopupType type = PopupType::GENERAL)
override {
168 popupText(newText, !numFlashes, type);
171 void popupText(
char const* text, PopupType type = PopupType::GENERAL)
override { popupText(text,
true, type); }
172 void popupTextTemporary(
char const* text, PopupType type = PopupType::GENERAL)
override {
173 popupText(text,
false, type);
176 void cancelPopup()
override { removePopup(); }
177 bool isLayerCurrentlyOnTop(NumericLayer* layer)
override {
return (!this->hasPopup()); }
178 void displayError(Error error)
override;
181 void displayLoadingAnimationText(
char const* text,
bool delayed =
false,
bool transparent =
false)
override {
182 displayWorkingAnimation(text);
184 void removeLoadingAnimation()
override { removeWorkingAnimation(); }
186 bool hasPopup()
override {
return isPopupPresent(); }
187 bool hasPopupOfType(PopupType type)
override {
return isPopupPresentOfType(type); }
190 void displayNotification(std::string_view param_title, std::optional<std::string_view> param_value)
override;
193 static bool needsSending;