|
|
@ -1,12 +1,18 @@ |
|
|
|
#include "main_adc.hh" |
|
|
|
#include "utils.hh" |
|
|
|
#include <functional> |
|
|
|
|
|
|
|
namespace Heck { |
|
|
|
namespace { // anonymous namespace for internal linkage
|
|
|
|
ld::DaisySeed seed{}; |
|
|
|
Observer<int> pot1{}; |
|
|
|
SWTimer scan_pots{}; |
|
|
|
|
|
|
|
Cache<u16> pot1{ []() { return seed.adc.Get(0); }, |
|
|
|
[](Cache<u16>& cache) { seed.PrintLine("POT_1: %d", cache.read()); } }; |
|
|
|
|
|
|
|
void scan_pots(u32) { |
|
|
|
pot1.update_and_notify_change(); |
|
|
|
} |
|
|
|
|
|
|
|
PeriodicTaskCT<scan_pots, 10> task_scan_pots{}; |
|
|
|
|
|
|
|
void init() |
|
|
|
{ |
|
|
@ -20,21 +26,14 @@ namespace Heck { |
|
|
|
seed.adc.Init(adc_cfg, 1); |
|
|
|
seed.adc.Start(); |
|
|
|
} |
|
|
|
|
|
|
|
scan_pots.set_period(10); |
|
|
|
scan_pots.set_callback([](u32) { |
|
|
|
pot1.on_change_fuzzy(seed.adc.Get(0), 20, [](int val) { |
|
|
|
seed.PrintLine("POT_1: %d", val); |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
void mainloop() |
|
|
|
{ |
|
|
|
u32&& time_boot_ms{}; |
|
|
|
u32 uptime{}; |
|
|
|
while (true) { |
|
|
|
time_boot_ms = ld::System::GetNow(); |
|
|
|
scan_pots.is_it_already_time_again(time_boot_ms); |
|
|
|
uptime = ld::System::GetNow(); |
|
|
|
task_scan_pots.run_pending(uptime); |
|
|
|
} |
|
|
|
} |
|
|
|
} // namespace
|
|
|
|