Deluge Firmware 1.3.0
Build date: 2025.07.14
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#include <string_view>
27
29
30namespace deluge::hid::display {
31
32class SevenSegment : public Display {
33public:
34 SevenSegment() : Display(DisplayType::SEVENSEG) { l10n::chosenLanguage = &l10n::built_in::seven_segment; }
35
36 void setText(std::string_view newText, bool alignRight = false, uint8_t drawDot = 255, bool doBlink = false,
37 uint8_t* newBlinkMask = nullptr, bool blinkImmediately = false, bool shouldBlinkFast = false,
38 int32_t scrollPos = 0, uint8_t* blinkAddition = nullptr, bool justReplaceBottomLayer = false) override;
39
40 void setNextTransitionDirection(int8_t thisDirection) override;
41 void displayPopup(std::string_view newText, int8_t numFlashes = 3, bool alignRight = false, uint8_t drawDot = 255,
42 int32_t blinkSpeed = 1, PopupType type = PopupType::GENERAL) override;
43 void freezeWithError(std::string_view) override;
44 void cancelPopup() override;
45 void displayError(Error error) override;
46
47 void setTextAsNumber(int16_t number, uint8_t drawDot = 255, bool doBlink = false) override;
48 void setTextAsSlot(int16_t currentSlot, int8_t currentSubSlot, bool currentSlotExists, bool doBlink = false,
49 int32_t blinkPos = -1, bool blinkImmediately = false) override;
50 void setTextWithMultipleDots(std::string_view newText, std::vector<uint8_t> dotPositions, bool alignRight = false,
51 bool doBlink = false, uint8_t* newBlinkMask = nullptr,
52 bool blinkImmediately = false) override;
53
54 void timerRoutine() override;
55 void removeTopLayer();
56 NumericLayerScrollingText* setScrollingText(std::string_view text, int32_t startAtPos = 0,
57 int32_t initialDelay = 600, int count = -1,
58 uint8_t fixedDot = 255) override;
59 int32_t getEncodedPosFromLeft(int32_t text_position, std::string_view text, bool* andAHalf) override;
60 void render();
61 void displayLoadingAnimation(bool delayed = false, bool transparent = false);
62 bool isLayerCurrentlyOnTop(NumericLayer* layer) override;
63 std::array<uint8_t, kNumericDisplayLength> getLast() override { return lastDisplay_; }
64
65 bool hasPopup() override { return this->popupActive; }
66 bool hasPopupOfType(PopupType type) override { return this->popupActive && type == this->popupType; }
67
68 constexpr size_t getNumBrowserAndMenuLines() override { return 1; }
69
70 void consoleText(std::string_view text) override { SevenSegment::displayPopup(text); }
71 void popupText(std::string_view text, PopupType type = PopupType::GENERAL) override {
72 SevenSegment::displayPopup(text, 0, false, 255, 1, type);
73 }
74 void popupTextTemporary(std::string_view text, PopupType type = PopupType::GENERAL) override {
75 SevenSegment::displayPopup(text, 3, false, 255, 1, type);
76 }
77
78 void removeWorkingAnimation() override {}
79
80 // Loading animations
81 void displayLoadingAnimationText(std::string_view text, bool delayed = false, bool transparent = false) override {
82 SevenSegment::displayLoadingAnimation(delayed, transparent);
83 }
84 void removeLoadingAnimation() override { SevenSegment::removeTopLayer(); }
85
86 void enableLowercase() { use_lowercase = true; }
87 void disableLowercase() { use_lowercase = false; }
88
89private:
91 NumericLayer* topLayer = nullptr;
92 int8_t nextTransitionDirection = 0;
93 bool popupActive = false;
94 PopupType popupType = PopupType::NONE;
95
96 void deleteAllLayers();
97
98 void innerSetText(std::string_view newText, bool alignRight = false, std::vector<uint8_t> dotPositions = {},
99 bool doBlink = false, uint8_t* newBlinkMask = nullptr, bool blinkImmediately = false,
100 bool shouldBlinkFast = false, int32_t scrollPos = 0, uint8_t* blinkAddition = nullptr,
101 bool justReplaceBottomLayer = false);
102 int32_t encodeText(std::string_view newText, uint8_t* destination, bool alignRight,
103 const std::vector<uint8_t>& dotPositions = {}, bool limitToDisplayLength = true,
104 int32_t scrollPos = 0) const;
105 void replaceBottomLayer(NumericLayer* newLayer);
106 void setTopLayer(NumericLayer* newTopLayer);
107 void transitionToNewLayer(NumericLayer* newLayer);
108 void setTextVeryBasicA1(std::string_view text);
109 std::array<uint8_t, kNumericDisplayLength> lastDisplay_ = {0};
110 bool use_lowercase = false;
111};
112} // namespace deluge::hid::display
Definition numeric_layer_basic_text.h:22
Definition numeric_layer_scrolling_text.h:22
Definition numeric_layer.h:23