Skip to content

Commit

Permalink
revive ld06 pwm control, make output visible to user
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeferguson committed Dec 13, 2023
1 parent 4075a25 commit e517b18
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
7 changes: 5 additions & 2 deletions libraries/libcpp/inc/ld06.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,6 @@ class LD06
{
++packets_;
// Disabled because scan is more stable when PWM is open loop
/*
last_speed_ = packet.radar_speed;
if (last_speed_ < MINIMUM_LASER_SPEED)
{
Expand All @@ -190,7 +189,6 @@ class LD06
control_pwm_ -= 1;
}
TIM12->CCR2 = control_pwm_;
*/
return EXPECTED_PACKET_LENGTH;
}

Expand Down Expand Up @@ -251,6 +249,11 @@ class LD06
state_ = BUS_READING_START;
}

uint16_t get_control_pwm()
{
return control_pwm_;
}

ld06_packet_t packet;

private:
Expand Down
6 changes: 6 additions & 0 deletions projects/etherbotix/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -823,6 +823,12 @@ void SysTick_Handler(void)
}
}

// Update laser, if active
if (user_io_laser_active_)
{
registers.tim12_mode = laser.get_control_pwm();
}

// Toggle LED
if (registers.system_time - last_packet < 500)
{
Expand Down

0 comments on commit e517b18

Please sign in to comment.