Deluge Firmware 1.3.0
Build date: 2026.07.07
Loading...
Searching...
No Matches
display.h
1#pragma once
2#include "definitions_cxx.hpp"
3#include "util/string.h"
4#include <array>
5#include <optional>
6#include <string_view>
7#include <vector>
8
9extern "C" {
10#include "util/cfunctions.h"
11}
12
13class NumericLayer;
15
16enum class PopupType {
17 NONE,
19 GENERAL,
21 LOADING,
23 PROBABILITY,
25 ITERANCE,
27 FILL,
29 SWING,
31 TEMPO,
33 QUANTIZE,
35 THRESHOLD_RECORDING_MODE,
37 NOTIFICATION,
38 // Note: Add here more popup types
39};
40
41namespace deluge::hid {
42
43enum struct DisplayType { OLED, SEVENSEG };
44
45class Display {
46public:
47 Display(DisplayType displayType) : displayType(displayType) {}
48
49 virtual ~Display() = default;
50
51 constexpr virtual size_t getNumBrowserAndMenuLines() = 0;
52
53 virtual void setText(std::string_view newText, bool alignRight = false, uint8_t drawDot = 255, bool doBlink = false,
54 uint8_t* newBlinkMask = nullptr, bool blinkImmediately = false, bool shouldBlinkFast = false,
55 int32_t scrollPos = 0, uint8_t* blinkAddition = nullptr,
56 bool justReplaceBottomLayer = false) {};
57
58 virtual void displayPopup(char const* newText, int8_t numFlashes = 3, bool alignRight = false,
59 uint8_t drawDot = 255, int32_t blinkSpeed = 1, PopupType type = PopupType::GENERAL) = 0;
60
61 virtual void displayPopup(uint8_t val, int8_t numFlashes = 3, bool alignRight = false, uint8_t drawDot = 255,
62 int32_t blinkSpeed = 1, PopupType type = PopupType::GENERAL) {
63 char valStr[4] = {0};
64 intToString(val, valStr, 1);
65 displayPopup(valStr, numFlashes, alignRight, drawDot, blinkSpeed, type);
66 }
67
68 virtual void displayPopup(char const* shortLong[2], int8_t numFlashes = 3, bool alignRight = false,
69 uint8_t drawDot = 255, int32_t blinkSpeed = 1, PopupType type = PopupType::GENERAL) {
70 displayPopup(have7SEG() ? shortLong[0] : shortLong[1], numFlashes, alignRight, drawDot, blinkSpeed, type);
71 }
72
73 virtual void popupText(char const* text, PopupType type = PopupType::GENERAL) = 0;
74 virtual void popupTextTemporary(char const* text, PopupType type = PopupType::GENERAL) = 0;
75
76 virtual void setNextTransitionDirection(int8_t thisDirection) {};
77
78 virtual void cancelPopup() = 0;
79 virtual void freezeWithError(char const* text) = 0;
80 virtual bool isLayerCurrentlyOnTop(NumericLayer* layer) = 0;
81 virtual void displayError(Error error) = 0;
82
83 virtual void removeWorkingAnimation() = 0;
84
85 // Loading animations
86 virtual void displayLoadingAnimation() {};
87 virtual void displayLoadingAnimationText(char const* text, bool delayed = false, bool transparent = false) = 0;
88 virtual void removeLoadingAnimation() = 0;
89
90 virtual void displayNotification(std::string_view paramTitle, std::optional<std::string_view> paramValue) {}
91
92 virtual bool hasPopup() = 0;
93 virtual bool hasPopupOfType(PopupType type) = 0;
94
95 virtual void consoleText(char const* text) = 0;
96
97 virtual void timerRoutine() = 0;
98
99 virtual void setTextAsNumber(int16_t number, uint8_t drawDot = 255, bool doBlink = false) {}
100 virtual int32_t getEncodedPosFromLeft(int32_t textPos, char const* text, bool* andAHalf) { return 0; }
101 virtual void setTextAsSlot(int16_t currentSlot, int8_t currentSubSlot, bool currentSlotExists, bool doBlink = false,
102 int32_t blinkPos = -1, bool blinkImmediately = false) {}
103 virtual void setTextWithMultipleDots(std::string_view newText, std::vector<uint8_t> dotPositions,
104 bool alignRight = false, bool doBlink = false, uint8_t* newBlinkMask = nullptr,
105 bool blinkImmediately = false) {}
106 virtual NumericLayerScrollingText* setScrollingText(char const* newText, int32_t startAtPos = 0,
107 int32_t initialDelay = 600, int count = -1,
108 uint8_t fixedDot = 255) {
109 return nullptr;
110 }
111
112 virtual std::array<uint8_t, kNumericDisplayLength> getLast() { return {0}; }; // to match SevenSegment
113
114 bool haveOLED() { return displayType == DisplayType::OLED; }
115 bool have7SEG() { return displayType == DisplayType::SEVENSEG; }
116
117private:
118 DisplayType displayType;
119};
120
121} // namespace deluge::hid
122
123extern deluge::hid::Display* display;
124
125namespace deluge::hid::display {
126void swapDisplayType();
127// physical screen is oled
128extern bool have_oled_screen;
129} // namespace deluge::hid::display
130
131extern "C" void consoleTextIfAllBootedUp(char const* text);
Definition numeric_layer_scrolling_text.h:22
Definition numeric_layer.h:23
Definition display.h:45