Deluge Firmware
1.3.0
Build date: 2026.08.23
Toggle main menu visibility
Loading...
Searching...
No Matches
volts.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
#include "gui/menu_item/decimal.h"
19
#include "gui/menu_item/formatted_title.h"
20
#include "gui/ui/sound_editor.h"
21
#include "hid/display/display.h"
22
#include "hid/display/oled.h"
23
#include "processing/engines/cv_engine.h"
24
25
namespace
deluge::gui::menu_item::cv {
26
class
Volts final :
public
Decimal
,
public
FormattedTitle {
27
public
:
28
Volts(l10n::String name, l10n::String title_format_str) :
Decimal
(name), FormattedTitle(title_format_str) {}
29
30
[[nodiscard]] std::string_view
getTitle
()
const override
{
return
FormattedTitle::title(); }
31
32
[[nodiscard]] int32_t getMinValue()
const override
{
return
0; }
33
[[nodiscard]] int32_t getMaxValue()
const override
{
return
200; }
34
[[nodiscard]] int32_t getNumDecimalPlaces()
const override
{
return
2; }
35
[[nodiscard]] int32_t getDefaultEditPos()
const override
{
return
1; }
36
void
readCurrentValue
()
override
{
37
this->setValue(cvEngine.cvChannels[soundEditor.currentSourceIndex].voltsPerOctave);
38
}
39
void
writeCurrentValue()
override
{
40
cvEngine.setCVVoltsPerOctave(soundEditor.currentSourceIndex, this->getValue());
41
}
42
void
drawPixelsForOled
()
override
{
43
deluge::hid::display::oled_canvas::Canvas
& canvas = hid::display::OLED::main;
44
if
(this->getValue() == 0) {
45
canvas.
drawStringCentred
(
"Hz/V"
, 20, kTextHugeSpacingX, kTextHugeSizeY);
46
}
47
else
{
48
Decimal::drawPixelsForOled
();
49
}
50
}
51
52
void
drawValue()
override
{
53
if
(this->getValue() == 0) {
54
display->setText(
"HZPV"
,
false
, 255,
true
);
55
}
56
else
{
57
Decimal::drawValue();
58
}
59
}
60
61
void
horizontalEncoderAction
(int32_t offset)
override
{
62
if
(this->getValue() != 0) {
63
Decimal::horizontalEncoderAction
(offset);
64
}
65
}
66
};
67
}
// namespace deluge::gui::menu_item::cv
deluge::gui::menu_item::Decimal
Definition
decimal.h:24
deluge::gui::menu_item::Decimal::drawPixelsForOled
void drawPixelsForOled() override
Paints the pixels below the standard title block.
Definition
decimal.cpp:142
deluge::gui::menu_item::Decimal::horizontalEncoderAction
void horizontalEncoderAction(int32_t offset) override
Handle horizontal encoder movement.
Definition
decimal.cpp:91
deluge::gui::menu_item::cv::Volts::readCurrentValue
void readCurrentValue() override
Like readValueAgain, but does not redraw.
Definition
volts.h:36
deluge::gui::menu_item::cv::Volts::getTitle
std::string_view getTitle() const override
Get the title to be used when rendering on OLED, both as a deluge::gui::menu_item::Submenu and when d...
Definition
volts.h:30
deluge::gui::menu_item::cv::Volts::drawPixelsForOled
void drawPixelsForOled() override
Paints the pixels below the standard title block.
Definition
volts.h:42
deluge::gui::menu_item::cv::Volts::horizontalEncoderAction
void horizontalEncoderAction(int32_t offset) override
Handle horizontal encoder movement.
Definition
volts.h:61
deluge::hid::display::oled_canvas::Canvas
Definition
canvas.h:52
deluge::hid::display::oled_canvas::Canvas::drawStringCentred
void drawStringCentred(char const *string, int32_t pixelY, int32_t textWidth, int32_t textHeight, int32_t centrePos=OLED_MAIN_WIDTH_PIXELS/2)
Definition
canvas.cpp:383