Camera control 53/188153/4
authorMichal Skorupinski <m.skorupinsk@samsung.com>
Fri, 31 Aug 2018 19:13:59 +0000 (21:13 +0200)
committerMichal Skorupinski <m.skorupinsk@samsung.com>
Thu, 4 Oct 2018 16:50:21 +0000 (18:50 +0200)
Change-Id: Icb988c2e39c8e443128bc680db7ca0f599fa9447
Signed-off-by: Michal Skorupinski <m.skorupinsk@samsung.com>
src/app.c

index 53f4e8d..01d8c73 100644 (file)
--- a/src/app.c
+++ b/src/app.c
@@ -136,7 +136,21 @@ static int __driving_motors(int servo, int speed)
 
 static void __camera(int azimuth, int elevation)
 {
-       //TODO: Camera steering
+       static const int camer_input_min = -1000;
+       static const int camer_input_max = 1000;
+       static const int camer_azimuth_min = 200;
+       static const int camer_azimuth_max = 700;
+       static const int camer_elevation_min = 200;
+       static const int camer_elevation_max = 400;
+
+       int val_azimuth = __map_range_val(camer_input_min, camer_input_max, camer_azimuth_min, camer_azimuth_max, azimuth);
+       int val_elevation = __map_range_val(0, camer_input_max, camer_elevation_min, camer_elevation_max, elevation); // No need to look upside down
+
+       _D("camera - azimuth[%4d : %4d], elevation[%4d : %4d]", azimuth, val_azimuth, elevation, val_elevation);
+#if ENABLE_MOTOR
+       resource_set_servo_motor_value(14, val_elevation);
+       resource_set_servo_motor_value(15, val_azimuth);
+#endif
 }
 
 static void __command_received_cb(command_s command) {
@@ -161,6 +175,8 @@ static void __command_received_cb(command_s command) {
 
 static void _initialize_config()
 {
+       net_util_init();
+
        config_init();
 
        char *id = NULL;