From 1f1e71e0d9e1a60eac38040ea5e6a49c14d81b71 Mon Sep 17 00:00:00 2001
From: Roland Reichwein <mail@reichwein.it>
Date: Fri, 3 Jan 2025 18:36:05 +0100
Subject: Added log

---
 main.cpp | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

(limited to 'main.cpp')

diff --git a/main.cpp b/main.cpp
index 4c33bc4..8fb4822 100644
--- a/main.cpp
+++ b/main.cpp
@@ -4,6 +4,7 @@
 #include "Timer.h"
 #include "UI.h"
 #include "config.h"
+#include "log.h"
 
 #include <chrono>
 #include <cmath>
@@ -32,6 +33,8 @@ int main(void)
 {
   try {
     //debug_cout.activate();
+    log_cout.activate();
+    log_cout.log_lines(log_lines);
 
     MIDI midi;
     ClickStream stream;
@@ -40,19 +43,19 @@ int main(void)
 
     pcm.write();
 
-    Timer timer_300ms(300ms, true);
-    timer_300ms.start();
+    Timer timer_500ms(500ms, true);
+    timer_500ms.start();
 
     // Main signals
     boost::signals2::signal<void()> signal_count_loops;
 
     // Signal-Slot Connections:
     midi.signal_click.connect([&](){stream.click();});
-    timer_300ms.elapsed.connect([&](){ui.draw();});
+    timer_500ms.elapsed.connect([&](){ui.draw();});
     signal_count_loops.connect([&](){ui.count_main_loops();});
 
     while (true) {
-      //std::cout << "Main loop entered." << std::endl;
+      debug_cout << "Main loop entered." << std::endl;
       signal_count_loops();
 
       fd_set read_set;
@@ -67,14 +70,14 @@ int main(void)
 #endif
 
       struct timeval timeout;
-      timeout.tv_sec = 1;
-      timeout.tv_usec = 300000;
+      timeout.tv_sec = 0;
+      timeout.tv_usec = 20000;
 
       int result = select(FD_SETSIZE, &read_set, nullptr/*&write_set*/, nullptr, &timeout);
       if (result < 0) {
         throw std::runtime_error("select() failed");
       } else if (result == 0) {
-        std::cout << "select() timeout" << std::endl;
+        debug_cout << "select() timeout" << std::endl;
       }
 
       while (midi.event_ready())
@@ -91,7 +94,7 @@ int main(void)
       }
 
       // handle timers, TODO: make updates more efficient at scale
-      timer_300ms.update();
+      timer_500ms.update();
     }
   } catch (const std::exception& ex) {
     std::cerr << "Error: " << ex.what() << std::endl;
-- 
cgit v1.2.3