From 99e96d779378dd37d1ed24a4d90a7095bdfe529a Mon Sep 17 00:00:00 2001 From: heck Date: Thu, 12 Sep 2024 14:02:08 +0200 Subject: [PATCH] Add sequencer record button --- src/globals.hh | 1 + src/main_perkons.cc | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/globals.hh b/src/globals.hh index 2aba6d5..b2d00b6 100644 --- a/src/globals.hh +++ b/src/globals.hh @@ -44,6 +44,7 @@ namespace Heck { //Hardware extern ld::DaisySeed hw; + extern ld::Switch but_rec; } // namespace Heck diff --git a/src/main_perkons.cc b/src/main_perkons.cc index a92c73d..404982c 100644 --- a/src/main_perkons.cc +++ b/src/main_perkons.cc @@ -19,6 +19,7 @@ namespace Heck { // INIT // ============================================================================================= ld::DaisySeed hw{}; + ld::Switch but_rec{}; static ld::MidiUartHandler midi{}; static ld::FIFO event_log{}; @@ -45,6 +46,8 @@ namespace Heck { hw.Init(); hw.StartLog(); + but_rec.Init(hw.GetPin(28), 0); + hw.PrintLine("Setting Blocksize: %i", Constants::BUFFERSIZE); hw.SetAudioBlockSize(Constants::BUFFERSIZE); @@ -147,8 +150,15 @@ namespace Heck { bool heartbeat_led_state{ false }; u32 heartbeat_time{}; + bool seq_recording{false}; + + while (1) { now = ld::System::GetNow(); + + but_rec.Debounce(); + seq_recording = but_rec.Pressed(); + while (midi.HasEvents()) { ld::MidiEvent msg = midi.PopEvent(); if (msg.type == ld::MidiMessageType::NoteOn) { @@ -200,8 +210,11 @@ namespace Heck { } } - if (now - log_time > 5) { + if (now - log_time > 100) { log_time = now; + if(seq_recording) { + hw.PrintLine("REC"); + } if (!event_log.IsEmpty()) { auto msg = event_log.PopFront(); char outstr[128];