You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
50 lines
1.2 KiB
50 lines
1.2 KiB
#include "main_adc.hh"
|
|
#include "dizzy.hh"
|
|
|
|
namespace Heck {
|
|
namespace { // anonymous namespace for internal linkage
|
|
ld::DaisySeed seed{};
|
|
|
|
dz::Cache<u16> pot1{ []() { return seed.adc.Get(0); },
|
|
[](dz::Cache<u16>& cache) {
|
|
seed.PrintLine("POT_1: %d", cache.read());
|
|
} };
|
|
|
|
void scan_pots(u32)
|
|
{
|
|
pot1.update_and_notify_change();
|
|
}
|
|
|
|
dz::PeriodicTaskCT<scan_pots, 10> task_scan_pots{};
|
|
|
|
void init()
|
|
{
|
|
seed.Init(Constants::CPU_BOOST480MHZ);
|
|
seed.StartLog(Constants::Developer::LOG_BLOCKS_BOOT);
|
|
|
|
{ // ADC config
|
|
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();
|
|
}
|
|
}
|
|
|
|
void mainloop()
|
|
{
|
|
u32 uptime{};
|
|
while (true) {
|
|
uptime = ld::System::GetNow();
|
|
task_scan_pots.run_pending(uptime);
|
|
}
|
|
}
|
|
} // namespace
|
|
} // namespace Heck
|
|
|
|
|
|
int main()
|
|
{
|
|
Heck::init();
|
|
Heck::mainloop();
|
|
}
|