Deluge Firmware
1.3.0
Build date: 2026.08.23
Toggle main menu visibility
Loading...
Searching...
No Matches
magnitude.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/enumeration.h"
19
#include "hid/display/display.h"
20
#include "hid/display/oled.h"
21
#include "model/sync.h"
22
#include "storage/flash_storage.h"
23
#include "util/d_string.h"
24
25
namespace
deluge::gui::menu_item::defaults {
26
class
Magnitude
final :
public
Enumeration
{
27
public
:
28
using
Enumeration::Enumeration;
29
void
readCurrentValue
()
override
{ this->setValue(FlashStorage::defaultMagnitude); }
30
void
writeCurrentValue()
override
{
31
int32_t oldMagnitude = FlashStorage::defaultMagnitude;
32
FlashStorage::defaultMagnitude = this->getValue();
33
// Adjust swing interval to keep the same musical meaning if possible: magnitude affects its interpretation.
34
int32_t delta = FlashStorage::defaultMagnitude - oldMagnitude;
35
int32_t oldSwing = FlashStorage::defaultSwingInterval;
36
FlashStorage::defaultSwingInterval = clampSwingIntervalSyncLevel(FlashStorage::defaultSwingInterval - delta);
37
}
38
void
drawPixelsForOled
()
override
{
39
char
buffer[12];
40
deluge::hid::display::oled_canvas::Canvas
& canvas = hid::display::OLED::main;
41
42
intToString(96 << this->getValue(), buffer);
43
canvas.
drawStringCentred
(buffer, 18 + OLED_MAIN_TOPMOST_PIXEL, 18, 20);
44
}
45
46
void
drawValue()
override
{ display->setTextAsNumber(96 << this->getValue()); }
47
size_t
size()
override
{
return
7; }
48
};
49
}
// namespace deluge::gui::menu_item::defaults
deluge::gui::menu_item::Enumeration
An enumeration has a fixed number of items, with values from 1 to n (exclusive).
Definition
enumeration.h:9
deluge::gui::menu_item::defaults::Magnitude
Definition
magnitude.h:26
deluge::gui::menu_item::defaults::Magnitude::drawPixelsForOled
void drawPixelsForOled() override
Paints the pixels below the standard title block.
Definition
magnitude.h:38
deluge::gui::menu_item::defaults::Magnitude::readCurrentValue
void readCurrentValue() override
Like readValueAgain, but does not redraw.
Definition
magnitude.h:29
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