Deluge Firmware 1.3.0
Build date: 2025.11.26
Loading...
Searching...
No Matches
amount_unpatched.h
1/*
2 * Copyright (c) 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#pragma once
18
19#include "gui/menu_item/integer.h"
20
21namespace deluge::gui::menu_item::delay {
22class Amount_Unpatched final : public UnpatchedParam {
23public:
24 using UnpatchedParam::UnpatchedParam;
25
26 float normalize(int32_t value) override {
27 const int32_t clamped = std::clamp<int32_t>(value, 0, max_value_in_horizontal_menu);
28 return clamped / static_cast<float>(max_value_in_horizontal_menu);
29 }
30
31 void renderInHorizontalMenu(const SlotPosition& slot) override {
32 drawBar(slot);
33
34 if (getValue() > max_value_in_horizontal_menu) {
35 // Draw exclamation mark
36 oled_canvas::Canvas& image = OLED::main;
37 constexpr uint8_t excl_mark_width = 3;
38 constexpr uint8_t excl_mark_height = 11;
39 const uint8_t center_x = slot.start_x + slot.width / 2;
40 const uint8_t excl_mark_start_y = slot.start_y + kHorizontalMenuSlotYOffset - 1;
41 const uint8_t excl_mark_end_y = excl_mark_start_y + excl_mark_height - 1;
42 const uint8_t excl_mark_start_x = center_x - 1;
43
44 // Fill the mark area
45 for (uint8_t x = center_x - 2; x <= center_x + 2; x++) {
46 for (uint8_t y = excl_mark_start_y - 1; y <= excl_mark_end_y + 1; y++) {
47 image.drawPixel(x, y);
48 }
49 }
50
51 image.invertArea(excl_mark_start_x, excl_mark_width, excl_mark_start_y, excl_mark_start_y + 6);
52 image.invertArea(excl_mark_start_x, excl_mark_width, excl_mark_start_y + 8, excl_mark_start_y + 10);
53 }
54 }
55
56 void getColumnLabel(StringBuf& label) override { label.append(l10n::get(l10n::String::STRING_FOR_AMOUNT_SHORT)); }
57
58private:
59 constexpr static int32_t max_value_in_horizontal_menu = 24;
60};
61} // namespace deluge::gui::menu_item::delay
Definition d_stringbuf.h:16
Definition amount_unpatched.h:22
Definition menu_item.h:33