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