/* * cppmain.cc * * Created on: Jul 4, 2023 * Author: heck */ #include "cppmain.h" #include "main.h" #include "usbd_cdc_if.h" #include #include #include const double pi{ std::acos(-1) }; void log(const std::string &msg) { std::string out{ msg }; out.append("\r\n"); CDC_Transmit_FS((uint8_t *)out.data(), out.size()); } void log(std::string &&msg) { log(msg); } std::function printheck = [] { log("heck"); }; void cppmain(void) { log(pi); long i{ 0 }; while (true) { const float piwrap{ std::fmod(float(i / 100.), float(2. * pi)) }; const float sin_factor = std::abs(float(sin(piwrap))); HAL_Delay(static_cast(sin_factor * 100.0)); HAL_GPIO_TogglePin(LED_GREEN_GPIO_Port, LED_GREEN_Pin); log({ "hello heck:" + std::to_string(i) + " piwrap:" + std::to_string(piwrap) + " fact:" + std::to_string(sin_factor) }); printheck(); i++; } }