Config for different led colors displaying the car states
[apps/native/gear-racing-car.git] / src / lap_counter / lap_counter.c
index 347c72f..0c67fd2 100644 (file)
 #define MIN_LAP_TIME 5
 #define MAX_NAME_LENGTH 256
 
+#define CONFIG_LED_STATE_KEY_LAP "lap"
+#define CONFIG_DEFAULT_LED_3BIT_LAP 0, 1, 0
+#define CONFIG_DEFAULT_LED_24BIT_LAP 0, 255, 0
+
+#define CONFIG_LED_STATE_KEY_FIRST_LAP "first.lap"
+#define CONFIG_DEFAULT_LED_3BIT_FIRST_LAP 0, 0, 1
+#define CONFIG_DEFAULT_LED_24BIT_FIRST_LAP 0, 0, 255
+
 typedef struct lap_counter_data {
        char *user_name;
        struct timespec last_timestamp;
@@ -99,6 +107,11 @@ static inline struct timespec _calculate_lap_time(struct timespec *prev, struct
        _D("----------------------------------------------");
 
        cloud_communication_post_lap(lap.tv_sec * 1e3 + lap.tv_nsec / 1e6, s_info.user_name);
+       resource_led_blink_rgb_colors(CONFIG_LED_STATE_KEY_LAP,
+                       CONFIG_DEFAULT_LED_3BIT_LAP,
+                       CONFIG_DEFAULT_LED_24BIT_LAP,
+                       LED_COLOR_NONE,
+                       1000);
 
        return lap;
 }
@@ -113,9 +126,12 @@ void lap_counter_get_lap_time()
                _calculate_lap_time(&s_info.last_timestamp, &timestamp);
        } else {
                _D("Initial lap");
-               resource_bi_led_blink(LED_COLOR_RED, 1000);
-               resource_gpio_rgb_blink(1, 0, 1, 1000);
-               resource_rgb_l2c_blink(255, 0, 255, 1000);
+
+               resource_led_blink_rgb_colors(CONFIG_LED_STATE_KEY_FIRST_LAP,
+                               CONFIG_DEFAULT_LED_3BIT_FIRST_LAP,
+                               CONFIG_DEFAULT_LED_24BIT_FIRST_LAP,
+                               LED_COLOR_NONE,
+                               1000);
        }
 
        s_info.last_timestamp.tv_sec = timestamp.tv_sec;