diff --git a/src/bedsidemon/application.cpp b/src/bedsidemon/application.cpp index 3b39db4..93807db 100644 --- a/src/bedsidemon/application.cpp +++ b/src/bedsidemon/application.cpp @@ -50,6 +50,25 @@ application::application(bool window, std::string_view res_path) : this->gui.context.get().loader.mount_res_pack(*this->get_res_file(papki::as_dir(res_path))); auto c = make_root_widgets(this->gui.context); + + // set up clock update + { + constexpr auto clock_update_interval_ms = 1000; + + this->clock_timer = utki::make_shared( // + this->gui.context.get().updater, + [this](uint32_t elapsed_ms) { + // TODO: update time + std::cout << "timeout" << std::endl; + this->clock_timer->stop(); + this->clock_timer->start(clock_update_interval_ms); + std::cout << "timeout exit" << std::endl; + ASSERT(this->clock_timer->is_running()) + } + ); + this->clock_timer->start(0); + } + this->gui.set_root(c); auto& pw_container = c.get().get_widget_as("pw_container"); diff --git a/src/bedsidemon/application.hpp b/src/bedsidemon/application.hpp index 23ea5cf..b2fc689 100644 --- a/src/bedsidemon/application.hpp +++ b/src/bedsidemon/application.hpp @@ -21,6 +21,7 @@ along with this program. If not, see . #pragma once +#include #include #include "spo2/spo2_sensor.hpp" @@ -31,6 +32,9 @@ class application : public ruisapp::application { std::unique_ptr spo2_sensor_v; + // timer for updating clock view once a second + std::shared_ptr clock_timer; + public: application(bool window, std::string_view res_path); }; diff --git a/src/bedsidemon/gui.cpp b/src/bedsidemon/gui.cpp index 2082c45..ce03247 100644 --- a/src/bedsidemon/gui.cpp +++ b/src/bedsidemon/gui.cpp @@ -23,8 +23,10 @@ along with this program. If not, see . #include #include +#include #include #include +#include #include "style.hpp" @@ -97,14 +99,17 @@ std::vector> make_buttons(utki::shared_ref make_separator(utki::shared_ref c) +utki::shared_ref make_separator(utki::shared_ref c, bool vertical = false) { // clang-format off return m::rectangle( std::move(c), { .layout_params = { - .dims = {lp::fill, 1_pp} + .dims = { + vertical ? 1_pp : lp::fill, + vertical ? lp::fill : 1_pp + } }, .color_params = { .color = style::color_border @@ -113,6 +118,16 @@ utki::shared_ref make_separator(utki::shared_ref ); // clang-format on } + +auto make_horizontal_separator(utki::shared_ref c) +{ + return make_separator(c); +} + +auto make_vertical_separator(utki::shared_ref c) +{ + return make_separator(c, true); +} } // namespace utki::shared_ref bedsidemon::make_root_widgets(utki::shared_ref c) @@ -129,18 +144,60 @@ utki::shared_ref bedsidemon::make_root_widgets(utki::shared_ref bedsidemon::make_root_widgets(utki::shared_ref> make_widgets(utki::shared_refheart.set_visible(false); + std::cout << "heart" << std::endl; } diff --git a/src/bedsidemon/style.hpp b/src/bedsidemon/style.hpp index 7257f58..5d8de54 100644 --- a/src/bedsidemon/style.hpp +++ b/src/bedsidemon/style.hpp @@ -21,9 +21,15 @@ along with this program. If not, see . #pragma once +#include + namespace bedsidemon::style { constexpr auto color_border = 0xff808080; constexpr auto color_info_text = 0xff808080; +constexpr auto font_size_label = ruis::length::make_pp(16); +constexpr auto pw_padding = ruis::length::make_pp(5); +constexpr auto clock_padding = ruis::length::make_pp(10); + } // namespace bedsidemon::style