summaryrefslogtreecommitdiffhomepage
path: root/UI.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'UI.cpp')
-rw-r--r--UI.cpp45
1 files changed, 25 insertions, 20 deletions
diff --git a/UI.cpp b/UI.cpp
index dfc704d..8aefa9d 100644
--- a/UI.cpp
+++ b/UI.cpp
@@ -68,6 +68,7 @@ UI::UI(Config& config):
m_midi_notes{},
m_active_sensing_timestamp{},
m_midi_timestamp{},
+ m_midi_monitor{30s},
m_note_bpm{2000ms},
m_clock_bpm{2000ms},
m_touchpad{}
@@ -127,7 +128,7 @@ void UI::draw()
std::cout << "\x1B[2J\x1B[H";
//std::cout << std::endl;
- std::cout << fmt::format(editable_color, "{:3}", bpm) << " BPM " << fmt::format(input_color, "(+/-)") << std::endl;
+ std::cout << fmt::format(editable_color, "Speed: {:3}", bpm) << " BPM " << fmt::format(input_color, "(+/-)") << std::endl;
std::cout << "Mode " << fmt::format(input_color, "(m)") << ": ";
for (int i = 0; i < mode_names.size(); ++i) {
if (i == mode) {
@@ -144,19 +145,13 @@ void UI::draw()
std::cout << std::endl;
std::cout << "Status:" << std::endl;
- std::cout << " CPU:";
- for (auto& i: cpuloads) {
- std::cout << fmt::format(" {:2}%", i);
- }
- int max = *std::max_element(cpuloads.begin(), cpuloads.end());
- std::cout << fmt::format(", max. {:2}%", max) << std::endl;
-
std::cout << " MIDI Notes: ";
- if (m_midi_monitor.empty()) {
+ if (m_midi_monitor.value().empty()) {
std::cout << "--";
} else {
int count{};
- for (const auto& i: m_midi_monitor) {
+ auto midi_monitor = m_midi_monitor.value();
+ for (const auto& i: midi_monitor) {
if (count == 0) {
std::cout << fmt::format(editable_color, " {}/{}", i.first, i.second);
} else {
@@ -178,8 +173,15 @@ void UI::draw()
std::cout << fmt::format(" MIDI Clock: {:3} BPM", m_clock_bpm.value()) << std::endl;
std::cout << fmt::format(" Internal: {:3} BPM", internal_bpm) << std::endl;
- std::cout << fmt::format(" Main loops/s: {:3}", main_loops_per_second) << std::endl;
+ std::cout << " CPU:";
+ for (auto& i: cpuloads) {
+ std::cout << fmt::format(" {:2}%", i);
+ }
+ int max = *std::max_element(cpuloads.begin(), cpuloads.end());
+ std::cout << fmt::format(", max. {:2}%", max) << std::endl;
+
std::cout << fmt::format(" Temperature: {:3} C", temperature) << std::endl;
+ std::cout << fmt::format(" Main loops/s: {:3}", main_loops_per_second) << std::endl;
std::cout << std::endl;
std::cout << "Log:" << std::endl;
@@ -206,9 +208,10 @@ void UI::handle_input()
} else if (c == 'm') {
m_config.set_mode((m_config.get_mode() + 1) % 3);
} else if (c == 'n') {
- if (!m_midi_monitor.empty()) {
- m_config.set_midi_channel(m_midi_monitor.front().first);
- m_config.set_midi_note(m_midi_monitor.front().second);
+ auto midi_monitor = m_midi_monitor.value();
+ if (!midi_monitor.empty()) {
+ m_config.set_midi_channel(midi_monitor.front().first);
+ m_config.set_midi_note(midi_monitor.front().second);
}
} else if (c == 'o') {
m_config.set_output(1 - m_config.get_output());
@@ -224,9 +227,10 @@ void UI::handle_input()
if (m_touchpad.event_is_button1(ev)) {
m_config.set_mode((m_config.get_mode() + 1) % 3);
} else if (m_touchpad.event_is_button2(ev)) {
- if (!m_midi_monitor.empty()) {
- m_config.set_midi_channel(m_midi_monitor.front().first);
- m_config.set_midi_note(m_midi_monitor.front().second);
+ auto midi_monitor = m_midi_monitor.value();
+ if (!midi_monitor.empty()) {
+ m_config.set_midi_channel(midi_monitor.front().first);
+ m_config.set_midi_note(midi_monitor.front().second);
}
}
}
@@ -257,10 +261,11 @@ void UI::slot_midi_note(int channel, int note, uint64_t timestamp)
{
m_midi_timestamp = timestamp;
- m_midi_monitor.emplace_front(channel, note);
+ auto midi_monitor = m_midi_monitor.update();
+ midi_monitor.emplace_front(channel, note);
- while (m_midi_monitor.size() > midi_monitor_max_size) {
- m_midi_monitor.pop_back();
+ while (midi_monitor.size() > midi_monitor_max_size) {
+ midi_monitor.pop_back();
}
count_midi_notes();