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();
59 static uint32_t getMainImageGeneration() {
return mainImageGeneration; }
61 static void setupBlink(int32_t minX, int32_t width, int32_t minY, int32_t maxY,
bool shouldBlinkImmediately);
62 static void stopBlink();
64 static void sendMainImage();
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();
75 static bool isWorkingAnimationPresent();
77 static void displayWorkingAnimation(
char const* word);
79 static int32_t setupConsole(int32_t height);
80 static void drawConsoleTopLine();
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);
89 static void markChanged() {
92 D_PRINTLN(
"Fresh dirty mark");
98 void consoleTimerEvent();
99 static void scrollingAndBlinkingTimerEvent();
101 static void renderEmulated7Seg(
const std::array<uint8_t, kNumericDisplayLength>& display);
103 static oled_canvas::Canvas main;
104 static oled_canvas::Canvas popup;
105 static oled_canvas::Canvas console;
108 static uint8_t (*oledCurrentImage)[OLED_MAIN_WIDTH_PIXELS];
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;
160 void removeWorkingAnimation()
override;
161 void timerRoutine()
override;
162 void consoleText(
char const* text)
override;
163 void freezeWithError(
char const* text)
override;
167 constexpr size_t getNumBrowserAndMenuLines()
override {
return 3; }
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);
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);
179 void cancelPopup()
override { removePopup(); }
180 bool isLayerCurrentlyOnTop(NumericLayer* layer)
override {
return (!this->hasPopup()); }
181 void displayError(Error error)
override;
184 void displayLoadingAnimationText(
char const* text,
bool delayed =
false,
bool transparent =
false)
override {
185 displayWorkingAnimation(text);
187 void removeLoadingAnimation()
override { removeWorkingAnimation(); }
189 bool hasPopup()
override {
return isPopupPresent(); }
190 bool hasPopupOfType(PopupType type)
override {
return isPopupPresentOfType(type); }
193 void displayNotification(std::string_view param_title, std::optional<std::string_view> param_value)
override;
196 static uint32_t mainImageGeneration;
197 static bool needsSending;