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