mirror of
https://github.com/alexandrebobkov/ESP-Nodes.git
synced 2025-08-15 00:06:46 +00:00
ESP-IDF Robot Controls
This commit is contained in:
@@ -58,8 +58,8 @@ static const char *TAG = "ESP IDF Robot";
|
|||||||
#define LEDC_MODE LEDC_LOW_SPEED_MODE // LEDC_LOW_SPEED_MODE
|
#define LEDC_MODE LEDC_LOW_SPEED_MODE // LEDC_LOW_SPEED_MODE
|
||||||
#define LEDC_OUTPUT_IO (5) // Define the output GPIO
|
#define LEDC_OUTPUT_IO (5) // Define the output GPIO
|
||||||
#define LEDC_CHANNEL LEDC_CHANNEL_0 // Right side motors
|
#define LEDC_CHANNEL LEDC_CHANNEL_0 // Right side motors
|
||||||
#define MTR_FRONT_LEFT 0
|
#define MTR_FRONT_LEFT LEDC_CHANNEL_1
|
||||||
#define MTR_FRONT_RIGHT 0
|
#define MTR_FRONT_RIGHT LEDC_CHANNEL_0
|
||||||
#define MTR_REAR_LEFT 0
|
#define MTR_REAR_LEFT 0
|
||||||
#define MTR_REAR_RIGHT 0
|
#define MTR_REAR_RIGHT 0
|
||||||
#define MTR_CHANNEL_L LEDC_CHANNEL_1 // Left side motors
|
#define MTR_CHANNEL_L LEDC_CHANNEL_1 // Left side motors
|
||||||
@@ -268,16 +268,16 @@ static void motors_init (void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void ledc_init (void) {
|
static void ledc_init (void) {
|
||||||
ledc_timer_config_t ledc_timer = {
|
ledc_timer_config_t ledc_timer_1 = {
|
||||||
.speed_mode = LEDC_MODE,
|
.speed_mode = LEDC_MODE,
|
||||||
.duty_resolution = LEDC_DUTY_RES,
|
.duty_resolution = LEDC_DUTY_RES,
|
||||||
.timer_num = LEDC_TIMER,
|
.timer_num = LEDC_TIMER,
|
||||||
.freq_hz = LEDC_FREQUENCY,
|
.freq_hz = LEDC_FREQUENCY,
|
||||||
.clk_cfg = LEDC_APB_CLK
|
.clk_cfg = LEDC_APB_CLK
|
||||||
};
|
};
|
||||||
ESP_ERROR_CHECK(ledc_timer_config(&ledc_timer));
|
ESP_ERROR_CHECK(ledc_timer_config(&ledc_timer_1));
|
||||||
|
|
||||||
ledc_channel_config_t ledc_channel = {
|
ledc_channel_config_t ledc_channel_1 = {
|
||||||
.speed_mode = LEDC_MODE,
|
.speed_mode = LEDC_MODE,
|
||||||
.channel = LEDC_CHANNEL,
|
.channel = LEDC_CHANNEL,
|
||||||
.timer_sel = LEDC_TIMER,
|
.timer_sel = LEDC_TIMER,
|
||||||
@@ -286,7 +286,27 @@ static void ledc_init (void) {
|
|||||||
.duty = LEDC_DUTY,
|
.duty = LEDC_DUTY,
|
||||||
.hpoint = 0,
|
.hpoint = 0,
|
||||||
};
|
};
|
||||||
ESP_ERROR_CHECK(ledc_channel_config(&ledc_channel));
|
ESP_ERROR_CHECK(ledc_channel_config(&ledc_channel_2));
|
||||||
|
|
||||||
|
ledc_timer_config_t ledc_timer_1 = {
|
||||||
|
.speed_mode = LEDC_MODE,
|
||||||
|
.duty_resolution = LEDC_DUTY_RES,
|
||||||
|
.timer_num = LEDC_TIMER,
|
||||||
|
.freq_hz = LEDC_FREQUENCY,
|
||||||
|
.clk_cfg = LEDC_APB_CLK
|
||||||
|
};
|
||||||
|
ESP_ERROR_CHECK(ledc_timer_config(&ledc_timer_2));
|
||||||
|
|
||||||
|
ledc_channel_config_t ledc_channel_1 = {
|
||||||
|
.speed_mode = LEDC_MODE,
|
||||||
|
.channel = LEDC_CHANNEL_,
|
||||||
|
.timer_sel = LEDC_TIMER,
|
||||||
|
.intr_type = LEDC_INTR_DISABLE,
|
||||||
|
.gpio_num = LEDC_OUTPUT_IO,
|
||||||
|
.duty = LEDC_DUTY,
|
||||||
|
.hpoint = 0,
|
||||||
|
};
|
||||||
|
ESP_ERROR_CHECK(ledc_channel_config(&ledc_channel_2));
|
||||||
//ESP_ERROR_CHECK(ledc_set_duty(LEDC_MODE, LEDC_CHANNEL, LEDC_DUTY));
|
//ESP_ERROR_CHECK(ledc_set_duty(LEDC_MODE, LEDC_CHANNEL, LEDC_DUTY));
|
||||||
//ESP_ERROR_CHECK(ledc_update_duty(LEDC_MODE, LEDC_CHANNEL));
|
//ESP_ERROR_CHECK(ledc_update_duty(LEDC_MODE, LEDC_CHANNEL));
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user