From 4075a25ca9690b897802c737cd091dd4ec373a34 Mon Sep 17 00:00:00 2001 From: Michael Ferguson Date: Sun, 12 Nov 2023 17:13:01 -0500 Subject: [PATCH] disable ld06 pwm loop --- libraries/libcpp/inc/ld06.hpp | 3 +++ projects/etherbotix/user_io.hpp | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/libraries/libcpp/inc/ld06.hpp b/libraries/libcpp/inc/ld06.hpp index 34b5c00..54c1189 100644 --- a/libraries/libcpp/inc/ld06.hpp +++ b/libraries/libcpp/inc/ld06.hpp @@ -178,6 +178,8 @@ class LD06 if (crc == packet.crc) { ++packets_; + // Disabled because scan is more stable when PWM is open loop + /* last_speed_ = packet.radar_speed; if (last_speed_ < MINIMUM_LASER_SPEED) { @@ -188,6 +190,7 @@ class LD06 control_pwm_ -= 1; } TIM12->CCR2 = control_pwm_; + */ return EXPECTED_PACKET_LENGTH; } diff --git a/projects/etherbotix/user_io.hpp b/projects/etherbotix/user_io.hpp index 81ae8d1..1dc42d6 100644 --- a/projects/etherbotix/user_io.hpp +++ b/projects/etherbotix/user_io.hpp @@ -238,6 +238,12 @@ inline void user_io_set_direction() inline bool user_io_ld06_init() { + if (user_io_laser_active_) + { + // Don't re-init the laser if already active - this slows the laser + return true; + } + user_io_laser_active_ = 1; // Uses USART3 and TIM12