diff --git a/examples/main_template_full.cc b/examples/main_template_full.cc index 1de486b..ab797b7 100644 --- a/examples/main_template_full.cc +++ b/examples/main_template_full.cc @@ -1,8 +1,6 @@ -// Hecks perkons extension - -#include #include "main_template_full.hh" #include "utils.hh" +#include namespace Heck { namespace { // anonymous namespace for internal linkage @@ -13,12 +11,14 @@ namespace Heck { static ld::MidiUartHandler midi{}; + Observer pot1{}; + SWTimer scan_pots{}; + // function prototypes void audio_callback( ld::AudioHandle::InputBuffer in, ld::AudioHandle::OutputBuffer out, - size_t size) - ; + size_t size); void midi_realtime_handler(const ld::MidiEvent& msg); void init() @@ -27,6 +27,14 @@ namespace Heck { seed.Init(Constants::CPU_BOOST480MHZ); seed.StartLog(Constants::Developer::LOG_BLOCKS_BOOT); + { + ld::AdcChannelConfig adc_cfg[1]; + adc_cfg[0].InitSingle(ld::DaisySeed::GetPin(Constants::Hardware::PIN_POT_1)); + + seed.adc.Init(adc_cfg, 1); + seed.adc.Start(); + } + seed.PrintLine("Setting Blocksize: %i", Constants::AUDIO_BUFFERSIZE); seed.SetAudioBlockSize(Constants::AUDIO_BUFFERSIZE); @@ -91,7 +99,16 @@ namespace Heck { void mainloop() { seed.PrintLine("Entering MainLoop"); - u32 systick_now{}; + u32 time_boot_ms{}; + + + scan_pots.set_period(10); + scan_pots.set_callback([]() { + pot1.on_change_fuzzy(seed.adc.Get(0), 10, [](int val) { + seed.PrintLine("POT_1: %d", val); + }); + }); + bool heartbeat_led_state{ false }; @@ -104,13 +121,14 @@ namespace Heck { }); while (true) { - systick_now = ld::System::GetNow(); + time_boot_ms = ld::System::GetNow(); while (midi.HasEvents()) { midi_async_handler(midi.PopEvent()); } - heartbeat.is_it_already_time_again(systick_now); + scan_pots.is_it_already_time_again(time_boot_ms); + heartbeat.is_it_already_time_again(time_boot_ms); } } } // namespace diff --git a/examples/main_template_full.hh b/examples/main_template_full.hh index d0619af..092b4fc 100644 --- a/examples/main_template_full.hh +++ b/examples/main_template_full.hh @@ -1,5 +1,5 @@ -#ifndef HECK_DAISY_GLOBALS_HH -#define HECK_DAISY_GLOBALS_HH +#ifndef HECK_LIBDIZZY_MAIN_TEMPLATE_FULL_HH +#define HECK_LIBDIZZY_MAIN_TEMPLATE_FULL_HH #include #include "daisy_seed.h" @@ -10,6 +10,7 @@ namespace Heck { namespace Constants { namespace Hardware { // constexpr int PIN_BUTTON_RECORD = 28; + constexpr int PIN_POT_1 = 15; } constexpr bool CPU_BOOST480MHZ = false;