Skip to content

Commit

Permalink
added description for mapping.
Browse files Browse the repository at this point in the history
  • Loading branch information
SuperChamp234 committed Feb 1, 2024
1 parent 2071ad3 commit 7435bdc
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/motor_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ esp_err_t enable_motor_driver(motor_handle_t *motor, int motor_id) {
}

esp_err_t set_motor_speed(motor_handle_t motor, int direction, float speed) {
// map is used to map the speed from 0-100 to 0-MCPWM_TICKS. MCPWM_TICKS is the resolution of the pwm signal. It is calculated as MCPWM_TICKS = MCPWM_RESOLUTION / MCPWM_FREQ
speed = (uint32_t)map(speed, 0, 100, 0, MCPWM_RESOLUTION / MCPWM_FREQ);
if(direction == MOTOR_FORWARD){
motor->forward(motor);
Expand Down

0 comments on commit 7435bdc

Please sign in to comment.