Deluge Firmware 1.3.0
Build date: 2026.03.02
Loading...
Searching...
No Matches
seven_segment.h
1/*
2 * Copyright © 2014-2023 Synthstrom Audible Limited
3 *
4 * This file is part of The Synthstrom Audible Deluge Firmware.
5 *
6 * The Synthstrom Audible Deluge Firmware is free software: you can redistribute it and/or modify it under the
7 * terms of the GNU General Public License as published by the Free Software Foundation,
8 * either version 3 of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
11 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 * See the GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License along with this program.
15 * If not, see <https://www.gnu.org/licenses/>.
16 */
17
18#pragma once
19
20#include "definitions_cxx.hpp"
21#include "gui/l10n/language.h"
22#include "hid/display/display.h"
23#include "hid/display/numeric_layer/numeric_layer_basic_text.h"
24#include <array>
25#include <string>
26
28
29namespace deluge::hid::display {
30
31class SevenSegment : public Display {
32public:
33 SevenSegment() : Display(DisplayType::SEVENSEG) { l10n::chosenLanguage = &l10n::built_in::seven_segment; }
34
35 void setText(std::string_view newText, bool alignRight = false, uint8_t drawDot = 255, bool doBlink = false,
36 uint8_t* newBlinkMask = nullptr, bool blinkImmediately = false, bool shouldBlinkFast = false,
37 int32_t scrollPos = 0, uint8_t* blinkAddition = nullptr, bool justReplaceBottomLayer = false) override;
38
39 void setNextTransitionDirection(int8_t thisDirection) override;
40 void displayPopup(char const* newText, int8_t numFlashes = 3, bool alignRight = false, uint8_t drawDot = 255,
41 int32_t blinkSpeed = 1, PopupType type = PopupType::GENERAL) override;
42 void freezeWithError(char const* text) override;
43 void cancelPopup() override;
44 void displayError(Error error) override;
45
46 void setTextAsNumber(int16_t number, uint8_t drawDot = 255, bool doBlink = false) override;
47 void setTextAsSlot(int16_t currentSlot, int8_t currentSubSlot, bool currentSlotExists, bool doBlink = false,
48 int32_t blinkPos = -1, bool blinkImmediately = false) override;
49 void setTextWithMultipleDots(std::string_view newText, std::vector<uint8_t> dotPositions, bool alignRight = false,
50 bool doBlink = false, uint8_t* newBlinkMask = nullptr,
51 bool blinkImmediately = false) override;
52
53 void timerRoutine() override;
54 void removeTopLayer();
55 NumericLayerScrollingText* setScrollingText(char const* newText, int32_t startAtPos = 0, int32_t initialDelay = 600,
56 int count = -1, uint8_t fixedDot = 255) override;
57 int32_t getEncodedPosFromLeft(int32_t textPos, char const* text, bool* andAHalf) override;
58 void render();
59 void displayLoadingAnimation(bool delayed = false, bool transparent = false);
60 bool isLayerCurrentlyOnTop(NumericLayer* layer) override;
61 std::array<uint8_t, kNumericDisplayLength> getLast() override { return lastDisplay_; }
62
63 bool hasPopup() override { return this->popupActive; }
64 bool hasPopupOfType(PopupType type) override { return this->popupActive && type == this->popupType; }
65
66 constexpr size_t getNumBrowserAndMenuLines() override { return 1; }
67
68 void consoleText(char const* text) override { SevenSegment::displayPopup(text); }
69 void popupText(char const* text, PopupType type = PopupType::GENERAL) override {
70 SevenSegment::displayPopup(text, 0, false, 255, 1, type);
71 }
72 void popupTextTemporary(char const* text, PopupType type = PopupType::GENERAL) override {
73 SevenSegment::displayPopup(text, 3, false, 255, 1, type);
74 }
75
76 void removeWorkingAnimation() override {}
77
78 // Loading animations
79 void displayLoadingAnimationText(char const* text, bool delayed = false, bool transparent = false) override {
80 SevenSegment::displayLoadingAnimation(delayed, transparent);
81 }
82 void removeLoadingAnimation() override { SevenSegment::removeTopLayer(); }
83
84 void enableLowercase() { use_lowercase = true; }
85 void disableLowercase() { use_lowercase = false; }
86
87private:
89 NumericLayer* topLayer = nullptr;
90 int8_t nextTransitionDirection = 0;
91 bool popupActive = false;
92 PopupType popupType = PopupType::NONE;
93
94 void deleteAllLayers();
95
96 void innerSetText(std::string_view newText, bool alignRight = false, std::vector<uint8_t> dotPositions = {},
97 bool doBlink = false, uint8_t* newBlinkMask = nullptr, bool blinkImmediately = false,
98 bool shouldBlinkFast = false, int32_t scrollPos = 0, uint8_t* blinkAddition = nullptr,
99 bool justReplaceBottomLayer = false);
100 int32_t encodeText(std::string_view newText, uint8_t* destination, bool alignRight,
101 const std::vector<uint8_t>& dotPositions = {}, bool limitToDisplayLength = true,
102 int32_t scrollPos = 0) const;
103 void replaceBottomLayer(NumericLayer* newLayer);
104 void setTopLayer(NumericLayer* newTopLayer);
105 void transitionToNewLayer(NumericLayer* newLayer);
106 void setTextVeryBasicA1(char const* text);
107 std::array<uint8_t, kNumericDisplayLength> lastDisplay_ = {0};
108 bool use_lowercase = false;
109};
110} // namespace deluge::hid::display
Definition numeric_layer_basic_text.h:22
Definition numeric_layer_scrolling_text.h:22
Definition numeric_layer.h:23