#define _E(fmt, arg...) log_print(DLOG_ERROR, LOG_TAG, "[%s:%d] " fmt "\n", __func__, __LINE__, ##arg)
#endif
+#define FUNCTION_START _D("\033[0;32m ***************************** START ***************************** \033[0m")
+#define FUNCTION_END _D("\033[0;32m ***************************** END ***************************** \033[0m")
+
#define retvm_if(expr, val, fmt, arg...) do { \
if (expr) { \
_E(fmt, ##arg); \
static void _initialize_components(app_data *ad)
{
+ FUNCTION_START;
+
net_util_init();
_initialize_config();
cloud_communication_init();
s_info.stering_pin, s_info.azimuth_pin, s_info.elevation_pin,
s_info.engine_1_forward_pin, s_info.engine_1_back_pin, s_info.engine_1_channel,
s_info.engine_2_forward_pin, s_info.engine_2_back_pin, s_info.engine_2_channel);
+
+ FUNCTION_END;
}
static bool service_app_create(void *data)
{
+ FUNCTION_START;
+
int ret = 0;
app_data *ad = data;
_D("-----------------------=======================================================================-----------------------");
_D("-----------------------=======================================================================-----------------------");
+ _initialize_components(ad);
+
/*
* if you want to use default configuration,
* Do not need to call resource_set_motor_driver_L298N_configuration(),
}
#endif
- _initialize_components(ad);
resource_lap_counter_init();
cloud_communication_start(CLOUD_REQUESTS_FREQUENCY);
CONFIG_DEFAULT_LED_24BIT_INIT,
LED_COLOR_RED);
+ FUNCTION_END;
return true;
}
static void service_app_control(app_control_h app_control, void *data)
{
+ FUNCTION_START;
#if ENABLE_MOTOR
/* set speed 0, to reduce delay of initializing motor driver */
resource_set_motor_driver_L298N_speed(MOTOR_ID_1, 0);
resource_set_motor_driver_L298N_speed(MOTOR_ID_2, 0);
- resource_set_servo_motor_value(s_info.stering_pin, STERING_SERVO_CENTER);
- resource_set_servo_motor_value(s_info.elevation_pin, ELEVATION_MIN);
- resource_set_servo_motor_value(s_info.azimuth_pin, (AZIMUTH_MIN + AZIMUTH_MAX) / 2);
+ resource_set_servo_motor_value(s_info.stering_pin, s_info.stering_center);
+ resource_set_servo_motor_value(s_info.elevation_pin, s_info.camera_elevation_min);
+ resource_set_servo_motor_value(s_info.azimuth_pin, s_info.camera_azimuth_center);
#endif
+ FUNCTION_END;
return;
}
CONFIG_DEFAULT_LED_24BIT_OFF,
LED_COLOR_NONE);
- resource_set_servo_motor_value(s_info.stering_pin, STERING_SERVO_CENTER);
- resource_set_servo_motor_value(s_info.elevation_pin, ELEVATION_MIN);
- resource_set_servo_motor_value(s_info.azimuth_pin, (AZIMUTH_MIN + AZIMUTH_MAX) / 2);
+ resource_set_servo_motor_value(s_info.stering_pin, s_info.stering_center);
+ resource_set_servo_motor_value(s_info.elevation_pin, s_info.camera_elevation_min);
+ resource_set_servo_motor_value(s_info.azimuth_pin, s_info.camera_azimuth_center);
resource_lap_counter_destroy();
resource_led_destroy();
static int __set_default_configuration_by_id(motor_id_e id)
{
+ FUNCTION_START;
+
unsigned int pin_1, pin_2, en_ch;
switch (id) {
g_md_h[id].en_ch = en_ch;
g_md_h[id].motor_state = MOTOR_STATE_CONFIGURED;
+ FUNCTION_END;
return 0;
}
peripheral_gpio_set_direction(g_md_h[id].pin1_h,
PERIPHERAL_GPIO_DIRECTION_OUT_INITIALLY_LOW);
else {
- _E("failed to open Motor[%d] gpio pin1[%u]", id, g_md_h[id].pin_1);
+ _E("failed to open Motor[%d] gpio pin1[%u]. Error: %s", id, g_md_h[id].pin_1, get_error_message(ret));
goto ERROR;
}
peripheral_gpio_set_direction(g_md_h[id].pin2_h,
PERIPHERAL_GPIO_DIRECTION_OUT_INITIALLY_LOW);
else {
- _E("failed to open Motor[%d] gpio pin2[%u]", id, g_md_h[id].pin_2);
+ _E("failed to open Motor[%d] gpio pin2[%u]. Error: %s", id, g_md_h[id].pin_2, get_error_message(ret));
goto ERROR;
}
ERROR:
resource_pca9685_fini(g_md_h[id].en_ch);
+ _E("Motor init error: %s", get_error_message(ret));
+
if (g_md_h[id].pin1_h) {
peripheral_gpio_close(g_md_h[id].pin1_h);
g_md_h[id].pin1_h = NULL;