Resetting the lap counter when a new name is recived 14/191714/4
authorMichal Skorupinski <m.skorupinsk@samsung.com>
Mon, 22 Oct 2018 15:28:03 +0000 (17:28 +0200)
committerMichal Skorupinski <m.skorupinsk@samsung.com>
Fri, 26 Oct 2018 13:34:41 +0000 (15:34 +0200)
Change-Id: Ie8234f77b7a1d26b0f9b32d4a267b683b88fb519
Signed-off-by: Michal Skorupinski <m.skorupinsk@samsung.com>
inc/lap_counter/lap_counter.h
src/app.c
src/lap_counter/lap_counter.c

index 0fc3b0c..fefff62 100644 (file)
@@ -22,5 +22,6 @@ void lap_counter_set_user_name(const char *user_name);
 const char *lap_counter_get_user_name(void);
 void lap_counter_get_lap_time();
 void lap_counter_shutdown();
+void lap_counter_set_start_lap();
 
 #endif //LAP_COUNTER_H_
index b645682..5c6a593 100644 (file)
--- a/src/app.c
+++ b/src/app.c
@@ -31,7 +31,6 @@
 #include "controller_connection_manager.h"
 #include "lap_counter/lap_counter.h"
 #include "command.h"
-#include "lap_counter/lap_counter.h"
 
 #define ENABLE_MOTOR 1
 #define STERING_SERVO_CENTER 340
@@ -168,8 +167,11 @@ static void __command_received_cb(command_s command) {
        }
 }
 
-static void __user_name_received_cb(const char *name) {
+static void __user_name_received_cb(const char *name)
+{
+       _D("User name received: %s", name);
        lap_counter_set_user_name(name);
+       lap_counter_set_start_lap();
 }
 
 static void _initialize_config()
index 0894a87..aa9746d 100644 (file)
@@ -117,6 +117,12 @@ void lap_counter_get_lap_time()
        s_info.last_timestamp.tv_nsec = timestamp.tv_nsec;
 }
 
+void lap_counter_set_start_lap()
+{
+       s_info.last_timestamp.tv_nsec = 0;
+       s_info.last_timestamp.tv_sec = 0;
+}
+
 void lap_counter_shutdown()
 {
        free(s_info.user_name);