Deluge Firmware 1.3.0
Build date: 2025.04.16
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 void setNextTransitionDirection(int8_t thisDirection) override;
40 void displayPopup(std::string_view 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(std::string_view) 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 timerRoutine() override;
50 void removeTopLayer();
51 NumericLayerScrollingText* setScrollingText(std::string_view text, int32_t startAtPos = 0,
52 int32_t initialDelay = 600, int count = -1,
53 uint8_t fixedDot = 255) override;
54 int32_t getEncodedPosFromLeft(int32_t text_position, std::string_view text, bool* andAHalf) override;
55 void render();
56 void displayLoadingAnimation(bool delayed = false, bool transparent = false);
57 bool isLayerCurrentlyOnTop(NumericLayer* layer) override;
58 std::array<uint8_t, kNumericDisplayLength> getLast() override { return lastDisplay_; }
59
60 bool hasPopup() override { return this->popupActive; }
61 bool hasPopupOfType(PopupType type) override { return this->popupActive && type == this->popupType; }
62
63 constexpr size_t getNumBrowserAndMenuLines() override { return 1; }
64
65 void consoleText(std::string_view text) override { SevenSegment::displayPopup(text); }
66 void popupText(std::string_view text, PopupType type = PopupType::GENERAL) override {
67 SevenSegment::displayPopup(text, 0, false, 255, 1, type);
68 }
69 void popupTextTemporary(std::string_view text, PopupType type = PopupType::GENERAL) override {
70 SevenSegment::displayPopup(text, 3, false, 255, 1, type);
71 }
72
73 void removeWorkingAnimation() override {}
74
75 // Loading animations
76 void displayLoadingAnimationText(std::string_view text, bool delayed = false, bool transparent = false) override {
77 SevenSegment::displayLoadingAnimation(delayed, transparent);
78 }
79 void removeLoadingAnimation() override { SevenSegment::removeTopLayer(); }
80
81 void enableLowercase() { use_lowercase = true; }
82 void disableLowercase() { use_lowercase = false; }
83
84private:
86 NumericLayer* topLayer = nullptr;
87 int8_t nextTransitionDirection = 0;
88 bool popupActive = false;
89 PopupType popupType = PopupType::NONE;
90
91 void deleteAllLayers();
92
93 int32_t encodeText(std::string_view newText, uint8_t* destination, bool alignRight, uint8_t drawDot = 255,
94 bool limitToDisplayLength = true, int32_t scrollPos = 0);
95 void replaceBottomLayer(NumericLayer* newLayer);
96 void setTopLayer(NumericLayer* newTopLayer);
97 void transitionToNewLayer(NumericLayer* newLayer);
98 void setTextVeryBasicA1(std::string_view text);
99 std::array<uint8_t, kNumericDisplayLength> lastDisplay_ = {0};
100 bool use_lowercase = false;
101};
102} // namespace deluge::hid::display
Definition numeric_layer_basic_text.h:22
Definition numeric_layer_scrolling_text.h:22
Definition numeric_layer.h:23