From 713fd42aa7dc0453b15c60e86526dad356cd6b24 Mon Sep 17 00:00:00 2001 From: Mk16kawai <1041324852hzq@sina.com> Date: Mon, 6 Jan 2025 18:02:48 +0800 Subject: [PATCH 1/3] fixed some tmc2209 bugs --- .../ext_dev/src/tmc2209/janelia-arduino_TMC2209/TMC2209.cpp | 3 +-- components/ext_dev/src/tmc2209/maix_tmc2209.cpp | 5 +++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/components/ext_dev/src/tmc2209/janelia-arduino_TMC2209/TMC2209.cpp b/components/ext_dev/src/tmc2209/janelia-arduino_TMC2209/TMC2209.cpp index 8390441b..bfbbe6a4 100644 --- a/components/ext_dev/src/tmc2209/janelia-arduino_TMC2209/TMC2209.cpp +++ b/components/ext_dev/src/tmc2209/janelia-arduino_TMC2209/TMC2209.cpp @@ -740,7 +740,6 @@ int TMC2209::serialRead() // auto all_datas = this->_uart->read(buffer+next_index, num, num); // next_index += num; // for (int i = 0; i < num; ++i) { - // } // } @@ -995,7 +994,7 @@ uint32_t TMC2209::read(uint8_t register_address) // if (reply_delay >= REPLY_DELAY_MAX_MICROSECONDS) // { - // return 0; + // return 0; // } // this->serialRead(); diff --git a/components/ext_dev/src/tmc2209/maix_tmc2209.cpp b/components/ext_dev/src/tmc2209/maix_tmc2209.cpp index 1edf3ac1..9fd4e1f0 100644 --- a/components/ext_dev/src/tmc2209/maix_tmc2209.cpp +++ b/components/ext_dev/src/tmc2209/maix_tmc2209.cpp @@ -17,9 +17,9 @@ static constexpr int TRY_NUM = 5; * speed ==> (360/step_angle)/(screw_pitch/speed) ==> 400 fullsteps/s * speed_factor ==> speed/SPEED_EACH_FACTOR ==> ((360/step_angle)/(screw_pitch/speed))/SPEED_EACH_FACTOR ==> 555 */ -static inline uint16_t calculate_speed_factor(uint16_t speed_mm_s, float step_angle, uint16_t screw_pitch) +static inline uint16_t calculate_speed_factor(float speed_mm_s, float step_angle, float screw_pitch) { - return static_cast(((360/step_angle)/(static_cast(screw_pitch)/speed_mm_s))/SPEED_EACH_FACTOR); + return static_cast(((360.0f/step_angle)/(screw_pitch/speed_mm_s))/SPEED_EACH_FACTOR); } class FileHandler { @@ -782,6 +782,7 @@ void ScrewSlide::move(float oft, int speed_mm_s, std::function call this->speed_factor_ : \ calculate_speed_factor(static_cast(speed_mm_s), this->step_angle, this->screw_pitch); + // maix::log::info("speed factor:%u", speed_factor); // maix::log::info("std::abs(oft): %0.3f", std::abs(oft)); // maix::log::info("this->micro_step_distance: %0.8f", this->micro_step_distance); // maix::log::info("std::abs(oft) / this->micro_step_distance: %0.3f", std::abs(oft) / this->micro_step_distance); From b9d4fca138940f71f5135c758d9d894d62e2e7af Mon Sep 17 00:00:00 2001 From: Mk16kawai <1041324852hzq@sina.com> Date: Mon, 6 Jan 2025 18:04:19 +0800 Subject: [PATCH 2/3] update thermal&tof app --- projects/app_thermal_camera/README.md | 6 ++++-- projects/app_thermal_camera/main/src/main.cpp | 2 +- projects/app_tof_camera/README.md | 6 ++++-- projects/app_tof_camera/main/src/main.cpp | 2 +- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/projects/app_thermal_camera/README.md b/projects/app_thermal_camera/README.md index 2fe72ebe..184de688 100644 --- a/projects/app_thermal_camera/README.md +++ b/projects/app_thermal_camera/README.md @@ -1,6 +1,8 @@ # Thermal camera -## support list +## Supported List -* mlx90640 \ No newline at end of file +[Consult purchase address](https://wiki.sipeed.com/en/store.html) + +* PMOD_Thermal32 diff --git a/projects/app_thermal_camera/main/src/main.cpp b/projects/app_thermal_camera/main/src/main.cpp index 2a32671c..08bbbd2c 100644 --- a/projects/app_thermal_camera/main/src/main.cpp +++ b/projects/app_thermal_camera/main/src/main.cpp @@ -51,7 +51,7 @@ struct BoolResult { BoolResult find_device() { - std::string suffix = "Support list:\nMLX90640\n\nClicked to exit."; + std::string suffix = "Support list:\nPMOD_Thermal32\n\nClicked to exit."; BoolResult res; bool total_flag = false; diff --git a/projects/app_tof_camera/README.md b/projects/app_tof_camera/README.md index a86c9451..832d9c22 100644 --- a/projects/app_tof_camera/README.md +++ b/projects/app_tof_camera/README.md @@ -1,6 +1,8 @@ # ToF camera -## support list +## Supported List -* OPNS3031 \ No newline at end of file +[Consult purchase address](https://wiki.sipeed.com/en/store.html) + +* PMOD_TOF100 \ No newline at end of file diff --git a/projects/app_tof_camera/main/src/main.cpp b/projects/app_tof_camera/main/src/main.cpp index 0031fa13..dce1f256 100644 --- a/projects/app_tof_camera/main/src/main.cpp +++ b/projects/app_tof_camera/main/src/main.cpp @@ -54,7 +54,7 @@ void show_error(display::Display& disp, touchscreen::TouchScreen& ts) { ui_total_deinit(); auto img = Image(disp.width(), disp.height()); - std::string msg = "Devices Not Found!\nSupport list:\nOPNS3031\n\nClicked to exit."; + std::string msg = "Devices Not Found!\nSupport list:\nPMOD_TOF100\n\nClicked to exit."; img.draw_string(0, 100, msg); disp.show(img); while (!app::need_exit()) { From fe7ff536adefa382db6063fc09d2e6668b4f435b Mon Sep 17 00:00:00 2001 From: Mk16kawai <1041324852hzq@sina.com> Date: Mon, 6 Jan 2025 18:06:30 +0800 Subject: [PATCH 3/3] fixed some modbus bugs --- components/comm/src/maix_modbus.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/comm/src/maix_modbus.cpp b/components/comm/src/maix_modbus.cpp index 538f3e0c..9a495d00 100644 --- a/components/comm/src/maix_modbus.cpp +++ b/components/comm/src/maix_modbus.cpp @@ -293,7 +293,7 @@ Slave::~Slave() ::maix::err::Err Slave::__receive__() { this->rc_ = ::modbus_receive(this->ctx_.get(), this->query_); - if (this->rc_ >= 0) { + if (this->rc_ > 0) { if (this->debug_) { log::info("%s receive, len: %d", this->TAG().c_str(), this->rc_); }