diff options
author | Michal Skorupinski <m.skorupinsk@samsung.com> | 2018-09-21 19:45:18 +0200 |
---|---|---|
committer | Krzysztof Wieclaw <k.wieclaw@samsung.com> | 2018-10-04 15:14:16 +0200 |
commit | f3018b9d956b3b637da009f941d186fe22a8fc7d (patch) | |
tree | 563789405335d00c3f77f483d8db43ca520d7bc0 | |
parent | 320c2343d814f7b4d2d1d9d0a2a2dd5d6afeebb4 (diff) | |
download | gear-racing-controller-f3018b9d956b3b637da009f941d186fe22a8fc7d.tar.gz gear-racing-controller-f3018b9d956b3b637da009f941d186fe22a8fc7d.tar.bz2 gear-racing-controller-f3018b9d956b3b637da009f941d186fe22a8fc7d.zip |
Config for rotation direction of stering indicator. Config for button step
Change-Id: Ie21257b1532b246fbdae30e9140fea33114354b6
Signed-off-by: Michal Skorupinski <m.skorupinsk@samsung.com>
-rw-r--r-- | inc/config.h | 4 | ||||
-rw-r--r-- | inc/view/view_racing.h | 3 | ||||
-rw-r--r-- | src/config.c | 26 | ||||
-rw-r--r-- | src/controller/controller_racing.c | 3 | ||||
-rw-r--r-- | src/view/view_racing.c | 24 |
5 files changed, 44 insertions, 16 deletions
diff --git a/inc/config.h b/inc/config.h index 45bfa74..23a7c33 100644 --- a/inc/config.h +++ b/inc/config.h @@ -19,6 +19,8 @@ void config_set_sensor_steering_bezel_velocity(); void config_set_bezel_steering_sensor_velocity(); -void config_set_sensor_stering_sensor_velocity(); +void config_set_sensor_stering_sensor_velocity_bezel_elev(); +void config_set_sensor_stering_sensor_velocity_bezel_azimuth(); + #endif /* CONFIG_H_ */ diff --git a/inc/view/view_racing.h b/inc/view/view_racing.h index 65be36d..61bf4e6 100644 --- a/inc/view/view_racing.h +++ b/inc/view/view_racing.h @@ -20,7 +20,8 @@ #include "view/view_base.h" -void view_racing_set_button_params(float min, float max); +void view_racing_set_button_params(float min, float max, float step); +void view_racing_set_direction_indicator_multiplier(float multiplier); s_view_base *view_racing_init(Evas_Object *parent); #endif /* VIEW_VIEW_RACING_H_ */ diff --git a/src/config.c b/src/config.c index c982082..d13a4f0 100644 --- a/src/config.c +++ b/src/config.c @@ -30,6 +30,7 @@ #define CAM_ELEVATION_DEADZONE 3.0f #define MAX_CAM_ELEVATION 5.0f +#define CAM_AZIMUTH_STEP 0.01 #define MAX_ABSOLOUTE_SENSORS_OUTPUT_VALUE 1.0f #define FINAL_SENSOR_MULTIPLIER 1.0f @@ -46,6 +47,7 @@ #define MAX_BEZEL_VALUE 1.0f #define MAX_BUTTON_VALUE 1.0f #define MAX_ELEVATION_VALUE 0.0f +#define BUTTON_MULTIPLIER 1.0f void config_set_sensor_steering_bezel_velocity() { @@ -56,7 +58,8 @@ void config_set_sensor_steering_bezel_velocity() model_sensors_set_acceleration_sensor_params(MAX_DIRECTION, MAX_ABSOLOUTE_SENSORS_OUTPUT_VALUE, DIRECTION_DEADZONE, FINAL_SENSOR_MULTIPLIER, false, 0, 0); model_sensors_set_gravity_sensor_params(MAX_GRAVITY, MAX_INCREMENTAL_OUTPUT_VALUE, INCREMENTAL_MODE_GRAVITY_DEADZONE, FINAL_SENSOR_MULTIPLIER, true, -MAX_INCREMENTAL_VALUE, MAX_INCREMENTAL_VALUE); //camera - view_racing_set_button_params(-MAX_BUTTON_VALUE, MAX_BUTTON_VALUE); + view_racing_set_button_params(-MAX_BUTTON_VALUE, MAX_BUTTON_VALUE, CAM_AZIMUTH_STEP); + view_racing_set_direction_indicator_multiplier(BUTTON_MULTIPLIER); } void config_set_bezel_steering_sensor_velocity() @@ -68,10 +71,11 @@ void config_set_bezel_steering_sensor_velocity() model_sensors_set_acceleration_sensor_params(MAX_DIRECTION, MAX_INCREMENTAL_OUTPUT_VALUE, INCREMENTAL_MODE_ACC_DEADZONE, -FINAL_SENSOR_MULTIPLIER, true, -MAX_INCREMENTAL_VALUE, MAX_INCREMENTAL_VALUE); //camera model_sensors_set_gravity_sensor_params(MAX_GRAVITY, MAX_ABSOLOUTE_SENSORS_OUTPUT_VALUE, GRAVITY_DEADZONE, FINAL_SENSOR_MULTIPLIER, false, 0.0f, 0.0f); - view_racing_set_button_params(-MAX_BUTTON_VALUE, MAX_ELEVATION_VALUE); + view_racing_set_button_params(-MAX_BUTTON_VALUE, MAX_ELEVATION_VALUE, -CAM_AZIMUTH_STEP); + view_racing_set_direction_indicator_multiplier(-BUTTON_MULTIPLIER); } -void config_set_sensor_stering_sensor_velocity() +void config_set_sensor_stering_sensor_velocity_bezel_elev() { model_device_to_connection_set_control_roles(STERING_MODE_DIRETION, STERING_MODE_THROTTLE, STERING_MODE_CAM_ELEVATION, STERING_MODE_CAM_AZIMUTH); model_hw_set_bezel_params(BEZEL_SLOW_STEP, BEZEL_DEADZONE, false, 0, false); @@ -80,5 +84,19 @@ void config_set_sensor_stering_sensor_velocity() model_sensors_set_acceleration_sensor_params(MAX_DIRECTION, MAX_ABSOLOUTE_SENSORS_OUTPUT_VALUE, DIRECTION_DEADZONE, FINAL_SENSOR_MULTIPLIER, false, 0.0f, 0.0f); model_sensors_set_gravity_sensor_params(MAX_GRAVITY, MAX_ABSOLOUTE_SENSORS_OUTPUT_VALUE, GRAVITY_DEADZONE, FINAL_SENSOR_MULTIPLIER, false, 0.0f, 0.0f); - view_racing_set_button_params(-MAX_BUTTON_VALUE, MAX_BUTTON_VALUE); + view_racing_set_button_params(-MAX_BUTTON_VALUE, MAX_BUTTON_VALUE, CAM_AZIMUTH_STEP); + view_racing_set_direction_indicator_multiplier(BUTTON_MULTIPLIER); +} + +void config_set_sensor_stering_sensor_velocity_bezel_azimuth() +{ + model_device_to_connection_set_control_roles(STERING_MODE_DIRETION, STERING_MODE_THROTTLE, STERING_MODE_CAM_AZIMUTH, STERING_MODE_CAM_ELEVATION); + model_hw_set_bezel_params(BEZEL_SLOW_STEP, BEZEL_DEADZONE, false, 0, false); + model_hw_set_bezel_max_min(-MAX_BEZEL_VALUE, MAX_BEZEL_VALUE); + + model_sensors_set_acceleration_sensor_params(MAX_DIRECTION, MAX_ABSOLOUTE_SENSORS_OUTPUT_VALUE, DIRECTION_DEADZONE, FINAL_SENSOR_MULTIPLIER, false, 0.0f, 0.0f); + model_sensors_set_gravity_sensor_params(MAX_GRAVITY, 1.0f, GRAVITY_DEADZONE, 1.0f, false, 0.0f, 0.0f); + + view_racing_set_button_params(-MAX_BUTTON_VALUE, MAX_ELEVATION_VALUE, -CAM_AZIMUTH_STEP); + view_racing_set_direction_indicator_multiplier(BUTTON_MULTIPLIER); } diff --git a/src/controller/controller_racing.c b/src/controller/controller_racing.c index 77b9c7b..714f0b3 100644 --- a/src/controller/controller_racing.c +++ b/src/controller/controller_racing.c @@ -89,6 +89,9 @@ void controller_racing_set_stop(bool stop) void controller_racing_set_button_value(float button_value) { + e_device device = model_device_to_connection_buttons_get_function(); + _map_device_to_view(device, button_value); + model_device_to_connection_buttons(button_value); } diff --git a/src/view/view_racing.c b/src/view/view_racing.c index 4b970c1..a8817dd 100644 --- a/src/view/view_racing.c +++ b/src/view/view_racing.c @@ -21,8 +21,6 @@ #include "log.h" #include "math_helper.h" -#define CAM_AZIMUTH_STEP 0.01 - typedef enum _e_camera_button_action { CAMERA_BUTTON_RIGHT_UP, CAMERA_BUTTON_RIGHT_DOWN, @@ -53,6 +51,8 @@ typedef struct _s_view_racing { float button_value_min; float button_value_max; + float button_step; + float direction_indicator_angle_multiplier; } s_view_racing; static s_view_racing s_info = { @@ -107,7 +107,7 @@ static void _controller_cb(void *data) { s_controller_data *controller_data = (s_controller_data *)data; - float angle = math_helper_range_map(controller_data->direction, -1, 1, s_info.dir_min_angle, s_info.dir_max_angle); + float angle = math_helper_range_map(controller_data->direction * s_info.direction_indicator_angle_multiplier, -1, 1, s_info.dir_min_angle, s_info.dir_max_angle); view_base_set_angle(s_info.direction, angle, 180.0, 180.0); // _D("VIEW VALUES: %f %f DIR: %f", controller_data->direction, controller_data->throttle, angle); @@ -115,8 +115,8 @@ static void _controller_cb(void *data) angle = math_helper_range_map(fabsf(controller_data->throttle), 0, 1, s_info.vel_min_angle, s_info.vel_max_angle); view_base_set_angle(s_info.velocity, angle, 180.0, 180.0); - angle = math_helper_range_map(controller_data->cam_elevation, 0, 1, 0, 90); - view_base_set_angle(s_info.camera_elevation_indicator, 90 - angle, 180.0, 180.0); + angle = math_helper_range_map(controller_data->cam_elevation, -1, 0, 0, 90); + view_base_set_angle(s_info.camera_elevation_indicator, angle, 180.0, 180.0); angle = math_helper_range_map(controller_data->cam_azimuth, -1, 1, -90.0f, 90.0f); view_base_set_angle(s_info.camera_azimuth_indicator, angle, 180.0, 180.0); @@ -165,9 +165,9 @@ static Eina_Bool _button_value_animator_cb(void *data) float prev = s_info.button_value; if (s_info.buttons_pressed[0] && !s_info.buttons_pressed[1]) { - s_info.button_value -= CAM_AZIMUTH_STEP; + s_info.button_value -= s_info.button_step; } else if (!s_info.buttons_pressed[0] && s_info.buttons_pressed[1]) { - s_info.button_value += CAM_AZIMUTH_STEP; + s_info.button_value += s_info.button_step; } if (prev * s_info.button_value < 0) { @@ -182,8 +182,6 @@ static Eina_Bool _button_value_animator_cb(void *data) controller_racing_set_button_value(s_info.button_value); - float angle = math_helper_range_map(s_info.button_value, s_info.button_value_min, s_info.button_value_max, -90.0f, 90.0f); - view_base_set_angle(s_info.camera_azimuth_indicator, angle, 180.0, 180.0); _D("[CAM] AZIMUTH: % f", s_info.button_value); return ECORE_CALLBACK_RENEW; @@ -292,10 +290,16 @@ static void _hide_cb(void) ASSERT_FUNCTION_END; } -void view_racing_set_button_params(float min, float max) +void view_racing_set_button_params(float min, float max, float step) { s_info.button_value_min = min; s_info.button_value_max = max; + s_info.button_step = step; +} + +void view_racing_set_direction_indicator_multiplier(float multiplier) +{ + s_info.direction_indicator_angle_multiplier = multiplier; } s_view_base *view_racing_init(Evas_Object *parent) |