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