From 432b6143618666b107f7f8903546abe360153fba Mon Sep 17 00:00:00 2001 From: heck Date: Sat, 21 Sep 2024 09:12:41 +0200 Subject: [PATCH] blink - update to use types.hh --- src/main_blink.cc | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/src/main_blink.cc b/src/main_blink.cc index cac3593..a3fb4e4 100644 --- a/src/main_blink.cc +++ b/src/main_blink.cc @@ -1,16 +1,31 @@ #include "daisy_seed.h" +#include "types.hh" -namespace ld = daisy; +namespace Heck { + namespace Constants { + constexpr float BLINK_FREQ_HZ{ 1 }; + } + + ld::DaisySeed hw{}; + + float hz_to_ms(float hz) + { + return 1000. / hz; + } -static ld::DaisySeed hw{}; + int main() + { + hw.Init(); + while (true) { + hw.SetLed(true); + hw.DelayMs(hz_to_ms(Constants::BLINK_FREQ_HZ * 2)); + hw.SetLed(false); + hw.DelayMs(hz_to_ms(Constants::BLINK_FREQ_HZ * 2)); + } + } +} // namespace Heck int main() { - hw.Init(); - while (true) { - hw.SetLed(true); - hw.DelayMs(100); - hw.SetLed(false); - hw.DelayMs(100); - } + return Heck::main(); }