Skip to content

Commit

Permalink
Merge pull request #196 from ye-luo-xi-tui/master
Browse files Browse the repository at this point in the history
Add anti-shake to stick
  • Loading branch information
ye-luo-xi-tui authored Aug 8, 2023
2 parents 8da34c2 + c3ce967 commit 4077a1e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions rm_dbus/include/rm_dbus/dbus.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ class DBus

private:
DBusData_t d_bus_data_{};
int s0_count_ = 0, s1_count_ = 0;
int port_{};
int16_t buff_[18]{};
bool is_success{};
Expand Down
14 changes: 12 additions & 2 deletions rm_dbus/src/dbus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,18 @@ void DBus::unpack()
if (d_bus_data_.ch3 <= 10 && d_bus_data_.ch3 >= -10)
d_bus_data_.ch3 = 0;

d_bus_data_.s1 = ((buff_[5] >> 4) & 0x000C) >> 2;
d_bus_data_.s0 = (buff_[5] >> 4) & 0x0003;
if (d_bus_data_.s0 != ((buff_[5] >> 4) & 0x0003))
s0_count_++;
else
s0_count_ = 0;
if (d_bus_data_.s1 != ((buff_[5] >> 4) & 0x000C) >> 2)
s1_count_++;
else
s1_count_ = 0;
if (s0_count_ > 3)
d_bus_data_.s0 = (buff_[5] >> 4) & 0x0003;
if (s1_count_ > 3)
d_bus_data_.s1 = ((buff_[5] >> 4) & 0x000C) >> 2;

if ((abs(d_bus_data_.ch0) > 660) || (abs(d_bus_data_.ch1) > 660) || (abs(d_bus_data_.ch2) > 660) ||
(abs(d_bus_data_.ch3) > 660))
Expand Down

0 comments on commit 4077a1e

Please sign in to comment.