From e517b18377c89792ae3b18fc25383d215a6d6d18 Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Wed, 13 Dec 2023 11:17:51 -0500 Subject: [PATCH] revive ld06 pwm control, make output visible to user --- libraries/libcpp/inc/ld06.hpp | 7 +++++-- projects/etherbotix/main.cpp | 6 ++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/libraries/libcpp/inc/ld06.hpp b/libraries/libcpp/inc/ld06.hpp index 54c1189..7acde1f 100644 --- a/libraries/libcpp/inc/ld06.hpp +++ b/libraries/libcpp/inc/ld06.hpp @@ -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) { @@ -190,7 +189,6 @@ class LD06 control_pwm_ -= 1; } TIM12->CCR2 = control_pwm_; - */ return EXPECTED_PACKET_LENGTH; } @@ -251,6 +249,11 @@ class LD06 state_ = BUS_READING_START; } + uint16_t get_control_pwm() + { + return control_pwm_; + } + ld06_packet_t packet; private: diff --git a/projects/etherbotix/main.cpp b/projects/etherbotix/main.cpp index e4d95ba..6971209 100644 --- a/projects/etherbotix/main.cpp +++ b/projects/etherbotix/main.cpp @@ -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) {